Skip to content

fix(Vectorizer): handle nested SVG in getRelativeTransformation()#3176

Merged
Geliogabalus merged 2 commits intoclientIO:masterfrom
kumilingus:fix/get-transform-to-element
Feb 13, 2026
Merged

fix(Vectorizer): handle nested SVG in getRelativeTransformation()#3176
Geliogabalus merged 2 commits intoclientIO:masterfrom
kumilingus:fix/get-transform-to-element

Conversation

@kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Feb 12, 2026

Problem

getRelativeTransformation() returned null for elements that span a nested <svg> boundary. This is because it compared the immediate ownerSVGElement of each node, which differs when one element is inside a nested <svg>:

<svg id="root">                        <!-- ownerSVGElement: null -->
  <g id="A" transform="translate(10,20)">  <!-- ownerSVGElement: #root -->
    <g>
      <svg id="nested" x="30" y="40">     <!-- ownerSVGElement: #root -->
        <g transform="translate(5,5)">     <!-- ownerSVGElement: #nested  ← different! -->
          <rect id="B" />                  <!-- ownerSVGElement: #nested  ← different! -->
        </g>
      </svg>
    </g>
  </g>
</svg>

Calling V(A).getTransformToElement(B) would return null because A.ownerSVGElement (#root) !== B.ownerSVGElement (#nested), even though both elements live in the same document.

Fix

  • Added getRootSVG() helper that walks the ownerSVGElement chain up to the root <svg>, so both A and B resolve to #root
  • getRootSVG() returns null for detached non-SVG elements, and getRelativeTransformation() handles this gracefully
  • Added regression test asserting expected matrix translation values across a nested <svg> boundary

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Vectorizer’s relative transform calculation across nested <svg> boundaries by comparing root SVG containers rather than immediate ownerSVGElement, and adds a regression test to cover the scenario.

Changes:

  • Add getRootSVG() helper and use it in getRelativeTransformation() to support nested SVG hierarchies.
  • Add QUnit test validating getTransformToElement() behavior across a nested <svg>.
  • Update external SVG images example (highlighter options) and add Volta toolchain pins.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/joint-core/src/V/transform.mjs Adjusts root-SVG comparison logic via getRootSVG() to avoid returning null across nested SVG boundaries.
packages/joint-core/test/vectorizer/vectorizer.js Adds regression test for nested SVG transformation behavior.
examples/external-svg-images-js/src/main.js Changes example highlighter configuration (nonScalingStroke).
examples/external-svg-images-js/package.json Adds Volta toolchain pinning for the example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ped in extra SVG document

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kumilingus kumilingus force-pushed the fix/get-transform-to-element branch from f33f8d9 to e886d85 Compare February 13, 2026 10:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Geliogabalus Geliogabalus merged commit 5adf3c2 into clientIO:master Feb 13, 2026
9 checks passed
kumilingus added a commit to kumilingus/joint that referenced this pull request Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants