We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 753390d commit d53304cCopy full SHA for d53304c
src/dom-helper.js
@@ -1,4 +1,10 @@
1
-const stripHtml = element => element?.innerHTML?.replace(/<[^>]*>?/gm, '')
+const stripHtml = element => {
2
+ if (element && element.innerHTML) {
3
+ return element.innerHTML.replace(/<[^>]*>?/gm, '')
4
+ }
5
+
6
+ return null
7
+}
8
9
const parseStrDimensionToInt = elementSize => parseInt(elementSize, 10)
10
@@ -46,10 +52,12 @@ const hasClass = (element, className) => {
46
52
}
47
53
48
54
const findFirstChildWithClassName = (element, className) => {
49
- const matches = element?.getElementsByClassName(className)
55
+ if (element && element.getElementsByClassName) {
56
+ const matches = element.getElementsByClassName(className)
50
57
51
- if (matches && matches.length > 0) {
- return matches[0]
58
+ if (matches && matches.length > 0) {
59
+ return matches[0]
60
61
62
63
return null
0 commit comments