feat(core): upgrade css-selector-parser to v3 and match input types case-insensitively #5358
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
straker
cpruijsen
Reworked following the review below: this now upgrades
css-selector-parserto v3 and uses theiattribute flag in the rule selectors, instead of case folding inputtypeinside the engine.<input type="SUBMIT">,type="buTTON"andtype="ImAGE"were missed byinput-button-nameandinput-image-alt, because axe compared thetypevalue case-sensitively. HTML treatstypeas ASCII case-insensitive, and so does nativequerySelectorAll.Changes
css-selector-parser1.4.1 to 3.3.0.utils/matchesis ported to the v3 AST and still produces the same internal expressions.iandsmodifiers.ifolds 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.iis added to the inputtypeselectors ininput-button-name,input-image-alt,color-contrast-matchesandno-naming-method-matches.axe.imports.CssSelectorParseris kept as a deprecated wrapper with the same constructor andparse()method.parse()now returns the v3 AST.Breaking changes
Both are in the commit's
BREAKING CHANGEfooter 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 oraxe.utils.matches/querySelectorAllcall using one now throws, asdocument.querySelectorAllalready does.page-has-heading-oneused[aria-level=1]and is quoted here.Behaviour note
The
iflag applies whatever the document language, so in XHTML documents these inputtypeselectors 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
matches,querySelectorAllandclosestinlib/) ondevelopand on this branch, then compared the converted expressions. The only differences are the newiselectors and[aria-level="1"].i,Iandson every attribute operator, ASCII against non-ASCII folding, both combinators,:notand:is.SUBMIT,buTTONandImAGEpass 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, althoughconvertAttributesalready handled it. It is tested here and can be dropped if you prefer to keep the operator set unchanged.Closes: #4612