]> source.dussan.org Git - jquery.git/commitdiff
Fixed some bugs relating to the setter arg change in val and html. Also optimized...
authorjeresig <jeresig@gmail.com>
Thu, 7 Jan 2010 14:53:16 +0000 (09:53 -0500)
committerjeresig <jeresig@gmail.com>
Thu, 7 Jan 2010 14:53:16 +0000 (09:53 -0500)
src/attributes.js
src/manipulation.js

index a5a6662c4f08f1607ad3cfa0a9e34047dc7a2107..1dd70842c74ab7d375c31ab81a59e03b875c1206 100644 (file)
@@ -195,28 +195,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 +221,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 ) {
index 730dfca5e1296d299a05676f74f423845cd09202..081bb54819c6866f362ad443cbe962d477eec8c0 100644 (file)
@@ -173,7 +173,7 @@ jQuery.fn.extend({
 
        html: function( value ) {
                if ( value === undefined ) {
-                       return this[0] ?
+                       return this[0] && this[0].nodeType === 1 ?
                                this[0].innerHTML.replace(rinlinejQuery, "") :
                                null;