diff --git a/.changeset/brave-rivers-jam.md b/.changeset/brave-rivers-jam.md new file mode 100644 index 0000000000..c8dcd42c0d --- /dev/null +++ b/.changeset/brave-rivers-jam.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure user effects are correctly executed on initialisation diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index 193c6df145..6e24ce5724 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -192,8 +192,7 @@ export function user_effect(fn) { // until the component is mounted var defer = active_effect !== null && - (active_effect.f & RENDER_EFFECT) !== 0 && - // TODO do we actually need this? removing them changes nothing + (active_effect.f & BRANCH_EFFECT) !== 0 && component_context !== null && !component_context.m; diff --git a/packages/svelte/tests/runtime-runes/samples/effect-order-5/_config.js b/packages/svelte/tests/runtime-runes/samples/effect-order-5/_config.js new file mode 100644 index 0000000000..2067a5b3dd --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/effect-order-5/_config.js @@ -0,0 +1,7 @@ +import { test } from '../../test'; + +export default test({ + async test({ assert, logs }) { + assert.deepEqual(logs, ['effect 1', 'effect 2']); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/effect-order-5/main.svelte b/packages/svelte/tests/runtime-runes/samples/effect-order-5/main.svelte new file mode 100644 index 0000000000..986cb8d72b --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/effect-order-5/main.svelte @@ -0,0 +1,15 @@ + + +{template()}