Skip to content

Commit

Permalink
Don't add "px" to unit-less properties when animating them. Fixes jqu…
Browse files Browse the repository at this point in the history
  • Loading branch information
jitter committed Feb 13, 2011
1 parent dba8c20 commit c5edf98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/effects.js
Expand Up @@ -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" ) {
Expand Down Expand Up @@ -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;

Expand Down
10 changes: 10 additions & 0 deletions test/unit/effects.js
Expand Up @@ -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();
});
});

0 comments on commit c5edf98

Please sign in to comment.