LibWeb: Add select and option collection set length

This commit is contained in:
Bastiaan van der Plaat 2024-04-08 21:50:35 +02:00 committed by Andreas Kling
parent 4e5ce7b63e
commit 5c277144d8
Notes: sideshowbarker 2024-07-16 23:17:55 +09:00
8 changed files with 95 additions and 5 deletions

View file

@ -100,12 +100,18 @@ JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-length
size_t HTMLSelectElement::length()
WebIDL::UnsignedLong HTMLSelectElement::length()
{
// The length IDL attribute must return the number of nodes represented by the options collection. On setting, it must act like the attribute of the same name on the options collection.
return const_cast<HTMLOptionsCollection&>(*options()).length();
}
WebIDL::ExceptionOr<void> HTMLSelectElement::set_length(WebIDL::UnsignedLong length)
{
// On setting, it must act like the attribute of the same name on the options collection.
return const_cast<HTMLOptionsCollection&>(*options()).set_length(length);
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-item
DOM::Element* HTMLSelectElement::item(size_t index)
{