@@ -380,22 +380,38 @@ class Router {
380
380
return
381
381
}
382
382
383
- let prevRoute = this . _currentRoute
384
- let prevTransition = this . _currentTransition
383
+ let currentRoute = this . _currentRoute
384
+ let currentTransition = this . _currentTransition
385
385
386
- // do nothing if going to the same route.
387
386
// the route only changes when a transition successfully
388
387
// reaches activation; we don't need to do anything
389
388
// if an ongoing transition is aborted during validation
390
389
// phase.
391
- if ( prevTransition && path === prevRoute . path ) {
392
- return
390
+ if ( currentTransition ) {
391
+ if ( currentTransition . to . path === path ) {
392
+ // do nothing if we have an active transition going to the same path
393
+ return
394
+ } else if ( currentRoute . path === path ) {
395
+ // We are going to the same path, but we also have an ongoing but
396
+ // not-yet-validated transition. Abort that transition and reset to
397
+ // prev transition.
398
+ currentTransition . aborted = true
399
+ this . _currentTransition = this . _prevTransition
400
+ return
401
+ } else {
402
+ // going to a totally different path. abort ongoing transition.
403
+ currentTransition . aborted = true
404
+ }
393
405
}
394
406
395
407
// construct new route and transition context
396
408
let route = new Route ( path , this )
397
- let transition = new Transition ( this , route , prevRoute )
398
- this . _prevTransition = prevTransition
409
+ let transition = new Transition ( this , route , currentRoute )
410
+
411
+ // current transition is updated right now.
412
+ // however, current route will only be updated after the transition has
413
+ // been validated.
414
+ this . _prevTransition = currentTransition
399
415
this . _currentTransition = transition
400
416
401
417
if ( ! this . app ) {
@@ -448,12 +464,6 @@ class Router {
448
464
*/
449
465
450
466
_onTransitionValidated ( transition ) {
451
- // now that this one is validated, we can abort
452
- // the previous transition.
453
- let prevTransition = this . _prevTransition
454
- if ( prevTransition ) {
455
- prevTransition . aborted = true
456
- }
457
467
// set current route
458
468
let route = this . _currentRoute = transition . to
459
469
// update route context for all children
@@ -569,12 +579,6 @@ Router.install = function (externalVue) {
569
579
View ( Vue )
570
580
Link ( Vue )
571
581
util . Vue = Vue
572
- // 1.0 only: enable route mixins
573
- var strats = Vue . config . optionMergeStrategies
574
- if ( strats ) {
575
- // use the same merge strategy as methods (object hash)
576
- strats . route = strats . methods
577
- }
578
582
Router . installed = true
579
583
}
580
584
0 commit comments