|
|
@@ -41,6 +41,7 @@ export function genSelf(
|
|
|
export function genChildren(
|
|
|
dynamic: IRDynamicInfo,
|
|
|
context: CodegenContext,
|
|
|
+ pushBlock: (...items: CodeFragment[]) => number,
|
|
|
from: string = `n${dynamic.id}`,
|
|
|
): CodeFragment[] {
|
|
|
const { helper } = context
|
|
|
@@ -72,17 +73,17 @@ export function genChildren(
|
|
|
// p for "placeholder" variables that are meant for possible reuse by
|
|
|
// other access paths
|
|
|
const variable = id === undefined ? `p${context.block.tempId++}` : `n${id}`
|
|
|
- push(NEWLINE, `const ${variable} = `)
|
|
|
+ pushBlock(NEWLINE, `const ${variable} = `)
|
|
|
|
|
|
if (prev) {
|
|
|
if (elementIndex - prev[1] === 1) {
|
|
|
- push(...genCall(helper('next'), prev[0]))
|
|
|
+ pushBlock(...genCall(helper('next'), prev[0]))
|
|
|
} else {
|
|
|
- push(...genCall(helper('nthChild'), from, String(elementIndex)))
|
|
|
+ pushBlock(...genCall(helper('nthChild'), from, String(elementIndex)))
|
|
|
}
|
|
|
} else {
|
|
|
if (elementIndex === 0) {
|
|
|
- push(...genCall(helper('child'), from))
|
|
|
+ pushBlock(...genCall(helper('child'), from))
|
|
|
} else {
|
|
|
// check if there's a node that we can reuse from
|
|
|
let init = genCall(helper('child'), from)
|
|
|
@@ -91,7 +92,7 @@ export function genChildren(
|
|
|
} else if (elementIndex > 1) {
|
|
|
init = genCall(helper('nthChild'), from, String(elementIndex))
|
|
|
}
|
|
|
- push(...init)
|
|
|
+ pushBlock(...init)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -109,7 +110,7 @@ export function genChildren(
|
|
|
|
|
|
if (childrenToGen.length) {
|
|
|
for (const [child, from] of childrenToGen) {
|
|
|
- push(...genChildren(child, context, from))
|
|
|
+ push(...genChildren(child, context, pushBlock, from))
|
|
|
}
|
|
|
}
|
|
|
|