Skip to content

Commit a3ac37d

Browse files
committed
custom properties without values are valid
1 parent d45b1ef commit a3ac37d

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,14 @@ Property mediaExpression() :
777777
String p;
778778
LexicalUnit e = null;
779779
Property prop;
780+
Token t;
780781
}
781782
{
782783
<LROUND>
783784
( <S> )*
784-
p = property()
785+
( t = <IDENT> ( <S> )* { p = unescape(t.image, false); }
786+
| t = <CUSTOM_PROPERTY_NAME> ( <S> )* { p = unescape(t.image, false); }
787+
)
785788
(
786789
<COLON> ( <S> )*
787790
e = expr()
@@ -1007,19 +1010,6 @@ char unaryOperator() :
10071010
( <MINUS> { return '-'; } | <PLUS> { return '+'; } )
10081011
}
10091012

1010-
//
1011-
// property
1012-
// : IDENT S*
1013-
// ;
1014-
//
1015-
String property() :
1016-
{
1017-
Token t;
1018-
}
1019-
{
1020-
t = <IDENT> ( <S> )* { return unescape(t.image, false); }
1021-
| t = <CUSTOM_PROPERTY_NAME> ( <S> )* { return unescape(t.image, false); }
1022-
}
10231013

10241014
//
10251015
// ruleset
@@ -1476,7 +1466,7 @@ void styleDeclaration() :
14761466
void declaration() :
14771467
{
14781468
String p;
1479-
LexicalUnit e;
1469+
LexicalUnit e = null;
14801470
Token t;
14811471
boolean priority = false;
14821472
Locator starHack = null;
@@ -1489,12 +1479,18 @@ void declaration() :
14891479
// infamous css-star-hack (http://en.wikipedia.org/wiki/CSS_filter#Star_hack)
14901480
// smart (means: ignoring only one decl)
14911481
( <ASTERISK> { starHack = createLocator(token); } )?
1492-
p = property()
1493-
{
1494-
locator = createLocator(token);
1495-
}
1496-
<COLON> ( <S> )*
1497-
e = expr()
1482+
( (
1483+
t = <IDENT> ( <S> )* { p = unescape(t.image, false); locator = createLocator(t); }
1484+
<COLON> ( <S> )*
1485+
e = expr()
1486+
)
1487+
|
1488+
( t = <CUSTOM_PROPERTY_NAME> ( <S> )* { p = unescape(t.image, false); locator = createLocator(t); }
1489+
<COLON> ( <S> )*
1490+
( e = expr() )?
1491+
)
1492+
)
1493+
14981494
( priority = prio() )?
14991495

15001496
// maybe there are strange characters at the end - create error and skip

src/test/java/org/htmlunit/cssparser/parser/CSS3ParserTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,7 @@ public void varExpressions() throws Exception {
15751575
expression("h1 { --my-var: 2px; }");
15761576
expression("h1 { --my-var: 10pt; }");
15771577
expression("h1 { --my-var: 11%; }");
1578+
expression("h1 { --my-var: ; }");
15781579
expression("h1 { --my-var: rgb(255, 255, 255); }");
15791580
expression("h1 { --my-var: rgba(255, 255, 255, 0); }");
15801581
expression("h1 { --my-var: var(--test); }");
@@ -4193,8 +4194,8 @@ public void realWorldBootstrap520() throws Exception {
41934194
+ "(prefers-reduced-motion: no-preference);"
41944195
+ "(prefers-reduced-motion: reduce);"
41954196
+ "print;";
4196-
realWorld("realworld/bootstrap_5_2_0.css", 1198, 3018, media, 55, 0);
4197-
realWorld("realworld/bootstrap_5_2_0.min.css", 1198, 3018, media, 55, 0);
4197+
realWorld("realworld/bootstrap_5_2_0.css", 1198, 3033, media, 40, 0);
4198+
realWorld("realworld/bootstrap_5_2_0.min.css", 1198, 3033, media, 40, 0);
41984199
}
41994200

42004201
/**

0 commit comments

Comments
 (0)