Skip to content

Commit 31b24ef

Browse files
author
Gordon McNaughton
committed
Fixes NV#2 (calling removeClass() with no arguments does not remove all classes).
jQuery's behavior changed somewhere between 1.4.4 and 1.11.3; the 'empty' test case works against 1.4.4 but not 1.11.3 or 2.1.4. Changing the fallback case to pass along the original arguments verbatim fixes the issue.
1 parent 257332b commit 31b24ef

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

jquery.removeClass.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
}
1818
} else {
19-
removeClass.call(this, value);
19+
removeClass.apply(this, Array.prototype.slice.apply(arguments));
2020
}
2121
return this;
2222
}

test/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>jquery.removeClass and jquery.hasClass tests</title>
55
<link rel="stylesheet" href="qunit/qunit.css">
66
<script src="qunit/qunit.js"></script>
7-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
7+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
88
<script src="../jquery.removeClass.js"></script>
99
<script src="removeClass.test.js"></script>
1010
<script src="../jquery.hasClass.js"></script>

test/removeClass.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ test("string", function() {
4141
elem.removeClass("disabled state-open");
4242
equal(elem[0].className, "");
4343
});
44+
45+
test("empty params", function() {
46+
var elem = jQuery("<div class='state-open state-loading disabled'/>");
47+
elem.removeClass();
48+
equal(elem[0].className, "");
49+
});

0 commit comments

Comments
 (0)