@@ -19,12 +19,12 @@ const functionalIds = new Map()
19
19
// Some instances may be both on a component and on a child abstract/functional component
20
20
const captureIds = new Map ( )
21
21
22
- export function walkTree ( instance , pFilter : string , ctx : BackendContext ) : ComponentTreeNode [ ] {
22
+ export async function walkTree ( instance , pFilter : string , ctx : BackendContext ) : Promise < ComponentTreeNode [ ] > {
23
23
initCtx ( ctx )
24
24
filter = pFilter
25
25
functionalIds . clear ( )
26
26
captureIds . clear ( )
27
- const result = findQualifiedChildren ( instance )
27
+ const result : ComponentTreeNode [ ] | ComponentTreeNode = await findQualifiedChildren ( instance )
28
28
if ( Array . isArray ( result ) ) {
29
29
return result
30
30
}
@@ -71,7 +71,7 @@ function initCtx (ctx: BackendContext) {
71
71
* traversal - e.g. if an instance is not matched, we will
72
72
* recursively go deeper until a qualified child is found.
73
73
*/
74
- function findQualifiedChildrenFromList ( instances : any [ ] ) : any [ ] {
74
+ function findQualifiedChildrenFromList ( instances : any [ ] ) : ComponentTreeNode [ ] {
75
75
instances = instances
76
76
. filter ( child => ! isBeingDestroyed ( child ) )
77
77
return ! filter
@@ -84,7 +84,7 @@ function findQualifiedChildrenFromList (instances: any[]): any[] {
84
84
* If the instance itself is qualified, just return itself.
85
85
* This is ok because [].concat works in both cases.
86
86
*/
87
- function findQualifiedChildren ( instance ) {
87
+ async function findQualifiedChildren ( instance ) : Promise < ComponentTreeNode [ ] | ComponentTreeNode > {
88
88
if ( isQualified ( instance ) ) {
89
89
return capture ( instance )
90
90
} else {
@@ -102,13 +102,10 @@ function findQualifiedChildren (instance) {
102
102
/**
103
103
* Get children from a component instance.
104
104
*/
105
- function getInternalInstanceChildren ( instance ) {
105
+ function getInternalInstanceChildren ( instance ) : any [ ] {
106
106
if ( instance . $children ) {
107
107
return instance . $children
108
108
}
109
- if ( Array . isArray ( instance . subTree . children ) ) {
110
- return instance . subTree . children . filter ( vnode => ! ! vnode . component ) . map ( vnode => vnode . component )
111
- }
112
109
return [ ]
113
110
}
114
111
@@ -142,7 +139,7 @@ function captureChild (child) {
142
139
/**
143
140
* Capture the meta information of an instance. (recursive)
144
141
*/
145
- function capture ( instance , index ?: number , list ?: any [ ] ) : ComponentTreeNode {
142
+ async function capture ( instance , index ?: number , list ?: any [ ] ) : Promise < ComponentTreeNode > {
146
143
if ( instance . __VUE_DEVTOOLS_FUNCTIONAL_LEGACY__ ) {
147
144
instance = instance . vnode
148
145
}
@@ -216,10 +213,9 @@ function capture (instance, index?: number, list?: any[]): ComponentTreeNode {
216
213
mark ( instance )
217
214
const name = getInstanceName ( instance )
218
215
219
- const children = getInternalInstanceChildren ( instance )
216
+ const children = ( await Promise . all ( ( await getInternalInstanceChildren ( instance ) )
220
217
. filter ( child => ! isBeingDestroyed ( child ) )
221
- . map ( capture )
222
- . filter ( Boolean )
218
+ . map ( capture ) ) ) . filter ( Boolean )
223
219
224
220
const ret : ComponentTreeNode = {
225
221
uid : instance . _uid ,
0 commit comments