Repository navigation
fix(rules): a11y hidden-control checks read decidable <style> rules #678 - #921
Conversation
The accessibility checks that skip controls out of the accessibility tree (aria-hidden-focus, button-name, form-labels, aria-labels, aria-command-name, aria-dialog-name, aria-input-field-name) now read the page's own <style> blocks, not only inline styles. A rule is applied when it is unconditional, every selector in its list is one compound of a tag, .class, #id, [attr] or [attr=value], and its declarations are plainly written, in cascade order (!important, inline, specificity, source order). Anything else that sets display or visibility (combinators, pseudo-classes, at-rules, invalid selectors, unreadable values, media/title/svg/@namespace sheets, visibility animations) is kept as uncertain for the elements it could reach, which makes their answer unknown (unconfirmed), never hidden. On a page with an external stylesheet, hiding from a <style> rule and inherited visibility stay unconfirmed. Reading is bounded: style text, rules, selector length, nesting, index entries and a per-page budget of rule checks. Checked against Chromium (getComputedStyle) on 239 fixture rows: none returns hidden where Chromium shows the element. Closes #664 Closes #665 Closes #671 Closes #678 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of #921 (read the diff and the new The design is conservative in the right direction. Anything the reader can't decide becomes
I found no correctness or security blockers. |
…678 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of #921, a partial read. I read the diff of No blocking problems found.
|
|
Triage of the first review, plus a CodeQL fix (e2a416f):
|
|
Triage of the second review (e2a416f), nothing blocking:
|
The accessibility checks that skip hidden controls now read the page's own
<style>blocks, not only inline styles. The affected rules area11y/aria-hidden-focus,button-name,form-labels,aria-labels,aria-command-name,aria-dialog-nameandaria-input-field-name.Closes #664, closes #665, closes #671, closes #678
Design
packages/rules/src/shared/page-styles.tsis a new, deliberately narrow<style>reader.static-hidden.tsconsults it fordisplayandvisibility.Decidable rules are applied. A rule is decidable when all of these hold:
.class,#id,[attr]or[attr=value];Decidable rules are applied in cascade order:
!important, then inline, then specificity, then source order.Everything else is uncertain. An uncertain rule makes the answer for every element it could reach
unknown, which is reported as unconfirmed and never as hidden. This covers:@media,@layerand@supports;.123,b*,#a#b);revert-layer;<style>blocks with a non-trivialmedia, atitle, an@namespaceor an escaped at-keyword, or inside<svg>;visibility(it outranks ordinary declarations, inline ones too);Special cases:
<style media="print">block is ignored.<template>and<noscript>styles are not read.External stylesheets (
<link rel=stylesheet>,as=style,@import) are not read. When a page has one, hiding from a<style>rule and inherited visibility stay unconfirmed. An inlinedisplay:noneis still trusted, as before, and the docs say so.Bounds on hostile input:
unknown.Measured worst cases:
@medianest each read in 1.5 ms, with about +0.3 MB RSS.Verified against Chromium
tests/fixtures/static-hidden-chromium.jsonnow has 239 rows. Each row's verdict comes from headless Chromium (getComputedStyle), and the rows include every adversarial repro from review.The test asserts that no row Chromium shows is reported hidden.
Codex reviewed the change in six passes and ended with "no findings". Its repros were run in Chromium before any fix. Two of them did not reproduce: Chromium matches
RECT{}and[viewbox]against SVG.Acceptance criteria
#664
aria-hiddenthat is hidden by an inline style or a decidable<style>rule is not reported.static-hidden.tsis used.#665
cssfixture passes.#671
a11y-name-rules-hidden-671.test.ts.#678
display-noneandvisibility-hiddenfixtures and a11y/button-name: hidden controls reported as unnamed buttons #665'scssfixture pass.static-hidden.test.tsunder "<style> reading is bounded".Score effect
<style>rule hides goes from fail to pass.<style>hiding on a page with external CSS, goes from fail to warn (unconfirmed).visibility:hiddencontainer goes from warn to pass.The amended #678 criterion. Originally the criterion read as follows, and was amended because these cases were wrongly passing before. The criterion says "nothing that passed before warns or fails". That cannot hold together with the no-false-hidden criterion in two rare cases.
The first case is a
<style>rule that shows a control again, which Chromium confirms:!importantrule that beats an inlinedisplay:none;visibility: visibleinside a hidden container;displayrule over thehiddenattribute.There the control is now checked, so pass can become fail.
The second case is an undecided
!importantrule, or avisibilityanimation, over an inline hiding. There the control is unconfirmed, so pass can become warn.Both cases are real browser behaviour, and both are stated in the CHANGELOG. The golden fixtures do not change: 209 pass.
Other changes
The unconfirmed row now reads "may be hidden by a style (unconfirmed)", instead of "… by an inline style …".
Checks
check --strictanddocs/scripts/check-links.tspass.Skill impact
The
squirrelagent skill needs no change. Rule ids and options are unchanged, and the unconfirmed message wording is not referenced by the skill.Known limits, also in the docs
!importantrule in an external stylesheet over an inlinedisplay:noneis missed.<template shadowrootmode>) are not seen by any rule, because linkedom keeps them in the template's content. This is unchanged by this PR and is filed as Rules do not see controls inside a declarative shadow root (<template shadowrootmode>) #922.