Repository navigation
fix SVG preserveAspectRatio="none" handling for <symbol>/<use> - #9261
Conversation
davepagurek
left a comment
There was a problem hiding this comment.
This is looking good! Do you think we could add some visual tests so it's easier to verify the output?
I also was looking at https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/preserveAspectRatio to see what other options there are than none. Do you have a sense of what it might take to fully cover this attribute and whether that's worth adding?
Thanks, Dave! I appreciate the feedback. I'll look into the existing visual testing setup and add appropriate visual coverage for this case. I'll also review the other preserveAspectRatio options and assess the scope of supporting them, so we can decide whether they belong in this PR or would be better handled separately. I'll follow up with my findings! |
Thanks for the feedback, Dave! I've pushed a visual regression test comparing the default I also looked into the other Supporting the other alignment options appears relatively straightforward by parsing the alignment values and adjusting the translation offsets. Supporting I think that broader support would be worthwhile, but my preference would be to keep this PR focused on |
Sounds good! Feel free to open another issue if you're interested. |
davepagurek
left a comment
There was a problem hiding this comment.
Looks good to me too, thanks!
|
@all-contributors please add @Danyccsf for bug, code |
|
I've put up a pull request to add @Danyccsf! 🎉 |
Hi Dave, |
Resolves #9257
Description
This PR fixes SVG import handling of
preserveAspectRatio="none"when a<use>element references a<symbol>with aviewBox.Previously, the SVG importer always applied uniform scaling using the default
xMidYMid meetbehavior, even when the referenced symbol explicitly specifiedpreserveAspectRatio="none". This caused symbols to retain their proportions instead of stretching to the dimensions specified by<use>.Changes
preserveAspectRatio="none"when a<use>element references a<symbol>with aviewBox.viewBoxorigins when applying the transform.xMidYMid meetbehavior and leave the fallback behavior for other values unchanged.viewBoxorigins.meetbehavior withnone, including an SVG fixture and reference screenshot.Testing
Screenshots of the change
Added a visual regression screenshot under:
test/unit/visual/screenshots/svg/SVG Import - defs and use/symbol preserveAspectRatio none/000.pngThe screenshot compares two SVG symbols:
xMidYMid meetbehavior, preserving the symbol's proportions.preserveAspectRatio="none", stretching the symbol horizontally to fill its viewport.Scope and follow-up considerations
nonevalue for referenced SVG symbols.sliceare not implemented by this change. Supporting them would require additional alignment parsing and transformation logic, with viewport clipping considerations forslice.PR Checklist
npm run lintpasses