Materialize SVG artwork that carries rendering hints - #1565
Merged
Conversation
SVG rendering hints (shape-rendering, text-rendering, image-rendering, color-rendering, color-interpolation, paint-order) are presentation-only: they tune rasterization and carry no scripting or external reference. They were missing from the passive-attribute allowlist, so any artwork setting one was disqualified from the native image path and preserved as a core/html island instead. Add them to the allowlist so such artwork materializes as an editable core/image backed by a portable SVG asset.
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.
Fixes #1243.
Problem
SVG rendering hints —
shape-rendering,text-rendering,image-rendering,color-rendering,color-interpolation,paint-order— were missing from the passive-attribute allowlist inSvgMaterializer::isPassiveSvgMarkup().These are presentation-only attributes. They tune rasterization quality and carry no scripting, no external references, and no document dependency. But because they were unlisted,
isPassiveSvgElement()rejected the element,isNativeImageCompatibleSvg()returned false, and otherwise-passive artwork fell through to the "honest floor" at the end ofinlineSvgBlockFromElement()and was preserved as acore/htmlisland.One unlisted presentation attribute was enough to disqualify an entire graphic from the native image path.
Fix
Add the six rendering-hint attributes to
$allowedAttributes. Nothing else changes: the safety gates forscript, event handlers,javascript:URLs, externalhref,currentColor,var()and page-CSS-animated descendants are untouched.Measured
Imported https://www.biajmsb.ca/ (Wix, 14 routes) through Studio → Data Liberation → Static Site Importer → Blocks Engine.
The site logo carries
shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality"and appears twice per page (desktop + mobile responsive variants), so it produced twocore/htmlislands on every route.core_html_blocksfailure_reasonsunsupported_html_fallback,core_html_blockunsupported_html_fallbackcore_html_blockis no longer a failure reason for this site. The two remainingunsupported_fallbacksare the contact form and are unrelated to this change.Isolated reproduction of the same logo markup:
Tests
tests/unit/filtered-svg-materialization.phpgains two assertions covering artwork that sets all six hints: it must materialize ascore/imagewith nocore/html, and the hints must survive into the materialized SVG asset so rasterization intent is preserved.Both assertions fail on
trunkand pass with this change.Verification
filtered-svg-materialization— 16 passedsvg-element-converter— 13 passedsvg-materialized-paint-cascade— 20 passedcore-html-fallback-reduction— 9 assertionsrich-text-svg-transaction— passedcomposer test:canonical— no failurescomposer test:parity— 297 fixtures passedOut of scope
The materialized logo now emits as
core/imagebut still resolves to0×0in the header, so it remains visually absent on this site. That geometry collapse is a separate defect on the image-carrier sizing path and is not addressed here; this PR is scoped to the fallback classification only.AI assistance
Investigated, root-caused, implemented, tested and verified end to end by Claude Sonnet 4.5 running in Claude Code, including the before/after re-import measurement. Chris Huber directed the work and is responsible for the submitted change.