SVG: usando getComputedTextLength para quebrar o texto

Estou tentando quebrar o texto criando uma sequência de texto e usandogetComputedTextLength para descobrir quando o texto ultrapassa a largura permitida. No entanto, não consigo encontrar uma maneira simples de criar incrementalmente o texto que funcionará comgetComputedTextLength.

A ideia geral é:

  str = svgDocument.createTextNode(myText[word]); // first word on new line
  word++;
  obj = text.cloneNode(true);                     // new text element for this line
  obj.appendChild(str);
  svgDocument.documentElement.appendChild(obj);   // reqd for getComputedTextLength?
  for( ; word < myText.length; word++) {
     next_width = obj.getComputedTextLength();    // get current line width
     if(next_width >= extent)
        break;
     str += " ";                                  // add next word to the line
     str += myText[word];
     ...
  }

Alguém pode me dizer como fazer isso funcionar? Presumivelmentestr é copiado em vez de referenciado emobj, mas também tentei colocarobj.removeChild(str) eobj.appendChild(str) no loop, mas oappendChild trava. Eu também tentei várias combinações de movimento nodocumentElement.appendChild e removendoobj e anexando-o novamente, e assim por diant

questionAnswers(2)

yourAnswerToTheQuestion