diff --git a/.changeset/gorgeous-hats-wonder.md b/.changeset/gorgeous-hats-wonder.md new file mode 100644 index 0000000000..e1ce7bdaed --- /dev/null +++ b/.changeset/gorgeous-hats-wonder.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: ensure element size bindings don't unsubscribe multiple times from the resize observer diff --git a/packages/svelte/src/internal/client/dom/elements/bindings/size.js b/packages/svelte/src/internal/client/dom/elements/bindings/size.js index e0ad045d80..c817787497 100644 --- a/packages/svelte/src/internal/client/dom/elements/bindings/size.js +++ b/packages/svelte/src/internal/client/dom/elements/bindings/size.js @@ -1,4 +1,5 @@ import { effect, teardown } from '../../../reactivity/effects.js'; +import { untrack } from '../../../runtime.js'; /** * Resize observer singleton. @@ -100,7 +101,8 @@ export function bind_element_size(element, type, update) { var unsub = resize_observer_border_box.observe(element, () => update(element[type])); effect(() => { - update(element[type]); + // The update could contain reads which should be ignored + untrack(() => update(element[type])); return unsub; }); }