From 009033bb4566079c1f5006ca0e4521ad64117cd0 Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Fri, 11 May 2007 22:29:16 +0000 Subject: [PATCH] Fix for #1167 --- src/jquery/coreTest.js | 7 ++++++- src/jquery/jquery.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index d829d3092..dc9c8ed48 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -766,7 +766,7 @@ test("addClass(String)", function() { }); test("removeClass(String) - simple", function() { - expect(2); + expect(3); var div = $("div").addClass("test").removeClass("test"), pass = true; for ( var i = 0; i < div.size(); i++ ) { @@ -782,6 +782,11 @@ test("removeClass(String) - simple", function() { if ( div.get(i).className.match(/test|bar|foo/) ) pass = false; } ok( pass, "Remove multiple classes" ); + + reset(); + var div = $("div:eq(0)").addClass("test").removeClass(""); + ok( div.is('.test'), "Empty string passed to removeClass" ); + }); test("toggleClass(String)", function() { diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 118b41487..6fb1d5d1d 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1349,7 +1349,7 @@ jQuery.extend({ // internal only, use removeClass("class") remove: function( elem, c ){ - elem.className = c ? + elem.className = c != undefined ? jQuery.grep( elem.className.split(/\s+/), function(cur){ return !jQuery.className.has( c, cur ); }).join(" ") : ""; -- 2.39.5