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) {
46
46
// instead of activating now. This is so that the
47
47
// child's activate hook is called after the
48
48
// parent's has resolved.
49
+ this . parentView = parentView
49
50
parentView . childView = this
50
51
}
51
52
@@ -64,6 +65,9 @@ export default function (Vue) {
64
65
} ,
65
66
66
67
unbind ( ) {
68
+ if ( this . parentView ) {
69
+ this . parentView . childView = null
70
+ }
67
71
this . router . _views . $remove ( this )
68
72
componentDef . unbind . call ( this )
69
73
}
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ describe('Core', function () {
381
381
} )
382
382
} )
383
383
384
- it ( 'v-link active classes with named routes' , function ( done ) {
384
+ it ( 'v-link active classes with named routes' , function ( done ) {
385
385
router = new Router ( {
386
386
abstract : true ,
387
387
linkActiveClass : 'active'
@@ -994,6 +994,62 @@ it('v-link active classes with named routes', function (done) {
994
994
done ( )
995
995
} , wait * 3 )
996
996
} )
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
+ } )
997
1053
}
998
1054
999
1055
function assertRoutes ( matches , options , done ) {
You can’t perform that action at this time.
0 commit comments