refactor: extract dynamicChildren

This commit is contained in:
三咲智子 Kevin Deng 2023-11-27 14:16:05 +08:00
parent 339a658cef
commit c53af4d57d
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 46 additions and 45 deletions

View File

@ -169,9 +169,14 @@ function transformChildren(
const childrenTemplate: string[] = []
children.forEach((child, i) => walkNode(child, i))
processDynamicChildren()
ctx.template += childrenTemplate.join('')
if (root) ctx.registerTemplate()
function processDynamicChildren() {
let prevChildren: DynamicInfo[] = []
let hasStatic = false
for (let index = 0; index < children.length; index++) {
const child = ctx.dynamic.children[index]
@ -212,11 +217,7 @@ function transformChildren(
})
}
}
ctx.template += childrenTemplate.join('')
// finalize template
if (root) ctx.registerTemplate()
}
function walkNode(node: TemplateChildNode, index: number) {
const child = createContext(node, ctx, index)