Skip to content

Memory Leak: Event Listeners Not Cleaned Up on Component Destroy #3

@kpj2006

Description

@kpj2006

Event listeners are attached to various DOM elements (including a document-level keydown listener) but are not properly removed during component teardown.

The destroy() method currently removes DOM elements but does not unregister event listeners. In applications where components are mounted and unmounted frequently (such as SPAs, SSR hydration, or dynamic routing), this can lead to memory leaks and unexpected behavior.

Expected Behavior

All event listeners should be removed during destroy().

Suggested Fix

  • Track all registered event listeners centrally
  • Ensure removeEventListener is called for:

    • document / window listeners
    • Element-bound listeners

for reference:
#1 (comment)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions