Skip to content

Commit

Permalink
Revert "fix: Exclude scripts loaded with rel=modulepreload from sna…
Browse files Browse the repository at this point in the history
…pshots (#1128)"

This reverts commit b540c04.
  • Loading branch information
Juice10 committed Feb 14, 2023
1 parent b540c04 commit 1d5a5b8
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ function buildNode(
continue;
} else if (
tagName === 'link' &&
(n.attributes.rel === 'preload' ||
n.attributes.rel === 'modulepreload') &&
n.attributes.rel === 'preload' &&
n.attributes.as === 'script'
) {
// ignore
Expand Down
5 changes: 2 additions & 3 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,9 @@ function slimDOMExcluded(
slimDOMOptions.script &&
// script tag
(sn.tagName === 'script' ||
// (module)preload link
// preload link
(sn.tagName === 'link' &&
(sn.attributes.rel === 'preload' ||
sn.attributes.rel === 'modulepreload') &&
sn.attributes.rel === 'preload' &&
sn.attributes.as === 'script') ||
// prefetch link
(sn.tagName === 'link' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ exports[`integration tests [html file]: preload.html 1`] = `
<title>Document</title>
<link />
<link />
<link />
</head>
<body></body></html>"
`;
Expand Down
1 change: 0 additions & 1 deletion packages/rrweb-snapshot/test/html/preload.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="modulepreload" href="https://example/path/to/preload.js" as="script" />
<link rel="preload" href="https://example/path/to/preload.js" as="script" />
<link rel="prefetch" href="https://example/path/to/prefetch.js" />
</head>
Expand Down

0 comments on commit 1d5a5b8

Please sign in to comment.