1
Fork 0
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:
Andreas Kling 2020-12-01 15:47:50 +01:00
parent 09da5f7263
commit 7c4c706ebe
3 changed files with 13 additions and 0 deletions

View file

@ -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())