🌐 AI搜索 & 代理 主页
Skip to content

Commit 0c9852a

Browse files
committed
CSS: Skip the px-appending logic for animations of non-element props
Ref jquerygh-4055
1 parent 7646836 commit 0c9852a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/css/adjustCSS.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function adjustCSS( elem, prop, valueParts, tween ) {
1919
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
2020

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

2526
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {

test/unit/effects.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,17 @@ QUnit.test( "animate non-element", function( assert ) {
607607
this.clock.tick( 200 );
608608
} );
609609

610+
QUnit.test( "animate non-element's zIndex without appending \"px\"", function( assert ) {
611+
assert.expect( 1 );
612+
613+
var obj = { zIndex: 0 };
614+
615+
jQuery( obj ).animate( { zIndex: 200 }, 200, function() {
616+
assert.equal( obj.zIndex, 200, "The custom property should be modified without appending \"px\"." );
617+
} );
618+
this.clock.tick( 200 );
619+
} );
620+
610621
QUnit.test( "stop()", function( assert ) {
611622
assert.expect( 4 );
612623

0 commit comments

Comments
 (0)