Skip to content

Commit

Permalink
fix: handle v-for with v-once correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Sep 9, 2024
1 parent 904167f commit 9441b3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/language-core/lib/codegen/template/vFor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function* generateVFor(
ctx.addLocalVariable(varName);
}
let isFragment = true;
for (const argument of node.codegenNode?.children.arguments ?? []) {
// children is undefined with v-once (#4827)
for (const argument of node.codegenNode?.children?.arguments ?? []) {
if (
argument.type === CompilerDOM.NodeTypes.JS_FUNCTION_EXPRESSION
&& argument.returns?.type === CompilerDOM.NodeTypes.VNODE_CALL
Expand Down
3 changes: 3 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/#4827/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<pre v-for="_ in []" v-once></pre>
</template>

0 comments on commit 9441b3a

Please sign in to comment.