Merge branch 'master' of git://github.com/jquery/jquery into fixedbuild
[jquery.git] / src / effects.js
index 2dd7011..d9e9a8b 100644 (file)
@@ -185,11 +185,11 @@ jQuery.fn.extend({
 
                                } else {
                                        var parts = rfxnum.exec(val),
-                                               start = e.cur() || 0;
+                                               start = e.cur();
 
                                        if ( parts ) {
                                                var end = parseFloat( parts[2] ),
-                                                       unit = parts[3] || "px";
+                                                       unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
 
                                                // We need to compute starting value
                                                if ( unit !== "px" ) {
@@ -336,8 +336,12 @@ jQuery.fx.prototype = {
                        return this.elem[ this.prop ];
                }
 
-               var r = parseFloat( jQuery.css( this.elem, this.prop ) );
-               return r || 0;
+               var parsed,
+                       r = jQuery.css( this.elem, this.prop );
+               // Empty strings, null, undefined and "auto" are converted to 0,
+               // complex values such as "rotate(1rad)" are returned as is,
+               // simple values such as "10px" are parsed to Float.
+               return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
        },
 
        // Start an animation from one number to another
@@ -348,7 +352,7 @@ jQuery.fx.prototype = {
                this.startTime = jQuery.now();
                this.start = from;
                this.end = to;
-               this.unit = unit || this.unit || "px";
+               this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
                this.now = this.start;
                this.pos = this.state = 0;
 
@@ -505,42 +509,17 @@ if ( jQuery.expr && jQuery.expr.filters ) {
 }
 
 function defaultDisplay( nodeName ) {
-       var stylesheets = document.styleSheets,
-                       disabled = [],
-                       elem, display, style, idx;
-
        if ( !elemdisplay[ nodeName ] ) {
+               var elem = jQuery("<" + nodeName + ">").appendTo("body"),
+                       display = elem.css("display");
 
-               // #8099 - If the end-dev has globally changed a default
-               // display, we can temporarily disable their styles to check
-               // for the correct default value
-               for ( idx = 0; idx < stylesheets.length; ++idx  ) {
-                       style = stylesheets[ idx ];
-                       disabled[ idx ] = style.disabled;
-                       style.disabled = true;
-               }
-               
-               // To accurately check an element's default display value, 
-               // create a temp element and check it's default display, this
-               // will ensure that the value returned is not a user-tampered
-               // value.
-               elem = jQuery("<" + nodeName + ">").appendTo("body"),
-               display = elem.css("display");
-               
-               // Remove temp element
                elem.remove();
 
                if ( display === "none" || display === "" ) {
                        display = "block";
                }
-               
-               // Store the correct default display
-               elemdisplay[ nodeName ] = display;
 
-               // Restore stylesheets
-               for ( idx = 0; idx < stylesheets.length; ++idx  ) {
-                       stylesheets[ idx ].disabled = disabled[ idx ];
-               }
+               elemdisplay[ nodeName ] = display;
        }
 
        return elemdisplay[ nodeName ];