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

Commit ab59cc6

Browse files
fix(jqLite): forgive unregistration of a non-registered handler
1 parent ad2b8c5 commit ab59cc6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/jqLite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function JQLiteOff(element, type, fn) {
212212
removeEventListenerFn(element, type, events[type]);
213213
delete events[type];
214214
} else {
215-
arrayRemove(events[type], fn);
215+
arrayRemove(events[type] || [], fn);
216216
}
217217
});
218218
}

test/jqLiteSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,12 @@ describe('jqLite', function() {
890890
aElem.off('click', function() {});
891891
});
892892

893+
it('should do nothing when a specific listener was not registered', function () {
894+
var aElem = jqLite(a);
895+
aElem.on('click', function() {});
896+
897+
aElem.off('mouseenter', function() {});
898+
});
893899

894900
it('should deregister all listeners', function() {
895901
var aElem = jqLite(a),

0 commit comments

Comments
 (0)