Skip to content

Commit

Permalink
[fixed] appElement detection...
Browse files Browse the repository at this point in the history
We can't use window.HTMLElement to check the `appElement`
when combined in a iframe.

window.HTMLElement !== window.HTMLElement (on the iframe)
  • Loading branch information
diasbruno committed May 14, 2021
1 parent 9523683 commit 8b8b12c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/helpers/safeHTMLElement.js
Expand Up @@ -2,7 +2,18 @@ import ExecutionEnvironment from "exenv";

const EE = ExecutionEnvironment;

const SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {};
const NodeTypeElement = 1;

const IHTMLElement = function(props, propName) {
const element = props[propName];
return (
element.nodeType === NodeTypeElement &&
element.setAttribute &&
element.removeAttribute
);
};

const SafeHTMLElement = EE.canUseDOM ? IHTMLElement : {};

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

Expand Down

0 comments on commit 8b8b12c

Please sign in to comment.