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));
|
testing.expectEqual(range2, sel.getRangeAt(0));
|
||||||
|
|
||||||
// Removing non-existent range does nothing
|
// Removing non-existent range does nothing
|
||||||
sel.removeRange(range1);
|
testing.expectError('NotFoundError', () => { sel.removeRange(range1); });
|
||||||
testing.expectEqual(1, sel.rangeCount);
|
testing.expectEqual(1, sel.rangeCount);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -99,13 +99,15 @@ pub fn addRange(self: *Selection, range: *Range, page: *Page) !void {
|
|||||||
return try self._ranges.append(page.arena, range);
|
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| {
|
for (self._ranges.items, 0..) |r, i| {
|
||||||
if (r == range) {
|
if (r == range) {
|
||||||
_ = self._ranges.orderedRemove(i);
|
_ = self._ranges.orderedRemove(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return error.NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn removeAllRangesInner(self: *Selection, reset_direction: bool) void {
|
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 getRangeAt = bridge.function(Selection.getRangeAt, .{ .dom_exception = true });
|
||||||
pub const modify = bridge.function(Selection.modify, .{});
|
pub const modify = bridge.function(Selection.modify, .{});
|
||||||
pub const removeAllRanges = bridge.function(Selection.removeAllRanges, .{});
|
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 selectAllChildren = bridge.function(Selection.selectAllChildren, .{});
|
||||||
pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true });
|
pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true });
|
||||||
pub const setPosition = bridge.function(Selection.setPosition, .{});
|
pub const setPosition = bridge.function(Selection.setPosition, .{});
|
||||||
|
|||||||
Reference in New Issue
Block a user