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

Commit

Permalink
fix(jqLite): throw when jqLite#off called with 4 args
Browse files Browse the repository at this point in the history
Closes #3501
  • Loading branch information
ksheedlo authored and IgorMinar committed Aug 9, 2013
1 parent 5c56011 commit 4f5dfbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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, 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');
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

0 comments on commit 4f5dfbc

Please sign in to comment.