Add support for layer declarations ending with semicolon - #1624
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for semicolon-terminated at-rules without consuming subsequent CSS rules.
Changes:
- Adds
AtRuleStatementparsing and rendering. - Preserves block-form
@layerbehavior. - Adds unit and parser regression tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/CSSList/CSSList.php |
Distinguishes statement and block at-rules. |
src/Property/AtRuleStatement.php |
Represents semicolon-terminated at-rules. |
tests/CSSList/AtRuleStatementTest.php |
Tests parsing and rule boundaries. |
tests/Unit/Property/AtRuleStatementTest.php |
Tests the new representation. |
CHANGELOG.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Unknown other at rule (font-face or such) | ||
| $arguments = \trim($parserState->consumeUntil('{', false, true)); | ||
| // Unknown other at rule (font-face, @layer, or such) | ||
| $arguments = \trim($parserState->consumeUntil(['{', ';'], false, false)); |
There was a problem hiding this comment.
It's the same with {. Fixing it is beyond the scope of this PR. #1625 added.
JakeQZ
left a comment
There was a problem hiding this comment.
Wow. Excellent contribution @samuil-banti-wpenigne. Hard to pick any holes in that.
The functional tests for the new class should be in a different location (and namespace), and I don't think we need a changelog entry that tests have been added.
Otherwise, looks perfect. Thank you so much, particularly for taking the time to understand the codebase.
@oliverklee, do you have any other nitpicks?
JakeQZ
left a comment
There was a problem hiding this comment.
LGTM now. One of the best PR submissions we've ever had. Thank you.
@oliverklee, anything else to pick up on?
phar.io server is currently down, causing failing checks...
|
@JakeQZ I most probably won't have time to look at this today or tomorrow, and I don't want to block this. So feel free to merge in the meantime. |
OK. Happy to do so so that people can pick up the The only thing I can think of that might be falling short is whether the tests cover every eventuality and format of at-rules. But they never will - there's always an edge case that has been missed. AI was surprisingly smart at picking up the pre-existing lack of string parsing, which has been logged as #1625. Any other issues found can be resolved as a follow-up. Thanks again @samuil-banti-wpenigne for your excellent contribution. |
Semicolon-terminated
@layeris valid CSS but was parsed as a block, so later rules were swallowed.@layerhas two forms (CSS Cascade 5):Generic at-rule parsing always searched for {. For
@layer reset;, that meant consuming through the next { (e.g.@property), so the rest of the stylesheet was treated as nested contents of a fake layer block.Fix: stop at
{or;. A;becomesAtRuleStatement;a{still becomesAtRuleBlockListorAtRuleSet. layer stays inBLOCK_RULES, so@layer theme { … }is unchanged.