1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibWeb: Move get_element_by_id() to a NonElementParentNode mixin class

This matches the current version of the DOM spec. And since C++ doesn't
have mixins this is actually a CRTP class.
This commit is contained in:
Andreas Kling 2020-03-28 09:12:13 +01:00
parent 95cc4c7e74
commit 660ec504ca
5 changed files with 68 additions and 17 deletions

View file

@ -295,19 +295,6 @@ void Document::set_hovered_node(Node* node)
invalidate_style();
}
const Element* Document::get_element_by_id(const String& id) const
{
const Element* found_element = nullptr;
for_each_in_subtree_of_type<Element>([&](auto& element) {
if (element.attribute("id") == id) {
found_element = &element;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
return found_element;
}
Vector<const Element*> Document::get_elements_by_name(const String& name) const
{
Vector<const Element*> elements;