fix: memory leak in unmount where document event listeners are not being removed (#12101)

* Fix memory leak in unmount where document event listeners are not being removed

* changeset

---------

Co-authored-by: Mark Siano <marksiano@Marks-MBP.lan>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
pull/12165/head
markpsiano 6 months ago committed by GitHub
parent 2814e9ebbd
commit 752f872a1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: remove correct event listener from document

@ -265,7 +265,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);
document.removeEventListener(event_name, bound_document_event_listener);
}
root_event_handles.delete(event_handle);
mounted_components.delete(component);

Loading…
Cancel
Save