From 46cbdd43e951ce969fd574a73b3f2e1afeaad66c Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Sat, 29 Jun 2024 22:08:20 +0100 Subject: [PATCH] address feedback --- .../phases/3-transform/client/visitors/template.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index f8d04a01c1..659bd42234 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -2209,7 +2209,12 @@ export const template_visitors = { ); if (init.length !== 0 || update.length !== 0 || after_update.length !== 0) { - context.state.init.push(b.block([...init, serialize_render_stmt(update), ...after_update])); + const block = b.block([...init]); + if (update.length > 0) { + block.body.push(serialize_render_stmt(update)); + } + block.body.push(...after_update); + context.state.init.push(block); } if (has_direction_attribute) {