diff --git a/src/jqLite.js b/src/jqLite.js index 8a8a28e8d2d4..775fef512a67 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 e74c09a54731..3648cda487d7 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),