Repository navigation
Description
What happens
Since v0.0.122, an unnamed control that carries a no-js class is reported as a fail by a11y/aria-input-field-name and a11y/form-labels when the page has an external stylesheet. The no-js class is the usual marker for a fallback that is only meant for visitors without JavaScript. The change that exposed this is #964 (pub#940).
In a browser that runs scripts, the theme hides that fallback. A typical rule is .js .no-js { display: none } or .no-js:not(html) { display: none !important }, and it lives in the external theme stylesheet, which the a11y style reader does not read. A real visitor with JavaScript never meets the control, so the fail is false.
Observed on cloud report 01M5FFSA0FCYBYJV7M8PM1EQZ8 (100 pages, scheduled run):
aria-input-field-nameandform-labelswent from 98 pages unconfirmed on the site's previous run (pre-v0.0.122 engine) to 98 pages fail.- The element is a product form's variant fallback,
select[name="id"].no-js, on a crawled page whose<html>has the classjs(it was a rendered page).
Bisect
I replayed the stored crawl locally on each release, v0.0.119 through v0.0.124:
- v0.0.119 to v0.0.121: unconfirmed.
- v0.0.122 onward: fail.
The only <style> rule that reached the element was an icon-font prefix rule, [class^="icon-"] { display: inline-block }. Before #964, that rule left the element unconfirmed, by accident. Since #964 it is correctly treated as show-only, so the element is decided as shown. It fails because nothing the reader can see hides it.
This gap existed before #964. Without such a show-only rule, the same element fails on every release (case B below). The hide that applies once scripts run is not on the page at all. The only signal the page carries is the convention itself: the no-js class on the element, plus a root class that a script manages (js added by a script, or no-js that a script replaces).
Minimal repro (generic)
Run a11y/aria-input-field-name and a11y/form-labels on each page:
| Case | Page | v0.0.121 | v0.0.122+ |
|---|---|---|---|
| A | <html class="js"><head><link rel="stylesheet" href="/theme.css"><style>[class^="icon-"]{display:inline-block}</style></head><body><form><select name="id" class="no-js"><option>Small</option></select></form></body></html> |
unconfirmed | fail |
| B | A without the <style> block |
fail | fail |
| C | A plus <style>.js .no-js{display:none}</style> |
unconfirmed | unconfirmed (correct: the hide is readable, and a state-gated hide stays unknown) |
| D | A with <html class="no-js"> (an unrendered fetch; a browser's script swaps the class to js) |
unconfirmed | fail |
Expected
The reader should fail closed. Take a page whose styles are incomplete (an external stylesheet, or an @import). On such a page, an element that carries the marker for "hidden once scripts run" is not decided as shown. The marker is no-js on the element itself or on a non-root ancestor.
- Its finding should be
-unconfirmed, with a reason saying the control may be hidden once scripts run. The generic "a style sets display or visibility in a way squirrel cannot settle" reason should not be used for this case. - Keep the marker vocabulary narrow, and decide it in the PR:
no-jsas a whole class token on a non-root element. - Markers that mean the opposite (for example
no-js-hidden: hidden only without scripts, shown with them) are out of scope. With scripts that element is shown, so a fail stays correct. - A page whose styles are complete (no external sheet and no
@import) keeps today's verdict.
Not in scope
a11y/aria-hidden-focus on the same report also moved from unconfirmed to fail with #964, for the same reason: only the icon prefix rule reached these elements. The affected elements are:
- closed drawers and dialogs,
[aria-hidden="true"][tabindex="0"], mostly custom elements; - inactive tab panels.
These carry no script-state marker. A theme sheet might hide them (display or visibility), or might only move them off screen, which would be a real aria-hidden-focus failure. Which one applies can't be known without the external sheet, the same as on any page without that rule. They are left as is, by design.
Acceptance Criteria
- Repro A, B and D:
aria-input-field-nameandform-labelsreport the select as-unconfirmed, notfail, with a reason that names the script-state marker. The finding does not lower the score. - Repro C: unchanged (unconfirmed).
- The same markup with styles complete (no external stylesheet, no
@import): unchanged (fail). - On the same page, a control with
no-js-hiddenor with no marker: unchanged (fail). -
button-name,aria-command-name,aria-labelsandaria-hidden-focusapply the same rule to the elements they check. - The CLI and cloud reports show the same verdicts.
- The docs that list the a11y unconfirmed reasons include the new reason.
Activity
fix(rules): a no-js control on a page with unread styles is unconfirm…