mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Use HTMLOptionElement in select item getter
fix item
This commit is contained in:
parent
6f84f69677
commit
8342525434
Notes:
sideshowbarker
2024-07-17 00:37:23 +09:00
Author: https://github.com/bplaat
Commit: 8342525434
Pull-request: https://github.com/SerenityOS/serenity/pull/23895
Reviewed-by: https://github.com/shannonbooth
3 changed files with 8 additions and 10 deletions
|
@ -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
|
// 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.
|
// 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
|
// 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.
|
// 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
|
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
|
||||||
|
|
|
@ -36,8 +36,8 @@ public:
|
||||||
|
|
||||||
WebIDL::UnsignedLong length();
|
WebIDL::UnsignedLong length();
|
||||||
WebIDL::ExceptionOr<void> set_length(WebIDL::UnsignedLong);
|
WebIDL::ExceptionOr<void> set_length(WebIDL::UnsignedLong);
|
||||||
DOM::Element* item(size_t index);
|
HTMLOptionElement* item(WebIDL::UnsignedLong index);
|
||||||
DOM::Element* named_item(FlyString const& name);
|
HTMLOptionElement* named_item(FlyString const& name);
|
||||||
WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
|
WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
|
||||||
void remove();
|
void remove();
|
||||||
void remove(WebIDL::Long);
|
void remove(WebIDL::Long);
|
||||||
|
|
|
@ -19,10 +19,8 @@ interface HTMLSelectElement : HTMLElement {
|
||||||
|
|
||||||
[SameObject] readonly attribute HTMLOptionsCollection options;
|
[SameObject] readonly attribute HTMLOptionsCollection options;
|
||||||
[CEReactions] attribute unsigned long length;
|
[CEReactions] attribute unsigned long length;
|
||||||
// FIXME: Element is really HTMLOptionElement
|
getter HTMLOptionElement? item(unsigned long index);
|
||||||
getter Element? item(unsigned long index);
|
HTMLOptionElement? namedItem(DOMString name);
|
||||||
// FIXME: Element is really HTMLOptionElement
|
|
||||||
Element? namedItem(DOMString name);
|
|
||||||
[CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
[CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
||||||
[CEReactions] undefined remove(); // ChildNode overload
|
[CEReactions] undefined remove(); // ChildNode overload
|
||||||
[CEReactions] undefined remove(long index);
|
[CEReactions] undefined remove(long index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue