mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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
Notes:
sideshowbarker
2024-07-18 22:31:41 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/5a9094a70a8 Pull-request: https://github.com/SerenityOS/serenity/pull/5264 Reviewed-by: https://github.com/Lubrsi
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
|
||||
{
|
||||
// FIXME: Support "*" for tag_name
|
||||
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
|
||||
NonnullRefPtrVector<Element> elements;
|
||||
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);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
return elements;
|
||||
|
|
Loading…
Reference in a new issue