Are keybindings removed automatically if bound to element?
felixhayashi opened this issue · 2 comments
felixhayashi commented
Hi Alex,
keycharm is great and very easy to use, thanks! Just wanted to ask whether keybindings are removed automatically if bound to an element (not the window)? I expect this to be the case but the docs mention a destructor...
-Felix
AlexDM0 commented
Woohoo my first issue :).
I am going to assume your question is if the listeners are automatically removed if the element is removed? I am using the addEventListener method of the DOM API and it depends on the browser.
Going by this:
http://stackoverflow.com/questions/12528049/if-a-dom-element-is-removed-are-its-listeners-also-removed-from-memory
I think it would be wise to remove the bindings manually just in case with the destroy method. The reset does not clear the listeners, it clears the callbacks!
Regards,
Alex
felixhayashi commented
Woohoo my first issue :)
…and it is not a bug!! First issues on my repos are usually bugs :D
I am going to assume your question is if the listeners are automatically removed if the element is removed?
Yes, sorry forgot to say that.
I am using the addEventListener method of the DOM API and it depends on the browser.
I also had a look at the code and the way you do it, I do not think there is a need to call the destroy
. I don't support below IE 10 anyways :D
-Felix