diff options
author | louisremi <louisremi@louisremi-laptop.(none)> | 2011-02-17 17:26:23 +0100 |
---|---|---|
committer | Anton M <obhvsbypqghgc@gmail.com> | 2011-02-17 17:26:23 +0100 |
commit | 85d9343271da85fc945bf37a604873eaf247a3a7 (patch) | |
tree | 302ce8461a3ed1096a4a396189ec3a87dcaedeb0 /src/effects.js | |
parent | b9f5e2b97458f89cbcac3a333ba95b0eac568d49 (diff) | |
download | jquery-85d9343271da85fc945bf37a604873eaf247a3a7.tar.gz jquery-85d9343271da85fc945bf37a604873eaf247a3a7.zip |
Fixes #7912. Make sure .cur() only returns 0 as fallback value when it needs to ("", auto, undefined, null).
This change makes .cur() more .cssHooks friendly. .cur() now returns the unmodified value by
.css() if it isn't a number, number-alike or a value that needs a fallback to 0.
This way fx.start doesn't need to be recalculated for complex values.
Diffstat (limited to 'src/effects.js')
-rw-r--r-- | src/effects.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/effects.js b/src/effects.js index fd832ce4a..d9e9a8b31 100644 --- a/src/effects.js +++ b/src/effects.js @@ -185,7 +185,7 @@ jQuery.fn.extend({ } else { var parts = rfxnum.exec(val), - start = e.cur() || 0; + start = e.cur(); if ( parts ) { var end = parseFloat( parts[2] ), @@ -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 |