diff --git a/.changeset/lemon-llamas-reflect.md b/.changeset/lemon-llamas-reflect.md new file mode 100644 index 0000000000..c858403bd4 --- /dev/null +++ b/.changeset/lemon-llamas-reflect.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure resume effects are scheduled in topological order diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index 149cbd2d38..428f69281b 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -602,17 +602,21 @@ export function resume_effect(effect) { */ function resume_children(effect, local) { if ((effect.f & INERT) === 0) return; + effect.f ^= INERT; + + // Ensure the effect is marked as clean again so that any dirty child + // effects can schedule themselves for execution + if ((effect.f & CLEAN) === 0) { + effect.f ^= CLEAN; + } // If a dependency of this effect changed while it was paused, - // apply the change now + // schedule the effect to update if (check_dirtiness(effect)) { - update_effect(effect); + set_signal_status(effect, DIRTY); + schedule_effect(effect); } - // Ensure we toggle the flag after possibly updating the effect so that - // each block logic can correctly operate on inert items - effect.f ^= INERT; - var child = effect.first; while (child !== null) { diff --git a/packages/svelte/tests/runtime-runes/samples/transition-each-4/_config.js b/packages/svelte/tests/runtime-runes/samples/transition-each-4/_config.js new file mode 100644 index 0000000000..a0e29ec8ff --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/transition-each-4/_config.js @@ -0,0 +1,35 @@ +import { flushSync } from '../../../../src/index-client.js'; +import { test } from '../../test'; + +export default test({ + async test({ assert, raf, target, logs }) { + assert.htmlEqual( + target.innerHTML, + '