Stage 2: fold geometry-neutral single-child wrappers by restating their consumed class and id on the child

Aperta
#7,505 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
css, php
Ambito
tooling

Direzione di ricerca

Start with the WrapperDecision stage in the php-transformer conversion layer and the existing wrapper dispositions, then read php-transformer/docs/wrapper-decisions.md. Use tools/import-loop/structure.php to measure single-child core/group counts on squarespace-bedford and sdnunca. Done means a new named fold reason that keeps every emitted CSS selector matching the same elements, with unit tests and no visual regressions in import-loop/corpus.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Part of #7471 (stage 2: retire wrapper heuristics one PR at a time, each A/B'd on the corpus). Stage 1 is done: every conversion-layer wrapper decision now goes through WrapperDecision (#7472, #7474, #7479, #7488, #7495, #7502).

Evidence: what the surviving single-child groups are

Trunk c35c3acf, real imports of the 8 corpus captures. For each core/group with exactly one block child, I recorded its attributes and the child's block name:

site single-child groups top shape
squarespace-bedford 497 of 750 groups class-only group > core/group: 159; same with anchor: 132; with anchor,metadata: 41
sdnunca (Wix) 225 of 369 class-only group > core/group: 50; with anchor: 37
base44-imb 214 of 600 colored group > core/image: 66; class-only group > core/group: 32

The class-only group > group wrappers on bedford are mostly layout scaffolding: sqs-col sqs-col-N span-N (64), row sqs-row (21), sqs-layout sqs-grid-N, sqs-block-content, pre-footer-inner, main-content. On sdnunca they are _backgroundLayer_* (27), _image*, builder-root, wix-presets-wrapper. These wrappers carry no style or layout attribute: they survive only because their class (sometimes their id) is consumed by emitted CSS.

An instrumented run logged every WrapperDisposition across the corpus. The largest refusals are presentation_attributes (wrapperRetention, 5,759) and the depth-budget preserves (native_group_tree_within_budget 9,127, single_wrapper_ancestry 8,848). #7420's measurement points the same way: wrappers there are refused because a consumed attribute or style lives on them, not because they paint or size anything.

Required: a restatement-backed fold for consumed-class single-child wrappers

A new, named WrapperDecision stage. For a wrapper with exactly one element child:

  1. Geometry and paint neutrality from evidence:
    • Use the captured box-tree or computed evidence that ADR 0006 / #7420 consume. The wrapper's border box equals its child's margin box at every captured viewport.
    • The wrapper paints nothing: no background, border, shadow, outline, opacity, transform, filter, clip, overflow clipping, or stacking context. It also creates no containing block or formatting context the child depends on.
    • With no evidence, preserve (today's behavior).
  2. Restate what the wrapper carries onto the child, then fold:
    • Its classes and its id/anchor move onto the child, only when the child has no id of its own.
    • Every emitted CSS rule whose selector depends on the moved class or id must still match exactly the same elements after the move. A selector where the token is the subject (.col) now matches the child. A compound that also names the child's own tokens (.col.x) is fine. A selector where the token sits on an ancestor of other matched elements (.col .block, .col > .x) must be rewritten so it matches both ways, for example .col .block, .col.block. Otherwise the wrapper is preserved.
    • Use the engine's existing selector projection machinery. No platform-specific class lists: the rule is generic over class and id consumption.
  3. Inherited text properties the wrapper declares (font, color, line-height and the like) go through the existing inherited-text restatement path. Declarations the child already wins over are dropped.
  4. The disposition is fold with a new named reason. Refusals name the failing condition, so the next slice can be read off a histogram.

Acceptance (A/B on the corpus; I verify by real import)

  • Single-child groups drop on squarespace-bedford and sdnunca (measured with the scoreboard's structure metrics, tools/import-loop/structure.php in static-site-importer).
  • No visual cell regresses on any of the 8 corpus sites (import-loop/corpus check).
  • Unit tests for each case:
    • a subject rule moved;
    • a descendant rule rewritten;
    • a wrapper preserved when a rule can't be preserved;
    • preserved without evidence;
    • an id moved, and preserved when the child has its own id.
  • Update php-transformer/docs/wrapper-decisions.md.
  • Use Refs #7471 and Refs #7420. State the before/after counts in the PR body if you measured them; otherwise say so.

Filed by Franklin (Claude Opus via Pi, Roadie).

Lingua principale
PHP
Stelle
31
Fork
7
Merge medio
3h 40m
PR unite (30g)
813

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Automattic/blocks-engine

Tutte le issue di Automattic/blocks-engine

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.