Skip to content

Commit

Permalink
fix(vue2): fix async capture errors (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
a20185 committed Aug 14, 2021
1 parent 729e924 commit e03ea3c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/app-backend-vue2/src/components/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
const functionalId = contextUid + ':functional:' + id
markFunctional(functionalId, instance)

const children = (instance.children
const childrenPromise = (instance.children
? instance.children.map(
child => child.fnContext
? captureChild(child)
Expand All @@ -172,7 +172,10 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
: undefined
)
// router-view has both fnContext and componentInstance on vnode.
: instance.componentInstance ? [capture(instance.componentInstance)] : []).filter(Boolean)
: instance.componentInstance ? [capture(instance.componentInstance)] : [])

// await all childrenCapture to-be resolved
const children = (await Promise.all(childrenPromise)).filter(Boolean) as ComponentTreeNode[]

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

if (instance._vnode && instance._vnode.children) {
const vnodeChildren = await Promise.all(instance._vnode.children.map(captureChild))
ret.children = ret.children.concat(
flatten(instance._vnode.children.map(captureChild))
.filter(Boolean)
flatten(vnodeChildren).filter(Boolean)
)
ret.hasChildren = !!ret.children.length
}
Expand Down

0 comments on commit e03ea3c

Please sign in to comment.