Made sure that .removeClass(null) doesn't throw an exception. Fixes #3847.
This commit is contained in:
parent
a78557472c
commit
cd28922b78
|
@ -708,7 +708,7 @@ jQuery.extend({
|
|||
|
||||
// internal only, use hasClass("class")
|
||||
has: function( elem, className ) {
|
||||
return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
|
||||
return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1557,7 +1557,7 @@ test("addClass(String)", function() {
|
|||
});
|
||||
|
||||
test("removeClass(String) - simple", function() {
|
||||
expect(4);
|
||||
expect(5);
|
||||
|
||||
var $divs = jQuery('div');
|
||||
|
||||
|
@ -1566,13 +1566,17 @@ test("removeClass(String) - simple", function() {
|
|||
ok( !$divs.is('.test'), "Remove Class" );
|
||||
|
||||
reset();
|
||||
|
||||
|
||||
$divs.addClass("test").addClass("foo").addClass("bar");
|
||||
$divs.removeClass("test").removeClass("bar").removeClass("foo");
|
||||
|
||||
ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );
|
||||
|
||||
reset();
|
||||
|
||||
// Make sure that a null value doesn't cause problems
|
||||
$divs.eq(0).addClass("test").removeClass(null);
|
||||
ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" );
|
||||
|
||||
$divs.eq(0).addClass("test").removeClass("");
|
||||
ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );
|
||||
|
|
Loading…
Reference in a new issue