diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-21 22:21:59 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-21 22:21:59 +0100 |
commit | 19b5033dc47694d9eda4c461501cfd5ff9df6e96 (patch) | |
tree | 89dde25d2d8b89cd673aa68b782762076b76d3ae /Userland/Libraries | |
parent | 8b2499b11211556cc5998aa4e08501cf580e4c93 (diff) | |
download | serenity-19b5033dc47694d9eda4c461501cfd5ff9df6e96.zip |
LibWeb: Implement Node.removeChild() in terms of "pre-remove"
This is what the spec wants us to do.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Node.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Node.h | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index dff4980614..c15ebbc8e4 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -348,6 +348,12 @@ ExceptionOr<NonnullRefPtr<Node>> Node::pre_insert(NonnullRefPtr<Node> node, RefP return node; } +// https://dom.spec.whatwg.org/#dom-node-removechild +ExceptionOr<NonnullRefPtr<Node>> Node::remove_child(NonnullRefPtr<Node> child) +{ + return pre_remove(child); +} + // https://dom.spec.whatwg.org/#concept-node-pre-remove ExceptionOr<NonnullRefPtr<Node>> Node::pre_remove(NonnullRefPtr<Node> child) { @@ -383,7 +389,7 @@ void Node::remove(bool suppress_observers) // FIXME: Let oldPreviousSibling be node’s previous sibling. (Currently unused so not included) // FIXME: Let oldNextSibling be node’s next sibling. (Currently unused so not included) - parent->remove_child(*this); + parent->TreeNode::remove_child(*this); // FIXME: If node is assigned, then run assign slottables for node’s assigned slot. diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 77ebef33f6..6f5c5a4a26 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -90,6 +90,8 @@ public: ExceptionOr<NonnullRefPtr<Node>> pre_remove(NonnullRefPtr<Node>); ExceptionOr<NonnullRefPtr<Node>> append_child(NonnullRefPtr<Node>); + ExceptionOr<NonnullRefPtr<Node>> remove_child(NonnullRefPtr<Node>); + void insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool suppress_observers = false); void remove(bool suppress_observers = false); void remove_all_children(bool suppress_observers = false); |