mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
properly return NotFoundError on removeRange
This commit is contained in:
@@ -143,7 +143,7 @@
|
||||
testing.expectEqual(range2, sel.getRangeAt(0));
|
||||
|
||||
// Removing non-existent range does nothing
|
||||
sel.removeRange(range1);
|
||||
testing.expectError('NotFoundError', () => { sel.removeRange(range1); });
|
||||
testing.expectEqual(1, sel.rangeCount);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -99,13 +99,15 @@ pub fn addRange(self: *Selection, range: *Range, page: *Page) !void {
|
||||
return try self._ranges.append(page.arena, range);
|
||||
}
|
||||
|
||||
pub fn removeRange(self: *Selection, range: *Range) void {
|
||||
pub fn removeRange(self: *Selection, range: *Range) !void {
|
||||
for (self._ranges.items, 0..) |r, i| {
|
||||
if (r == range) {
|
||||
_ = self._ranges.orderedRemove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return error.NotFound;
|
||||
}
|
||||
|
||||
fn removeAllRangesInner(self: *Selection, reset_direction: bool) void {
|
||||
@@ -392,7 +394,7 @@ pub const JsApi = struct {
|
||||
pub const getRangeAt = bridge.function(Selection.getRangeAt, .{ .dom_exception = true });
|
||||
pub const modify = bridge.function(Selection.modify, .{});
|
||||
pub const removeAllRanges = bridge.function(Selection.removeAllRanges, .{});
|
||||
pub const removeRange = bridge.function(Selection.removeRange, .{});
|
||||
pub const removeRange = bridge.function(Selection.removeRange, .{ .dom_exception = true });
|
||||
pub const selectAllChildren = bridge.function(Selection.selectAllChildren, .{});
|
||||
pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true });
|
||||
pub const setPosition = bridge.function(Selection.setPosition, .{});
|
||||
|
||||
Reference in New Issue
Block a user