diff --git a/.changeset/smooth-dogs-travel.md b/.changeset/smooth-dogs-travel.md new file mode 100644 index 000000000000..0a33331f1f5f --- /dev/null +++ b/.changeset/smooth-dogs-travel.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: decode non ASCII anchor hashes when scrolling into view diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 2f4099c6cb50..5f251a07362f 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -2121,7 +2121,7 @@ function _start_router() { if (hash === '' || (hash === 'top' && a.ownerDocument.getElementById('top') === null)) { window.scrollTo({ top: 0 }); } else { - a.ownerDocument.getElementById(hash)?.scrollIntoView(); + a.ownerDocument.getElementById(decodeURIComponent(hash))?.scrollIntoView(); } return; diff --git a/packages/kit/test/apps/basics/src/routes/anchor/anchor/+page.svelte b/packages/kit/test/apps/basics/src/routes/anchor/anchor/+page.svelte index 2cf545d88a6b..c977dfcf429c 100644 --- a/packages/kit/test/apps/basics/src/routes/anchor/anchor/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/anchor/anchor/+page.svelte @@ -8,3 +8,4 @@
The browser scrolls to me