From 7f087c4b039156dc810f32bf4efaae843282feb3 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Thu, 20 Jun 2024 09:49:04 +0100 Subject: [PATCH] fix: remove document event listeners on unmount (#12105) --- .changeset/twenty-gifts-develop.md | 5 +++++ packages/svelte/src/internal/client/render.js | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/twenty-gifts-develop.md 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);