LibWeb: Add ParentNode::remove_all_children()

This safely removes all children from a Node.
This commit is contained in:
Andreas Kling 2020-03-25 18:52:03 +01:00
parent 1146ab0fae
commit 632cc53e2c
Notes: sideshowbarker 2024-07-19 08:07:35 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -26,3 +26,13 @@
#include <LibWeb/DOM/ParentNode.h>
namespace Web {
void ParentNode::remove_all_children()
{
while (RefPtr<Node> child = first_child()) {
remove_child(*child);
}
}
}

View file

@ -35,6 +35,8 @@ public:
template<typename F> void for_each_child(F) const;
template<typename F> void for_each_child(F);
void remove_all_children();
protected:
explicit ParentNode(Document& document, NodeType type)
: Node(document, type)