aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Sheedlo2013-08-07 21:55:44 -0700
committerIgor Minar2013-08-08 22:40:04 -0700
commit4f5dfbc362d9683177708ebcc00c98cf594d1287 (patch)
treee738dde764bfcb8dbfbdcab21992a0b78e04bee6
parent5c560117425e7b3f7270389274476e843d6f69ec (diff)
downloadangular.js-4f5dfbc362d9683177708ebcc00c98cf594d1287.tar.bz2
fix(jqLite): throw when jqLite#off called with 4 args
Closes #3501
-rw-r--r--src/jqLite.js4
-rw-r--r--test/jqLiteSpec.js13
2 files changed, 14 insertions, 3 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index ae6da9f7..dbd57447 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, selector) {
+ if (isDefined(selector)) throw jqLiteMinErr('off_args', 'jqLite#off() does not support the `selector` argument');
var events = JQLiteExpandoStore(element, 'events'),
handle = JQLiteExpandoStore(element, 'handle');
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index ab98a70f..f8d71bc9 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\]/);
+ });
+ }
});