From 25c13494e1d3effc9eff211a6ac1c2049af519fd Mon Sep 17 00:00:00 2001 From: Aleksey Popov Date: Mon, 11 Jul 2022 19:49:07 +0400 Subject: [PATCH] fix: fixed function findIframeByWindow --- src/client/core/utils/dom.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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)