No need to run trim on every class iteration in addClass, thanks for the heads-up Leeoniya.
This commit is contained in:
parent
053af95294
commit
437ddb931d
|
@ -40,12 +40,13 @@ jQuery.fn.extend({
|
||||||
elem.className = value;
|
elem.className = value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var className = " " + elem.className + " ";
|
var className = " " + elem.className + " ", setClass = elem.className;
|
||||||
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||||
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
|
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
|
||||||
elem.className = jQuery.trim( elem.className + " " + classNames[c] );
|
setClass += " " + classNames[c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elem.className = jQuery.trim( setClass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,7 +438,7 @@ test("val(Function) with incoming value", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var testAddClass = function(valueObj) {
|
var testAddClass = function(valueObj) {
|
||||||
expect(4);
|
expect(5);
|
||||||
var div = jQuery("div");
|
var div = jQuery("div");
|
||||||
div.addClass( valueObj("test") );
|
div.addClass( valueObj("test") );
|
||||||
var pass = true;
|
var pass = true;
|
||||||
|
@ -460,6 +460,10 @@ var testAddClass = function(valueObj) {
|
||||||
div.attr("class", " foo");
|
div.attr("class", " foo");
|
||||||
div.addClass( valueObj("test") );
|
div.addClass( valueObj("test") );
|
||||||
equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
|
equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
|
||||||
|
|
||||||
|
div.attr("class", "foo");
|
||||||
|
div.addClass( valueObj("bar baz") );
|
||||||
|
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
|
||||||
};
|
};
|
||||||
|
|
||||||
test("addClass(String)", function() {
|
test("addClass(String)", function() {
|
||||||
|
|
Loading…
Reference in a new issue