Skip to content

fix: support :has() and :only-child and modern pseudo-classes in ExtractStyleBlocks - #488

Open
ezyang wants to merge 2 commits into
masterfrom
fix/397-has-only-child
Open

fix: support :has() and :only-child and modern pseudo-classes in ExtractStyleBlocks#488
ezyang wants to merge 2 commits into
masterfrom
fix/397-has-only-child

Conversation

@ezyang

@ezyang ezyang commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Fixes #397

  • Expand _enum_attrdef whitelist to include has, only-child and 30+ modern pseudo-classes/elements (from issue comment)
  • Handle functional pseudo-classes (has(), not(), nth-child() etc.) with parentheses - validate function name and keep whole value
  • Protect : inside functional pseudo parentheses so :has(br:only-child) is not split into has(br + only-child)

Before: p:has(br:only-child) { margin:0 } -> p { margin:0 } (stripped)
After: preserved as p:has(br:only-child)

Closes #397

ezyang added 2 commits August 12, 2026 00:06
…actStyleBlocks

- Expand _enum_attrdef whitelist to include has, only-child and 30+ modern
  pseudo-classes/elements (from issue #397 comment)
- Handle functional pseudo-classes (has(), not(), nth-child() etc.) with
  parentheses - validate function name and keep whole value
- Protect : inside functional pseudo parentheses so :has(br:only-child)
  is not split into has(br + only-child)

Fixes #397 - p:has(br:only-child) was stripped to p
Rename inner loop var $k => $ck to prevent overwriting outer foreach key.

Fixes 20 ExtractStyleBlocksTest failures where numeric key 0/2/4
leaked as '0 { ... }'.
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.

CSS pseudo class "has()" not supported

1 participant