@@ -80,11 +80,9 @@ export class ComponentWalker {
80
80
const list = [ ]
81
81
if ( subTree . component ) {
82
82
list . push ( subTree . component )
83
- }
84
- if ( subTree . suspense ) {
83
+ } else if ( subTree . suspense ) {
85
84
list . push ( ...this . getInternalInstanceChildren ( subTree . suspense . activeBranch ) )
86
- }
87
- if ( Array . isArray ( subTree . children ) ) {
85
+ } else if ( Array . isArray ( subTree . children ) ) {
88
86
subTree . children . forEach ( childSubTree => {
89
87
if ( childSubTree . component ) {
90
88
list . push ( childSubTree . component )
@@ -129,20 +127,26 @@ export class ComponentWalker {
129
127
const children = this . getInternalInstanceChildren ( instance . subTree )
130
128
. filter ( child => ! isBeingDestroyed ( child ) )
131
129
130
+ const parents = this . getComponentParents ( instance ) || [ ]
131
+
132
+ const inactive = ! ! instance . isDeactivated || parents . some ( parent => parent . isDeactivated )
133
+
132
134
const treeNode : ComponentTreeNode = {
133
135
uid : instance . uid ,
134
136
id,
135
137
name,
136
138
renderKey : getRenderKey ( instance . vnode ? instance . vnode . key : null ) ,
137
- inactive : ! ! instance . isDeactivated ,
139
+ inactive,
138
140
hasChildren : ! ! children . length ,
139
141
children : [ ] ,
140
142
isFragment : isFragment ( instance ) ,
141
143
tags : [ ]
142
144
}
143
145
146
+ const isKeepAliveChildren = parents . some ( parent => parent . type . __isKeepAlive )
147
+
144
148
// capture children
145
- if ( depth < this . maxDepth ) {
149
+ if ( isKeepAliveChildren || depth < this . maxDepth ) {
146
150
treeNode . children = await Promise . all ( children
147
151
. map ( ( child , index , list ) => this . capture ( child , list , depth + 1 ) )
148
152
. filter ( Boolean ) )
@@ -153,9 +157,8 @@ export class ComponentWalker {
153
157
const cachedComponents = Array . from ( instance . __v_cache . values ( ) ) . map ( ( vnode : any ) => vnode . component ) . filter ( Boolean )
154
158
for ( const child of cachedComponents ) {
155
159
if ( ! children . includes ( child ) ) {
156
- const node = await this . capture ( child , null , depth + 1 )
160
+ const node = await this . capture ( { ... child , isDeactivated : true } , null , depth + 1 )
157
161
if ( node ) {
158
- node . inactive = true
159
162
treeNode . children . push ( node )
160
163
}
161
164
}
0 commit comments