mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
LibWeb: Make getElementsByTagName() case-insensitive for HTML elements
From https://dom.spec.whatwg.org/#concept-getelementsbytagname: 2. Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements: * Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase. * Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.
This commit is contained in:
parent
27a395d964
commit
5a9094a70a
1 changed files with 6 additions and 1 deletions
|
@ -487,10 +487,15 @@ NonnullRefPtrVector<Element> Document::get_elements_by_name(const String& name)
|
||||||
|
|
||||||
NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const FlyString& tag_name) const
|
NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const FlyString& tag_name) const
|
||||||
{
|
{
|
||||||
|
// FIXME: Support "*" for tag_name
|
||||||
|
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
|
||||||
NonnullRefPtrVector<Element> elements;
|
NonnullRefPtrVector<Element> elements;
|
||||||
for_each_in_subtree_of_type<Element>([&](auto& element) {
|
for_each_in_subtree_of_type<Element>([&](auto& element) {
|
||||||
if (element.local_name() == tag_name)
|
if (element.namespace_() == Namespace::HTML
|
||||||
|
? element.local_name().to_lowercase() == tag_name.to_lowercase()
|
||||||
|
: element.local_name() == tag_name) {
|
||||||
elements.append(element);
|
elements.append(element);
|
||||||
|
}
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
return elements;
|
return elements;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue