fix: correct each block update index type (#9425)

* fix: correctly handle index within each block updates

* changeset
pull/9426/head
Dominic Gannaway 1 year ago committed by GitHub
parent 1daadc357d
commit 5a6afe5463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correct update_block index type

@ -2078,7 +2078,7 @@ function get_first_element(block) {
/**
* @param {import('./types.js').EachItemBlock} block
* @param {any} item
* @param {import('./types.js').MaybeSignal<number>} 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<number>} */ (prev_index).value;
index = /** @type {import('./types.js').Signal<number>} */ (index).value;
}
const items = block.parent.items;
if (prev_index !== index && /** @type {number} */ (index) < items.length) {

Loading…
Cancel
Save