@@ -89,7 +89,7 @@ fn performSearch(cmd: anytype) !void {
8989// dispatchSetChildNodes send the setChildNodes event for the whole DOM tree
9090// hierarchy of each nodes.
9191// We dispatch event in the reverse order: from the top level to the direct parents.
92- // TODO we should dispatch a node only if it has never been sent.
92+ // We should dispatch a node only if it has never been sent.
9393fn dispatchSetChildNodes (cmd : anytype , nodes : []* parser.Node ) ! void {
9494 const arena = cmd .arena ;
9595 const bc = cmd .browser_context orelse return error .BrowserContextNotLoaded ;
@@ -103,6 +103,7 @@ fn dispatchSetChildNodes(cmd: anytype, nodes: []*parser.Node) !void {
103103
104104 // Register the node.
105105 const node = try bc .node_registry .register (p );
106+ if (node .set_child_nodes_event ) break ;
106107 try parents .append (arena , node );
107108 n = p ;
108109 }
@@ -111,14 +112,13 @@ fn dispatchSetChildNodes(cmd: anytype, nodes: []*parser.Node) !void {
111112 const plen = parents .items .len ;
112113 if (plen == 0 ) return ;
113114
114- var uniq : std .AutoHashMapUnmanaged (Node.Id , bool ) = .{};
115115 var i : usize = plen ;
116116 while (i > 0 ) {
117117 i -= 1 ;
118118 const node = parents .items [i ];
119+ if (node .set_child_nodes_event ) continue ;
119120
120- if (uniq .contains (node .id )) continue ;
121- try uniq .putNoClobber (arena , node .id , true );
121+ node .set_child_nodes_event = true ;
122122
123123 // If the node has no parent, it's the root node.
124124 // We don't dispatch event for it because we assume the root node is
0 commit comments