From ab674f3bf6fedc3b75afbf6be7f3f1a3b59b623c Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Thu, 21 Sep 2023 20:09:51 +1200 Subject: [PATCH] LibWeb: Make Element::remove_attribute take a StringView It already delegates to a function which accepts a StringView, so there is no advantage here in taking a FlyString. Ideally, both of these functions should be taking a 'FlyString const&', so leave a FIXME for that. In the meantime, this should help in porting away from DeprecatedString. --- Userland/Libraries/LibWeb/DOM/Element.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.h | 4 +++- Userland/Libraries/LibWeb/DOM/NamedNodeMap.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 337c68d783..0c0b68dadf 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -295,7 +295,7 @@ WebIDL::ExceptionOr> Element::set_attribute_node_ns(Attr& attr) } // https://dom.spec.whatwg.org/#dom-element-removeattribute -void Element::remove_attribute(DeprecatedFlyString const& name) +void Element::remove_attribute(StringView name) { // The removeAttribute(qualifiedName) method steps are to remove an attribute given qualifiedName and this, and then return undefined. m_attributes->remove_attribute(name); diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 5ddea054c0..3d8bfaef62 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -114,7 +114,9 @@ public: WebIDL::ExceptionOr> set_attribute_node(Attr&); WebIDL::ExceptionOr> set_attribute_node_ns(Attr&); - void remove_attribute(DeprecatedFlyString const& name); + // FIXME: This should take a 'FlyString cosnt&' + void remove_attribute(StringView name); + WebIDL::ExceptionOr toggle_attribute(DeprecatedFlyString const& name, Optional force); size_t attribute_list_size() const; NamedNodeMap const* attributes() const { return m_attributes.ptr(); } diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index cd26b10425..96226a2ff3 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -50,6 +50,8 @@ public: WebIDL::ExceptionOr> set_attribute(Attr& attribute); void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index); void append_attribute(Attr& attribute); + + // FIXME: This should take a 'FlyString cosnt&' Attr const* remove_attribute(StringView qualified_name); Attr const* remove_attribute_ns(StringView namespace_, StringView local_name);