Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4f5dfbc

Browse files
ksheedloIgorMinar
authored andcommitted
fix(jqLite): throw when jqLite#off called with 4 args
Closes #3501
1 parent 5c56011 commit 4f5dfbc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/jqLite.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ function JQLiteDealoc(element){
193193
}
194194
}
195195

196-
function JQLiteOff(element, type, fn) {
197-
if ( arguments.length > 4 ) throw jqLiteMinErr('off_args', 'jqLite#off() does not support the `selector` parameter');
196+
function JQLiteOff(element, type, fn, selector) {
197+
if (isDefined(selector)) throw jqLiteMinErr('off_args', 'jqLite#off() does not support the `selector` argument');
198198

199199
var events = JQLiteExpandoStore(element, 'events'),
200200
handle = JQLiteExpandoStore(element, 'handle');

test/jqLiteSpec.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ describe('jqLite', function() {
901901
});
902902

903903

904-
describe('unbind', function() {
904+
describe('off', function() {
905905
it('should do nothing when no listener was registered with bound', function() {
906906
var aElem = jqLite(a);
907907

@@ -1051,6 +1051,17 @@ describe('jqLite', function() {
10511051
expect(masterSpy).not.toHaveBeenCalled();
10521052
expect(extraSpy).toHaveBeenCalledOnce();
10531053
});
1054+
1055+
// Only run this test for jqLite and not normal jQuery
1056+
if ( _jqLiteMode ) {
1057+
it('should throw an error if a selector is passed', function () {
1058+
var aElem = jqLite(a);
1059+
aElem.on('click', noop);
1060+
expect(function () {
1061+
aElem.off('click', noop, '.test');
1062+
}).toThrowMatching(/\[jqLite:off_args\]/);
1063+
});
1064+
}
10541065
});
10551066

10561067

0 commit comments

Comments
 (0)