Technocrat
Technocrat

Reputation: 99

Failed to execute 'getStartPositionOfChar' on 'SVGTextContentElement'

What is the reason of the following exception?

DOMException: Failed to execute 'getStartPositionOfChar' on 'SVGTextContentElement': The charnum provided (0) is greater than or equal to the maximum bound (0).

Actually, I'm trying to integrate https://github.com/nlplab/brat with my own created backend. It uses svg with jquery.svg.min.js and jquery.svgdom.min.js. But I am stuck at this exception. The exeption is raised on text element of svg while making the call as

text.getStartPositionOfChar(firstChar).x;

where text is as

<text x="0" y="0">Some Text</text>

and firstChar=0.

Upvotes: 1

Views: 912

Answers (2)

bendecko
bendecko

Reputation: 2793

Using the latest git branch didn't work for me (although it might fix other things)!

I think it is a timing issue as sometimes the re-render worked, other times failed with the above error.

I added a small timeout value to the function (on line 3141) and it seems to have fixed it, at the cost of a small delay in render.

enter image description here

Upvotes: 0

Amadan
Amadan

Reputation: 198496

I believe that bug is fixed in the master branch, but not on the packaged version 1.3. Try to replace your brat with one directly cloned from GitHub (git clone https://github.com/nlplab/brat.git).

Upvotes: 0

Related Questions