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 c18074a310
commit ac5b9055f6
2 changed files with 7 additions and 1 deletions

View file

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

View file

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