Skip to content

fix(rules): a page past the style reader's limits reads elements as unknown, not shown #1015 - #1020

Merged
nc9 merged 2 commits into
mainfrom
fix/1015-style-rule-cap
Oct 22, 2026
Merged

nc9 merged 2 commits into
mainfrom
fix/1015-style-rule-cap

Conversation

@nc9

@nc9 nc9 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

readPageStyles returned an empty result when it gave up at a limit, so an element the dropped rules hid read as shown (an unnamed control inside it failed) while the same page one rule under the cap read hidden. An incomplete read is now unknown for every element, never shown.

  • packages/rules/src/shared/page-styles.ts: the give-up result carries one rule that may apply to any element (display and visibility) and no step budget, so the cascade answers unknown. No new work: the result is a shared constant, and the over-cap page is read no slower than before (timed in the test).
  • This covers every give-up path of the reader, not only the rule count: over-size <style>, over-long selector, entry cap, and a rule nested inside another (the last one is also a11y style reader: a nested CSS rule that hides an element reads as shown, not unknown #1013's shape; that PR adds the Chromium rows).
  • Existing static-hidden bound tests asserted shown after the cap; they now assert unknown.
  • Docs: the "What squirrel can see" section of the 7 a11y rule pages that carry it; CHANGELOG bullet.

Tests: page-styles-rule-cap-1015.test.ts (4; 3 fail without the change): 4,900 / 5,000 / 5,100 flat hiding rules give hidden / unknown / unknown, a descendant and an unrelated element are unknown over the cap, an unnamed button in the hidden element is button-name-unconfirmed (not a fail) over the cap, and the timing check. Also pass: static-hidden (343), the width-media, show-only, where-is, attr-operators, vendor-display, naming-rules-hidden, select-name-hidden, button-name-hidden, aria-hidden-focus and hidden-text suites. tsgo clean in packages/rules; tangly check --strict clean.

Tradeoff: a page past a limit now has all its naming checks unconfirmed instead of failing, because the reader cannot say which elements the dropped rules reach.

Agent skill (squirrelscan/skills): not needed.

Closes #1015

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff and the code that reads INCOMPLETE (elementKeys always includes *, and the null-subject rule falls through to unknown). The change is sound: an over-limit page now reads unknown instead of shown. Inline !important declarations still outrank it. The docs and CHANGELOG match the behavior. I didn't run the tests.

  • (nit) packages/rules/tests/page-styles-rule-cap-1015.test.ts: the timing test (time(5_100) < time(4_900) * 3 + 50) compares wall-clock time and could be flaky on a loaded CI runner. A generous absolute bound, as in static-hidden.test.ts, would be steadier.
  • (nit) The same style-limits paragraph is copied into seven rule docs. A shared snippet would keep them from drifting, if the docs tooling supports one.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff for #1020. I found no blocking problems.

  • The incomplete() change is sound. Every element now reads "unknown" instead of "shown" when the style reader gives up. It returns a fresh object per call, so the spent step budget doesn't leak between pages. The "*" key is one of the keys elementKeys looks up, so the catch-all entry is always consulted.

  • The test coverage is good. It covers the rule cap, the entry cap, the U+00A0 case, a descendant element, the button-name check, and a fresh state per page.

  • I didn't run the tests or check CI status.

  • (low) packages/rules/tests/page-styles-rule-cap-1015.test.ts: the timing test (time(5_100) < time(4_900) * 3 + 50) compares wall-clock time, so it can flake on a loaded CI runner. Consider a looser bound, or assert on the step budget instead.

  • (nit) The U+00A0 case now marks the whole page unknown, where before it only dropped that block. This is conservative and matches the changelog. A short note in the rule docs that this can raise -unconfirmed warnings on pages with stray non-ASCII spaces in <style> would help users.

@nc9
nc9 merged commit f4152b3 into main Oct 22, 2026
15 checks passed
@nc9
nc9 deleted the fix/1015-style-rule-cap branch October 22, 2026 09:26
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 page over the 5000-rule cap reads hidden elements as shown instead of unknown

1 participant