Merge pull request #1632 from tjoekbezoer/master

Issue #1631: Fixed a bug on removeEventListener
This commit is contained in:
Vladimir Agafonkin 2013-04-29 05:15:52 -07:00
commit 8c7126af26
2 changed files with 12 additions and 0 deletions

View File

@ -126,6 +126,14 @@ describe('Events', function() {
expect(spy5.called).to.be(false);
});
it('can handle calls to #removeEventListener on objects with no registered event listeners', function () {
var obj = new Klass();
var removeNonExistentListener = function () {
obj.removeEventListener('test');
};
expect(removeNonExistentListener).to.not.throwException();
});
// added due to context-sensitive removeListener optimization
it('fires multiple listeners with the same context with id', function () {
var obj = new Klass(),

View File

@ -63,6 +63,10 @@ L.Mixin.Events = {
removeEventListener: function (types, fn, context) { // ([String, Function, Object]) or (Object[, Object])
if (!this[eventsKey]) {
return this;
}
if (!types) {
return this.clearAllEventListeners();
}