You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iframes have their own copy of HTMLElement, so target instanceof HTMLElement returns false, while target instanceof otherwindow.HTMLElement returns true.
Open to ideas on how this might be best implemented - perhaps with another optional property specifying the reference window?
/**
* Usage: <div use:portal={'css selector'}> or <div use:portal={document.body}> or <div use:portal={document.body} window={otherwindowcontext}>
*
* @param {HTMLElement} el
* @param {HTMLElement|string} target DOM Element or CSS Selector
* @param {Window} [window=window] Target window DOM document
*/
The text was updated successfully, but these errors were encountered:
HexaCubist
changed the title
element targets assume window context
Element targets assume window context
Oct 31, 2022
The type check here assumes that the target element is in the same window context as the script:
https://github.com/romkor/svelte-portal/blob/master/src/Portal.svelte#L25
This might not always be the case, such as running across iframes or windows. See this StackOverflow answer: https://stackoverflow.com/a/26251098/3902950
Iframes have their own copy of HTMLElement, so
target instanceof HTMLElement
returnsfalse
, whiletarget instanceof otherwindow.HTMLElement
returnstrue
.Open to ideas on how this might be best implemented - perhaps with another optional property specifying the reference window?
The text was updated successfully, but these errors were encountered: