Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Make the rendered element tree match the source tree, and gate it

Open
#2,890 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
8/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
ci-cd, frontend

Research direction

This is a design proposal, so there is no single file to edit yet. Start by reading the linked issues #1454, #1483 and #1904, then the merged fixes listed in the table, to see how each divergence was repaired. The first useful contribution is the measurement the issue asks for: classifying root causes on other imported sites. Done means a decision on each core block's structure and an agreed scope for the CI topology check.

Written by the indexing model from the issue text.

Description

Problem

Imported author CSS is written against the source page's element tree. When the rendered tree differs from it, by an added, removed or wrapped element, author selectors stop matching where the author intended. Today each such difference is found as visual drift, traced by hand, and repaired with a selector rewrite or a compensating engine rule.

The nostar2.com parity loop (front end and editor) produced 17 merged fixes. In 12 of them the root cause was a difference between the source element tree and the rendered one:

Divergence Fixes
Synthetic figure around a source image #2791, #2807, #2867
Synthetic or kept-empty paragraphs #2802, #2803, #2868
Wrapper links, neutral mark carriers, comment seams #2813, #2848, #2871
Engine editor layer and core's editor transport wrapper #2865, #2869, #2866

The other 5 had different causes: srcset selection (#2763), SVG currentColor (#2816), inline SVG geometry (#2817), embed height (#2819) and separator border (#2799).

Earlier work handled parts of this class one case at a time: #1454 (editor inner-blocks wrappers in CSS-owned layouts) and #1483 (editor presentation as a chain of symptom patches). Nothing currently states or checks the invariant itself.

Proposal

  1. Invariant. Every source element renders as exactly one element with the same tag and the same parent/child/sibling relationships, on the front end and in the editor canvas. Engine-added elements are either removed or declared as transparent to author CSS (for example display:contents with no box-forming styles).
  2. Gate. Add a topology check to CI over a corpus of real captures. It records each source element, the matching front-end element and the matching editor element, then diffs the three trees: added, removed and re-parented elements, plus changed sibling indexes for :nth-*/+/~ selectors. Every difference is either declared (with its reason) or a failure.
  3. Remove compensation. Once a divergence is gone or declared, delete the selector-rewriting and engine-support rules that existed only to cover it.

Expected result

  • This class of parity bug fails in CI before an import, instead of surfacing as drift on a live site.
  • Editor parity follows from the same contract as the front end, with no separate editor patch layer.
  • Fewer selector rewrites and engine support rules.

Measurement before committing

  • Classify the root causes of parity issues on other imported sites. One site (12 of 17) is not enough to justify an architecture change.
  • List the places where core blocks force structure, for example core/image → figure and RichText's padding and placeholders. For each, decide between a generated block that keeps the source tag (and accept the cost to editability) and a declared, CSS-transparent divergence.
  • Note: the wrapper count is mostly source structure, not engine additions (see #1904; every wrapper carries a blocks-engine-source-div-* identity). This proposal targets parity, not nesting depth.

Found and reduced with Claude (Anthropic) in the Pi coding agent during the nostar2.com import parity loop.

Dominant language
PHP
Stars
22
Forks
2
Avg merge
8h 22m
Merged PRs (30d)
659

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/blocks-engine

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.