From e7d37a80fbe45cb4f7bea50c628107fcee205090 Mon Sep 17 00:00:00 2001 From: Andy Earnshaw Date: Mon, 21 Jul 2025 10:04:09 +0100 Subject: [PATCH] fix: avoid duplicate iframe children cloning Fixes #543 --- src/clone-node.ts | 5 ----- test/resources/iframe/node.html | 17 +++++++++++++++++ test/spec/special.spec.ts | 7 +++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 test/resources/iframe/node.html diff --git a/src/clone-node.ts b/src/clone-node.ts index 5dfcd117..8aa85ca8 100644 --- a/src/clone-node.ts +++ b/src/clone-node.ts @@ -88,11 +88,6 @@ async function cloneChildren( if (isSlotElement(nativeNode) && nativeNode.assignedNodes) { children = toArray(nativeNode.assignedNodes()) - } else if ( - isInstanceOfElement(nativeNode, HTMLIFrameElement) && - nativeNode.contentDocument?.body - ) { - children = toArray(nativeNode.contentDocument.body.childNodes) } else { children = toArray((nativeNode.shadowRoot ?? nativeNode).childNodes) } diff --git a/test/resources/iframe/node.html b/test/resources/iframe/node.html new file mode 100644 index 00000000..acb23075 --- /dev/null +++ b/test/resources/iframe/node.html @@ -0,0 +1,17 @@ + diff --git a/test/spec/special.spec.ts b/test/spec/special.spec.ts index 6425195a..93f72853 100644 --- a/test/spec/special.spec.ts +++ b/test/spec/special.spec.ts @@ -59,4 +59,11 @@ describe('special cases', () => { .then(done) .catch(done) }) + + it('should render iframe content', (done) => { + bootstrap('iframe/node.html') + .then(assertTextRendered(['SOME TEXT', 'SOME MORE TEXT'])) + .then(done) + .catch(done) + }) })