support iframes inside open shadow dom
This commit is contained in:
parent
4fdc300b61
commit
fbaf50def1
@ -79,9 +79,28 @@ class FrameOffsetForwarder {
|
|||||||
sourceFrame = frame;
|
sourceFrame = frame;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceFrame === null) {
|
if (sourceFrame === null) {
|
||||||
this._forwardFrameOffsetOrigin(null, uniqueId);
|
const getShadowRootElements = (documentOrElement) => {
|
||||||
return;
|
const elements = Array.from(documentOrElement.querySelectorAll('*'))
|
||||||
|
.filter((el) => !!el.shadowRoot);
|
||||||
|
const childElements = elements
|
||||||
|
.map((el) => el.shadowRoot)
|
||||||
|
.map(getShadowRootElements);
|
||||||
|
elements.push(childElements.flat());
|
||||||
|
|
||||||
|
return elements.flat();
|
||||||
|
};
|
||||||
|
|
||||||
|
sourceFrame = getShadowRootElements(document)
|
||||||
|
.map((el) => Array.from(el.shadowRoot.querySelectorAll('frame, iframe:not(.yomichan-float)')))
|
||||||
|
.flat()
|
||||||
|
.find((el) => el.contentWindow === e.source);
|
||||||
|
|
||||||
|
if (!sourceFrame) {
|
||||||
|
this._forwardFrameOffsetOrigin(null, uniqueId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [forwardedX, forwardedY] = offset;
|
const [forwardedX, forwardedY] = offset;
|
||||||
|
@ -77,5 +77,22 @@ document.querySelector('#fullscreen-link1').addEventListener('click', () => togg
|
|||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="test">
|
||||||
|
<div class="description"><iframe> element inside of an open shadow DOM.</div>
|
||||||
|
<div id="shadow-iframe-container-open"></div>
|
||||||
|
<template id="shadow-iframe-container-open-content-template">
|
||||||
|
<iframe src="test-document2-frame1.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const shadowIframeContainer = document.querySelector('#shadow-iframe-container-open');
|
||||||
|
const shadow = shadowIframeContainer.attachShadow({mode: 'open'});
|
||||||
|
const template = document.querySelector('#shadow-iframe-container-open-content-template').content;
|
||||||
|
const content = document.importNode(template, true);
|
||||||
|
shadow.appendChild(content);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user