diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 9853f60e90c..838987857eb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -34,6 +34,13 @@ RefPtr const& HTMLSelectElement::options() return m_options; } +// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add +DOM::ExceptionOr HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional before) +{ + // Similarly, the add(element, before) method must act like its namesake method on that same options collection. + return const_cast&>(options())->add(move(element), move(before)); +} + // https://html.spec.whatwg.org/multipage/form-elements.html#concept-select-option-list NonnullRefPtrVector HTMLSelectElement::list_of_options() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h index 1d0f3964dc1..c8ad0930a66 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -23,6 +23,8 @@ public: RefPtr const& options(); + DOM::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); + int selected_index() const; void set_selected_index(int); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl index e473f31070a..3717993572c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl @@ -8,6 +8,8 @@ interface HTMLSelectElement : HTMLElement { [Reflect] attribute boolean required; [SameObject] readonly attribute HTMLOptionsCollection options; + [CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); + attribute long selectedIndex; };