Unverified Commit 670bf326 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

chore(turbopack): regenerate snapshots after rebase onto canary

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 9ac47e18
;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="b4c3766a-bc53-60b0-28d2-9d8aaf741728")}catch(e){}}(); ;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="24776b7f-22e0-684b-d260-4af76b268cd2")}catch(e){}}();
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0rv8_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0bjegbrfzt05o.js", "output/0rv8_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0bjegbrfzt05o.js",
{"otherChunks":["output/0_9x_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_03ibyvsq4xsbk.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/0_9x_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_03ibyvsq4xsbk.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/browser/input/index.js [test] (ecmascript)"]}
...@@ -2316,15 +2316,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2316,15 +2316,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2335,12 +2341,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2335,12 +2341,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2351,7 +2357,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2351,7 +2357,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2602,7 +2608,7 @@ let DEV_BACKEND; ...@@ -2602,7 +2608,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
...@@ -2695,5 +2701,5 @@ chunkListsToRegister.forEach(registerChunkList); ...@@ -2695,5 +2701,5 @@ chunkListsToRegister.forEach(registerChunkList);
})(); })();
//# debugId=b4c3766a-bc53-60b0-28d2-9d8aaf741728 //# debugId=24776b7f-22e0-684b-d260-4af76b268cd2
//# sourceMappingURL=0_9x_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0bjegbrfzt05o.js.map //# sourceMappingURL=0_9x_turbopack-tests_tests_snapshot_debug-ids_browser_input_index_0bjegbrfzt05o.js.map
\ No newline at end of file
...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2601,7 +2607,7 @@ let DEV_BACKEND; ...@@ -2601,7 +2607,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
......
...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2601,7 +2607,7 @@ let DEV_BACKEND; ...@@ -2601,7 +2607,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
......
...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2601,7 +2607,7 @@ let DEV_BACKEND; ...@@ -2601,7 +2607,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
......
...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2601,7 +2607,7 @@ let DEV_BACKEND; ...@@ -2601,7 +2607,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
......
...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2315,15 +2315,21 @@ function getAssetSuffixFromScriptSrc() {
*/ function matchesChunkUrl(value, url, decodedUrl) { */ function matchesChunkUrl(value, url, decodedUrl) {
return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?')); return value != null && (value === url || value.startsWith(url + '?') || value === decodedUrl || value.startsWith(decodedUrl + '?'));
} }
// These lookups iterate the tag collection and compare attribute values as // These lookups only search `<head>`: the runtime inserts its chunk tags there,
// plain strings. A document-wide `querySelectorAll` with attribute selectors // and chunk tags rendered into the HTML are expected there too. Tags in
// costs time proportional to the size of the whole DOM on every call, and // `<body>` are deliberately ignored, so that the cost of a lookup does not grow
// would need the URL to be CSS-escaped. // with the size of the page content. A chunk whose tag is only in `<body>` is
/** // loaded again through a new tag in `<head>`, and unloading a chunk leaves its
* Returns all `<script>` elements in the document whose `src` refers to `url`. // `<body>` tags in place.
//
// They iterate the tag collection and compare attribute values as plain
// strings. `querySelectorAll` with attribute selectors would need the URL to be
// CSS-escaped.
/**
* Returns all `<script>` elements in `<head>` whose `src` refers to `url`.
*/ function findChunkScripts(url) { */ function findChunkScripts(url) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const scripts = document.getElementsByTagName('script'); const scripts = document.head.getElementsByTagName('script');
const result = []; const result = [];
for(let i = 0; i < scripts.length; i++){ for(let i = 0; i < scripts.length; i++){
const script = scripts[i]; const script = scripts[i];
...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2334,12 +2340,12 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link>` elements in the document whose `href` refers to `url`. * Returns all `<link>` elements in `<head>` whose `href` refers to `url`.
* With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet` * With `stylesheetsOnly`, only links whose `rel` is exactly `stylesheet`
* (ASCII case-insensitive) are returned. * (ASCII case-insensitive) are returned.
*/ function findChunkLinks(url, stylesheetsOnly = false) { */ function findChunkLinks(url, stylesheetsOnly = false) {
const decodedUrl = decodeURI(url); const decodedUrl = decodeURI(url);
const links = document.getElementsByTagName('link'); const links = document.head.getElementsByTagName('link');
const result = []; const result = [];
for(let i = 0; i < links.length; i++){ for(let i = 0; i < links.length; i++){
const link = links[i]; const link = links[i];
...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() { ...@@ -2350,7 +2356,7 @@ function getAssetSuffixFromScriptSrc() {
return result; return result;
} }
/** /**
* Returns all `<link rel=stylesheet>` elements in the document whose `href` * Returns all `<link rel=stylesheet>` elements in `<head>` whose `href`
* refers to `url`. * refers to `url`.
*/ function findChunkStylesheets(url) { */ function findChunkStylesheets(url) {
return findChunkLinks(url, true); return findChunkLinks(url, true);
...@@ -2601,7 +2607,7 @@ let DEV_BACKEND; ...@@ -2601,7 +2607,7 @@ let DEV_BACKEND;
} else if (isJs(chunkUrl)) { } else if (isJs(chunkUrl)) {
// Unloading a JS chunk would have no effect, as it lives in the JS // Unloading a JS chunk would have no effect, as it lives in the JS
// runtime once evaluated. // runtime once evaluated.
// However, we still want to remove the script tag from the DOM to keep // However, we still want to remove the script tag from `<head>` to keep
// the HTML somewhat consistent from the user's perspective. // the HTML somewhat consistent from the user's perspective.
for (const script of findChunkScripts(baseChunkUrl)){ for (const script of findChunkScripts(baseChunkUrl)){
script.remove(); script.remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment