Fix CSS Nesting selector validation#47
Conversation
Update fork to match updated original
There was a problem hiding this comment.
Pull Request Overview
This PR adds CSS Nesting support by fixing the validation of the nesting selector & when followed immediately by other selector parts (e.g., &:hover, &.foo). The grammar now correctly recognizes & as a valid nesting selector and includes it in selector matching patterns throughout the grammar.
Key Changes:
- Added nesting selector
&as a valid selector type with scopeentity.name.tag.nesting.css - Updated selector validation patterns to include
&in lookahead and lookaround assertions - Added comprehensive test coverage for CSS nesting scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spec/css-spec.mjs | Adds four comprehensive test cases covering the nesting selector & in isolation, with classes, with pseudo-classes, and with combinators |
| grammars/css.cson | Updates the CSS grammar to recognize & as a valid nesting selector, refactors arithmetic operators, adds function nesting support, and updates selector validation patterns to include & in various contexts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| { | ||
| 'include': '#property-values' | ||
| }, |
There was a problem hiding this comment.
Trailing comma after the object in the patterns array. This is invalid CSON syntax and will cause a parsing error.
| }, | |
| } |
38c45ef to
390604c
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@microsoft-github-policy-service agree |
|
@torresgol10 does this need to be fixed here? |
|
Hi @thernstig , thanks for linking that issue! It's an interesting topic. However, this PR won't fix that problem. The directives mentioned (@variant, @utilities, @apply, etc.) are Tailwind-specific syntax, not standard CSS. This PR focuses solely on native CSS Nesting support as per the W3C specification. |
|
Is this fix to multi-line urls #28 (comment) not integrated into this PR? {
"begin": "\\\\$\\s*?",
"end": "^(?<!\\G)",
"name": "constant.character.escape.newline.css"
},Considering how long it's taking to get this merged, let's not forget about that tiny thing which completely breaks highlighting in a whole file. 😆 |
|
That seems unrelated to this PR |
|
@controversial If this single character actually breaks tests or something, I can understand moving it to a separate PR, but if it doesn't, that would seem to be a waste of resources. |
Supersedes #30. Continues the work of @jacobcassidy to add CSS Nesting support.
This should fix #9 and #15.
Changes:
Updated css.cson to allow & followed by identifier characters.
Added tests in css-spec.mjs covering nesting scenarios.