diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 465189e205..aa23b36bb3 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -302,7 +302,7 @@ void Element::remove_attribute(StringView name) } // https://dom.spec.whatwg.org/#dom-element-hasattribute -bool Element::has_attribute(DeprecatedFlyString const& name) const +bool Element::has_attribute(StringView name) const { return m_attributes->get_attribute(name) != nullptr; } diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 67683400ea..0d0b68e386 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -91,7 +91,8 @@ public: // NOTE: This is for the JS bindings DeprecatedFlyString namespace_uri() const { return namespace_(); } - bool has_attribute(DeprecatedFlyString const& name) const; + // FIXME: This should be taking a 'FlyString const&' + bool has_attribute(StringView name) const; bool has_attribute_ns(DeprecatedFlyString namespace_, DeprecatedFlyString const& name) const; bool has_attributes() const; @@ -104,6 +105,7 @@ public: return String::from_deprecated_string(ret).release_value(); } + // FIXME: This should be taking a 'FlyString const&' / 'Optional const&' DeprecatedString get_attribute(DeprecatedFlyString const& name) const; DeprecatedString get_attribute_value(DeprecatedFlyString const& local_name, DeprecatedFlyString const& namespace_ = {}) const; diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index 96226a2ff3..61ef322fb4 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -43,6 +43,7 @@ public: WebIDL::ExceptionOr remove_named_item_ns(Optional const& namespace_, StringView local_name); // Methods defined by the spec for internal use: + // FIXME: These should be taking `FlyString const&' / 'Optional const&' Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr); Attr* get_attribute_ns(StringView namespace_, StringView local_name, size_t* item_index = nullptr); Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 396960095e..ed81c15be0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -164,9 +164,9 @@ String const& HTMLSelectElement::type() const Optional HTMLSelectElement::default_role() const { // https://www.w3.org/TR/html-aria/#el-select-multiple-or-size-greater-1 - if (has_attribute("multiple")) + if (has_attribute(AttributeNames::multiple)) return ARIA::Role::listbox; - if (has_attribute("size")) { + if (has_attribute(AttributeNames::size)) { auto size_attribute = deprecated_attribute("size").to_int(); if (size_attribute.has_value() && size_attribute.value() > 1) return ARIA::Role::listbox; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp index 1939546e1d..96678977b7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGradientElement.cpp @@ -94,7 +94,7 @@ JS::GCPtr SVGGradientElement::linked_gradient() const // FIXME: This entire function is an ad-hoc hack! // It can only resolve # in the same document. - auto link = has_attribute("href") ? get_attribute("href") : get_attribute("xlink:href"); + auto link = has_attribute(AttributeNames::href) ? get_attribute(AttributeNames::href) : get_attribute("xlink:href"sv); if (auto href = link; !href.is_empty()) { auto url = document().parse_url(href); auto id = url.fragment();