From 564905ddf526fd8e533eb570a6a01604dbb5c5bf Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 13 Feb 2023 10:37:50 -0500 Subject: [PATCH 1/2] fix: Exclude `modulepreload` as well We were only excluding `` but we should include `rel="modulepreload"` as well --- packages/rrweb-snapshot/src/rebuild.ts | 2 +- packages/rrweb-snapshot/src/snapshot.ts | 4 ++-- .../test/__snapshots__/integration.test.ts.snap | 1 + packages/rrweb-snapshot/test/html/preload.html | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/rrweb-snapshot/src/rebuild.ts b/packages/rrweb-snapshot/src/rebuild.ts index 854d6c957b..92fafc2bf1 100644 --- a/packages/rrweb-snapshot/src/rebuild.ts +++ b/packages/rrweb-snapshot/src/rebuild.ts @@ -221,7 +221,7 @@ function buildNode( continue; } else if ( tagName === 'link' && - n.attributes.rel === 'preload' && + (n.attributes.rel === 'preload' || n.attributes.rel === 'modulepreload') && n.attributes.as === 'script' ) { // ignore diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 99a23ff7be..9558c3aa5b 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -813,9 +813,9 @@ function slimDOMExcluded( slimDOMOptions.script && // script tag (sn.tagName === 'script' || - // preload link + // (module)preload link (sn.tagName === 'link' && - sn.attributes.rel === 'preload' && + (sn.attributes.rel === 'preload' || sn.attributes.rel === 'modulepreload') && sn.attributes.as === 'script') || // prefetch link (sn.tagName === 'link' && diff --git a/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap b/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap index 448823cbce..529a51eeff 100644 --- a/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap +++ b/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap @@ -370,6 +370,7 @@ exports[`integration tests [html file]: preload.html 1`] = ` Document + " `; diff --git a/packages/rrweb-snapshot/test/html/preload.html b/packages/rrweb-snapshot/test/html/preload.html index 32e84a260d..c160f60895 100644 --- a/packages/rrweb-snapshot/test/html/preload.html +++ b/packages/rrweb-snapshot/test/html/preload.html @@ -4,6 +4,7 @@ Document + From 84605b5a582478323619fb962386e8dbc416bd0b Mon Sep 17 00:00:00 2001 From: billyvg Date: Mon, 13 Feb 2023 16:25:54 +0000 Subject: [PATCH 2/2] Apply formatting changes --- packages/rrweb-snapshot/src/rebuild.ts | 3 ++- packages/rrweb-snapshot/src/snapshot.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/rrweb-snapshot/src/rebuild.ts b/packages/rrweb-snapshot/src/rebuild.ts index 92fafc2bf1..1582104a45 100644 --- a/packages/rrweb-snapshot/src/rebuild.ts +++ b/packages/rrweb-snapshot/src/rebuild.ts @@ -221,7 +221,8 @@ function buildNode( continue; } else if ( tagName === 'link' && - (n.attributes.rel === 'preload' || n.attributes.rel === 'modulepreload') && + (n.attributes.rel === 'preload' || + n.attributes.rel === 'modulepreload') && n.attributes.as === 'script' ) { // ignore diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 9558c3aa5b..e8078388a7 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -815,7 +815,8 @@ function slimDOMExcluded( (sn.tagName === 'script' || // (module)preload link (sn.tagName === 'link' && - (sn.attributes.rel === 'preload' || sn.attributes.rel === 'modulepreload') && + (sn.attributes.rel === 'preload' || + sn.attributes.rel === 'modulepreload') && sn.attributes.as === 'script') || // prefetch link (sn.tagName === 'link' &&