Skip to content

Commit 07a3d55

Browse files
committed
feat(url): call afterEach hooks after url is ensured
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 8ac478f commit 07a3d55

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
@@ -64,9 +64,13 @@ export class History {
6464
transitionTo (location: RawLocation, onComplete?: Function, onAbort?: Function) {
6565
const route = this.router.match(location, this.current)
6666
this.confirmTransition(route, () => {
67+
const prev = this.current
6768
this.updateRoute(route)
6869
onComplete && onComplete(route)
6970
this.ensureURL()
71+
this.router.afterHooks.forEach(hook => {
72+
hook && hook(route, prev)
73+
})
7074

7175
// fire ready cbs once
7276
if (!this.ready) {
@@ -183,12 +187,8 @@ export class History {
183187
}
184188

185189
updateRoute (route: Route) {
186-
const prev = this.current
187190
this.current = route
188191
this.cb && this.cb(route)
189-
this.router.afterHooks.forEach(hook => {
190-
hook && hook(route, prev)
191-
})
192192
}
193193
}
194194

0 commit comments

Comments
 (0)