addClass doesn't fail when passed an undefined or null variable (#1309)

This commit is contained in:
Brandon Aaron 2007-07-21 01:55:05 +00:00
parent b965c98ff1
commit 480aae72d3

View file

@ -1365,7 +1365,7 @@ jQuery.extend({
className: { className: {
// internal only, use addClass("class") // internal only, use addClass("class")
add: function( elem, c ){ add: function( elem, c ){
jQuery.each( c.split(/\s+/), function(i, cur){ jQuery.each( (c || "").split(/\s+/), function(i, cur){
if ( !jQuery.className.has( elem.className, cur ) ) if ( !jQuery.className.has( elem.className, cur ) )
elem.className += ( elem.className ? " " : "" ) + cur; elem.className += ( elem.className ? " " : "" ) + cur;
}); });