Skip to content

feat: Add support for most CSS nesting rules #37

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Apr 18, 2025

This pull request implements parsing for most CSS nesting rules. This works for rules beginning with:

  • Universal selector
  • Attribute selector
  • Class name selector
  • ID selector
  • Pseudoclass/pseudoelement selector

The only I couldn't figure out is the element selector. I've also pushed these changes to csstree#337 in the hopes to get some feedback on how to do that.

In the meantime, I don't want to hold up getting these changes merged in.

Expansion of test cases for nested CSS rules:

  • Replaced the test case for invalid nested rules with new cases for valid nested selectors, including class, ID, attribute, universal, and pseudoclass selectors in fixtures/ast/rule/nesting.json. These updates ensure the parser correctly handles a broader range of nested selectors. [1] [2] [3]

Parsing logic updates:

  • Added new token types (Delim, Hash, Colon, LeftSquareBracket) and a selectorStarts set to identify valid selector starting characters in lib/syntax/node/Block.js.
  • Updated the consumeDeclaration function to include a helper method isSelectorStart, which checks for valid selector starting tokens.
  • Modified the parse function to use isSelectorStart for determining whether to consume a rule, enabling support for more selector types.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 14574924483

Details

  • 19 of 19 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 98.6%

Totals Coverage Status
Change from base Build 14558259965: 0.002%
Covered Lines: 11718
Relevant Lines: 11850

💛 - Coveralls

@fasttime fasttime added this to Triage Apr 22, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Apr 22, 2025
@fasttime fasttime moved this from Needs Triage to Triaging in Triage Apr 22, 2025
@fasttime
Copy link
Member

Enhancements to CSS property handling:

* Added support for `overflow-x` and `overflow-y` properties with vendor-specific keywords in `data/patch.json`.

* Introduced the `position-try-options` property to support fallback strategies for CSS positioning.

I don't see any changes in data/patch.json. Maybe you forgot to commit the file?

@nzakas
Copy link
Member Author

nzakas commented Apr 22, 2025

It got updated on main before this, so when I rebased that file disappeared.

@fasttime
Copy link
Member

Ah, I see!

Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@fasttime fasttime merged commit 9d6b65f into main Apr 22, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Triaging to Complete in Triage Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

3 participants