Description
Describe the bug
I have some routes where I store application data encoded in the URL hash (not for routing). When the data is gzipped with a gzip:
prefix, SvelteKit's reset_focus
function crashes because it tries to call document.querySelector(location.hash)
with an invalid CSS selector.
kit/packages/kit/src/runtime/client/client.js
Line 2804 in 5594597
Reproduction
https://github.com/taasan/sveltekit-reset-focus-bug/
Logs
Edit: replaced firefox backtrace, which was a mile long, with the chrome stacktrace
Uncaught (in promise) SyntaxError: Failed to execute 'querySelector' on 'Document': '#gzip:H4sIAAAAAAAAA0sqTQcAFL+MNQMAAAA=' is not a valid selector.
at reset_focus (client.js?v=2915ee31:2804:46)
System Info
System:
OS: Linux 6.14 Fedora Linux 42 (Workstation Edition)
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Memory: 19.58 GB / 31.09 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.16.0 - /usr/bin/node
npm: 10.9.2 - /usr/bin/npm
Browsers:
Chrome: 137.0.7151.68
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.0.1
@sveltejs/kit: ^2.16.0 => 2.21.4
@sveltejs/vite-plugin-svelte: ^5.0.0 => 5.1.0
svelte: ^5.0.0 => 5.33.19
vite: ^6.2.6 => 6.3.5
Severity
annoyance
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels