Skip to content

Commit

Permalink
fix: memory leak in unmount where document event listeners are not be…
Browse files Browse the repository at this point in the history
…ing removed (#12101)

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

* changeset

---------

Co-authored-by: Mark Siano <[email protected]>
Co-authored-by: Rich Harris <[email protected]>
Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
4 people committed Jun 24, 2024
1 parent 2814e9e commit 752f872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/bright-berries-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: remove correct event listener from document
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 752f872

Please sign in to comment.