Issue #1631: Fixed a bug on removeEventListener
Bugfix for issue #1631 where removeEventListener would throw when no event listeners are registered on the object.
This commit is contained in:
parent
b31c9d50b8
commit
52498f1ef9
@ -126,6 +126,11 @@ 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();
|
||||
obj.removeEventListener('test');
|
||||
});
|
||||
|
||||
// added due to context-sensitive removeListener optimization
|
||||
it('fires multiple listeners with the same context with id', function () {
|
||||
var obj = new Klass(),
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user