fix(php-transformer): hoist viewport-partitioned chrome into shared parts - #2243
Merged
Merged
Conversation
…arts When desktop and mobile landmarks match across routes but differ from each other, keep one template-bound header or footer and hide the inactive variant with the existing document-variant class instead of leaving both copies page-owned.
Viewport classes on layout-shell wrappers were invisible to shell identity, so a matching desktop and mobile pair stayed page-owned. Ignore menu selection and generated block hashes when comparing that chrome.
… not cover A trailing shell candidate can sit beside the footer landmark. Strip the viewport landmarks anyway, and ignore in-page URL fragments when comparing header identity so the front page joins the shared part.
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.
Problem
Captures with desktop and mobile document variants shipped no shared header or footer template parts. #2241 stopped the double-rendered chrome by keeping those landmarks page-owned, so every route carried its own copy and templates were only
<!-- wp:post-content /-->.Root cause
ShellExtraction::retainsResponsiveVariantLandmarkrefused a shared shell whenever another responsive document still contained that landmark. Identical chrome was already removed from every variant, so that path still hoisted. Divergent viewport chrome was not: the clustered copy was extracted, the other variant's landmark remained, and the guard discarded the part. Variant scope classes also live on layout-shellwrappers, which the landmark walk did not read, so the two copies never compared as one viewport partition.Fix
When the remaining landmarks are a consistent per-viewport set, hoist one
header/footerpart that wraps each variant in its existing document-variant class (data-liberation-*-document/site-document-variant-*) and strip those landmarks from page content. The template part itself is adiv, so only the active variant's landmark is visible. Menu selection state, generated block hashes, and in-page URL fragments are ignored for identity so current-route differences do not split the cluster. A route whose chrome does not match stays on an exclusion template.Regression test
php tests/contract/shared-shell-plan.phpFails before:
Passes after:
Also passed:
wordpress-site-plan,viewport-hidden-document-variants,entry-point-transform-parity,shared-chrome-stylesheet-scope.Verification
Fresh import with Static Site Importer
origin/main@db49134bpackaged againstc8d1d2cfd.parts/header.htmlandparts/footer.htmlexist.front-page,page,index, andsearchreference both.Visible landmarks (1 header / 1 footer at 390, 768, and 1440) and document height versus the loop-3 baseline:
Home, shop, services, and blog
post_contentcontain no header or footer landmarks. Mobile menu at 390 still opens (Home, Blog, Shop, Events, Contact).Residual: cart-page mobile chrome is structurally different, so its header stays page-owned (one visible header, exclusion template). Shop at 390 is 30px taller because a page-background layer starts below the hoisted header and keeps a 900px box. The post route already showed two visible headers and footers in the baseline; heights there are unchanged.
Fixes #1945
AI disclosure: implemented by xAI Grok 4.7 via OpenCode (
opencode run), orchestrated and reviewed by Claude (Anthropic).