diff --git a/.changeset/slow-toes-clap.md b/.changeset/slow-toes-clap.md new file mode 100644 index 000000000000..77838348c450 --- /dev/null +++ b/.changeset/slow-toes-clap.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: transform link[rel='shortcut icon'] and link[rel='apple-touch-icon'] to be absolute to avoid console error when navigating diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 37660a425e65..09618a4b2b9e 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -46,6 +46,8 @@ import { INVALIDATED_PARAM, TRAILING_SLASH_PARAM, validate_depends } from '../sh import { get_message, get_status } from '../../utils/error.js'; import { writable } from 'svelte/store'; +const ICON_REL_ATTRIBUTES = new Set(['icon', 'shortcut icon', 'apple-touch-icon']); + let errored = false; // We track the scroll position associated with each history entry in sessionStorage, @@ -2307,7 +2309,9 @@ function _start_router() { // URLs after a pushState/replaceState, resulting in a 404 — see // https://github.com/sveltejs/kit/issues/3748#issuecomment-1125980897 for (const link of document.querySelectorAll('link')) { - if (link.rel === 'icon') link.href = link.href; // eslint-disable-line + if (ICON_REL_ATTRIBUTES.has(link.rel)) { + link.href = link.href; // eslint-disable-line + } } addEventListener('pageshow', (event) => {