From d5409a056a031e175483b311f21cadf0a613c4fa Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sat, 12 Aug 2023 21:30:18 +1200 Subject: [PATCH] LibWeb: Port HTMLCollection from DeprecatedString to String --- Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp | 6 ++++-- Userland/Libraries/LibWeb/DOM/HTMLCollection.h | 2 +- Userland/Libraries/LibWeb/DOM/HTMLCollection.idl | 2 +- Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index d61fe9da0a..69879bd5a8 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -77,8 +77,10 @@ Element* HTMLCollection::item(size_t index) const } // https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem-key -Element* HTMLCollection::named_item(DeprecatedFlyString const& name) const +Element* HTMLCollection::named_item(FlyString const& name_) const { + auto name = name_.to_deprecated_fly_string(); + // 1. If key is the empty string, return null. if (name.is_empty()) return nullptr; @@ -147,7 +149,7 @@ WebIDL::ExceptionOr HTMLCollection::item_value(size_t index) const WebIDL::ExceptionOr HTMLCollection::named_item_value(DeprecatedFlyString const& index) const { - auto* element = named_item(index); + auto* element = named_item(FlyString::from_deprecated_fly_string(index).release_value()); if (!element) return JS::js_undefined(); return const_cast(element); diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index 4d1d332525..1e9185078f 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -40,7 +40,7 @@ public: size_t length() const; Element* item(size_t index) const; - Element* named_item(DeprecatedFlyString const& name) const; + Element* named_item(FlyString const& name) const; JS::MarkedVector collect_matching_elements() const; diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl b/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl index 0bcf02221c..806a3a5048 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl @@ -1,6 +1,6 @@ #import -[Exposed=Window, LegacyUnenumerableNamedProperties] +[Exposed=Window, LegacyUnenumerableNamedProperties, UseNewAKString] interface HTMLCollection { readonly attribute unsigned long length; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 022c7d78d9..b2fc037e15 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -65,7 +65,7 @@ DOM::Element* HTMLSelectElement::item(size_t index) DOM::Element* HTMLSelectElement::named_item(DeprecatedFlyString const& name) { // The namedItem(name) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument. - return const_cast(*options()).named_item(name); + return const_cast(*options()).named_item(FlyString::from_deprecated_fly_string(name).release_value()); } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add