Skip to content

Commit 2df9bab

Browse files
committed
chore: adjust fix for #3637
1 parent 6b971a0 commit 2df9bab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/client/app/router.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ export function createRouter(
6464
}
6565

6666
async function go(href: string = inBrowser ? location.href : '/') {
67+
const currentHash = inBrowser ? location.hash : ''
6768
href = normalizeHref(href)
6869
if ((await router.onBeforeRouteChange?.(href)) === false) return
6970
updateHistory(href)
7071
await loadPage(href)
7172
await router.onAfterRouteChanged?.(href)
73+
// do after the route is changed so location.hash in theme code is the new hash
74+
if (new URL(href, fakeHost).hash !== currentHash) {
75+
window.dispatchEvent(new Event('hashchange'))
76+
}
7277
}
7378

7479
let latestPendingPath: string | null = null
@@ -211,12 +216,7 @@ export function createRouter(
211216
window.scrollTo(0, 0)
212217
}
213218
} else {
214-
go(href).then(() => {
215-
// do after the route is changed so location.hash in theme code is the new hash
216-
if (hash !== currentUrl.hash) {
217-
window.dispatchEvent(new Event('hashchange'))
218-
}
219-
})
219+
go(href)
220220
}
221221
}
222222
}

0 commit comments

Comments
 (0)