diff --git a/.changeset/twenty-gifts-develop.md b/.changeset/twenty-gifts-develop.md new file mode 100644 index 0000000000..f610d9647f --- /dev/null +++ b/.changeset/twenty-gifts-develop.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: remove document event listeners on unmount diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 82d2c6bd57..f380f3729f 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -251,6 +251,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro return () => { for (const event_name of registered_events) { target.removeEventListener(event_name, bound_event_listener); + document.removeEventListener(event_name, bound_event_listener); } root_event_handles.delete(event_handle); mounted_components.delete(component);