diff --git a/src/client/core/utils/dom.js b/src/client/core/utils/dom.js index 749156c10af..d9935445785 100644 --- a/src/client/core/utils/dom.js +++ b/src/client/core/utils/dom.js @@ -390,8 +390,16 @@ export function isTopWindow (win) { } } -export function findIframeByWindow (iframeWindow, iframeDestinationWindow) { - const iframes = (iframeDestinationWindow || window).document.getElementsByTagName('iframe'); +export function findIframeByWindow (iframeWindow) { + const iframes = []; + + document.querySelectorAll('*').forEach(elem => { + if (elem.tagName === 'IFRAME') + iframes.push(elem); + + if (elem.shadowRoot) + elem.shadowRoot.querySelectorAll('iframe').forEach(iframe => iframes.push(iframe)); + }); for (let i = 0; i < iframes.length; i++) { if (nativeMethods.contentWindowGetter.call(iframes[i]) === iframeWindow)