mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibWeb: Implement HTMLSelectElement.add()
HTMLSelectElement simply defers to its HTMLOptionsCollection.
This commit is contained in:
parent
ff9856a214
commit
27eb70cbba
3 changed files with 11 additions and 0 deletions
|
@ -34,6 +34,13 @@ RefPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
|
||||||
return m_options;
|
return m_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
|
||||||
|
DOM::ExceptionOr<void> HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before)
|
||||||
|
{
|
||||||
|
// Similarly, the add(element, before) method must act like its namesake method on that same options collection.
|
||||||
|
return const_cast<RefPtr<HTMLOptionsCollection>&>(options())->add(move(element), move(before));
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-select-option-list
|
// https://html.spec.whatwg.org/multipage/form-elements.html#concept-select-option-list
|
||||||
NonnullRefPtrVector<HTMLOptionElement> HTMLSelectElement::list_of_options() const
|
NonnullRefPtrVector<HTMLOptionElement> HTMLSelectElement::list_of_options() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,8 @@ public:
|
||||||
|
|
||||||
RefPtr<HTMLOptionsCollection> const& options();
|
RefPtr<HTMLOptionsCollection> const& options();
|
||||||
|
|
||||||
|
DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
|
||||||
|
|
||||||
int selected_index() const;
|
int selected_index() const;
|
||||||
void set_selected_index(int);
|
void set_selected_index(int);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ interface HTMLSelectElement : HTMLElement {
|
||||||
[Reflect] attribute boolean required;
|
[Reflect] attribute boolean required;
|
||||||
[SameObject] readonly attribute HTMLOptionsCollection options;
|
[SameObject] readonly attribute HTMLOptionsCollection options;
|
||||||
|
|
||||||
|
[CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
|
||||||
|
|
||||||
attribute long selectedIndex;
|
attribute long selectedIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue