mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +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:
parent
fc9abee84b
commit
83d2c3f2f5
7 changed files with 31 additions and 25 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue