Patch Changes
-
#509
1c6369e
Thanks @clauderic! - Helpers have been updated to support rendering in foreignwindow
contexts (viaReactDOM.render
orReactDOM.createPortal
).For example, checking if an element is an instance of an
HTMLElement
is normally done like so:if (element instanceof HTMLElement)
However, when rendering in a different window, this can return false even if the element is indeed an HTMLElement, because this code is equivalent to:
if (element instanceof window.HTMLElement)
And in this case, the
window
of theelement
is different from the main execution contextwindow
, because we are rendering via a portal into another window.This can be solved by finding the local window of the element:
const elementWindow = element.ownerDocument.defaultView; if (element instanceof elementWindow.HTMLElement)