Skip to content

Commit 5dce70e

Browse files
authored
fix: put more executions after the render effect(s) (#10186)
snippets and slots should also come after the render effect so that they are executed in order with all the other things (if blocks, actions, etc etc)
1 parent 1b675c0 commit 5dce70e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/svelte/src/compiler/phases/3-transform/client/types.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ export interface ComponentClientTransformState extends ClientTransformState {
2929
readonly hoisted: Array<Statement | ModuleDeclaration>;
3030
readonly events: Set<string>;
3131

32-
/** Stuff that happens before the render effect */
32+
/** Stuff that happens before the render effect(s) */
3333
readonly init: Statement[];
34-
3534
/** Stuff that happens inside separate render effects (due to call expressions) */
3635
readonly update_effects: Statement[];
3736
/** Stuff that happens inside the render effect */
@@ -42,7 +41,7 @@ export interface ComponentClientTransformState extends ClientTransformState {
4241
/** Used if condition for singular prop is false (see comment above) */
4342
grouped: Statement;
4443
}[];
45-
/** Stuff that happens after the render effect (bindings, actions) */
44+
/** Stuff that happens after the render effect (control blocks, dynamic elements, bindings, actions, etc) */
4645
readonly after_update: Statement[];
4746
/** The HTML template string */
4847
readonly template: string[];

packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,11 +1798,11 @@ export const template_visitors = {
17981798
}
17991799

18001800
if (is_reactive) {
1801-
context.state.init.push(
1801+
context.state.after_update.push(
18021802
b.stmt(b.call('$.snippet_effect', b.thunk(snippet_function), ...args))
18031803
);
18041804
} else {
1805-
context.state.init.push(b.stmt(b.call(snippet_function, ...args)));
1805+
context.state.after_update.push(b.stmt(b.call(snippet_function, ...args)));
18061806
}
18071807
},
18081808
AnimateDirective(node, { state, visit }) {
@@ -2974,7 +2974,7 @@ export const template_visitors = {
29742974
: b.member(b.member(b.id('$$props'), b.id('$$slots')), name, true, true);
29752975

29762976
const slot = b.call('$.slot', context.state.node, expression, props_expression, fallback);
2977-
context.state.init.push(b.stmt(slot));
2977+
context.state.after_update.push(b.stmt(slot));
29782978
},
29792979
SvelteHead(node, context) {
29802980
// TODO attributes?

0 commit comments

Comments
 (0)