From 934693924ef1e47eb43eb3a40d7f3a15bd762102 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 13 Feb 2026 15:06:17 +0800 Subject: [PATCH 1/2] Fix Range.compareBoundaryPoint START_TO_END and END_TO_START had their logic swapped. This fixes the remaining 862 failing cases in dom/ranges/Range-compareBoundaryPoints.html --- src/browser/webapi/Range.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/browser/webapi/Range.zig b/src/browser/webapi/Range.zig index 1d1f6442..f88e210a 100644 --- a/src/browser/webapi/Range.zig +++ b/src/browser/webapi/Range.zig @@ -150,10 +150,10 @@ pub fn compareBoundaryPoints(self: *const Range, how_raw: i32, source_range: *co source_range._proto._start_offset, ), 1 => AbstractRange.compareBoundaryPoints( // START_TO_END - self._proto._start_container, - self._proto._start_offset, - source_range._proto._end_container, - source_range._proto._end_offset, + self._proto._end_container, + self._proto._end_offset, + source_range._proto._start_container, + source_range._proto._start_offset, ), 2 => AbstractRange.compareBoundaryPoints( // END_TO_END self._proto._end_container, @@ -162,10 +162,10 @@ pub fn compareBoundaryPoints(self: *const Range, how_raw: i32, source_range: *co source_range._proto._end_offset, ), 3 => AbstractRange.compareBoundaryPoints( // END_TO_START - self._proto._end_container, - self._proto._end_offset, - source_range._proto._start_container, - source_range._proto._start_offset, + self._proto._start_container, + self._proto._start_offset, + source_range._proto._end_container, + source_range._proto._end_offset, ), else => unreachable, }; From e3b5437f612cbde39bee5544e7e8ecf66eb5cb05 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 13 Feb 2026 16:28:53 +0800 Subject: [PATCH 2/2] fix test to match swapped (correct) implementation --- src/browser/tests/range.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/browser/tests/range.html b/src/browser/tests/range.html index c1fb901f..d62ffe72 100644 --- a/src/browser/tests/range.html +++ b/src/browser/tests/range.html @@ -743,11 +743,11 @@ // range1 start is before range2 start testing.expectEqual(-1, range1.compareBoundaryPoints(Range.START_TO_START, range2)); - // range1 start is before range2 end - testing.expectEqual(-1, range1.compareBoundaryPoints(Range.START_TO_END, range2)); - // range1 end is after range2 start - testing.expectEqual(1, range1.compareBoundaryPoints(Range.END_TO_START, range2)); + testing.expectEqual(1, range1.compareBoundaryPoints(Range.START_TO_END, range2)); + + // range1 start is before range2 end + testing.expectEqual(-1, range1.compareBoundaryPoints(Range.END_TO_START, range2)); // range1 end is before range2 end testing.expectEqual(-1, range1.compareBoundaryPoints(Range.END_TO_END, range2)); @@ -767,11 +767,11 @@ testing.expectEqual(0, range.compareBoundaryPoints(Range.START_TO_START, range)); testing.expectEqual(0, range.compareBoundaryPoints(Range.END_TO_END, range)); - // Start is before end - testing.expectEqual(-1, range.compareBoundaryPoints(Range.START_TO_END, range)); - // End is after start - testing.expectEqual(1, range.compareBoundaryPoints(Range.END_TO_START, range)); + testing.expectEqual(1, range.compareBoundaryPoints(Range.START_TO_END, range)); + + // Start is before end + testing.expectEqual(-1, range.compareBoundaryPoints(Range.END_TO_START, range)); }