Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow CSS custom properties with no value #1581

Merged
merged 1 commit into from
Dec 29, 2024
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
2 changes: 1 addition & 1 deletion src/main/java/org/idpf/epubcheck/util/css/CssParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private CssDeclaration handleDeclaration(CssToken name, CssTokenIterator iter,
CssToken value = iter.next();
if (MATCH_SEMI_CLOSEBRACE.apply(value))
{
if (declaration.components.size() < 1)
if (declaration.components.size() < 1 && !declaration.name.or("").startsWith("--"))
{
err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, iter.last.location,
messages.getLocale(), value.getChar(), messages.get("a_property_value")));
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/idpf/epubcheck/util/css/CssParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ public void testParser015() throws Exception {
HandlerImpl handler = checkBasics(exec(s));
assertEquals(0, handler.errors.size());
}

@Test
public void testParser016() throws Exception {
String s = "E { --my-property: ; } ";
HandlerImpl handler = checkBasics(exec(s));
assertEquals(0, handler.errors.size());
}

@Test
public void testParserAtRule001() throws Exception {
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/css/custom-properties.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

:root {
--main-bg-color: brown;
--empty:;
}

.one {
Expand Down
Loading