Skip to content

feat(css): implement CSS pseudo-classes parser, specificity and selector matching - #1

Merged
rahadbhuiya merged 2 commits into
mainfrom
feat/css-pseudo-classes
Nov 1, 2026
Merged

rahadbhuiya merged 2 commits into
mainfrom
feat/css-pseudo-classes

Conversation

@rahadbhuiya

Copy link
Copy Markdown
Owner

Summary

This PR implements comprehensive W3C CSS pseudo-classes support across the CSS parser, CSSOM data structures, specificity calculation, DOM query API, and selector matching engine.

Key Changes

  • CSSOM & Specificity: Added PseudoClass enum (:hover, :active, :focus, :first-child, :last-child, :only-child, :empty, :root, :checked, :disabled, :enabled, Other). Aligned Selector::specificity to count each pseudo-class into class specificity (spec.1) per W3C specification.
  • CSS Parser: Extended starts_simple_selector and parse_simple_selector to parse single and chained pseudo-classes (e.g. �utton:first-child:focus), with tolerant recovery for double-colon syntax.
  • DOM State & Query: Added interactive hover/focus/active state flags and methods to ElementData and Dom (set_hovered, set_focused, set_active).
  • Selector Matching: Implemented matches_pseudo covering structural element tree walks and form element state.
  • Tests: Added comprehensive test coverage in parser_tests, dom::tests, and main.rs. Updated ROADMAP.md.

@rahadbhuiya rahadbhuiya self-assigned this Nov 1, 2026
@rahadbhuiya
rahadbhuiya merged commit 809946d into main Nov 1, 2026
1 check passed
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.

1 participant