Skip to content

Conversation

iirvine
Copy link
Contributor

@iirvine iirvine commented Apr 15, 2013

This PR implements Events#clearAllListeners, a convenience method to deregister all of an object's event bindings. It can be called directly or by calling off() with no arguments. Fixes #1502.

else if (type.substr(-4) === '_idx') { clearObject(events[type], type); }
}
}
return this;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why not just do delete this[key] instead of all the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, because obviously that would be way too easy. :D

mourner added a commit that referenced this pull request Apr 17, 2013
@mourner mourner merged commit 443d43c into Leaflet:master Apr 17, 2013
@mourner
Copy link
Member

mourner commented Apr 17, 2013

Looks good :) I only wonder if the naming inconsistency is OK (all methods have Event in the name except this one), perhaps clearEventListeners would be a better name?

@iirvine
Copy link
Contributor Author

iirvine commented Apr 17, 2013

That's where I started, but thought it wasn't quite explicit enough - maybe split the difference with clearAllEventListeners? Pretty verbose, but it's proxied to off() anyway...

@mourner
Copy link
Member

mourner commented Apr 18, 2013

Renamed to clearAllEventListeners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Event.clearEventListeners()
2 participants