File tree 3 files changed +39
-9
lines changed
3 files changed +39
-9
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ const IndexChild2 = { template: '<div>index child2</div>' }
27
27
28
28
const Home = { template : '<div>home</div>' }
29
29
30
+ const ViewWithKeepalive = { template : '<keep-alive><router-view></router-view></keep-alive>' }
31
+
30
32
const router = new VueRouter ( {
31
33
mode : 'history' ,
32
34
base : __dirname ,
@@ -58,6 +60,26 @@ const router = new VueRouter({
58
60
path : '/with-guard2' ,
59
61
name : 'with-guard2' ,
60
62
component : WithGuard
63
+ } ,
64
+ {
65
+ path : '/one' ,
66
+ component : ViewWithKeepalive ,
67
+ children : [
68
+ {
69
+ path : 'two' ,
70
+ component : ViewWithKeepalive ,
71
+ children : [
72
+ {
73
+ path : 'child1' ,
74
+ component : IndexChild1
75
+ } ,
76
+ {
77
+ path : 'child2' ,
78
+ component : IndexChild2
79
+ }
80
+ ]
81
+ }
82
+ ]
61
83
}
62
84
]
63
85
} )
@@ -72,6 +94,8 @@ new Vue({
72
94
<li><router-link to="/home">/home</router-link></li>
73
95
<li><router-link to="/with-guard1">/with-guard1</router-link></li>
74
96
<li><router-link to="/with-guard2">/with-guard2</router-link></li>
97
+ <li><router-link to="/one/two/child1">/one/two/child1</router-link></li>
98
+ <li><router-link to="/one/two/child2">/one/two/child2</router-link></li>
75
99
</ul>
76
100
<keep-alive>
77
101
<router-view class="view"></router-view>
Original file line number Diff line number Diff line change @@ -26,14 +26,11 @@ export default {
26
26
let depth = 0
27
27
let inactive = false
28
28
while ( parent && parent . _routerRoot !== parent ) {
29
- const vnodeData = parent . $vnode && parent . $vnode . data
30
- if ( vnodeData ) {
31
- if ( vnodeData . routerView ) {
32
- depth ++
33
- }
34
- if ( vnodeData . keepAlive && parent . _inactive ) {
35
- inactive = true
36
- }
29
+ if ( parent . $vnode && parent . $vnode . data . routerView ) {
30
+ depth ++
31
+ }
32
+ if ( parent . _directInactive && parent . _inactive ) {
33
+ inactive = true
37
34
}
38
35
parent = parent . $parent
39
36
}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ module.exports = {
9
9
browser
10
10
. url ( 'http://localhost:8080/keepalive-view/' )
11
11
. waitForElementVisible ( '#app' , 1000 )
12
- . assert . count ( 'li a' , 5 )
12
+ . assert . count ( 'li a' , 7 )
13
13
14
14
. click ( 'li:nth-child(1) a' )
15
15
. assert . containsText ( '.view' , 'index child1' )
@@ -35,6 +35,15 @@ module.exports = {
35
35
. click ( 'li:nth-child(4) a' )
36
36
. assert . containsText ( '.view' , 'with-guard1: 3' )
37
37
38
+ // keep-alive deeply nested router-views
39
+ // https://github.com/vuejs/vue-router/issues/2923
40
+ . click ( 'li:nth-child(6) a' )
41
+ . assert . containsText ( '.view' , 'index child1' )
42
+ . click ( 'li:nth-child(3) a' )
43
+ . assert . containsText ( '.view' , 'home' )
44
+ . click ( 'li:nth-child(7) a' )
45
+ . assert . containsText ( '.view' , 'index child2' )
46
+
38
47
. end ( )
39
48
}
40
49
}
You can’t perform that action at this time.
0 commit comments