mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
remove children from previous parent
This commit is contained in:
@@ -156,6 +156,12 @@ pub fn replaceChildren(self: *DocumentFragment, nodes: []const Node.NodeOrText,
|
|||||||
const parent_is_connected = parent.isConnected();
|
const parent_is_connected = parent.isConnected();
|
||||||
for (nodes) |node_or_text| {
|
for (nodes) |node_or_text| {
|
||||||
const child = try node_or_text.toNode(page);
|
const child = try node_or_text.toNode(page);
|
||||||
|
|
||||||
|
// If the new children has already a parent, remove from it.
|
||||||
|
if (child._parent) |p| {
|
||||||
|
page.removeNode(p, child, .{ .will_be_reconnected = true });
|
||||||
|
}
|
||||||
|
|
||||||
try page.appendNode(parent, child, .{ .child_already_connected = parent_is_connected });
|
try page.appendNode(parent, child, .{ .child_already_connected = parent_is_connected });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user