File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 11import { warn } from '../util'
2+ const regexEscapeRE = / [ - . * + ? ^ $ { } ( ) | [ \] \/ \\ ] / g
23
34// install v-link, which provides navigation support for
45// HTML5 history mode
@@ -46,7 +47,9 @@ export default function (Vue) {
4647 let router = this . vm . $route . router
4748 let activeClass = router . _linkActiveClass
4849 let exactClass = activeClass + '-exact'
49- if ( path . indexOf ( dest ) === 0 && path !== '/' ) {
50+ if ( this . activeRE &&
51+ this . activeRE . test ( path ) &&
52+ path !== '/' ) {
5053 _ . addClass ( el , activeClass )
5154 } else {
5255 _ . removeClass ( el , activeClass )
@@ -60,6 +63,9 @@ export default function (Vue) {
6063
6164 update : function ( path ) {
6265 this . destination = path
66+ this . activeRE = path
67+ ? new RegExp ( '^' + path . replace ( regexEscapeRE , '\\$&' ) + '\\b' )
68+ : null
6369 this . updateClasses ( this . vm . $route . path )
6470 path = path || ''
6571 let router = this . vm . $route . router
Original file line number Diff line number Diff line change @@ -240,7 +240,13 @@ describe('Core', function () {
240240 nextTick ( function ( ) {
241241 expect ( linkA . className ) . toBe ( '' )
242242 expect ( linkB . className ) . toBe ( 'active' )
243- done ( )
243+ router . go ( '/bcd' )
244+ nextTick ( function ( ) {
245+ // #114 should not match
246+ expect ( linkA . className ) . toBe ( '' )
247+ expect ( linkB . className ) . toBe ( '' )
248+ done ( )
249+ } )
244250 } )
245251 } )
246252 } )
You can’t perform that action at this time.
0 commit comments