@@ -78,18 +78,19 @@ export class ComponentWalker {
78
78
/**
79
79
* Get children from a component instance.
80
80
*/
81
- private getInternalInstanceChildren ( subTree ) {
81
+ private getInternalInstanceChildren ( subTree , suspense = null ) {
82
82
const list = [ ]
83
83
if ( subTree . component ) {
84
- list . push ( subTree . component )
84
+ ! suspense ? list . push ( subTree . component ) : list . push ( { ... subTree . component , suspense } )
85
85
} else if ( subTree . suspense ) {
86
- list . push ( ...this . getInternalInstanceChildren ( subTree . suspense . activeBranch ) )
86
+ const suspenseKey = ! subTree . suspense . isInFallback ? 'default' : 'fallback'
87
+ list . push ( ...this . getInternalInstanceChildren ( subTree . suspense . activeBranch , { ...subTree . suspense , suspenseKey } ) )
87
88
} else if ( Array . isArray ( subTree . children ) ) {
88
89
subTree . children . forEach ( childSubTree => {
89
90
if ( childSubTree . component ) {
90
- list . push ( childSubTree . component )
91
+ ! suspense ? list . push ( childSubTree . component ) : list . push ( { ... childSubTree . component , suspense } )
91
92
} else {
92
- list . push ( ...this . getInternalInstanceChildren ( childSubTree ) )
93
+ list . push ( ...this . getInternalInstanceChildren ( childSubTree , suspense ) )
93
94
}
94
95
} )
95
96
}
@@ -159,9 +160,10 @@ export class ComponentWalker {
159
160
// keep-alive
160
161
if ( instance . type . __isKeepAlive && instance . __v_cache ) {
161
162
const cachedComponents = Array . from ( instance . __v_cache . values ( ) ) . map ( ( vnode : any ) => vnode . component ) . filter ( Boolean )
162
- for ( const child of cachedComponents ) {
163
- if ( ! children . includes ( child ) ) {
164
- const node = await this . capture ( { ...child , isDeactivated : true } , null , depth + 1 )
163
+ const childrenIds = children . map ( child => child . __VUE_DEVTOOLS_UID__ )
164
+ for ( const cachedChild of cachedComponents ) {
165
+ if ( ! childrenIds . includes ( cachedChild . __VUE_DEVTOOLS_UID__ ) ) {
166
+ const node = await this . capture ( { ...cachedChild , isDeactivated : true } , null , depth + 1 )
165
167
if ( node ) {
166
168
treeNode . children . push ( node )
167
169
}
@@ -193,6 +195,15 @@ export class ComponentWalker {
193
195
textColor : 0xffffff ,
194
196
tooltip : 'Suspense' ,
195
197
} )
198
+ if ( instance . suspense . suspenseKey ) {
199
+ treeNode . tags . push ( {
200
+ label : instance . suspense . suspenseKey ,
201
+ backgroundColor : 0xe492e4 ,
202
+ textColor : 0xffffff ,
203
+ } )
204
+ // update instanceMap
205
+ this . mark ( instance , true )
206
+ }
196
207
}
197
208
198
209
return this . api . visitComponentTree ( instance , treeNode , this . componentFilter . filter , this . ctx . currentAppRecord . options . app )
@@ -203,9 +214,9 @@ export class ComponentWalker {
203
214
*
204
215
* @param {Vue } instance
205
216
*/
206
- private mark ( instance ) {
217
+ private mark ( instance , force = false ) {
207
218
const instanceMap = this . ctx . currentAppRecord . instanceMap
208
- if ( ! instanceMap . has ( instance . __VUE_DEVTOOLS_UID__ ) ) {
219
+ if ( force || ! instanceMap . has ( instance . __VUE_DEVTOOLS_UID__ ) ) {
209
220
instanceMap . set ( instance . __VUE_DEVTOOLS_UID__ , instance )
210
221
}
211
222
}
0 commit comments