diff options
| author | Pawel Kozlowski | 2013-08-03 17:57:37 +0200 |
|---|---|---|
| committer | Pawel Kozlowski | 2013-08-07 18:52:47 +0200 |
| commit | ab59cc6c44705b1244a77eba999d736f9eb3c6ae (patch) | |
| tree | 2656c3d561bc793ea1a1d0b83b24f5e97d1d45e0 | |
| parent | ad2b8c5bd45173bb64c476934510f0a5f1b510ee (diff) | |
| download | angular.js-ab59cc6c44705b1244a77eba999d736f9eb3c6ae.tar.bz2 | |
fix(jqLite): forgive unregistration of a non-registered handler
| -rw-r--r-- | src/jqLite.js | 2 | ||||
| -rw-r--r-- | test/jqLiteSpec.js | 6 |
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), |
