Skip to content

Commit

Permalink
fix: correct each block update index type (#9425)
Browse files Browse the repository at this point in the history
* fix: correctly handle index within each block updates

* changeset
  • Loading branch information
trueadm authored Nov 13, 2023
1 parent 1daadc3 commit 5a6afe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-steaks-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correct update_block index type
3 changes: 1 addition & 2 deletions packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand All @@ -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) {
Expand Down

1 comment on commit 5a6afe5

@vercel
Copy link

@vercel vercel bot commented on 5a6afe5 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-octane.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-5-preview-svelte.vercel.app

Please sign in to comment.