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

Abierto
#7,505 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
css, php
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
PHP
Estrellas
31
Forks
7
Merge medio
3 h 40 min
PR fusionados (30 d)
813

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Automattic/blocks-engine

Todos los issues de Automattic/blocks-engine

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.