mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-12 02:30:30 +09:00
LibWeb: Port HTMLCollection from DeprecatedString to String
This commit is contained in:
parent
ebdfe2e863
commit
d5409a056a
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/shannonbooth
Commit: d5409a056a
Pull-request: https://github.com/SerenityOS/serenity/pull/20511
4 changed files with 7 additions and 5 deletions
|
@ -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<JS::Value> HTMLCollection::item_value(size_t index) const
|
|||
|
||||
WebIDL::ExceptionOr<JS::Value> 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*>(element);
|
||||
|
|
|
@ -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<Element*> collect_matching_elements() const;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import <DOM/Element.idl>
|
||||
|
||||
[Exposed=Window, LegacyUnenumerableNamedProperties]
|
||||
[Exposed=Window, LegacyUnenumerableNamedProperties, UseNewAKString]
|
||||
interface HTMLCollection {
|
||||
|
||||
readonly attribute unsigned long length;
|
||||
|
|
|
@ -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<HTMLOptionsCollection&>(*options()).named_item(name);
|
||||
return const_cast<HTMLOptionsCollection&>(*options()).named_item(FlyString::from_deprecated_fly_string(name).release_value());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue