File tree Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ export default function (Vue) {
4646 // instead of activating now. This is so that the
4747 // child's activate hook is called after the
4848 // parent's has resolved.
49+ this . parentView = parentView
4950 parentView . childView = this
5051 }
5152
@@ -64,6 +65,9 @@ export default function (Vue) {
6465 } ,
6566
6667 unbind ( ) {
68+ if ( this . parentView ) {
69+ this . parentView . childView = null
70+ }
6771 this . router . _views . $remove ( this )
6872 componentDef . unbind . call ( this )
6973 }
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ describe('Core', function () {
381381 } )
382382 } )
383383
384- it ( 'v-link active classes with named routes' , function ( done ) {
384+ it ( 'v-link active classes with named routes' , function ( done ) {
385385 router = new Router ( {
386386 abstract : true ,
387387 linkActiveClass : 'active'
@@ -994,6 +994,62 @@ it('v-link active classes with named routes', function (done) {
994994 done ( )
995995 } , wait * 3 )
996996 } )
997+
998+ it ( 'switching between rotues with conditional <router-view>' , function ( done ) {
999+ router = new Router ( {
1000+ abstract : true
1001+ } )
1002+ router . map ( {
1003+ '/foo' : {
1004+ component : {
1005+ template :
1006+ '<div>' +
1007+ '{{ a }}' +
1008+ '<router-view v-if="!$loadingRouteData"></router-view>' +
1009+ '</div>' ,
1010+ data : function ( ) {
1011+ return { a : 0 }
1012+ } ,
1013+ route : {
1014+ data : function ( transition ) {
1015+ setTimeout ( function ( ) {
1016+ transition . next ( {
1017+ a : 123
1018+ } )
1019+ } , wait )
1020+ }
1021+ }
1022+ } ,
1023+ subRoutes : {
1024+ '/bar' : {
1025+ component : {
1026+ template : 'rendered'
1027+ }
1028+ }
1029+ }
1030+ } ,
1031+ '/baz' : {
1032+ component : { template : 'baz' }
1033+ }
1034+ } )
1035+ router . start ( {
1036+ template : '<div><router-view></router-view></div>'
1037+ } , el )
1038+ router . go ( '/foo/bar' )
1039+ setTimeout ( function ( ) {
1040+ expect ( router . app . $el . textContent ) . toBe ( '123rendered' )
1041+ router . go ( '/baz' )
1042+ nextTick ( function ( ) {
1043+ expect ( router . app . $el . textContent ) . toBe ( 'baz' )
1044+ // go again
1045+ router . go ( '/foo/bar' )
1046+ setTimeout ( function ( ) {
1047+ expect ( router . app . $el . textContent ) . toBe ( '123rendered' )
1048+ done ( )
1049+ } , wait * 2 )
1050+ } )
1051+ } , wait * 2 )
1052+ } )
9971053 }
9981054
9991055 function assertRoutes ( matches , options , done ) {
You can’t perform that action at this time.
0 commit comments