LibWeb: Remove nodes from their old parent in appendChild/insertBefore
This commit is contained in:
parent
c70e0a4f29
commit
380e688123
Notes:
sideshowbarker
2024-07-18 20:43:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/380e6881232
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)
|
||||
{
|
||||
if (node->parent())
|
||||
node->parent()->remove_child(node);
|
||||
if (&node->document() != &document())
|
||||
document().adopt_node(node);
|
||||
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");
|
||||
return nullptr;
|
||||
}
|
||||
if (node->parent())
|
||||
node->parent()->remove_child(node);
|
||||
if (&node->document() != &document())
|
||||
document().adopt_node(node);
|
||||
TreeNode<Node>::insert_before(node, child, notify);
|
||||
|
|
Loading…
Add table
Reference in a new issue