Merge pull request #1632 from tjoekbezoer/master
Issue #1631: Fixed a bug on removeEventListener
This commit is contained in:
commit
8c7126af26
@ -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(),
|
||||
|
@ -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