Skip to content

fix(rules): a CSS-nesting rule that may hide an element reads unknown, with Chromium rows #1013 - #1022

Closed
nc9 wants to merge 2 commits into
fix/1015-style-rule-capfrom
fix/1013-css-nesting
Closed

nc9 wants to merge 2 commits into
fix/1015-style-rule-capfrom
fix/1013-css-nesting

Conversation

@nc9

@nc9 nc9 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Repro and the nesting shapes from #1014 by @dbdefault.

Stacked on #1020 (base branch fix/1015-style-rule-cap; GitHub retargets it to main when #1020 merges). The reader code change for this issue is #1020's: a rule nested inside a style rule made the reader give up, and giving up now reads every element as unknown, never shown. This PR adds what #1013 asks for on top: the Chromium evidence, the invariant test and the docs.

  • packages/rules/tests/fixtures/static-hidden-chromium.json: 13 nesting: rows, each rendered in headless Chromium at 1024px (the repro, @supports, & with a descendant, implicit &, & alone, a hiding outer rule beside a nested one, a nested sibling combinator, nested visibility, nesting inside an at-rule, and the four shown cases: nested rule that sets neither property, &:hover, a nested rule reaching another element, a false nested @media).
  • packages/rules/tests/static-hidden.test.ts: a new invariant, never shown where Chromium hides a nesting: element (all 9 hidden rows; they fail without fix(rules): a page past the style reader's limits reads elements as unknown, not shown #1015 #1020), plus a nested rule that sets neither property keeps shown and an unnested rule keeps hidden. The existing "never hidden where Chromium shows" invariant covers the 4 shown rows.
  • Docs: the "What squirrel can see" section of the 7 a11y pages that carry it names CSS nesting explicitly; CHANGELOG bullet.

Tests: static-hidden 371 pass (11 fail with #1020's change reverted); tsgo clean in packages/rules; tangly check --strict clean. Rows were generated with headless Chromium (script kept in ops scratch, not committed).

Tradeoff, same as #1020: the reader does not narrow nested rules to the elements they reach, so a page with a nested display/visibility rule reads all its elements as unconfirmed.

Agent skill (squirrelscan/skills): not needed.

Closes #1013

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff. It only changes docs, the Chromium fixture, one test file and the changelog. The reader change is in #1020, so I didn't review it here. I haven't run the tests.

No blocking issues. Findings:

  • (low) docs/rules/a11y/*.mdx: the new sentence says a nested display/visibility rule leaves "the elements it could reach" unconfirmed. The PR description says the reader doesn't narrow nested rules to the elements they reach, so every element on the page reads as unconfirmed. Saying so ("every element on the page") would stop users expecting the effect to be scoped. The same sentence is pasted into 7 pages, so it could drift. If the repo has a shared snippet or generation mechanism for these pages, use it.
  • (low) docs/rules/a11y/*.mdx: the limits sentence still lists "a rule nested inside another" as a limit that triggers unknown for everything. The new sentence then says a nested rule that sets neither property changes nothing. The two read as contradictory. Either drop nesting from the limits list or say it applies only when the nested rule sets display or visibility. This depends on fix(rules): a page past the style reader's limits reads elements as unknown, not shown #1015 #1020's behavior, so please check it against that PR.
  • (nit) static-hidden.test.ts: the new invariant asserts only the hidden rows, and the shown rows rely on the existing "never hidden" test. The two named tests cover only one shown case each. Asserting the exact expected verdict for the shown rows (&:hover, a nested rule reaching another element, a false @media) would pin the intended "unknown, not shown" tradeoff. Right now those rows would pass whether the verdict is shown or unknown.
  • (nit) The fixture rows were generated by a script kept outside the repo. Committing it, or noting the Chromium version in the fixture, would make the rows reproducible.
  • (nit) This PR is stacked on fix(rules): a page past the style reader's limits reads elements as unknown, not shown #1015 #1020. The tests fail without that change, so merge in order.

@nc9
nc9 force-pushed the fix/1013-css-nesting branch from f72d006 to 34b324e Compare October 22, 2026 09:10
@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Reviewed the diff (CHANGELOG, 7 a11y docs pages, the new Chromium fixture rows, and the new tests in static-hidden.test.ts). I did not run the tests. This PR adds no reader code; that is #1020's.

  • (low) packages/rules/tests/static-hidden.test.ts: the new "never shown" loop passes vacuously for the 4 shown rows, because the if has no assertion for them. The PR relies on the existing "never hidden where Chromium shows" invariant to cover them. That works, but a comment saying so would help, or assert not.toBe("hidden") for those rows in the loop. Also confirm the existing invariant really iterates all CHROMIUM rows with no name filter.
  • (low) The fixture rows were generated by a script that is "kept in ops scratch, not committed", so nobody else can regenerate them. A short note in the fixture or test header on how the rows were measured (Chromium version, 1024px) would help when the rows need refreshing.
  • (nit) The tests do not check that the reader is still unconfirmed rather than shown for the hidden rows. not.toBe("shown") is the right invariant, so this is fine as is.

Otherwise the docs wording and CHANGELOG entry are consistent, and the tradeoff is documented. No blocking issues.

@claude

claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review of #1022 (tests, fixture and docs on top of #1020). I only read the diff. I did not run the tests or check the Chromium rows.

  • (low) packages/rules/tests/static-hidden.test.ts: the new loop registers a test for all 13 nesting: rows, but the 4 rows where Chromium shows the element assert nothing (if (row.chromium === "hidden")). They pass vacuously and count towards the test total. The existing "never hidden where Chromium shows" invariant covers them, as the PR description says. Filtering to hidden rows, or asserting not.toBe("hidden") for shown rows here, would make the count honest and the test self-contained.
  • (nit) The "neither property" and "unnested rule" tests cover one HTML shape each. A nested @media that sets neither property would also pin the "changes nothing" claim in the docs.
  • (nit) The same paragraph is pasted into 7 doc pages. If these pages are generated or share a partial, edit it in one place. Otherwise they will drift.
  • (nit) The fixture rows were generated by a script that isn't committed. Adding a short note in the fixture or in the test header about how to regenerate them (Chromium version, viewport) would help future maintainers.

The invariant is the right one (never shown where Chromium hides), and the docs and CHANGELOG state the tradeoff clearly. I found nothing that should block the merge.

nc9 added a commit that referenced this pull request Oct 22, 2026
… as unknown, never shown (#1015) (#1020)

Every give-up path of readPageStyles (rule cap, over-size block, long selector, entry cap, non-ASCII space, nested rule) now answers unknown for every element; nested rules are covered (#1013 evidence follows in #1022). Over-cap pages get their naming checks unconfirmed instead of failing; narrowing is tracked in #1027.

Closes #1015.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 deleted the branch fix/1015-style-rule-cap October 22, 2026 09:26
@nc9 nc9 closed this Oct 22, 2026
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.

1 participant