mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibWeb: Implement Document.getElementsByClassName()
Note that we're taking a shortcut here and returning the elements as an Array instead of HTMLCollection. One day we'll have to bite the bullet and deal with HTMLCollection, but not today.
This commit is contained in:
parent
09da5f7263
commit
7c4c706ebe
3 changed files with 13 additions and 0 deletions
|
@ -458,6 +458,17 @@ NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const FlyString&
|
|||
return elements;
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<Element> Document::get_elements_by_class_name(const FlyString& class_name) const
|
||||
{
|
||||
NonnullRefPtrVector<Element> elements;
|
||||
for_each_in_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.has_class(class_name))
|
||||
elements.append(element);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
return elements;
|
||||
}
|
||||
|
||||
Color Document::link_color() const
|
||||
{
|
||||
if (m_link_color.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue