Repository navigation
Convert an image-only role="img" graphic to a named group of images - #5253
Merged
Merged
Conversation
An element with role="img" that holds only images is one named graphic, but it was classified as phrasing content. Beside a sibling text span the parent took the inline-RichText paragraph route, the role-bearing wrapper failed the inline image gate, and the whole parent became core/html. Inside a link tile the anchor took the same RichText route, fell back to core/html, and fallback reduction then rebuilt it as a core/button whose label held the images. Treat such a graphic as a flow child in the phrasing and link-wrapper checks, and lower it to a core/group of core/image blocks that carries the accessible name through the Group's ariaLabel support. Serialize the Group's aria-label as core's block support saves it. Fixes #5233.
chubes4
force-pushed
the
fix/issue-5233-blocks-engine
branch
from
November 9, 2026 17:42
b101559 to
f74a9c1
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
An element with
role="img"that holds only images is one named graphic (ARIA makes its children presentational), but the classifier treated it as phrasing content because it is a<span>.SourceElementClassifier::hasOnlyPhrasingChildren()accepted the parent, so it took the inline-RichText paragraph route.SourceDom::carriesOnlyRichTextInlineImages()rejects role-bearing wrappers, so the RichText fallback gate fired and the whole parent becamecore/html.ButtonLinkDispatcher::hasLinkWrapperChildren()saw only phrasing children, so the anchor went toparagraphHost()and hit the same gate, which producedcore/html. Fallback reduction then reparsed that island and rebuilt the anchor as acore/buttonwhose label held the images.Fix:
SourceDom::isImageOnlyNamedGraphic(), which matchesrole="img"with no text and only<img>descendants.InlineContentElementConverterto acore/groupofcore/imageblocks. The group carries the accessible name in the Group'sariaLabelattribute.BlockFactoryto save the Group'saria-label, the same way core's ariaLabel block support does.With this, the link tile goes through the existing link-wrapper group route, the same one used when the graphic is a
<div>.Before / after (reduced page
r1.html)<main><div class="image"><span class="mosaic" role="img" aria-label="Plates"><img src="a.png" alt=""><img src="b.png" alt=""></span><span>04</span></div></main>Before (Studio import, released engine):
After:
Link tile variant. Before, this was
core/buttons > core/button, and the button label contained the<span role="img">and its images. After:The empty
.overlayspan is dropped here, as it already is when the graphic is a<div>. That behaviour is existing link-wrapper behaviour and is unchanged by this PR.Tests
New
tests/unit/role-img-image-graphic-native-group.php, picked up bytests/run.phpdiscovery. It is one table with four cases: an unnamed graphic, a named single image, a named mosaic beside text, and a named mosaic in a link tile. Each case asserts:core/htmland nocore/buttoncore/imageper<img>ariaLabeland the savedaria-labelFails on trunk for all four cases (src stashed) and passes with the fix.
composer testran locally on the rebased branch: 1313 tests, and only the two Chrome-only contracts failed (artwork-slideshow.phpandcomponent-interactions.php); Chrome is not available locally.composer lintandcomposer test:lintare clean.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).