Skip to content

Commit 88f7687

Browse files
committed
cdp: dispatch DOM.setChildNodes on performSearch
1 parent f12a527 commit 88f7687

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/cdp/domains/dom.zig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ fn performSearch(cmd: anytype) !void {
7676

7777
const search = try bc.node_search_list.create(list.nodes.items);
7878

79+
// dispatch setChildNodesEvents to inform the client of the subpart of node
80+
// tree covering the results.
81+
for (list.nodes.items) |n| {
82+
// retrieve the node's parent
83+
if (try parser.nodeParentNode(n)) |p| {
84+
// Register the parent and send the node.
85+
const parent_node = try bc.node_registry.register(p);
86+
const node = bc.node_registry.lookup_by_node.get(n) orelse unreachable;
87+
// Should-we return one DOM.setChildNodes event per parentId
88+
// containing all its children in the nodes array?
89+
try cmd.sendEvent("DOM.setChildNodes", .{
90+
.parentId = parent_node.id,
91+
.nodes = .{bc.nodeWriter(node, .{})},
92+
}, .{});
93+
}
94+
}
95+
7996
return cmd.sendResult(.{
8097
.searchId = search.name,
8198
.resultCount = @as(u32, @intCast(search.node_ids.len)),

0 commit comments

Comments
 (0)