Skip to content

Conversation

@bencbradshaw
Copy link
Contributor

Feat: Add support for state() pseudo-class

Fixes:
#1036

[Acknowledgements]
WIP PR

[external]
Addresses and Enables
lit/lit#5208 (comment)

Note for Chromium based browser versions 90-124:
:state() will be in the output
Those browsers will ignore it (unknown selector = no match)

[x] - Tests Added
[x] - All tests Passing
[x] - documentation updated if needed (not needed)

Copilot AI review requested due to automatic review settings January 17, 2026 17:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for the CSS :state() pseudo-class, which is used for styling custom element states. The implementation enables web components to expose internal states that can be styled from outside the shadow DOM.

Changes:

  • Added parsing and serialization support for the :state() pseudo-class in the selector parser
  • Implemented browser compatibility tracking with appropriate version requirements, filtering out partial implementations from Chrome/Edge 90-124
  • Added comprehensive test coverage including basic usage, nesting, and complex selector scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/selector.rs Added :state() parsing, enum variant, CSS output, and compatibility feature mapping
src/lib.rs Added comprehensive tests for :state() including minification and nesting scenarios
src/compat.rs Added StatePseudoClass feature with browser version compatibility checks
scripts/build-prefixes.js Added MDN data extraction for :state() with filtering of partial implementations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Thank you!

@devongovett devongovett merged commit a177fd6 into parcel-bundler:master Jan 20, 2026
8 of 9 checks passed
@devongovett devongovett mentioned this pull request Jan 20, 2026
2 tasks
@jp-knj
Copy link

jp-knj commented Jan 20, 2026

Thanks!

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.

3 participants