Fix bug in attribute selector parsing#20303
Conversation
Otherwise if we have `[attribute]div` we would get:
Before:
```
{
kind: 'compound',
nodes: [
{ kind: 'selector', value: '[data-foo]div' },
],
},
```
After:
```
{
kind: 'compound',
nodes: [
{ kind: 'selector', value: '[data-foo]' },
{ kind: 'selector', value: 'div' },
],
},
```
Confidence Score: 5/5Safe to merge — the fix is a minimal, well-targeted one-line change to the attribute selector branch of the parser, backed by three new regression tests. The change replaces a single assignment ( No files require special attention. Reviews (2): Last reviewed commit: "update changelog" | Re-trigger Greptile |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR changes selector parsing so attribute selectors are emitted as their own selector nodes from the input slice, rather than being merged into the current buffer. It also refreshes inline comments in the parser, updates tests for compound selectors with adjacent attribute and type selectors, and adds a changelog entry for the parsing fix. ChangesRelated issues: None specified Related PRs: None specified Suggested labels: bug, tests Suggested reviewers: tailwindlabs maintainers 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
This PR fixes a bug in the selector parser where an attribute selector followed by a type selector inside a compound selector resulted in the wrong result.
Given you have this CSS:
[data-foo]div {}Then parsing it before this PR, would result in:
But with this PR, it's properly split:
I also tweaked some of the comments in the parser that are unrelated, but I was there already.
Test plan