Refine text-wrapper collapse: ignore zero-reset box values and flex layout (#630)#685
Merged
Merged
Conversation
…ayout
The initial typography-only collapse still left real eyebrows as groups on
imported sites, because two signals wrongly counted as box-model geometry:
1. A universal reset (`* { margin: 0; padding: 0 }`) sets zero-valued padding
on every element, so every wrapper looked like it owned box chrome.
2. `display:inline-flex`/`gap` was treated as disqualifying even though a
childless text leaf has no flex items — its flex layout only aligns a
`::before` decoration, which the wrapper class still applies to a paragraph.
The collapse now disqualifies only real box chrome (padding/border/explicit
sizing) with non-zero values, via cssValueIsNonZero(), and drops flex layout
from the blocking set (real flex containers carry child elements and are
already excluded by the childElementCount === 0 guard). This makes
`<div class="label">The Shop</div>` under a zero reset collapse to a single
styled paragraph, resolving the ~21px eyebrow offset on imported artist-site
routes, while box-chrome wrappers (`.tag`, `.use-case-result`) stay groups.
Full php-transformer suite green: 248 parity fixtures, 77 block-style-support
tests (adds a universal-reset eyebrow regression), all contracts.
Refs #630.
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.
Summary
Follow-up to #684. That change collapsed typography-only text wrappers to styled paragraphs, but on real imported sites the eyebrow still round-tripped as a
core/groupbecause two signals wrongly counted as box-model geometry:* , *::before, *::after { margin: 0; padding: 0 }, which sets a zero-valuedpaddingon every element. The collapse gate treated any present padding as box chrome, so every wrapper looked disqualified.display:inline-flex/gapwas treated as disqualifying, but a childless text leaf has no flex items — its flex layout only aligns a::beforedecoration (e.g. an eyebrow's leading dash), which the wrapper class still applies to a paragraph.Fix
cssValueIsNonZero()helper (treats0,0px,0 0 0 0,none, empty as no geometry).display,gap) are dropped from the collapse-blocking set. Real flex containers carry child elements and are already excluded by the existingchildElementCount === 0guard (e.g..tier-pricewrapping a<span>stays a group).Verification
End-to-end through the SSI fixture matrix (WP 7.0.2,
3-artist-music): the merch eyebrow now compiles and renders as a single styled paragraph in the sandbox —<p class="label pl pl-d1 wp-block-paragraph">instead ofdiv.wp-block-group labelwrapping a default paragraph — and the/contact/route visual mismatch dropped from 13.42% to 11.52%.Full
php-transformersuite green: 248 parity fixtures, 77 block-style-support tests (adds a universal-reset eyebrow regression:29b/29c), all contracts.AI assistance disclosure
Drafted with Claude (Sonnet 4.5) via opencode, used to trace the in-sandbox compile path, isolate the universal-reset
padding:0false positive via DOM/declaration introspection, and implement the zero-value guard. Every line reviewed by Chris Huber.Refs #630.