mousetrap
mousetrap copied to clipboard
give a way to the user to clear event listener
Hey !
First thanks for the library, really easy to use and do a good job.
I have a bit of a problem, when I'm attaching mousetrap to a specific element, it uses addEventListener
on it to bind the event _handleKeyEvent
for the library to do it magics. It's all fine and dandy, until I want to cleanup this element.
Since I have no way to removeEventListener
for _handlerKeyEvent
( as it is private to the library ), the event listener is still active, and thus create a detached DOM which is leaking.
Since my application is quite heavy on that, we are actually leaking quite a bit because of that.
I'm going to create a PR to have a function to cleanup these event when needed.
@ccampbell raising this to your attention again. Would be great to have the proposed fix in an official release and be able to 🔪🐀 at specific DOM nodes, without memory leaks. Not clear how to resolve the conflict in the .min file in that PR, but it seems like something that will probably work itself out as part of your build/release.
We love Mousetrap. Thanks for all you've done.