I have a script that (I think) needs to use surroundContents to wrap the selection area. Doing so allows me to append something, and then reassign the range as the selection.
I believe I've narrowed the problem down to a misuse of getRangeAt, but I'm not quite sure how to correct it.
Here's the brief bit of code:
function getRangeObject(selectionObject) {
// Moz
if (selectionObject.getRangeAt) {
return selectionObject.getRangeAt(0);
}
And here's line 89 where it throws an error at me:
rangeObject.surroundContents(newNode);
And of course, here's the error:
Error: uncaught exception: [Exception... "The boundary-points of a range does not meet specific requirements." code: "1" nsresult: "0x805c0001 (NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR)" location: "http://www.latentmotion.com/insertNode/index26.html Line: 89"]
If it's helpful to see the whole thing, you can view the script (so far) here: http://www.latentmotion.com/insertNode/index26.html
And the text selection helper that I was going off of was quirksmode - which doesn't detail the use of multiple ranges, located here.
Thanks in advance for your help.