Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving a text with an inside title element fails #1304

Closed
Shiuyin opened this issue Jun 28, 2023 · 4 comments
Closed

Moving a text with an inside title element fails #1304

Shiuyin opened this issue Jun 28, 2023 · 4 comments

Comments

@Shiuyin
Copy link

Shiuyin commented Jun 28, 2023

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.

@Shiuyin
Copy link
Author

Shiuyin commented Jun 29, 2023

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.

@Fuzzyma
Copy link
Member

Fuzzyma commented Sep 2, 2023

I attempted to fix it here: 8fa0873

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

@Fuzzyma Fuzzyma closed this as completed Sep 3, 2023
@Shiuyin
Copy link
Author

Shiuyin commented Mar 4, 2024

@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?

@Fuzzyma
Copy link
Member

Fuzzyma commented Jun 18, 2024

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

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

No branches or pull requests

2 participants