@@ -381,6 +381,83 @@ describe('Core', function () {
381381 } )
382382 } )
383383
384+ it ( 'v-link active classes with named routes' , function ( done ) {
385+ router = new Router ( {
386+ abstract : true ,
387+ linkActiveClass : 'active'
388+ } )
389+ router . map ( {
390+ '/a/:id' : {
391+ component : { } ,
392+ subRoutes : {
393+ 'b/:bid' : {
394+ name : 'b' ,
395+ component : { }
396+ }
397+ }
398+ }
399+ } )
400+ var App = Vue . extend ( {
401+ replace : false ,
402+ data : function ( ) {
403+ return { className : 'custom' }
404+ } ,
405+ template :
406+ '<a id="link" v-link="{ name: \'b\', params: { id: 1, bid: 2 }}">Link A</a>' +
407+ '<router-view></router-view>'
408+ } )
409+ router . start ( App , el )
410+ el = router . app . $el
411+ var link = el . querySelector ( '#link' )
412+ expect ( link . className ) . toBe ( '' )
413+ router . go ( '/a/1/b/1' )
414+ nextTick ( function ( ) {
415+ expect ( link . className ) . toBe ( '' )
416+ router . go ( { name : 'b' , params : { bid : 2 } } )
417+ nextTick ( function ( ) {
418+ expect ( link . className ) . toBe ( 'active' )
419+ expect ( router . _currentRoute . path ) . toBe ( '/a/1/b/2' )
420+ done ( )
421+ } )
422+ } )
423+ } )
424+
425+ it ( 'v-link active classes with v-link-active' , function ( done ) {
426+ router = new Router ( {
427+ abstract : true ,
428+ linkActiveClass : 'active'
429+ } )
430+ var App = Vue . extend ( {
431+ replace : false ,
432+ template :
433+ '<ul>' +
434+ '<li id="link-a" v-link-active>' +
435+ '<a v-link="{ path: \'/a\' }">Link A</a>' +
436+ '</li>' +
437+ '<li id="link-b" v-link-active>' +
438+ '<a v-link="{ path: \'/b\' }">Link B</a>' +
439+ '</li>' +
440+ '</ul>'
441+ } )
442+ router . start ( App , el )
443+ el = router . app . $el
444+ var linkA = el . querySelector ( '#link-a' )
445+ var linkB = el . querySelector ( '#link-b' )
446+ expect ( linkA . className ) . toBe ( '' )
447+ expect ( linkB . className ) . toBe ( '' )
448+ router . go ( '/a' )
449+ nextTick ( function ( ) {
450+ expect ( linkA . className ) . toBe ( 'active' )
451+ expect ( linkB . className ) . toBe ( '' )
452+ router . go ( '/b' )
453+ nextTick ( function ( ) {
454+ expect ( linkA . className ) . toBe ( '' )
455+ expect ( linkB . className ) . toBe ( 'active' )
456+ done ( )
457+ } )
458+ } )
459+ } )
460+
384461 it ( 'v-link relative querystring' , function ( done ) {
385462 router = new Router ( { abstract : true } )
386463 router . map ( {
0 commit comments