Skip to content

Fix :is() selector bug with compound selectors containing type selectors #21172

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

Closed
wants to merge 2 commits into from

Conversation

robobun
Copy link
Collaborator

@robobun robobun commented Jul 18, 2025

Summary

Fixes issue #21169 where CSS :is() selectors containing compound selectors with type selectors were incorrectly parsed, causing malformed CSS output.

The Problem

  • .foo:is(input:checked) was incorrectly becoming .fooinput:checked (missing space)
  • .foo:is(input:hover) was incorrectly becoming .fooinput:hover (missing space)
  • This happened because the hasTypeSelector function only checked the first component of a selector

The Fix

Modified the hasTypeSelector function in src/css/selectors/selector.zig to check all components in a selector, not just the first one. This prevents compound selectors containing type selectors from being incorrectly unwrapped.

Test Plan

  • Added comprehensive test cases in test/regression/issue/21169-is-selector-bug.test.ts
  • Verified all new tests pass
  • Verified existing CSS tests still pass
  • Confirmed that class-only selectors like .foo:is(.bar) can still be optimized correctly

🤖 Generated with Claude Code

The CSS parser was incorrectly handling :is() selectors containing compound
selectors with type selectors (like input:checked). The hasTypeSelector function
was only checking the first component, causing compound selectors to be
incorrectly optimized and losing the space between class and type selectors.

This fix ensures that compound selectors containing type selectors are not
unwrapped, preventing the incorrect concatenation like .foo:is(input:checked)
becoming .fooinput:checked.

Fixes oven-sh#21169

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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