]> source.dussan.org Git - jquery.git/commitdiff
Don't add "px" to unit-less properties when animating them. Fixes #4966.
authorAnton M <obhvsbypqghgc@gmail.com>
Sun, 13 Feb 2011 22:03:46 +0000 (23:03 +0100)
committerAnton M <obhvsbypqghgc@gmail.com>
Sun, 13 Feb 2011 22:17:58 +0000 (23:17 +0100)
src/effects.js
test/unit/effects.js

index b0675395f45ac8d2ab5eb6d366da3b5d0bf42186..0b08bc2dae7ec07b09eae1b0fee1c04195af8f74 100644 (file)
@@ -189,7 +189,7 @@ jQuery.fn.extend({
 
                                        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" ) {
@@ -348,7 +348,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;
 
index bab4f256402e843480ad5dde60733e1d4a5ebf3a..7fb1c7d8d972d2929245508117defc895c6d2eb1 100644 (file)
@@ -919,3 +919,13 @@ test("hide hidden elements, with animation (bug #7141)", function() {
                });
        });
 });
+
+test("animate unit-less properties (#4966)", 2, function() {
+       stop();
+       var div = jQuery( "<div style='z-index: 0'></div>" ).appendTo( "body" );
+       equal( div.css( "z-index" ), "0", "z-index is 0" );
+       div.animate({ zIndex: 2 }, function() {
+               equal( div.css( "z-index" ), "2", "z-index is 2" );
+               start();
+       });
+});