Repository navigation
Carry the source div marker on description-list rows - #5251
Merged
Merged
Conversation
Author type selectors such as `.intro dl div` are rewritten to the source div tag marker, but the description-list block rendered its row wrappers as plain divs, so the projected rule matched nothing. Persist the marker in each row wrapper's className attribute, the same source identity other converted elements carry, so saved markup stays editor-valid and the rewritten selector matches. Fixes #5235.
chubes4
force-pushed
the
fix/issue-5235-blocks-engine
branch
from
November 9, 2026 18:06
17792b0 to
dc7b924
Compare
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.
What and why
The theme stylesheet rewrites the author rule
.intro dl div{…}to.intro dl :where(.blocks-engine-source-div-<hash>-0):not(be-t-0){…}. This happens because the sourcedivtag has a projection marker: converted divs becomewp-block-group, paragraphs and similar blocks, and those blocks carry the marker class. The generated<theme>/description-listblock was the exception. It rendered its row wrappers as plain<div>s, so the rewritten rule matched nothing and the rows lost their borders and padding.Fix (option a):
DescriptionListBlockGenerator::wrapper()now merges the session's source tag marker for the row element (tagMarker('div')) into the wrapper'sclassName. The marker lives in the block'sgroups[].wrapper.classNameattribute. The JSsave()already renders that attribute (viamarkupAttributes), so saved markup stays editor-valid. Other converted elements keep source identity the same way:SourceBlockAttributeProjector::sourceProjectionClassName,LayoutShellLowering,TableAttributesBuilderandSourceDom::safeFallbackHtmlall add the tag marker to the rendered element.I picked this over option (b), keeping
divas a type selector when it sits underdl. Option (a) leaves the selector projector unchanged. Everydivtype selector is still rewritten the same way, includingdl + div,dl ~ divand.x dl .y div. So no un-rewrittendivselector can reach the wrapper divs WordPress adds, and the fix applies only to the rows this block actually renders. The marker is added only when the author CSS allocated one, so lists on pages withoutdivtype selectors render unchanged.Evidence (reduced page
dlist.html)Theme CSS (unchanged):
.intro dl :where(.blocks-engine-source-div-d5880a8e6d01-0):not(be-t-0){border-top:1px solid #ccc;padding:1.25rem 0}Before (Studio import, released engine):
After (this branch):
Tests
tests/unit/description-list-source-tag-selector.php(added totest:unit). It runs a single table-driven case throughHtmlTransformer, takes the emitted author CSS selectors and checks them withCssSelectorMatcheragainst the emitted block markup:.intro dl divis rewritten to the marker and matches both rendered rows, but not the following sibling.dl + divis still rewritten (no baredivtype selector). It matches the following sibling and neither row.wp_block_validity.descendant row selector: row match is true for .intro dl :where(.blocks-engine-source-div-…):not(be-t-0) on <div><dt>Color story</dt>…. Passes with the fix.description-list-block,functional-source-tag-identity,author-selector-semantics,richtext-type-selector-preservation,css-selector-matcher,list-element-converters,htmlcompilation-generator-builders,html-result-composer,companion-plugin-namespace,tests/contract/run.php,tests/contract/wordpress-site-plan.php, and the parity suite (351 fixtures).AI disclosure: Claude (claude-fable-5-1) running in Pi wrote the fix, the test and this PR as a subagent of the Data Liberation import-loop orchestrator. Finalized outside Homeboy with Chris's authorization because Homeboy cook finalization is blocked (homeboy#16292).