const text1 = document.createElement("text");
const text2 = document.createElement("text");
const range = new Range();
range.setStart(text1, 0);
const sourceRange = new Range();
sourceRange.setStart(text2, 0);
const position = range.compareBoundaryPoints(
Range.START_TO_START,
sourceRange,
); // shoud throw an error, since the text1 and text2 are in the different tree
console.log(position); // -1
Expected behaviorRange.compareBoundaryPoints should throw error if the compared ranges' boundary-point's are in different tree.
Describe the bug
Range.compareBoundaryPoints
should throw error instead of returning -1.To Reproduce
Repo to reproduce: compare-boundary-points-error
Expected behavior
Range.compareBoundaryPoints
should throw error if the compared ranges' boundary-point's are in different tree.Documentation: Range.compareBoundaryPoints 2nd point:
Device:
Additional context The issue was tested on vitest, and it worked well on jsdom, only caused error with happy-dom.