aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2018-04-30 18:52:39 +0200
committerGitHub <noreply@github.com>2018-04-30 18:52:39 +0200
commitf5e36bd8f2c2b28231bbed926c6c3dead94db545 (patch)
treea34ac08fd6129c2974b0d16248e83b26eaa07bc6
parent76468365779c2d07c7f25ded141e99bad97f78a7 (diff)
downloadjquery-f5e36bd8f2c2b28231bbed926c6c3dead94db545.tar.gz
jquery-f5e36bd8f2c2b28231bbed926c6c3dead94db545.zip
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
-rw-r--r--src/css/adjustCSS.js3
-rw-r--r--test/unit/effects.js11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/css/adjustCSS.js b/src/css/adjustCSS.js
index 626ec7475..8898789a7 100644
--- a/src/css/adjustCSS.js
+++ b/src/css/adjustCSS.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 ) {
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 462524ef3..e297273e4 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -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 );