Repository navigation
fix(php-transformer): keep shared stylesheet classes and compound aliases in route class alignment - #6221
Merged
Conversation
…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.
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. AI assistance: Claude (Anthropic) via Claude Code reviewed and simplified this under human direction. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 is50b853d863f.cadd3e699a6) →v0.45.699, probing whether anavigation-instance … :after{border-top-width:1px}rule was emitted: first bad commit is also50b853d863f.#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:withCopiesdoes 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..box .list dt{float:left;width:40%}),withCopiesonly 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)route-aligned-chrome-class-declarationsstill passes.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/ddcopy of its column rules.cf5da45a956)php tests/run.phpphp tests/parity/run.phpThe 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):
<dl>float:leftfloat:nonefloat:leftQuick-links vertical nav (2 columns, 7 links):
15px 015px 015px 0li::afterborder-top#d1d1d1#d1d1d1liflex directionThe 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.