Removed .removeAttr(Function), it didn't really make sense.
[jquery.git] / src / attributes.js
index a5a6662..004c6b3 100644 (file)
@@ -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 ) {
@@ -99,7 +92,7 @@ jQuery.fn.extend({
                if ( jQuery.isFunction( value ) ) {
                        return this.each(function(i) {
                                var self = jQuery(this);
-                               self.toggleClass( value.call(this, i, self.attr("class")), stateVal );
+                               self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
                        });
                }
 
@@ -195,28 +188,23 @@ jQuery.fn.extend({
                        return undefined;
                }
 
-               // Typecast once if the value is a number
-               if ( typeof value === "number" ) {
-                       value += "";
-               }
-
-               var val = value;
+               var isFunction = jQuery.isFunction(value);
 
                return this.each(function(i) {
-                       var self = jQuery(this);
+                       var self = jQuery(this), val = value;
 
-                       if ( jQuery.isFunction(value) ) {
-                               val = value.call(this, i, self.val());
+                       if ( this.nodeType !== 1 ) {
+                               return;
+                       }
 
-                               // Typecast each time if the value is a Function and the appended
-                               // value is therefore different each time.
-                               if ( typeof val === "number" ) {
-                                       val += "";
-                               }
+                       if ( isFunction ) {
+                               val = value.call(this, i, self.val());
                        }
 
-                       if ( this.nodeType !== 1 ) {
-                               return;
+                       // Typecast each time if the value is a Function and the appended
+                       // value is therefore different each time.
+                       if ( typeof val === "number" ) {
+                               val += "";
                        }
 
                        if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
@@ -226,7 +214,7 @@ jQuery.fn.extend({
                                var values = jQuery.makeArray(val);
 
                                jQuery( "option", this ).each(function() {
-                                       this.selected = jQuery.inArray( self.val(), values ) >= 0;
+                                       this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
                                });
 
                                if ( !values.length ) {