Skip to content

Commit e03ea3c

Browse files
authored
fix(vue2): fix async capture errors (#1536)
1 parent 729e924 commit e03ea3c

File tree

1 file changed

+7
-4
lines changed
  • packages/app-backend-vue2/src/components

1 file changed

+7
-4
lines changed

packages/app-backend-vue2/src/components/tree.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
163163
const functionalId = contextUid + ':functional:' + id
164164
markFunctional(functionalId, instance)
165165

166-
const children = (instance.children
166+
const childrenPromise = (instance.children
167167
? instance.children.map(
168168
child => child.fnContext
169169
? captureChild(child)
@@ -172,7 +172,10 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
172172
: undefined
173173
)
174174
// router-view has both fnContext and componentInstance on vnode.
175-
: instance.componentInstance ? [capture(instance.componentInstance)] : []).filter(Boolean)
175+
: instance.componentInstance ? [capture(instance.componentInstance)] : [])
176+
177+
// await all childrenCapture to-be resolved
178+
const children = (await Promise.all(childrenPromise)).filter(Boolean) as ComponentTreeNode[]
176179

177180
const treeNode = {
178181
uid: functionalId,
@@ -231,9 +234,9 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
231234
}
232235

233236
if (instance._vnode && instance._vnode.children) {
237+
const vnodeChildren = await Promise.all(instance._vnode.children.map(captureChild))
234238
ret.children = ret.children.concat(
235-
flatten(instance._vnode.children.map(captureChild))
236-
.filter(Boolean)
239+
flatten(vnodeChildren).filter(Boolean)
237240
)
238241
ret.hasChildren = !!ret.children.length
239242
}

0 commit comments

Comments
 (0)