Skip to content

Commit dec600d

Browse files
committed
fix transition abort before activation
1 parent 00b8dff commit dec600d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/router/internal.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,27 @@ module.exports = function (Vue, Router) {
132132
return
133133
}
134134

135-
var previousRoute = this._currentRoute
136-
if (this.app && path === previousRoute.path) {
137-
return
135+
var prevRoute = this._currentRoute
136+
var prevTransition = this._currentTransition
137+
138+
// abort ongoing transition
139+
if (prevTransition && path !== prevTransition.to.path) {
140+
prevTransition.aborted = true
138141
}
139142

140-
// abort previous transition
141-
if (this._currentTransition) {
142-
this._currentTransition.aborted = true
143+
// do nothing if going to the same route.
144+
// the route only changes when a transition successfully
145+
// reaches activation; we don't need to do anything
146+
// if an ongoing transition is aborted during validation
147+
// phase.
148+
if (prevTransition && path === prevRoute.path) {
149+
return
143150
}
144151

145152
// construct new route and transition context
146153
var route = new Route(path, this)
147154
var transition = this._currentTransition =
148-
new RouteTransition(this, route, previousRoute)
155+
new RouteTransition(this, route, prevRoute)
149156

150157
if (!this.app) {
151158
// initial render

0 commit comments

Comments
 (0)