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

fix(jqLite): throw when jqLite#off called with 4 args #3501

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
13 changes: 12 additions & 1 deletion test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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\]/);
});
}
});


Expand Down