Skip to content

Step 3c: CSS selectors, specificity, and cascade #69

@thomasnemer

Description

@thomasnemer

Parent: #22
Prerequisites: Step 3b

Goal

Implement selector parsing, matching, specificity calculation, and the cascade algorithm.

Implementation

  • Selector struct: compounds + combinators (descendant, child, sibling)
  • CompoundSelector: type, id, classes, attributes, pseudo-classes
  • Attribute selectors: [attr], [attr=val], [attr~=val], etc.
  • Pseudo-classes: :hover, :focus, :first-child, :last-child, :nth-child(an+b), :not()
  • Specificity(a, b, c) calculation and comparison
  • Cascade: collect matching declarations, sort by origin/specificity/order
  • Origin: UserAgent, Author, with !important handling

Tests

  • Selector parsing, specificity calculation, cascade ordering
  • ~15 tests

Acceptance Criteria

  • cargo test -p ie-css passes
  • Clippy clean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions