File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,16 @@ export function createRouter(
64
64
}
65
65
66
66
async function go ( href : string = inBrowser ? location . href : '/' ) {
67
+ const currentHash = inBrowser ? location . hash : ''
67
68
href = normalizeHref ( href )
68
69
if ( ( await router . onBeforeRouteChange ?.( href ) ) === false ) return
69
70
updateHistory ( href )
70
71
await loadPage ( href )
71
72
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
+ }
72
77
}
73
78
74
79
let latestPendingPath : string | null = null
@@ -211,12 +216,7 @@ export function createRouter(
211
216
window . scrollTo ( 0 , 0 )
212
217
}
213
218
} 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 )
220
220
}
221
221
}
222
222
}
You can’t perform that action at this time.
0 commit comments