svgdotjs/svg.js

Moving a text with an inside title element fails

Shiuyin opened this issue · 4 comments

If you have a text element with a title element inside, moving that text element will fail with:

Uncaught TypeError: Cannot read properties of undefined (reading 'newLined') at Dom.<anonymous> (Text.js:56:22) at Text.each (Dom.js:84:13) at Text.rebuild (Text.js:50:12) at Text.attr (attr.js:79:12) at Text.ax (textable.js:68:15)

DOM:
<text x="200" y="294">row10<title>row10</title></text>

Reason: .ax() is leading to a rebuild of the text element. Rebuilding the text element will also go through all children. When reaching the title child element, there is no this.dom.

If your text elements are not multiline, you can use the following workaround:

textElement.rebuild(false)

This will prevent rebuilding (which seems to be only necessary for multiline support in text elements) and therefore prevent the NP.

I attempted to fix it here: 8fa0873

Please test and report back if it works for you.
Sorry for the long wait!

@Fuzzyma Thank you for your work. It works as intended now. When can we get a new build in order to profit from these fixes?

I am sorry, I somehow forgot to publish all the fixes I made. I just released it:
https://github.com/svgdotjs/svg.js/releases/tag/3.2.1