🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ jQuery.extend( {
}

// If a number was passed in, add the unit (except for certain CSS properties)
if ( type === "number" ) {
// The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a url we can reference for this statement/plan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this PR lands I'll rebase #4055 and add a removal of this part there so I just need to remember about it until that moment. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I landed this PR & rebased PR #4055, reverting this fix there.

// "px" to a few hardcoded values.
if ( type === "number" && !isCustomProp ) {
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
}

Expand Down
15 changes: 15 additions & 0 deletions test/unit/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,21 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
}
} );

QUnit[ supportsCssVars ? "test" : "skip" ]( "Don't append px to CSS vars", function( assert ) {
assert.expect( 3 );

var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" );

$div
.css( "--a", 3 )
.css( "--line-height", 4 )
.css( "--lineHeight", 5 );

assert.equal( $div.css( "--a" ), "3", "--a: 3" );
assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" );
assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" );
} );
} )();

}