fix(jqLite): forgive unregistration of a non-registered handler

This commit is contained in:
Pawel Kozlowski 2013-08-03 17:57:37 +02:00
parent ad2b8c5bd4
commit ab59cc6c44
2 changed files with 7 additions and 1 deletions

View file

@ -212,7 +212,7 @@ function JQLiteOff(element, type, fn) {
removeEventListenerFn(element, type, events[type]);
delete events[type];
} else {
arrayRemove(events[type], fn);
arrayRemove(events[type] || [], fn);
}
});
}

View file

@ -890,6 +890,12 @@ describe('jqLite', function() {
aElem.off('click', function() {});
});
it('should do nothing when a specific listener was not registered', function () {
var aElem = jqLite(a);
aElem.on('click', function() {});
aElem.off('mouseenter', function() {});
});
it('should deregister all listeners', function() {
var aElem = jqLite(a),