← Back to Pull requests

feat(core): upgrade css-selector-parser to v3 and match input types case-insensitively #5358

Open
cpruijsen opened this pull request with 366 lines diff across 4 files
View on GitHub
cpruijsen cpruijsen commented on Sep 11, 2026 07:38 UTC
Author

Reworked following the review below: this now upgrades css-selector-parser to v3 and uses the i attribute flag in the rule selectors, instead of case folding input type inside the engine.

<input type="SUBMIT">, type="buTTON" and type="ImAGE" were missed by input-button-name and input-image-alt, because axe compared the type value case-sensitively. HTML treats type as ASCII case-insensitive, and so does native querySelectorAll.

Changes

  • css-selector-parser 1.4.1 to 3.3.0. utils/matches is ported to the v3 AST and still produces the same internal expressions.

  • Attribute selectors support the i and s modifiers. i folds ASCII letters only, as CSS Selectors 4 specifies, and the case-insensitive patterns are built once when the selector is converted, so matching adds no work per node.

  • i is added to the input type selectors in input-button-name, input-image-alt, color-contrast-matches and no-naming-method-matches.

  • axe.imports.CssSelectorParser is kept as a deprecated wrapper with the same constructor and parse() method. parse() now returns the v3 AST.
  • Breaking changes

    Both are in the commit's BREAKING CHANGE footer for the release notes.

    1. axe.imports.CssSelectorParser().parse() returns the v3 AST instead of the v1 AST.
    2. The v3 parser rejects selectors that are not valid CSS but that v1 accepted: unquoted numeric attribute values ([aria-level=1]) and ids that start with a digit (#1). A custom rule, check option or axe.utils.matches / querySelectorAll call using one now throws, as document.querySelectorAll already does. page-has-heading-one used [aria-level=1] and is quoted here.

    Behaviour note

    The i flag applies whatever the document language, so in XHTML documents these input type selectors now match case-insensitively as well. The previous version of this PR kept XHTML case-sensitive; with the flag, that is the selector's choice rather than an engine rule.

    Verification

  • A throwaway script parsed all 91 distinct selectors axe uses (every rule and check selector, plus the static strings passed to matches, querySelectorAll and closest in lib/) on develop and on this branch, then compared the converted expressions. The only differences are the new i selectors and [aria-level="1"].

  • New unit tests cover i, I and s on every attribute operator, ASCII against non-ASCII folding, both combinators, :not and :is.

  • The integration and virtual-rule tests for mixed-case SUBMIT, buTTON and ImAGE pass through the new path.

  • test:tsc, build, and the core, integration, virtual-rules, rule-matches, checks, commons and api suites all pass locally.
  • |= is now enabled in the parser config. v1 never registered it, although convertAttributes already handled it. It is tested here and can be dropped if you prefer to keep the operator set unchanged.

    Closes: #4612

    Diff: 366 lines (+274 / -92) across 4 files Reviewer: straker Review duration: 120099m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 366 lines diff across 4 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5358"
    general weight: 0.35
    Reviewers
    Assignees
    cpruijsen cpruijsen
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.5% · Safe to merge
    27.5%