33import type Router from '../index'
44import { History } from './base'
55import { NavigationDuplicated } from './errors'
6+ import { isExtendedError } from '../util/warn'
67
78export class AbstractHistory extends History {
89 index : number
@@ -15,18 +16,26 @@ export class AbstractHistory extends History {
1516 }
1617
1718 push ( location : RawLocation , onComplete ? : Function , onAbort ? : Function ) {
18- this . transitionTo ( location , route => {
19- this . stack = this . stack . slice ( 0 , this . index + 1 ) . concat ( route )
20- this . index ++
21- onComplete && onComplete ( route )
22- } , onAbort )
19+ this . transitionTo (
20+ location ,
21+ route => {
22+ this . stack = this . stack . slice ( 0 , this . index + 1 ) . concat ( route )
23+ this . index ++
24+ onComplete && onComplete ( route )
25+ } ,
26+ onAbort
27+ )
2328 }
2429
2530 replace ( location : RawLocation , onComplete ? : Function , onAbort ? : Function ) {
26- this . transitionTo ( location , route => {
27- this . stack = this . stack . slice ( 0 , this . index ) . concat ( route )
28- onComplete && onComplete ( route )
29- } , onAbort )
31+ this . transitionTo (
32+ location ,
33+ route => {
34+ this . stack = this . stack . slice ( 0 , this . index ) . concat ( route )
35+ onComplete && onComplete ( route )
36+ } ,
37+ onAbort
38+ )
3039 }
3140
3241 go ( n : number ) {
@@ -42,7 +51,7 @@ export class AbstractHistory extends History {
4251 this . updateRoute ( route )
4352 } ,
4453 err => {
45- if ( err instanceof NavigationDuplicated ) {
54+ if ( isExtendedError ( NavigationDuplicated , err ) ) {
4655 this . index = targetIndex
4756 }
4857 }
0 commit comments