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

Closes #3501
This commit is contained in:
Ken Sheedlo 2013-08-07 21:55:44 -07:00 committed by Igor Minar
parent 5c56011742
commit 4f5dfbc362
2 changed files with 14 additions and 3 deletions

View file

@ -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');

View file

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