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

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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