mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
apply similar fix to selectAllChildren
This commit is contained in:
@@ -313,12 +313,17 @@ pub fn modify(
|
||||
}
|
||||
|
||||
pub fn selectAllChildren(self: *Selection, parent: *Node, page: *Page) !void {
|
||||
if (parent._type == .document_type) return error.InvalidNodeTypeError;
|
||||
if (parent._type == .document_type) return error.InvalidNodeType;
|
||||
|
||||
// If the node is not contained in the document, do not change the selection
|
||||
if (!page.document.asNode().contains(parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const range = try Range.init(page);
|
||||
try range.setStart(parent, 0);
|
||||
|
||||
const child_count = parent.getLength();
|
||||
const child_count = parent.getChildrenCount();
|
||||
try range.setEnd(parent, @intCast(child_count));
|
||||
|
||||
self._range = range;
|
||||
@@ -433,7 +438,7 @@ pub const JsApi = struct {
|
||||
pub const modify = bridge.function(Selection.modify, .{});
|
||||
pub const removeAllRanges = bridge.function(Selection.removeAllRanges, .{});
|
||||
pub const removeRange = bridge.function(Selection.removeRange, .{ .dom_exception = true });
|
||||
pub const selectAllChildren = bridge.function(Selection.selectAllChildren, .{});
|
||||
pub const selectAllChildren = bridge.function(Selection.selectAllChildren, .{ .dom_exception = true });
|
||||
pub const setBaseAndExtent = bridge.function(Selection.setBaseAndExtent, .{ .dom_exception = true });
|
||||
pub const setPosition = bridge.function(Selection.collapse, .{ .dom_exception = true });
|
||||
pub const toString = bridge.function(Selection.toString, .{});
|
||||
|
||||
Reference in New Issue
Block a user