Repository navigation
Conversation
…once per nested element
a11y/aria-text ran querySelectorAll("*") per role="text" element, and
a11y/aria-hidden-focus did so per aria-hidden container plus an ancestor walk
per descendant: quadratic and cubic in nesting depth (5,000 nested role="text":
35 s; 1,000 nested aria-hidden: 56 s). aria-text now counts each element's
focusable descendants from a running counter between entering and leaving it;
aria-hidden-focus takes each container's findings from the run of reportable
elements between its entry and exit positions in one pre-order walk, with the
same order and multiplicity. After: 23 ms and 150 ms at 5,000 levels.
The previous implementations are kept as a test oracle; a parity test compares
both on 600 seeded random pages, and a budget test pins 5,000 levels under 1 s.
Benchmark record and harness in benchmarks/.
Fixes squirrelscan/repo#3066.
Signed-off-by: Nik Cubrilovic <[email protected]>
- aria-hidden-focus walks every top-level element, not only documentElement (a page with no <html> tag, a warning printed ahead of the doctype, content after </html>); a self-focusable aria-hidden honeypot keeps its honeypot label - neither walk enters a <template>, as the old document-wide queries did not; a role="text" template counts its own content as before - the parity generator adds those document shapes, templates, aria-hidden controls and SVG links (both previous versions fail it); 30 s test timeout Refs squirrelscan/repo#3066. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of the I read the rule diffs and traced the logic. I did not run the tests or the benchmarks. No blocking issues found.
Confirm |
a11y/aria-textranquerySelectorAll("*")once for everyrole="text"element, anda11y/aria-hidden-focusdid the same for everyaria-hiddencontainer, also walking up the ancestors of each descendant. A page that nests those elements made the first rule quadratic and the second cubic in the nesting depth. At 1,000 nestedaria-hiddencontainers, one page took 56 s. Both rules now walk the page once. squirrelscan/repo#3066.Changes
aria-textcounts each element's focusable descendants as the difference of a running counter between entering and leaving the element.aria-hidden-focusdoes one pre-order walk seeded fromdoc.children, so it also covers a page with no<html>element and top-level elements after</html>. Each container's findings come from the run of reportable elements between its entry and exit positions. Template content is skipped, as the old document-wide queries never entered it. A honeypot input that is itselfaria-hiddenkeeps its label.static-hidden.ts: the unconfirmed-hidden message moves into a shared helper.Results
a11y/aria-texta11y/aria-texta11y/aria-hidden-focusa11y/aria-hidden-focusMethod and the 20,000-level rows are in
benchmarks/2026-10-a11y-nesting.md(harnessbenchmarks/harness/a11y-nesting.ts). The parser has its own depth cost, tracked in squirrelscan/repo#3356.Tests
packages/rules/tests/a11y-nesting-parity-3066.test.tsruns copies of the previous implementations (tests/fixtures/reference-3066/) as an oracle on 600 seeded random pages plus fixed edge cases: no<html>, content after</html>, two<html>elements, templates (also inside SVG), SVG, noscript, tables and honeypot inputs. Both previous rule versions fail the generator, and the new ones pass. An independent mutation run killed 19 of 20 mutants, and the leaf added in the last commit kills the 20th.Docs and skill
No docs or skill change: findings are the same, only faster.
Gates
packages/rulesscripts/test-suites.ts --check