1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:47:34 +00:00

LibWeb: Add Node.insertBefore(Node node, Node? child)

This commit is contained in:
Andreas Kling 2020-06-21 16:45:21 +02:00
parent 82a75bcf5f
commit 213e2793bd
4 changed files with 43 additions and 0 deletions

View file

@ -200,4 +200,16 @@ RefPtr<Node> Node::append_child(NonnullRefPtr<Node> node, bool notify)
return node;
}
RefPtr<Node> Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool notify)
{
if (!child)
return append_child(move(node), notify);
if (child->parent_node() != this) {
dbg() << "FIXME: Trying to insert_before() a bogus child";
return nullptr;
}
TreeNode<Node>::insert_before(node, child, notify);
return node;
}
}