Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited306c0

Browse files
authored
CSS: Don’t trim whitespace of undefined custom property
Fixesgh-5105Closesgh-5106Signed-off-by: Anders Kaseorg <andersk@mit.edu>
1 parentd153c37 commited306c0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

‎src/css/curCSS.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function curCSS( elem, name, computed ) {
1515
ret=computed.getPropertyValue(name)||computed[name];
1616

1717
// trim whitespace for custom property (issue gh-4926)
18-
if(isCustomProp){
18+
if(isCustomProp&&ret!==undefined){
1919

2020
// rtrim treats U+000D CARRIAGE RETURN and U+000C FORM FEED
2121
// as whitespace while CSS does not, but this is not a problem

‎test/unit/css.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
17481748
" --prop10:\f\r\n\t val10 \f\r\n\t;\n"+
17491749
" --prop11:\u000C\u000D\u000A\u0009\u0020val11\u0020\u0009\u000A\u000D\u000C;\n"+
17501750
" --prop12:\u000Bval12\u000B;\n"+
1751+
" --empty:;\n"+
17511752
" }\n"+
17521753
"</style>"
17531754
);
@@ -1756,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
17561757
$elem=jQuery("<div>").addClass("test__customProperties")
17571758
.appendTo("#qunit-fixture"),
17581759
webkitOrBlink=/\bsafari\b/i.test(navigator.userAgent),
1759-
expected=17;
1760+
expected=19;
17601761

17611762
if(webkitOrBlink){
17621763
expected-=2;
@@ -1802,6 +1803,8 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
18021803
assert.equal($elem.css("--prop10"),"val10","Multiple preceding and following escaped unicode whitespace trimmed");
18031804
assert.equal($elem.css("--prop11"),"val11","Multiple preceding and following unicode whitespace trimmed");
18041805
assert.equal($elem.css("--prop12"),"\u000Bval12\u000B","Multiple preceding and following non-CSS whitespace reserved");
1806+
assert.equal($elem.css("--empty"),undefined);
1807+
assert.equal($elem.css("--nonexistent"),undefined);
18051808
});
18061809

18071810
// IE doesn't support CSS variables.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp