jquery core: casting numbers received by val() to string.
[jquery.git] / src / core.js
index 27cdbfe..d46f89d 100644 (file)
@@ -401,6 +401,9 @@ jQuery.fn = jQuery.prototype = {
                        return undefined;
                }
 
+               if( value.constructor == Number )
+                       value += '';
+
                return this.each(function(){
                        if ( this.nodeType != 1 )
                                return;
@@ -410,9 +413,7 @@ jQuery.fn = jQuery.prototype = {
                                        jQuery.inArray(this.name, value) >= 0);
 
                        else if ( jQuery.nodeName( this, "select" ) ) {
-                               var values = value.constructor == Array ?
-                                       value :
-                                       [ value ];
+                               var values = jQuery.makeArray(value);
 
                                jQuery( "option", this ).each(function(){
                                        this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
@@ -429,7 +430,7 @@ jQuery.fn = jQuery.prototype = {
 
        html: function( value ) {
                return value == undefined ?
-                       (this.length ?
+                       (this[0] ?
                                this[0].innerHTML :
                                null) :
                        this.empty().append( value );
@@ -506,9 +507,9 @@ jQuery.fn = jQuery.prototype = {
                                        this;
 
                                // execute all scripts after the elements have been injected
-                               if ( jQuery.nodeName( elem, "script" ) ) {
+                               if ( jQuery.nodeName( elem, "script" ) )
                                        scripts = scripts.add( elem );
-                               } else {
+                               else {
                                        // Remove any inner scripts for later evaluation
                                        if ( elem.nodeType == 1 )
                                                scripts = scripts.add( jQuery( "script", elem ).remove() );
@@ -639,7 +640,9 @@ jQuery.extend({
                        else
                                script.appendChild( document.createTextNode( data ) );
 
-                       head.appendChild( script );
+                       // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
+                       // This arises when a base node is used (#2709).
+                       head.insertBefore( script, head.firstChild );
                        head.removeChild( script );
                }
        },
@@ -745,14 +748,14 @@ jQuery.extend({
        },
 
        prop: function( elem, value, type, i, name ) {
-                       // Handle executable functions
-                       if ( jQuery.isFunction( value ) )
-                               value = value.call( elem, i );
-
-                       // Handle passing in a number to a CSS property
-                       return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
-                               value + "px" :
-                               value;
+               // Handle executable functions
+               if ( jQuery.isFunction( value ) )
+                       value = value.call( elem, i );
+
+               // Handle passing in a number to a CSS property
+               return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+                       value + "px" :
+                       value;
        },
 
        className: {