diff --git a/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts b/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts index d94e1f9fe6..85bf8dd278 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts +++ b/packages/svelte/src/compiler/phases/3-transform/client/types.d.ts @@ -29,9 +29,8 @@ export interface ComponentClientTransformState extends ClientTransformState { readonly hoisted: Array; readonly events: Set; - /** Stuff that happens before the render effect */ + /** Stuff that happens before the render effect(s) */ readonly init: Statement[]; - /** Stuff that happens inside separate render effects (due to call expressions) */ readonly update_effects: Statement[]; /** Stuff that happens inside the render effect */ @@ -42,7 +41,7 @@ export interface ComponentClientTransformState extends ClientTransformState { /** Used if condition for singular prop is false (see comment above) */ grouped: Statement; }[]; - /** Stuff that happens after the render effect (bindings, actions) */ + /** Stuff that happens after the render effect (control blocks, dynamic elements, bindings, actions, etc) */ readonly after_update: Statement[]; /** The HTML template string */ readonly template: string[]; 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 3e7cc21403..1e11ac0162 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 @@ -1798,11 +1798,11 @@ export const template_visitors = { } if (is_reactive) { - context.state.init.push( + context.state.after_update.push( b.stmt(b.call('$.snippet_effect', b.thunk(snippet_function), ...args)) ); } else { - context.state.init.push(b.stmt(b.call(snippet_function, ...args))); + context.state.after_update.push(b.stmt(b.call(snippet_function, ...args))); } }, AnimateDirective(node, { state, visit }) { @@ -2974,7 +2974,7 @@ export const template_visitors = { : b.member(b.member(b.id('$$props'), b.id('$$slots')), name, true, true); const slot = b.call('$.slot', context.state.node, expression, props_expression, fallback); - context.state.init.push(b.stmt(slot)); + context.state.after_update.push(b.stmt(slot)); }, SvelteHead(node, context) { // TODO attributes?