Commit 227c49a4 authored by Matthias Jäggli's avatar Matthias Jäggli Committed by Dave Methvin

Fix #12411, .removeClass(undefined) is a chaining no-op. Close gh-913.

.removeClass() //removes all classes, as documented
.removeClass(window.nonExistentVariable) // removes nothing
parent 23d125a5
...@@ -78,7 +78,7 @@ jQuery.fn.extend({ ...@@ -78,7 +78,7 @@ jQuery.fn.extend({
jQuery( this ).removeClass( value.call(this, j, this.className) ); jQuery( this ).removeClass( value.call(this, j, this.className) );
}); });
} }
if ( (value && typeof value === "string") || value === undefined ) { if ( (value && typeof value === "string") || !arguments.length ) {
removes = ( value || "" ).split( core_rspace ); removes = ( value || "" ).split( core_rspace );
for ( i = 0, l = this.length; i < l; i++ ) { for ( i = 0, l = this.length; i < l; i++ ) {
......
...@@ -1202,6 +1202,15 @@ test( "removeClass() removes duplicates", function() { ...@@ -1202,6 +1202,15 @@ test( "removeClass() removes duplicates", function() {
ok( !$div.hasClass("x"), "Element with multiple same classes does not escape the wrath of removeClass()" ); ok( !$div.hasClass("x"), "Element with multiple same classes does not escape the wrath of removeClass()" );
}); });
test("removeClass(undefined) is a no-op", function() {
expect( 1 );
var $div = jQuery("<div class='base second'></div>");
$div.removeClass( undefined );
ok( $div.hasClass("base") && $div.hasClass("second"), "Element still has classes after removeClass(undefined)" );
});
var testToggleClass = function(valueObj) { var testToggleClass = function(valueObj) {
expect( 17 ); expect( 17 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment