From 8b8b12c5fcbabf498fd3abf796ebdef92bc9f282 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Fri, 14 May 2021 11:17:45 -0300 Subject: [PATCH] [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) --- src/helpers/safeHTMLElement.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/helpers/safeHTMLElement.js b/src/helpers/safeHTMLElement.js index 8ae67884..384f0d05 100644 --- a/src/helpers/safeHTMLElement.js +++ b/src/helpers/safeHTMLElement.js @@ -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 : {};