.off("name") removes all matching listeners
Opened this issue · 1 comments
EventEmitter#removeListener
only removes 1 listener when an event name given:
https://nodejs.org/api/events.html#events_emitter_removelistener_event_listener
event-lite#off
removes all. The undocumented behavior could be fixed.
See #1. @JoshuaWise would have a right code to fix this! ;)
It seems jQuery's off("name")
removes all matching listeners, by the way.
If a simple event name such as "click" is provided, all events of that type (both direct and delegated) are removed from the elements in the jQuery set. When writing code that will be used as a plugin, or simply when working with a large code base, best practice is to attach and remove events using namespaces so that the code will not inadvertently remove event handlers attached by other code.
Adding a namespace is the best practice? I don't think that it's the best for event-lite to follow.