Skip to content

Commit

Permalink
Fixed css().css() (plus bind and attr), and added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
padolsey committed Apr 15, 2010
1 parent 418d1d5 commit b432b7b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
9 changes: 8 additions & 1 deletion jquery.lint.js
Expand Up @@ -491,7 +491,14 @@

// Check for calls like css().css().css()
// May as well use css({...})
if (lint.level > 2 && !types.object(args[0]) && !isFunction(args[1]) && (/^(css|attr)$/.test(name) || (name === 'bind' && version >= '1.4'))) {
if (
lint.level > 2 &&
!types.object(args[0]) &&
(
(/^(css|attr)$/.test(name) && args[1] !== undefined) ||
(name === 'bind' && version >= '1.4' && /* Data no passed as [1] */!isFunction(args[2]))
)
) {

if (this._lastMethodCalled === name) {
_console.warn(locale.methodTwice.replace(/%0/, name));
Expand Down
35 changes: 35 additions & 0 deletions test/test.js
Expand Up @@ -55,11 +55,46 @@ test('css()', function(){
$('<a/>').css('color','red').css('padding', 20);
$('<a/>').css('a','b','c','d');

$('<a/>').css('color');
$('<a/>').css('padding-top');
$('<a/>').css({});
$('<a/>').css('background', '#FFF');

});

test('attr()', function(){

expect(2);

$('<a/>').attr('rel','a').attr('href', '...');
$('<a/>').attr('a','b','c','d');

$('<a/>').attr('a');
$('<a/>').attr('b');
$('<a/>').attr({});
$('<a/>').attr('b', 'd');

});

test('bind()', function(){

expect(3);

// Throws error in 1.3:
$('<a/>').bind({});

// Throws error in 1.4:
$('<a/>').bind('a',function(){}).bind('b', function(){});

$('<a/>').bind('a','b','c','d');
$('<a/>').bind('b');

$('<a/>').bind('a',function(){}).bind('b', {/*data*/}, function(){});
$('<a/>').bind('click', {a:1}, function(){});


});

test('selectors', function(){

expect(1);
Expand Down

0 comments on commit b432b7b

Please sign in to comment.