Skip to content

fix(rules): skip presentational descendants in aria-required-parent - #1642

Merged
nc9 merged 3 commits into
squirrelscan:mainfrom
WilliamK112:codex/aria-required-parent-presentational-1640
Nov 9, 2026
Merged

nc9 merged 3 commits into
squirrelscan:mainfrom
WilliamK112:codex/aria-required-parent-presentational-1640

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • a11y/aria-required-parent no longer flags a native li, option, tr, td, th, thead, tbody or tfoot inside an ancestor whose children are presentational: an explicit role of button, checkbox, img, menuitemcheckbox, menuitemradio, meter, option, progressbar, radio, scrollbar, slider, switch or tab (WAI-ARIA 1.2 "Children Presentational: True"), or a native <progress> / <meter>
  • a focusable descendant (tabindex, any value, or contenteditable other than "false") keeps its semantics and is still evaluated
  • scope kept deliberately narrow, per the issue's "not a request to ignore every li inside any arbitrary parent":
    • only explicit roles (first token) grant the exception; implicit ones do not, because the role map treats <summary> as a button, but browsers keep its children exposed
    • separator is left out, since its children are presentational only when it is not focusable
    • explicit child roles (span[role=tab] under a progressbar) are still checked as before
  • documented the exception on the rule page and in the unreleased changelog

Closes #1640

Acceptance criteria

  • The issue's reproduction HTML reports exactly 1 element (the true orphan li), not 5
  • Implicit-role elements (li, option, tr, td, th, rowgroup) inside a presentational-children ancestor are not flagged
  • A genuine orphan li outside any list or presentational-children ancestor still fails
  • A plain ul > li still passes
  • Focusable descendants of a presentational-children ancestor keep their semantics and are still evaluated
  • Tests cover the progressbar case (packages/rules/tests/aria-required-parent-presentational-1640.test.ts; the rule had no dedicated test file), and the rule docs mention the exception

Verification

  • bun test ./packages/rules/tests/aria-required-parent-presentational-1640.test.ts — 19 pass, 0 fail
  • bun run scripts/test-suites.ts --run rules — 9,955 pass, 25 todo, 0 fail
  • bun run --cwd packages/rules typecheck
  • bun run lint, bun run format:check
  • bun run docs:check — all checks passed

Note: #1641 also adds a ### Fixed section under ## [Unreleased], so whichever lands second will need a one-line CHANGELOG merge; happy to rebase.

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Docs: docs/rules/a11y/aria-required-parent.mdx. Skill: none.

nc9 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 8a2aa0a

Verdict: no blocking findings, pending maintainer review. Thanks for the focused fix and the thorough tests.

Findings, most severe first:

  1. Low: isPresentationalDescendant in packages/rules/src/a11y/aria-required-parent.ts walks every ancestor, which matches WAI-ARIA 1.2 (all descendants are presentational, not just direct children), so <div role="progressbar"><div role="region"><li> is also skipped. This is correct, but no test pins it; one case would.
  2. Low: a native <progress> or <meter> that carries an unrelated explicit role (for example role="region") takes the explicit-role branch, so its tag name is not consulted and its fallback content is flagged. Arguably right, since the author overrode the role. No change needed unless you want it documented.
  3. Nit: the walk is O(depth) per candidate element, and only runs for elements in the second pass. Fine for realistic pages.
  4. Process: fix(rules): exclude hidden tables from table-duplicate-name #1641 also adds a ### Fixed section under ## [Unreleased] in CHANGELOG.md, so whichever lands second needs a one-line merge, as the author already noted.

Checks against the acceptance criteria of #1640: the repro reports one orphan li, focusable descendants (tabindex, contenteditable) are still evaluated, a genuine orphan li still fails, plain ul > li passes, explicit child roles are still checked, and the tests cover each case.

Conventions: rule docs updated, CHANGELOG [Unreleased] entry added, no new dependency, DCO sign-off present and the sign-off check is green. CI: every completed check is green or skipped; "CLI tests (rules, engine and the rest)" was still running when I reviewed, so confirm it finishes green.

nik

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Both low findings are addressed in 783ba8e7:

  1. Added a test pinning the nested case: <div role="progressbar"><div role="region"><li> passes, since WAI-ARIA 1.2 makes all descendants presentational.
  2. Added a test showing that <progress role="region"> / <meter role="region"> fallback content is still checked, and documented on the rule page that an explicit role decides when the author overrides the native one.

The focused file now has 21 passing tests, and docs:check passes. On the CHANGELOG overlap: I'll rebase whichever of #1641, #1642 and #1643 lands later.

nc9 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 783ba8e

Verdict: no blocking findings, pending maintainer review. Thanks for addressing the earlier notes quickly.

Changes since the last reviewed head (8a2aa0a), docs and tests only:

  1. Earlier finding 1 (nested descendants, no test): addressed. packages/rules/tests/aria-required-parent-presentational-1640.test.ts now pins <div role="progressbar"><div role="region"><li> as a pass.
  2. Earlier finding 2 (<progress>/<meter> with an unrelated explicit role): addressed. The rule page docs/rules/a11y/aria-required-parent.mdx now says the exception covers every descendant and that an explicit other role is judged by that role, and a test pins <progress role="region"> and <meter role="region"> as still flagged.
  3. Process, unchanged: fix(rules): exclude hidden tables from table-duplicate-name #1641 and fix(rules): report exposed and raw H1 counts separately in core/h1 #1643 also add a ### Fixed section under ## [Unreleased], so whichever lands later needs a one-line CHANGELOG merge.

Conventions: rule docs updated, CHANGELOG entry present, no new dependency, DCO sign-off present. CI on this head: all completed checks are green (the sign-off check, docs build, rules tests and golden tests included).

nik

nc9 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: ef5e6bb

Verdict: no blocking findings, pending maintainer review.

The only commit since the last reviewed head (783ba8e) is style(rules): format the #1640 test file with oxfmt. It touches only packages/rules/tests/aria-required-parent-presentational-1640.test.ts. I skimmed the diff for logic changes and found none, but a formatting commit like this rewrites every line, so it is worth one more glance at the test file if you want certainty. No source or docs changes, so the earlier review of the rule still stands.

Conventions unchanged: rule docs, CHANGELOG entry, no new dependency, DCO sign-off. CI: all 15 completed checks on this head are green, 1 skipped.

nik

@nc9
nc9 force-pushed the codex/aria-required-parent-presentational-1640 branch from ef5e6bb to a412404 Compare November 9, 2026 00:37
@nc9
nc9 merged commit 486cd13 into squirrelscan:main Nov 9, 2026
16 checks passed
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.

aria-required-parent reports implicit li inside presentational progressbar descendants

2 participants