mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28: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:
parent
2547e0b966
commit
f0420def78
Notes:
sideshowbarker
2024-07-17 05:23:38 +09:00
Author: https://github.com/Zaggy1024
Commit: f0420def78
Pull-request: https://github.com/SerenityOS/serenity/pull/15680
Reviewed-by: https://github.com/linusg
3 changed files with 27 additions and 0 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue