From 9e3e5909357d24d2082d7503d1098bd5d1090e59 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] add iframe tests and update urls in test file --- src/snapshot.ts | 8 ++++---- test/html/iframe-inner.html | 1 + test/html/iframe.html | 12 ++++++++++++ test/html/with-script.html | 4 ++-- test/html/with-style-sheet.html | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 test/html/iframe-inner.html create mode 100644 test/html/iframe.html diff --git a/src/snapshot.ts b/src/snapshot.ts index c5af9f58..0501f499 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -47,10 +47,10 @@ function serializeNode(n: Node, doc: Document): serializedNode | false { attributes[name] = value; } // remote css - if (tagName === 'link' && attributes.hasOwnProperty('href')) { - const stylesheet = Array.from(doc.styleSheets).find( - s => s.href === attributes.href, - ); + if (tagName === 'link') { + const stylesheet = Array.from(doc.styleSheets).find(s => { + return s.href === (n as HTMLLinkElement).href; + }); const cssText = getCssRulesString(stylesheet as CSSStyleSheet); if (cssText) { attributes = { diff --git a/test/html/iframe-inner.html b/test/html/iframe-inner.html new file mode 100644 index 00000000..2ef778d9 --- /dev/null +++ b/test/html/iframe-inner.html @@ -0,0 +1 @@ + diff --git a/test/html/iframe.html b/test/html/iframe.html new file mode 100644 index 00000000..8b45139e --- /dev/null +++ b/test/html/iframe.html @@ -0,0 +1,12 @@ + + + + + + + iframe + + + + + diff --git a/test/html/with-script.html b/test/html/with-script.html index 5ef140a7..d7271338 100644 --- a/test/html/with-script.html +++ b/test/html/with-script.html @@ -9,7 +9,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/test/html/with-style-sheet.html b/test/html/with-style-sheet.html index 14f09d38..9fc5bdad 100644 --- a/test/html/with-style-sheet.html +++ b/test/html/with-style-sheet.html @@ -6,7 +6,7 @@ with style sheet - +