Skip to content

fix(rules): :where()/:is() beside plain parts narrow an a11y style rule's subject #951 - #958

Merged
nc9 merged 1 commit into
mainfrom
fix/951-where-is-compound
Oct 20, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/951-where-is-compound

Conversation

@nc9

@nc9 nc9 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What

A :where(), :is(), :has() or :nth-child() beside a tag, class, id or attribute test now only narrows the rule. The a11y <style> reader (shared/page-styles.ts) keeps those plain parts as the rule's subject instead of treating the rule as reaching any element. A bare :where(.a) still reaches every element.

Why

Tailwind v4's preflight [hidden]:where(:not([hidden="until-found"])) { display: none !important } can only match elements with hidden, but it made every unnamed control on the page -unconfirmed (warn) instead of a fail.

Also: a hex escape ended by CRLF is now read as one whitespace (found by the codex pass: it would otherwise have turned into a false pass with the narrowed subject).

Elements the rule can reach (hidden) stay unconfirmed as before, never a failure.

Tests

New page-styles-where-is-951.test.ts (repro, hidden controls, bare :where(), narrowed class rule, CRLF escape). Existing static-hidden, button-name, a11y-name-rules, aria-hidden-focus and hidden-text tests pass.

Closes #951

skills: no change

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewed the diff. I found no problems.

  • The change is sound. :where(), :is(), :has() and :nth-child() only narrow a compound, so keeping the plain parts beside them as the subject is correct. A bare functional pseudo-class leaves an empty compound, which still means any element, so the previous conservative behaviour is kept there.
  • The CRLF handling in readIdent follows the CSS spec, where a hex escape ends at one whitespace and CRLF counts as one.
  • Test coverage is good. It covers the parser cases, the Tailwind preflight end to end through button-name, and the narrowed and bare cases.
  • (nit) The "bare :where()" test accepts either subject === null or an empty compound. Pinning it to the empty compound would make it stricter.

I only read the diff. I did not run the tests.

@nc9
nc9 force-pushed the fix/951-where-is-compound branch from 51f9303 to 8c6de0e Compare October 20, 2026 15:52
@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Reviewed the diff for #958. I found no issues, so there are no tagged findings. I only read the diff and did not run the tests.

  • Dropping anySubject is sound. The plain parts beside :is(), :where(), :has() and :nth-child() must still match, so keeping them as the subject can only narrow the rule. A bare functional pseudo-class leaves an empty compound, which still means any element. The new test covers that case.
  • The CRLF change to hex-escape parsing is correct per the CSS spec, and it has a regression test.
  • The tests cover the Tailwind preflight repro, hidden elements staying unconfirmed rather than failing, bare :where(), and a narrowed class rule.
  • The CHANGELOG entry is clear.

@nc9
nc9 force-pushed the fix/951-where-is-compound branch from 8c6de0e to c3da5ba Compare October 20, 2026 16:43
@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown

Review of #958: I found no blocking issues.

  • The fix is correct. :where(), :is(), :has() and :nth-*() can only narrow a compound, so keeping the plain parts beside them as the subject is sound. A bare functional pseudo-class still yields an empty compound, which matches any element, so the conservative behaviour is preserved.

  • The anySubject removal is clean, and :not() behaviour is unchanged.

  • The CRLF handling in readIdent matches the CSS spec: a CR LF pair counts as a single whitespace ending a hex escape.

  • Tests cover the parser shape, the end-to-end a11y/button-name cases (visible, hidden and hidden-ancestor buttons) and the CRLF case. The changelog entry is present.

  • (nit) page-styles-where-is-951.test.ts: the bare-pseudo test accepts either subject === null or an empty compound. Since the parser now never returns null for these selectors, asserting the empty compound exactly would make the test stricter.

  • (nit) The CRLF change is unrelated to a11y: a :where()/:is() compound such as Tailwind v4's [hidden]:where(...) preflight makes every control unconfirmed #951 and is not mentioned in the changelog. That's fine, but a short note would help.

@nc9
nc9 merged commit c50c98b into main Oct 20, 2026
15 checks passed
@nc9
nc9 deleted the fix/951-where-is-compound branch October 20, 2026 16:57
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: a :where()/:is() compound such as Tailwind v4's [hidden]:where(...) preflight makes every control unconfirmed

1 participant