Skip to content

Commit 8b8b12c

Browse files
committed
[fixed] appElement detection...
We can't use window.HTMLElement to check the `appElement` when combined in a iframe. window.HTMLElement !== window.HTMLElement (on the iframe)
1 parent 9523683 commit 8b8b12c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/helpers/safeHTMLElement.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ import ExecutionEnvironment from "exenv";
22

33
const EE = ExecutionEnvironment;
44

5-
const SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {};
5+
const NodeTypeElement = 1;
6+
7+
const IHTMLElement = function(props, propName) {
8+
const element = props[propName];
9+
return (
10+
element.nodeType === NodeTypeElement &&
11+
element.setAttribute &&
12+
element.removeAttribute
13+
);
14+
};
15+
16+
const SafeHTMLElement = EE.canUseDOM ? IHTMLElement : {};
617

718
export const SafeHTMLCollection = EE.canUseDOM ? window.HTMLCollection : {};
819

0 commit comments

Comments
 (0)