From 5a6afe546303f569fcaea2deefe1732a2b60d2f7 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Mon, 13 Nov 2023 17:53:55 +0000 Subject: [PATCH] fix: correct each block update index type (#9425) * fix: correctly handle index within each block updates * changeset --- .changeset/eight-steaks-shout.md | 5 +++++ packages/svelte/src/internal/client/render.js | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/eight-steaks-shout.md diff --git a/.changeset/eight-steaks-shout.md b/.changeset/eight-steaks-shout.md new file mode 100644 index 0000000000..62dbebafaf --- /dev/null +++ b/.changeset/eight-steaks-shout.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: correct update_block index type diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 045d3b5bf8..5c1ce1181d 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -2078,7 +2078,7 @@ function get_first_element(block) { /** * @param {import('./types.js').EachItemBlock} block * @param {any} item - * @param {import('./types.js').MaybeSignal} index + * @param {number} index * @param {number} type * @returns {void} */ @@ -2093,7 +2093,6 @@ export function update_each_item_block(block, item, index, type) { let prev_index = block.index; if (index_is_reactive) { prev_index = /** @type {import('./types.js').Signal} */ (prev_index).value; - index = /** @type {import('./types.js').Signal} */ (index).value; } const items = block.parent.items; if (prev_index !== index && /** @type {number} */ (index) < items.length) {