SurroundContents in a range spanning multiple tags (problem getRangeAt?)

I have a script that (I think) should use surroundContents to wrap the selection area. This allows me to add something and then reassign the range as a selection.

I believe that I narrowed down the problem to the wrong use of getRangeAt, but I'm not quite sure how to fix it.

Here's a short bit of code:

        function getRangeObject(selectionObject) {
        // Moz
        if (selectionObject.getRangeAt) {
            return selectionObject.getRangeAt(0);
        }

And here is line 89, where it causes me an error:

rangeObject.surroundContents(newNode);

And of course, here is the error:

: : [... " ." : "1" nsresult: "0x805c0001 (NS_ERROR_DOM_RANGE_BAD_BOUNDARYPOINTS_ERR)" : " http://www.latentmotion.com/insertNode/index26.html: 89" ]

, script (): http://www.latentmotion.com/insertNode/index26.html

, , quirksmode, , .

.

+3
1

, . DOM Range , , surroundContents Range.

+1

Source: https://habr.com/ru/post/1720954/


All Articles