Skip to content

Commit 1575a18

Browse files
authored
feat(url): call afterEach hooks after url is ensured (#2292)
Closes #2079 This helps integrating with external scripts and makes more sense as the navigation is finished. However, onComplete callback passed to `router.push` is now called before `afterEach` hooks. This shouldn't be a problem as there's no guarantee provided anywhere in the docs about this
1 parent af75417 commit 1575a18

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/history/base.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ export class History {
8181
this.confirmTransition(
8282
route,
8383
() => {
84+
const prev = this.current
8485
this.updateRoute(route)
8586
onComplete && onComplete(route)
8687
this.ensureURL()
88+
this.router.afterHooks.forEach(hook => {
89+
hook && hook(route, prev)
90+
})
8791

8892
// fire ready cbs once
8993
if (!this.ready) {
@@ -214,12 +218,8 @@ export class History {
214218
}
215219

216220
updateRoute (route: Route) {
217-
const prev = this.current
218221
this.current = route
219222
this.cb && this.cb(route)
220-
this.router.afterHooks.forEach(hook => {
221-
hook && hook(route, prev)
222-
})
223223
}
224224

225225
setupListeners () {

0 commit comments

Comments
 (0)