File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ export class AbstractHistory extends History {
37
37
this . confirmTransition ( route , ( ) => {
38
38
this . index = targetIndex
39
39
this . updateRoute ( route )
40
+ } , ( err ) => {
41
+ if ( err === 'SAME_ROUTE' ) {
42
+ this . index = targetIndex
43
+ }
40
44
} )
41
45
}
42
46
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export class History {
103
103
route . matched . length === current . matched . length
104
104
) {
105
105
this . ensureURL ( )
106
- return abort ( )
106
+ return abort ( 'SAME_ROUTE' )
107
107
}
108
108
109
109
const {
Original file line number Diff line number Diff line change @@ -35,4 +35,21 @@ describe('Usage in Node', () => {
35
35
expect ( router . getMatchedComponents ( '/' ) ) . toEqual ( [ Foo ] )
36
36
expect ( router . getMatchedComponents ( '/bar/baz' ) ) . toEqual ( [ Bar , Baz ] )
37
37
} )
38
+
39
+ it ( 'should navigate through history with same consecutive routes in history stack' , ( ) => {
40
+ const router = new VueRouter ( {
41
+ routes : [
42
+ { path : '/' , component : { name : 'foo' } } ,
43
+ { path : '/bar' , component : { name : 'bar' } }
44
+ ]
45
+ } )
46
+ router . push ( '/' )
47
+ router . push ( '/bar' )
48
+ router . push ( '/' )
49
+ router . replace ( '/bar' )
50
+ router . back ( )
51
+ expect ( router . history . current . path ) . toBe ( '/bar' )
52
+ router . back ( )
53
+ expect ( router . history . current . path ) . toBe ( '/' )
54
+ } )
38
55
} )
You can’t perform that action at this time.
0 commit comments