Repository navigation
perf(rules): a11y table rules and link-in-text-block walk the page once - #1136
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 26, 2026 02:44
|
Reviewed the source changes in
No blocking issues found. |
… nested table is its own table a11y/th-has-data-cells, td-headers-attr and table-headers read each table's rows and cells with table.querySelectorAll, which also returns those of every nested table: a nested table's cells were judged as the outer table's, and nested tables made the rules quadratic or worse (200 levels: 1.7 s). One walk now assigns each row and cell to its nearest table. link-in-text-block counted a link once per enclosing text block; it now counts each link once. squirrelscan/repo#3355 Signed-off-by: Nik Cubrilovic <[email protected]>
… checks, item text for the shown ten table-headers keeps counting the headers of nested tables (a table wrapping a data table is a layout table, as axe reads it), now from one walk. th-has-data-cells reads each row's and column's td once per table and starts each free-column search at the previous cell. Item text is read only for the ten items shown. Tests: table-headers parity on nested tables, a row inside a cell, 20,000-level budgets, and a check that no rule queries a subtree. squirrelscan/repo#3355 Signed-off-by: Nik Cubrilovic <[email protected]>
…ans and grid slots colspan="Infinity" (or 1e999) made the grid fill loop run until the process ran out of memory, from a page of about 60 bytes. A span that is not a finite number of at least 1 now counts as 1, a span past the HTML limits (1,000 columns, 65,534 rows) as the limit, and a table's grid stops at 1,000,000 slots. Tests for those spans, junk and fractional spans in the parity generator, and wide-row time budgets. squirrelscan/repo#3355 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
perf/3355-a11y-nested-tables
branch
from
October 26, 2026 04:14
d77a4bc to
6f12cd2
Compare
|
Review of the nested-table and text-block rewrite. I read the diff and did not run the tests. CI was still pending when I looked. The approach is sound. The shared
I found nothing critical or high-severity. Untrusted-input handling is good: the walk is iterative and the grid is bounded. |
nc9
added a commit
that referenced
this pull request
Oct 26, 2026
The squash of #1136 kept all three drafts of its entry; the last one, which names the span caps, stays. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
added a commit
that referenced
this pull request
Oct 26, 2026
The squash of #1136 kept all three drafts of its entry; the last one, which names the span caps, stays. Signed-off-by: Nik Cubrilovic <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four a11y rules scanned a subtree once per matched element, so nested markup multiplied the work (squirrelscan/repo#3355).
a11y/th-has-data-cells,a11y/td-headers-attr,a11y/table-headers) read each table's rows and cells withtable.querySelectorAll, which also returns those of every nested table.th-has-data-cellsit was also a correctness bug: a nested table's cells were judged as the outer table's.a11y/link-in-text-blocktook each text block's links, so a link in nested blocks was counted and reported once per enclosing block.Changes
shared/own-table-cells.tsdoes one walk of the page. Each row goes to its nearest table and each cell to its nearest row and table, as in the HTML table model.th-has-data-cellsbuilds each table's grid from that table's own rows and cells.td-headers-attrchecks each cell against the header cells of its own table, once.table-headersreports exactly as before. A table counts the headers of the tables nested in it, so a layout table wrapping a data table still passes, as axe reads it. It now gets that from one walk, propagating from nested tables up to their parents.link-in-text-blockmakes one walk, counting each link once, in document order.colspan="Infinity"(or1e999) made theth-has-data-cellsgrid fill loop run until the process ran out of memory, from a page of about 60 bytes. A span that is not a finite number of at least 1 now counts as 1, a span past the HTML limits (1,000 columns, 65,534 rows) as the limit, and a table's grid stops at 1,000,000 slots (judged on the cells placed before it). Finite spans up to the limits read as before.What changes in what users see:
th-has-data-cells, an outer header no longer gets data cells from a nested table. A row nested inside a cell (<th>B<div><tr>, which a browser closes the cell for) is now a row of its own.td-headers-attr, a badheadersreference inside a nested table is reported once, and a cell may reference only its own table's headers.link-in-text-block, a link in nested blocks is counted once.th-has-data-cells,td-headers-attrandlink-in-text-blocksay so.Results
Before and after were measured minutes apart at the same load.
a11y/th-has-data-cellsa11y/th-has-data-cellsa11y/td-headers-attra11y/table-headersa11y/link-in-text-blockMethod and the 20,000-level rows are in
benchmarks/2026-10-a11y-nested-tables.md. The harness isbenchmarks/harness/a11y-nested-tables.ts, and--beforeruns the previous rules. Parsing now grows faster than the rules do (squirrelscan/repo#3356). Cutting a row span at the end of its row group, as browsers do, is left to squirrelscan/repo#3383.Tests
The tests are in
packages/rules/tests/a11y-nested-tables-3355.test.ts. The previous implementations are kept as oracles intests/fixtures/reference-3355/; the link oracle has a one-linecountedset added.Parity with the previous implementations, each on 600 seeded random pages:
thead/tbody, caption, presentation roles, cross-tableheaders, cells with no row, a cell in a wrapper, and atd[headers]outside any table.table-headersgives identical results on pages of nested tables.link-in-text-blockgives identical results on pages of nested blocks, counting each link once.Nested verdicts: one test per rule, and one for a row inside a cell. Each shows both the old and the new result.
Cost:
Spans:
Infinity,1e999,-Infinity,NaN, junk, 0, negative and 0.5 read as 1; 1.5 reads as before.1.5,2.7,0,-1,abc,2px,2,1e1) and an uppercaseROWSPAN.querySelectorAllon an element, while a spy counts the old rules' calls per table and per block.Mutations caught:
Two independent review rounds (one fuzzing 4,000 seeds against the oracles) found nothing blocking; their findings are fixed here.
Other suites, all passing: the existing aria suites, item-cap, template-verdict, rule-verdict-scope, and the audit-engine golden baseline (518 pages, findings unchanged).
Docs and skill
The rule docs and the CHANGELOG are updated. No skill change.
Gates
packages/rulesscripts/test-suites.ts --checkmake validateindocs/