LibWeb: Use HTMLOptionElement in select item getter

fix item
This commit is contained in:
Bastiaan van der Plaat 2024-04-08 22:01:21 +02:00 committed by Andreas Kling
parent 6f84f69677
commit 8342525434
Notes: sideshowbarker 2024-07-17 00:37:23 +09:00
3 changed files with 8 additions and 10 deletions

View file

@ -114,17 +114,17 @@ WebIDL::ExceptionOr<void> HTMLSelectElement::set_length(WebIDL::UnsignedLong len
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-item
DOM::Element* HTMLSelectElement::item(size_t index)
HTMLOptionElement* HTMLSelectElement::item(WebIDL::UnsignedLong index)
{
// The item(index) 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()).item(index);
return verify_cast<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*options()).item(index));
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-nameditem
DOM::Element* HTMLSelectElement::named_item(FlyString const& name)
HTMLOptionElement* HTMLSelectElement::named_item(FlyString 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 verify_cast<HTMLOptionElement>(const_cast<HTMLOptionsCollection&>(*options()).named_item(name));
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add