aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jqLite.js2
-rw-r--r--test/jqLiteSpec.js6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index 8a8a28e8..775fef51 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -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);
}
});
}
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index e74c09a5..3648cda4 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -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),