Skip to content

Enable escaped curly brace test case and preserve empty CSS rules in output#7

Merged
jogibear9988 merged 5 commits intomainfrom
copilot/add-css-rule-support
Mar 17, 2026
Merged

Enable escaped curly brace test case and preserve empty CSS rules in output#7
jogibear9988 merged 5 commits intomainfrom
copilot/add-css-rule-support

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 17, 2026

The #\{\}{background:lime;} rule was commented out in the escapes test with a note that the parser doesn't support it. The parser already handles this correctly via indexOfArrayWithBracketAndQuoteSupport which skips backslash-escaped characters when scanning for delimiters — so this was just a stale test exclusion.

Additionally, the compiler's rule() method was stripping CSS rules with empty declaration blocks (e.g. .\3A \({}, ##fake-id{}, #-a-b-c-{}`). These are valid CSS rules per the spec and should be preserved in the output.

  • Uncommented #\{\}{background:lime;} in test/cases/escapes/input.css
  • Fixed rule() in src/stringify/compiler.ts to preserve rules with empty declaration blocks instead of dropping them (outputs selector {} in formatted mode, selector{} in compressed mode)
  • Updated golden files (ast.json, output.css, compressed.css) to include both the escaped curly brace rule and the previously-dropped empty-body rules

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 17, 2026 20:57
Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
… golden file changes

Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for valid CSS rules in parser Enable escaped curly brace test case in escapes suite Mar 17, 2026
Copilot AI requested a review from jogibear9988 March 17, 2026 21:00
@@ -1,2 +1,2 @@
/* tests compressed for easy testing */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These rules here are still removed, but they are valid css!
Also the following ones....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in f6d45e8. The compiler's rule() method was stripping rules with empty declaration blocks (!decls.lengthreturn ''). Updated it to preserve these valid CSS rules. Empty rules now output as selector {} in formatted mode and selector{} in compressed mode. All 6 empty-body rules (.\\3A \\\({}, .\31 a2b3c{}, #\#fake-id{}, #\---{}, #-a-b-c-{}, #©{}`) are now preserved in the output.

Copilot AI and others added 2 commits March 17, 2026 21:06
Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
Copilot AI changed the title Enable escaped curly brace test case in escapes suite Enable escaped curly brace test case and preserve empty CSS rules in output Mar 17, 2026
Copilot AI requested a review from jogibear9988 March 17, 2026 21:10
@jogibear9988 jogibear9988 marked this pull request as ready for review March 17, 2026 21:10
@jogibear9988 jogibear9988 merged commit a8dc366 into main Mar 17, 2026
@jogibear9988 jogibear9988 deleted the copilot/add-css-rule-support branch March 17, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants