Skip to content
Permalink
Browse files

CSS: Skip the px-appending logic for animations of non-element props

Without this change animating properties from jQuery.cssNumber on non-elements
throws an error.

Ref gh-4055
Closes gh-4061
  • Loading branch information...
mgol committed Apr 30, 2018
1 parent 7646836 commit f5e36bd8f2c2b28231bbed926c6c3dead94db545
Showing with 13 additions and 1 deletion.
  1. +2 −1 src/css/adjustCSS.js
  2. +11 −0 test/unit/effects.js
@@ -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 ) {
@@ -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 );

0 comments on commit f5e36bd

Please sign in to comment.
You can’t perform that action at this time.