Skip to content

Scope interaction-state refusals to elements the state rule can match (#3042) - #3047

Merged
chubes4 merged 2 commits into
trunkfrom
fix/issue-3042-blocks-engine
Oct 19, 2026
Merged

chubes4 merged 2 commits into
trunkfrom
fix/issue-3042-blocks-engine

Conversation

@chubes4

@chubes4 chubes4 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Attribute-only state rules such as `[type="checkbox"]:indeterminate:hover` no longer stop non-matching elements (navy sections) from binding to palette presets. Rules that can match, like `section:hover`, `a:hover` on links and `:hover`, still refuse. Fixes the candidate, which ignored class tokens (so `.text-rose:hover` blocked every element and broke the tailwind binding tests) and read attributes from descendants.

What changed

  • stateMatches keeps the pre-candidate rule: a subject with no tokens matches anything, otherwise it must share a token with the element. On top of that, a rule whose required attributes (presence or exact value) are missing from the element's own start tag is skipped; class and style are never used to skip a rule.
  • Attribute selectors are parsed by a new subjectAttributes() (ignoring functional pseudo-classes and other operators) and stored only on state subjects, so the !important and [style*=] rule handling is unchanged.
  • tagTokens reads attributes only when the caller passes a real start tag (bindBlock) and that tag parses completely; the generated <nav>/<mark> tags are treated as unknown, so attribute rules are assumed to match them.
  • Regression tests: navy sections with the A class-less :hover/:focus rule (Tailwind preflight checkbox) refuses every background preset binding #3042 checkbox rule bind to the palette slug; a state rule the section's own start tag satisfies refuses, a near-miss data-type attribute does not; section:hover, :hover and a mixed selector list refuse; a:hover does not block a section.

How to test

  1. Run cd php-transformer && composer install --no-interaction --prefer-dist --no-progress && composer test:canonical; expect passes as recorded by Cook's deterministic gate.

Compatibility

No public API change. Binding results change only where an attribute state rule was over-blocking. Everything else matches the code before the candidate. composer test:canonical passes; phpstan and phpcs are clean on PresetBinding.php.

Evidence

  • Verified command cd php-transformer && composer install --no-interaction --prefer-dist --no-progress && composer test:canonical: status=succeeded; candidate commit ee8d0b914a490ef1bbf5dbd94a622ce34554c0a3, tree d4203b9a0bbe11a2ee43abb3b6226dc7cdc99ade, fingerprint 231721507153e3998479a26215e42b3e622a610c8a4785e77c08a661cbdfe918; durable gate gate-1
  • Base unchanged since verification: trunk remains at 354dfdf.
  • CI expected: Homeboy CI after push
  • Candidate adoption provenance: the candidate was promoted from the recorded Cook task execution.
  • Cook deterministic verification: 1 gate(s) completed green.
  • Durable run execution: Succeeded
  • Reviewer-resolvable evidence from source_refs[0]: A class-less :hover/:focus rule (Tailwind preflight checkbox) refuses every background preset binding #3042
  • Task objective: Finish A class-less :hover/:focus rule (Tailwind preflight checkbox) refuses every background preset binding #3042 in this worktree. A candidate diff exists in php-transformer/src/WordPressSitePlan/PresetBinding.php (stateMatches with tag/attr subject tokens). Review it for correctness: element attribute tokens must come from the element's own start tag only (the current regex over $html may read descendants' attributes), and a state rule with no class tokens must still block elements it can match (e.g. `button:hover`, `a:hover`, `:hover`). Add a regression test using the issue's reduced reproduction (navy sections + `[type="checkbox"]:indeterminate:hover{background-color:currentcolor}`) asserting the navy sections bind to the palette slug, plus a case where a matching tag state rule still refuses. Keep the change minimal.
  • Verified candidate scope: 2 changed file(s): php-transformer/src/WordPressSitePlan/PresetBinding.php, php-transformer/tests/unit/design-system-usage-derivation.php.
  • Verified finalization base: trunk at 354dfdf
  • deterministic gate passed: sh -c cd php-transformer && composer install --no-interaction --prefer-dist --no-progress && composer test:canonical (Passed)

AI assistance

@chubes4
chubes4 merged commit f304358 into trunk Oct 19, 2026
15 checks passed
@chubes4
chubes4 deleted the fix/issue-3042-blocks-engine branch October 19, 2026 11:38
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