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

Commit ac5b905

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

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
@@ -205,7 +205,7 @@ function JQLiteUnbind(element, type, fn) {
205205
removeEventListenerFn(element, type, events[type]);
206206
delete events[type];
207207
} else {
208-
arrayRemove(events[type], fn);
208+
arrayRemove(events[type] || [], fn);
209209
}
210210
}
211211
}

test/jqLiteSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,12 @@ describe('jqLite', function() {
843843
aElem.unbind('click', function() {});
844844
});
845845

846+
it('should do nothing when a specific listener was not registered', function () {
847+
var aElem = jqLite(a);
848+
aElem.bind('click', function() {});
849+
850+
aElem.unbind('mouseenter', function() {});
851+
});
846852

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

0 commit comments

Comments
 (0)