Fix nested svg transform being applied twice#1084
Open
StefanoD wants to merge 1 commit into
Open
Conversation
A nested `svg` element was wrapped in a redundant group in `convert_element`, while `convert_svg` already creates its own group, so its `transform` (and other group properties) were applied twice. Route nested `svg` directly to `convert_svg` and return early, like `use` does. Fixes linebender#1066 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 #1066.
Problem
A
transformon a nested<svg>element was applied twice. The same happens toother group properties (e.g.
opacity). For example, a rect under<svg transform="translate(50,50)">was rendered at (100,100) instead of (50,50).Cause
In
convert_element, a nested<svg>was wrapped in aconvert_group(whichreads the element's
transform), and thenconvert_svgcreated its own group aswell — so the transform was applied in both.
<use>does not have this problembecause it is routed to its handler and returns before the
convert_groupwrapper.Fix
Route a nested
<svg>directly toconvert_svgand return early, exactly like<use>. The outermost<svg>(no parent element) is unaffected.Testing
nested_svg_transform_applied_once(fails onmainwithtranslate(20,40), passes with the fix astranslate(10,20)).usvgtest suite and all 1724resvgrender tests pass.Generated by Claude
Note: I accidentally closed the original PR (#1067) by deleting my fork, which auto-closed it. This reopens the same change — the branch and commits are unchanged.