diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index 19545e1678..b51107c04b 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -31,6 +31,7 @@ import { source, mutable_source, set } from '../../reactivity/sources.js'; import { is_array, is_frozen } from '../../utils.js'; import { INERT, STATE_SYMBOL } from '../../constants.js'; import { queue_micro_task } from '../task.js'; +import { current_effect } from '../../runtime.js'; /** * The row of a keyed each block that is currently updating. We track this @@ -414,6 +415,28 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) { } }); } + + // TODO this is inefficient, this should happen during linking, but that's currently tricky + /** @type {import('#client').Effect | null} */ + var effect = null; + var next = state.next; + + /** @type {import('#client').Effect} */ (current_effect).first = next && next.e; + + while (next) { + if (effect !== null) { + effect.next = next.e; + } + + next.e.prev = effect; + + effect = next.e; + next = next.next; + } + + if (effect !== null) { + effect.next = null; + } } /**