X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fattributes.js;h=4f7055a6e4f570cd388bbb461286ef34de6c86a3;hb=1844f95c5b2f92a1b388ff43e20aa4f065a6e57c;hp=3ae05421bcb08dd9dc2e64c514071ba0554d9a6e;hpb=d36b29fa8e24820e0d1feb6a4ab46c440f54155a;p=jquery.git diff --git a/src/attributes.js b/src/attributes.js index 3ae0542..4f7055a 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -12,14 +12,7 @@ jQuery.fn.extend({ return access( this, name, value, true, jQuery.attr ); }, - removeAttr: function( name ) { - if ( jQuery.isFunction( name ) ) { - return this.each(function(i) { - var self = jQuery(this); - self.removeAttr( name.call(this, i, self.attr(name)) ); - }); - } - + removeAttr: function( name, fn ) { return this.each(function(){ jQuery.attr( this, name, "" ); if ( this.nodeType === 1 ) { @@ -47,12 +40,13 @@ jQuery.fn.extend({ elem.className = value; } else { - var className = " " + elem.className + " "; + var className = " " + elem.className + " ", setClass = elem.className; for ( var c = 0, cl = classNames.length; c < cl; c++ ) { if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { - elem.className += " " + classNames[c]; + setClass += " " + classNames[c]; } } + elem.className = jQuery.trim( setClass ); } } } @@ -81,7 +75,7 @@ jQuery.fn.extend({ for ( var c = 0, cl = classNames.length; c < cl; c++ ) { className = className.replace(" " + classNames[c] + " ", " "); } - elem.className = className.substring(1, className.length - 1); + elem.className = jQuery.trim( className ); } else { elem.className = ""; @@ -288,7 +282,7 @@ jQuery.extend({ if ( set ) { // We can't allow the type property to be changed (since it causes problems in IE) if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { - throw "type property can't be changed"; + jQuery.error( "type property can't be changed" ); } elem[ name ] = value; @@ -337,7 +331,7 @@ jQuery.extend({ } // elem is actually elem.style ... set the style - // Using attr for specific style information is now deprecated. Use style insead. + // Using attr for specific style information is now deprecated. Use style instead. return jQuery.style( elem, name, value ); } });