diff --git a/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Libraries/LibWeb/CSS/SelectorEngine.cpp index cda81207f42..6b1627e2ed3 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -219,8 +219,7 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co auto const& attribute_name = attribute.qualified_name.name.name; - auto const* attr = element.namespace_uri() == Namespace::HTML ? element.attributes()->get_attribute_with_lowercase_qualified_name(attribute_name) - : element.attributes()->get_attribute(attribute_name); + auto const* attr = element.attributes()->get_attribute(attribute_name); if (attribute.match_type == CSS::Selector::SimpleSelector::Attribute::MatchType::HasAttribute) { // Early way out in case of an attribute existence selector. diff --git a/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 11ed46345cf..237538ca554 100644 --- a/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -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 const& namespace_, FlyString const& local_name, size_t* item_index) { diff --git a/Libraries/LibWeb/DOM/NamedNodeMap.h b/Libraries/LibWeb/DOM/NamedNodeMap.h index 27052935f52..bf59c3a13db 100644 --- a/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -53,8 +53,6 @@ public: Attr const* remove_attribute(FlyString const& qualified_name); Attr const* remove_attribute_ns(Optional const& namespace_, FlyString const& local_name); - Attr const* get_attribute_with_lowercase_qualified_name(FlyString const&) const; - WebIDL::ExceptionOr> remove_attribute_node(GC::Ref); private: diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/ParentNode-querySelector-All.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/ParentNode-querySelector-All.txt index 9e626d0def9..29487d7992a 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/ParentNode-querySelector-All.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/ParentNode-querySelector-All.txt @@ -6,8 +6,8 @@ Rerun Found 1975 tests -1923 Pass -52 Fail +1931 Pass +44 Fail Details Result Test Name MessagePass Selectors-API Test Suite: HTML Pass Document supports querySelector @@ -414,8 +414,8 @@ Pass Document.querySelectorAll: Attribute presence selector, matching align attr Pass Document.querySelector: Attribute presence selector, matching align attribute with value: .attr-presence-div1[align] Pass Document.querySelectorAll: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] Pass Document.querySelector: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] -Fail Document.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] -Fail Document.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Document.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Document.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] Pass Document.querySelectorAll: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Document.querySelector: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Document.querySelectorAll: Attribute presence selector, not matching attribute with similar name: .attr-presence-div3[align], .attr-presence-div4[align] @@ -810,8 +810,8 @@ Pass Detached Element.querySelectorAll: Attribute presence selector, matching al Pass Detached Element.querySelector: Attribute presence selector, matching align attribute with value: .attr-presence-div1[align] Pass Detached Element.querySelectorAll: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] Pass Detached Element.querySelector: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] -Fail Detached Element.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] -Fail Detached Element.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Detached Element.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Detached Element.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] Pass Detached Element.querySelectorAll: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Detached Element.querySelector: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Detached Element.querySelectorAll: Attribute presence selector, not matching attribute with similar name: .attr-presence-div3[align], .attr-presence-div4[align] @@ -1206,8 +1206,8 @@ Pass Fragment.querySelectorAll: Attribute presence selector, matching align attr Pass Fragment.querySelector: Attribute presence selector, matching align attribute with value: .attr-presence-div1[align] Pass Fragment.querySelectorAll: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] Pass Fragment.querySelector: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] -Fail Fragment.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] -Fail Fragment.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Fragment.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass Fragment.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] Pass Fragment.querySelectorAll: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Fragment.querySelector: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass Fragment.querySelectorAll: Attribute presence selector, not matching attribute with similar name: .attr-presence-div3[align], .attr-presence-div4[align] @@ -1602,8 +1602,8 @@ Pass In-document Element.querySelectorAll: Attribute presence selector, matching Pass In-document Element.querySelector: Attribute presence selector, matching align attribute with value: .attr-presence-div1[align] Pass In-document Element.querySelectorAll: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] Pass In-document Element.querySelector: Attribute presence selector, matching align attribute with empty value: .attr-presence-div2[align] -Fail In-document Element.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] -Fail In-document Element.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass In-document Element.querySelectorAll: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] +Pass In-document Element.querySelector: Attribute presence selector, matching title attribute, case insensitivity: #attr-presence [*|TiTlE] Pass In-document Element.querySelectorAll: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass In-document Element.querySelector: Attribute presence selector, matching custom data-* attribute: [data-attr-presence] Pass In-document Element.querySelectorAll: Attribute presence selector, not matching attribute with similar name: .attr-presence-div3[align], .attr-presence-div4[align]