fix(svg): drop SVG icon layers with no drawing segment#193
Merged
Conversation
A visible-painted SVG element that lowers to a moveto-only or moveto+close path (d="M12 12", a zero-length arc, the stray subpaths exporters emit) draws no ink, yet a lone moveto threw at SvgIcon#node(...) building an empty PathNode and a moveto+close rendered blank. SvgIconReader.emitLayer now drops a layer whose geometry has no LineTo/CubicTo (new package-private SvgPath.hasDrawingSegment()), so one degenerate element no longer fails the whole icon. An icon of only such elements still fails loudly via the existing 'no drawable geometry' guard. Adds two SvgIconTest cases. Full suite green (1380).
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.
Why
A visible-painted SVG element that lowers to a moveto-only or moveto+close path —
d="M12 12", a zero-length arc, the stray subpaths real exporters emit — draws no ink, yet ondevelop:SvgIcon#node(...)(it builds an emptyPathNode), failing the whole icon;One degenerate element from a messy exporter should not break the rest of the icon.
What
SvgPathgains a package-privatehasDrawingSegment()(true when aLineTo/CubicTois present).SvgIconReader.emitLayerdrops a layer whose geometry has no drawing segment, so a degenerate element contributes nothing instead of breaking the icon.layers.isEmpty()→ "no drawable geometry" guard.Tests
SvgIconTest: a stray moveto-only + moveto+close alongside a real box → only the box survives andnode(...)builds (it threw before); a degenerate-only icon fails with "no drawable geometry". Full suite 1380 green.Lane: canonical
document.svg(@beta reader robustness).