Skip to content

Commit a7020c6

Browse files
committed
refactor(language-core): narrow generateElementChildren param type
1 parent 2bab222 commit a7020c6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/language-core/lib/codegen/template/elementChildren.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { generateTemplateChild, getVIfNode } from './templateChild';
77
export function* generateElementChildren(
88
options: TemplateCodegenOptions,
99
ctx: TemplateCodegenContext,
10-
children: (CompilerDOM.TemplateChildNode | CompilerDOM.SimpleExpressionNode)[],
10+
children: CompilerDOM.TemplateChildNode[],
1111
enterNode = true,
1212
): Generator<Code> {
1313
const endScope = ctx.startScope();
@@ -20,7 +20,7 @@ export function* generateElementChildren(
2020
}
2121

2222
function normalizeIfBranch(
23-
children: (CompilerDOM.TemplateChildNode | CompilerDOM.SimpleExpressionNode)[],
23+
children: CompilerDOM.TemplateChildNode[],
2424
start: number,
2525
): [node: typeof children[number], end: number] {
2626
const first = children[start]!;
@@ -38,9 +38,6 @@ function normalizeIfBranch(
3838

3939
for (let i = start + 1; i < children.length; i++) {
4040
const sibling = children[i]!;
41-
if (sibling.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
42-
continue;
43-
}
4441
if (sibling.type === CompilerDOM.NodeTypes.COMMENT) {
4542
comments.push(sibling);
4643
continue;

packages/language-core/lib/codegen/template/templateChild.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ export function* generateTemplateChild(
8888
}
8989
else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
9090
// {{ ... }} {{ ... }}
91-
yield* generateElementChildren(options, ctx, node.children.filter(child => typeof child === 'object'), false);
91+
for (const child of node.children) {
92+
if (typeof child !== 'object') {
93+
continue;
94+
}
95+
yield* generateTemplateChild(options, ctx, child, false);
96+
}
9297
}
9398
else if (node.type === CompilerDOM.NodeTypes.INTERPOLATION) {
9499
// {{ ... }}

0 commit comments

Comments
 (0)