Skip to content

Commit 5446ba8

Browse files
committed
fix: only update lazy properties that have actually changed
1 parent 90f8b63 commit 5446ba8

File tree

1 file changed

+10
-1
lines changed
  • packages/svelte/src/internal/client

1 file changed

+10
-1
lines changed

packages/svelte/src/internal/client/each.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,16 @@ function update_each_item_block(block, item, index, type) {
789789
if ((type & EACH_ITEM_REACTIVE) !== 0) {
790790
set_signal_value(block.v, item);
791791
} else if (is_lazy_property(block.v)) {
792-
block.v.o[block.v.p] = item;
792+
// If we have lazy properties, it means that an array was used that has been
793+
// proxied. Given this, we need to re-sync the old array by mutating the backing
794+
// value to be the latest value to ensure the UI updates correctly. TODO: maybe
795+
// we should bypass any internal mutation checks for this?
796+
const o = block.v.o;
797+
const p = block.v.p;
798+
const prev = o[p];
799+
if (prev !== item) {
800+
o[p] = item;
801+
}
793802
}
794803
const transitions = block.s;
795804
const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0;

0 commit comments

Comments
 (0)