LibWeb: Use correct case-sensitivity when matching attribute selectors

Also removed get_attribute_with_lowercase_qualified_name
because it was buggy, duplicated logic, and now unused.
This commit is contained in:
Gingeh 2024-11-21 20:43:10 +11:00 committed by Andreas Kling
parent a2cf1d17fd
commit ba0cc7fe46
Notes: github-actions[bot] 2024-11-23 08:51:33 +00:00
4 changed files with 12 additions and 29 deletions

View file

@ -148,8 +148,7 @@ Attr const* NamedNodeMap::get_attribute(FlyString const& qualified_name, size_t*
*item_index = 0;
// 1. If element is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
// FIXME: Handle the second condition, assume it is an HTML document for now.
bool compare_as_lowercase = associated_element().namespace_uri() == Namespace::HTML;
bool compare_as_lowercase = associated_element().namespace_uri() == Namespace::HTML && associated_element().document().is_html_document();
// 2. Return the first attribute in elements attribute list whose qualified name is qualifiedName; otherwise null.
for (auto const& attribute : m_attributes) {
@ -168,19 +167,6 @@ Attr const* NamedNodeMap::get_attribute(FlyString const& qualified_name, size_t*
return nullptr;
}
Attr const* NamedNodeMap::get_attribute_with_lowercase_qualified_name(FlyString const& lowercase_qualified_name) const
{
bool compare_as_lowercase = associated_element().namespace_uri() == Namespace::HTML;
VERIFY(compare_as_lowercase);
for (auto const& attribute : m_attributes) {
if (attribute->lowercase_name() == lowercase_qualified_name)
return attribute;
}
return nullptr;
}
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
Attr* NamedNodeMap::get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index)
{