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');
|
||||
|
||||
|
@ -1574,6 +1574,10 @@ test("removeClass(String) - simple", function() {
|
|||
|
||||
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