From 4627417f667a6a82fe422278ba60d36052ce48d2 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 14 Sep 2022 17:44:24 +0200 Subject: [PATCH] [fix] update current.url on hashchange (#6802) Fixes #5693 --- .changeset/funny-cycles-travel.md | 5 +++++ packages/kit/src/runtime/client/client.js | 2 ++ .../basics/src/routes/routing/hashes/pagestore/+page.svelte | 3 ++- packages/kit/test/apps/basics/test/client.test.js | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/funny-cycles-travel.md diff --git a/.changeset/funny-cycles-travel.md b/.changeset/funny-cycles-travel.md new file mode 100644 index 000000000000..80f8a991c80a --- /dev/null +++ b/.changeset/funny-cycles-travel.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] update current.url on hashchange diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 09be6d707ab3..9cfcf0b3e6f7 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -1321,10 +1321,12 @@ export function create_client({ target, base, trailing_slash }) { if (hash !== undefined && base === location.href.split('#')[0]) { // set this flag to distinguish between navigations triggered by // clicking a hash link and those triggered by popstate + // TODO why not update history here directly? hash_navigating = true; update_scroll_positions(current_history_index); + current.url = url; stores.page.set({ ...page, url }); stores.page.notify(); diff --git a/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte b/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte index 4a20ec56a628..630589a9d5a1 100644 --- a/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte +++ b/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte @@ -17,5 +17,6 @@