From 4bc874141f7b69d5cc31696334707f9bd6e4ac2e Mon Sep 17 00:00:00 2001 From: Ken Sheedlo Date: Wed, 7 Aug 2013 21:55:44 -0700 Subject: [PATCH] fix(jqLite): throw when jqLite#off called with 4 args --- src/jqLite.js | 4 ++-- test/jqLiteSpec.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/jqLite.js b/src/jqLite.js index ae6da9f7055d..e08c5e43ddfb 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -193,8 +193,8 @@ function JQLiteDealoc(element){ } } -function JQLiteOff(element, type, fn) { - if ( arguments.length > 4 ) throw jqLiteMinErr('off_args', 'jqLite#off() does not support the `selector` parameter'); +function JQLiteOff(element, type, fn, other1) { + if (isDefined(other1)) throw jqLiteMinErr('off_args', 'jqLite#off() does not support the `selector` parameter'); var events = JQLiteExpandoStore(element, 'events'), handle = JQLiteExpandoStore(element, 'handle'); diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index ab98a70f4587..f8d71bc91e5c 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -901,7 +901,7 @@ describe('jqLite', function() { }); - describe('unbind', function() { + describe('off', function() { it('should do nothing when no listener was registered with bound', function() { var aElem = jqLite(a); @@ -1051,6 +1051,17 @@ describe('jqLite', function() { expect(masterSpy).not.toHaveBeenCalled(); expect(extraSpy).toHaveBeenCalledOnce(); }); + + // Only run this test for jqLite and not normal jQuery + if ( _jqLiteMode ) { + it('should throw an error if a selector is passed', function () { + var aElem = jqLite(a); + aElem.on('click', noop); + expect(function () { + aElem.off('click', noop, '.test'); + }).toThrowMatching(/\[jqLite:off_args\]/); + }); + } });