From 7677aa0f9be68ed47ac6ab15be5695d0ad998f14 Mon Sep 17 00:00:00 2001 From: Stefan Jongejan <1260212+sjongejan@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:04:32 +0100 Subject: [PATCH] Ensure callback execution regardless of `preserveUrl` in `history.pushState` and `history.replaceState` --- packages/core/src/history.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/src/history.ts b/packages/core/src/history.ts index 1f5c1b271..5db7605bf 100644 --- a/packages/core/src/history.ts +++ b/packages/core/src/history.ts @@ -31,10 +31,16 @@ class History { } public pushState(page: Page, cb: (() => void) | null = null): void { - if (isServer || this.preserveUrl) { + if (isServer) { return } + if (this.preserveUrl) { + cb && cb(); + + return; + } + this.current = page this.addToQueue(() => { @@ -98,10 +104,16 @@ class History { public replaceState(page: Page, cb: (() => void) | null = null): void { currentPage.merge(page) - if (isServer || this.preserveUrl) { + if (isServer) { return } + if (this.preserveUrl) { + cb && cb(); + + return; + } + this.current = page this.addToQueue(() => {