mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
LibWeb: Remove nodes from their old parent in appendChild/insertBefore
This commit is contained in:
parent
c70e0a4f29
commit
380e688123
1 changed files with 4 additions and 0 deletions
|
@ -181,6 +181,8 @@ const Element* Node::parent_element() const
|
||||||
|
|
||||||
RefPtr<Node> Node::append_child(NonnullRefPtr<Node> node, bool notify)
|
RefPtr<Node> Node::append_child(NonnullRefPtr<Node> node, bool notify)
|
||||||
{
|
{
|
||||||
|
if (node->parent())
|
||||||
|
node->parent()->remove_child(node);
|
||||||
if (&node->document() != &document())
|
if (&node->document() != &document())
|
||||||
document().adopt_node(node);
|
document().adopt_node(node);
|
||||||
TreeNode<Node>::append_child(node, notify);
|
TreeNode<Node>::append_child(node, notify);
|
||||||
|
@ -201,6 +203,8 @@ RefPtr<Node> Node::insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, b
|
||||||
dbgln("FIXME: Trying to insert_before() a bogus child");
|
dbgln("FIXME: Trying to insert_before() a bogus child");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (node->parent())
|
||||||
|
node->parent()->remove_child(node);
|
||||||
if (&node->document() != &document())
|
if (&node->document() != &document())
|
||||||
document().adopt_node(node);
|
document().adopt_node(node);
|
||||||
TreeNode<Node>::insert_before(node, child, notify);
|
TreeNode<Node>::insert_before(node, child, notify);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue