aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/attributes.js
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-06-07 20:54:11 -0400
committertimmywil <tim.willison@thisismedium.com>2011-06-07 21:00:44 -0400
commitdb437be6e31c924aade13bb719f9facc122b3d9c (patch)
tree183b1931d25d2040c70fea35eca060b96dba44e4 /test/unit/attributes.js
parent0a80be67f4fe968d99777564a02aeddbde1fbf35 (diff)
downloadjquery-db437be6e31c924aade13bb719f9facc122b3d9c.tar.gz
jquery-db437be6e31c924aade13bb719f9facc122b3d9c.zip
Check classes passed for duplicates. Fixes #9499.
Diffstat (limited to 'test/unit/attributes.js')
-rw-r--r--test/unit/attributes.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 56c398e5c..37260f2fa 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -761,12 +761,14 @@ test("val(select) after form.reset() (Bug #2551)", function() {
});
var testAddClass = function(valueObj) {
- expect(5);
+ expect(7);
var div = jQuery("div");
div.addClass( valueObj("test") );
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
- if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
+ if ( !~div.get(i).className.indexOf("test") ) {
+ pass = false;
+ }
}
ok( pass, "Add Class" );
@@ -787,6 +789,13 @@ var testAddClass = function(valueObj) {
div.attr("class", "foo");
div.addClass( valueObj("bar baz") );
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
+
+ div.removeAttr("class");
+ div.addClass( valueObj("foo") ).addClass( valueObj("foo") )
+ equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
+ div.removeAttr("class");
+ div.addClass( valueObj("bar bar") );
+ equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." );
};
test("addClass(String)", function() {