Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-pandas-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

perf: use a `Set` to check element ids when validating fragment links during prerendering
6 changes: 3 additions & 3 deletions packages/kit/src/core/postbuild/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env, vit
/** @type {Map<string, Set<string>>} */
const expected_hashlinks = new Map();

/** @type {Map<string, string[]>} */
/** @type {Map<string, Set<string>>} */
const actual_hashlinks = new Map();

/**
Expand Down Expand Up @@ -394,7 +394,7 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env, vit
handle_invalid_url({ href, referrer: decoded });
}

actual_hashlinks.set(decoded, ids);
actual_hashlinks.set(decoded, new Set(ids));

/** @param {string} href */
const removePrerenderOrigin = (href) => {
Expand Down Expand Up @@ -646,7 +646,7 @@ async function prerender({ hash, out, manifest_path, metadata, verbose, env, vit
// ignore fragment links to pages that were not prerendered
if (!hashlinks) continue;

if (!hashlinks.includes(id) && !SPECIAL_HASHLINKS.has(id)) {
if (!hashlinks.has(id) && !SPECIAL_HASHLINKS.has(id)) {
handle_missing_id({ id, path, referrers: Array.from(referrers) });
}
}
Expand Down
Loading