Skip to content

Commit

Permalink
CSS: Skip the px-appending logic for animations of non-element props
Browse files Browse the repository at this point in the history
  • Loading branch information
mgol committed Apr 26, 2018
1 parent 7646836 commit 0c9852a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/css/adjustCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function adjustCSS( elem, prop, valueParts, tween ) {
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),

// Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
initialInUnit = elem.nodeType &&
( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );

if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
Expand Down
11 changes: 11 additions & 0 deletions test/unit/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,17 @@ QUnit.test( "animate non-element", function( assert ) {
this.clock.tick( 200 );
} );

QUnit.test( "animate non-element's zIndex without appending \"px\"", function( assert ) {
assert.expect( 1 );

var obj = { zIndex: 0 };

jQuery( obj ).animate( { zIndex: 200 }, 200, function() {
assert.equal( obj.zIndex, 200, "The custom property should be modified without appending \"px\"." );
} );
this.clock.tick( 200 );
} );

QUnit.test( "stop()", function( assert ) {
assert.expect( 4 );

Expand Down

0 comments on commit 0c9852a

Please sign in to comment.