Skip to content

fix(php-transformer): keep shared stylesheet classes and compound aliases in route class alignment - #6221

Merged
chubes4 merged 2 commits into
trunkfrom
fix/footer-hours-quicklinks-regression
Nov 16, 2026
Merged

chubes4 merged 2 commits into
trunkfrom
fix/footer-hours-quicklinks-regression

Conversation

@chubes4

@chubes4 chubes4 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Root cause

Culprit: #5970 (50b853d863f, "Share headers across linked atomic sheets…"). I bisected both symptoms separately and both landed on that commit:

  • php-transformer-v0.45.519 → v0.45.699, probing whether the hours <dl> was renamed by route alignment: first bad commit is 50b853d863f.
  • fix(php-transformer): project attribute-gated nested CSS rules #5815 (cadd3e699a6) → v0.45.699, probing whether a navigation-instance … :after{border-top-width:1px} rule was emitted: first bad commit is also 50b853d863f.

#5815 was not reverted. Its projection still works, but after #5970 it never gets to run on the list it was written for.

Before #5970, every stylesheet file counted as global, so classes named in a file were never route-aligned. #5970 started reading each linked file as the linking route's own sheet, which suits a builder that serves a per-route atomic sheet. It has a side effect on builders that link a shared runtime/widget file on many routes and one extra widget file on a single route (here the contact page): every class that extra file names "reads differently" on that route. Shared vocabulary classes then get renamed to route-class-<hash> across the whole chrome. That breaks two things:

  1. Nested rules lose their target. withCopies does not copy rules that are nested inside another rule. A vertical menu's attribute-gated separator rule (&[layout] .list>.item:after{border-top-width:1px}) is never copied for the renamed list class. The separators disappear and #5815's projection has nothing to project.
  2. Compound selectors lose both names. For a selector naming two aliased classes (.box .list dt{float:left;width:40%}), withCopies only produced copies that renamed one class each (.alias-box .list dt, .box .alias-list dt). Aligned chrome wears both aliases, so neither copy matches. A footer definition list lost its floats and widths and stacked into one centered column.

Fix (RouteStateProjector::withRouteAlignedChromeClasses)

Diff: 3 files, +125 / −6 (+30/−6 in src, the rest is two contract tests).

Tests

Two new neutral contract tests. Each fails on trunk and passes with this change:

  • tests/contract/route-aligned-chrome-class-shared-stylesheet.php: a shared runtime file with a nested, attribute-gated separator rule, plus a widget file linked by one route only. The menu list keeps its class and the shared file is left as written.
  • tests/contract/route-aligned-chrome-class-compound-selectors.php: two route-own sheets that read differently. The aligned footer <dl> still gets a .alias-box .alias-list dt/dd copy of its column rules.
Check trunk (cf5da45a956) this branch
php tests/run.php 1585 tests, 3 failed 1587 tests, 3 failed
php tests/parity/run.php 358 passed 358 passed
phpstan (changed files) — no errors

The same 3 tests fail on trunk and on this branch: artwork-slideshow, component-interactions, positioned-carousel-stage.

Evidence

I compiled a 37-route builder capture through ArtifactCompiler::compile (website files plus capture reports), materialized it in a disposable WordPress Playground, and measured with Playwright at 1440px. Columns are source / trunk / this branch.

Opening-hours list (7 rows):

source trunk branch
<dl> 315×200 315×252 315×186
rows where dt and dd share a line 7/7 0/7 7/7
dt (first row) x194 w126, float:left x194 w315, float:none x194 w126, float:left
dd (first row) x323 w186 stacked below dt, w315 x323 w186

Quick-links vertical nav (2 columns, 7 links):

source trunk branch
link box 181×50 179×48 179×48
item pitch 51 48 49
link padding 15px 0 15px 0 15px 0
li::after border-top 1px solid #d1d1d1 0 none 1px solid #d1d1d1
li flex direction column row column
column x positions 844 / 1049 845 / 1050 845 / 1050

The branch numbers are identical on /, /pricing/ and /contact/. Route-class aliases emitted for this capture: 38 distinct on trunk, 0 on this branch. Template parts are unchanged between trunk and this branch: 11 parts, the same set.

The remaining 2px gap on the nav link box (181×50 vs 179×48) already existed at #5815 and is not part of this change.

AI assistance: authored with Claude (Anthropic) via Claude Code subagent; a human-directed agent reproduced, fixed, and verified.

…ases in route class alignment

Route class alignment (#5970) began reading every linked stylesheet file as
the linking route's own sheet. A shared runtime or widget file linked by
several routes then made its classes read differently on any route that also
linked one more widget sheet, so shared vocabulary classes were renamed.
Two losses followed: nested rules in the shared file were not copied for the
alias, and a selector naming two aliased classes only gained copies that
renamed one of them, matching nothing.

A file linked by several chrome documents is now shared vocabulary, read like
an unlinked file. A selector naming several aliased classes gains a copy for
each set of them.
@chubes4

chubes4 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

I simplified the selector copies. A selector naming several renamed classes now gets the existing one-copy-per-class plus a single copy with every class renamed, because aligned chrome wears every alias at once. That replaces the power-set copies and their 4-class cap. Both new tests still fail on trunk and pass here. php tests/run.php gives 1587 tests with the same 3 Chrome failures as trunk; parity has 358 passing; phpstan is clean.

AI assistance: Claude (Anthropic) via Claude Code reviewed and simplified this under human direction.

@chubes4
chubes4 merged commit 2611fd7 into trunk Nov 16, 2026
14 checks passed
@chubes4
chubes4 deleted the fix/footer-hours-quicklinks-regression branch November 16, 2026 08:30
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