mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibWeb: Move element_child_count to ParentNode and add its IDL attribute
I initially had it in Node just because, but then saw it was part of ParentNode in the spec.
This commit is contained in:
@@ -80,4 +80,15 @@ RefPtr<Element> ParentNode::last_element_child()
|
||||
return last_child_of_type<Element>();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-childelementcount
|
||||
u32 ParentNode::child_element_count() const
|
||||
{
|
||||
u32 count = 0;
|
||||
for (auto* child = first_child(); child; child = child->next_sibling()) {
|
||||
if (is<Element>(child))
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user