diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index 388474bb31..41494de258 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -109,6 +109,8 @@ export default class EachBlock extends Node { parentNode: string, parentNodes: string ) { + if (this.children.length === 0) return; + const { generator } = this; const each = this.var; diff --git a/test/runtime/samples/each-block-keyed-empty/_config.js b/test/runtime/samples/each-block-keyed-empty/_config.js new file mode 100644 index 0000000000..1edbb077f9 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-empty/_config.js @@ -0,0 +1,7 @@ +export default { + data: { + x: [{ z: 1 }, { z: 2 }], + }, + + html: `` +}; diff --git a/test/runtime/samples/each-block-keyed-empty/main.html b/test/runtime/samples/each-block-keyed-empty/main.html new file mode 100644 index 0000000000..f6610ae2c7 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-empty/main.html @@ -0,0 +1 @@ +{{#each x as y @z}}{{/each}}