Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(jqLite): forgive unregistration of a non-registered handler
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource committed Aug 7, 2013
1 parent ad2b8c5 commit ab59cc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
Expand Down
6 changes: 6 additions & 0 deletions test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit ab59cc6

Please sign in to comment.