Capture node ids read as landmark ids drop a route from the shared footer

Aperta Adatta ai principianti
#7,881 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Inizia individuando ArtifactPageCompiler::membersSharingLandmarkStyles() e verifica come estrae gli ID dei landmark dalle sorgenti dei fogli di stile. Usa la riproduzione ridotta nell’issue per verificare che vengano considerati solo gli attributi id effettivi, quindi conferma che il compilatore produca una parte footer per tutte e tre le route.

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

Descrizione

Summary

ArtifactPageCompiler::membersSharingLandmarkStyles() decides which stylesheets are a shared shell's "landmark stylesheets" by looking for the landmark's ids in each style source. The ids come from /\bid="([^"]+)"/. That pattern also matches data-blocks-engine-node-id="n253", because \b sits between - and id. Capture node ids are route-local evidence, so they are not selectors. Short values like n12 also turn up inside minified CSS (--Button1234-color contains n12).

When two routes' node ids happen to occur in a stylesheet every route loads, that stylesheet counts as a landmark stylesheet loaded by the majority. A route whose node ids don't occur in it is then treated as "missing" that stylesheet and dropped from the source-shared group, even though it loads the same <link>. That route's footer is then compared on its page-compiled identity, where route-local placement rules (for example a route-only min-height:0px) keep it apart. The route keeps its footer in post content, and the template the route uses has no footer part.

Seen on

A 3-route import (home + 2 legal pages) of a classic site builder export. Scorecard shared_shell fails with templates_missing_shell:["front-page"] and page_shell_landmarks: {"website/index.html":["footer"]}. Instrumented run: the footer source group held all 3 routes (same source identity), but membersSharingLandmarkStyles reported shared=2 and the home route as missing one capture stylesheet. Only the legal pages' footer node ids (n253, n367) occur in that stylesheet, inside custom-property names like --Button2534820817-…. The home route's node ids (n6xx) don't.

Ruled out: data-id/attribute order and prop: value vs prop:value style spacing differ between routes in the live source too (frozen live reference docs show both). ChromeIdentity/RenderEquivalentMarkup already canonicalize them, so they play no part here.

Reduced reproduction

$page = fn (string $title, int $node, string $placement): string => '<!doctype html><html><head><link rel="stylesheet" href="/assets/site.css"><style>.site-footer{padding:24px;background:#f4f4f4}body :where(.site-footer){' . $placement . '}</style></head><body>'
    . '<header><p class="brand">Brand</p><nav><a href="/">Home</a><a href="/about/">About</a><a href="/terms/">Terms</a></nav></header>'
    . '<main><h1>' . $title . '</h1></main>'
    . '<footer id="site-footer" class="site-footer" data-blocks-engine-node-id="n' . $node . '"><p data-blocks-engine-node-id="n' . ($node + 1) . '">&copy; 2035 by Example.</p><a class="button" href="/terms/" data-blocks-engine-node-id="n' . ($node + 2) . '">Terms</a></footer></body></html>';
$files = array(
    'assets/site.css' => '.button{--Button1234-color:#123456;color:var(--Button1234-color)}',
    'index.html' => $page('Welcome', 40, 'min-height:0px;position:relative'),
    'about/index.html' => $page('About', 12, 'margin-top:0%;position:relative'),
    'terms/index.html' => $page('Terms', 12, 'margin-bottom:0%;position:relative'),
);
$plan = (new ArtifactCompiler())->compile(array('entrypoint' => 'index.html', 'files' => $files))->toArray()['source_reports']['wordpress_site_plan'];

On trunk at 3da2edc724c: two footer parts (footer, footer-0eb547304658), and the home footer stays in post content. Changing the legal pages' node ids from n12 to n50 (so they no longer occur in site.css) makes one footer part serve every route. Node ids alone decide the outcome.

Expected

Only real id attributes name a landmark for this check. Then one footer part serves all three routes.

Loop signature: cdd79cd22c8f

Lingua principale
PHP
Stelle
31
Fork
7
Merge medio
7h 58m
PR unite (30g)
820

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.