mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 02:40:49 +00:00
LibWeb: Implement HTMLSelectElement length, item() and namedItem()
These are simple calls through to the HTMLOptionsCollection functions the same names, as with HTMLSelectElement.add().
This commit is contained in:
@@ -42,6 +42,27 @@ JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
|
||||
return m_options;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-length
|
||||
size_t 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();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-item
|
||||
DOM::Element* HTMLSelectElement::item(size_t 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);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-nameditem
|
||||
DOM::Element* 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);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
|
||||
WebIDL::ExceptionOr<void> HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user