From c5edf982d59977c506fececd504a3dbfd1a398dc Mon Sep 17 00:00:00 2001 From: Anton M Date: Sun, 13 Feb 2011 23:03:46 +0100 Subject: [PATCH] Don't add "px" to unit-less properties when animating them. Fixes #4966. --- src/effects.js | 4 ++-- test/unit/effects.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/effects.js b/src/effects.js index b0675395f4..0b08bc2dae 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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; diff --git a/test/unit/effects.js b/test/unit/effects.js index bab4f25640..7fb1c7d8d9 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -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( "
" ).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(); + }); +});