fix: Exclude scripts loaded with rel=modulepreload from snapshots (#1128)
* fix: Exclude `modulepreload` as well We were only excluding `<link rel="preload" as="script" />` but we should include `rel="modulepreload"` as well * Apply formatting changes
This commit is contained in:
@@ -221,7 +221,8 @@ function buildNode(
|
|||||||
continue;
|
continue;
|
||||||
} else if (
|
} else if (
|
||||||
tagName === 'link' &&
|
tagName === 'link' &&
|
||||||
n.attributes.rel === 'preload' &&
|
(n.attributes.rel === 'preload' ||
|
||||||
|
n.attributes.rel === 'modulepreload') &&
|
||||||
n.attributes.as === 'script'
|
n.attributes.as === 'script'
|
||||||
) {
|
) {
|
||||||
// ignore
|
// ignore
|
||||||
|
|||||||
@@ -813,9 +813,10 @@ function slimDOMExcluded(
|
|||||||
slimDOMOptions.script &&
|
slimDOMOptions.script &&
|
||||||
// script tag
|
// script tag
|
||||||
(sn.tagName === 'script' ||
|
(sn.tagName === 'script' ||
|
||||||
// preload link
|
// (module)preload link
|
||||||
(sn.tagName === 'link' &&
|
(sn.tagName === 'link' &&
|
||||||
sn.attributes.rel === 'preload' &&
|
(sn.attributes.rel === 'preload' ||
|
||||||
|
sn.attributes.rel === 'modulepreload') &&
|
||||||
sn.attributes.as === 'script') ||
|
sn.attributes.as === 'script') ||
|
||||||
// prefetch link
|
// prefetch link
|
||||||
(sn.tagName === 'link' &&
|
(sn.tagName === 'link' &&
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ exports[`integration tests [html file]: preload.html 1`] = `
|
|||||||
<title>Document</title>
|
<title>Document</title>
|
||||||
<link />
|
<link />
|
||||||
<link />
|
<link />
|
||||||
|
<link />
|
||||||
</head>
|
</head>
|
||||||
<body></body></html>"
|
<body></body></html>"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Document</title>
|
<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="preload" href="https://example/path/to/preload.js" as="script" />
|
||||||
<link rel="prefetch" href="https://example/path/to/prefetch.js" />
|
<link rel="prefetch" href="https://example/path/to/prefetch.js" />
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user