Skip to content

fix(rules): a no-js fallback on a page with unread styles is unconfirmed, not a failure #989 - #990

Merged
nc9 merged 1 commit into
mainfrom
fix/989-no-js
Oct 21, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/989-no-js

Conversation

@nc9

@nc9 nc9 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

What

On a page whose stylesheets were not all read (an external stylesheet or @import), a control that carries the no-js class, itself or on an ancestor other than <html>, is no longer decided as shown. The a11y naming rules and aria-hidden-focus report it as <check>-unconfirmed, with the item reason "it or an ancestor carries a no-js class, and a stylesheet squirrel did not read may hide it when JavaScript runs". A theme hides that fallback with a rule such as .js .no-js { display: none } in the stylesheet we never read.

Unchanged: pages whose styles were all read, controls with no marker, other tokens (no-js-hidden, NO-JS in standards mode), <html class="no-js"> alone (the root is a script-managed state, not a fallback marker), a stray second <html>/<body> class, and the readable .js .no-js hide (stays unconfirmed with the generic reason). The marker vocabulary is no-js only; no other state class is covered (follow-up if a report shows one).

Tests

New no-js-fallback-989.test.ts: the issue's cases A (external sheet + show-only rule), B (external sheet alone), C (readable hide), D (<html class="no-js"> fetch) for aria-input-field-name and form-labels, a non-root wrapper, complete styles, non-markers, plus button-name and aria-hidden-focus. 10 of the 18 first-round tests fail with the branch disabled. A Chromium row is not possible here (the behaviour depends on an unread sheet plus script state). Codex pass found two edge cases (case-sensitive class, stray second html/body), fixed with tests. Docs: the a11y rule pages gain a paragraph on the script-state reason and the solution text mentions it; tangly check --strict passes.

Closes #989

skills: no change

@claude

claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Review of #990 (no-js fallback → unconfirmed). The change is small and consistent. I read the diff and the test file but did not run the tests.

  • (low) packages/rules/src/shared/static-hidden.ts (sortUnnamedControls.add): the as T cast on the script-reason branch hides a type hole. If T has no id/label shape, the cast produces a mismatched item. Narrowing the generic (e.g. T extends string | { id: string; snippet?: string }) would remove the cast.
  • (low) static-hidden.ts (unconfirmedRow): a string item can never carry its own label. This works today because sortUnnamedControls converts script-reason strings to objects first, but the coupling is implicit. A short comment would help.
  • (low) static-hidden.ts (verdict ordering): noJs && !author.complete only applies after every other branch resolves to shown, which is intended. The aria-hidden-focus test only covers no-js on a descendant of the aria-hidden element. A case with no-js on the aria-hidden element itself would pin the ordering.
  • (nit) hasNoJsClass runs a regex split on every element visited, including ones with no class attribute. A cheap bail-out when the class is absent or lacks no-js would avoid the allocation on large pages.
  • (nit) Test coverage: there is no case for no-js on <body> alone (treated as a wrapper, so not a marker), or for a <template>/<svg> descendant carrying no-js.

No correctness or security problems found. The docs and CHANGELOG changes read fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a11y style reader: a no-js fallback control is decided as shown (fail) though the external theme sheet hides it once scripts run

1 participant