mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
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:
parent
a2cf1d17fd
commit
ba0cc7fe46
Notes:
github-actions[bot]
2024-11-23 08:51:33 +00:00
Author: https://github.com/Gingeh
Commit: ba0cc7fe46
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2478
Reviewed-by: https://github.com/AtkinsSJ
4 changed files with 12 additions and 29 deletions
|
@ -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 element’s 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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue