summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-03-21 20:03:37 -0400
committerAndreas Kling <kling@serenityos.org>2022-03-22 02:08:15 +0100
commit27eb70cbba9269ada769a0ea94dd2fe688504c3f (patch)
treec6a13251000b8dde850ea00d85f0bbee88e206bf /Userland/Libraries/LibWeb/HTML
parentff9856a21447445394ce34543b301ac9a9460d57 (diff)
downloadserenity-27eb70cbba9269ada769a0ea94dd2fe688504c3f.zip
LibWeb: Implement HTMLSelectElement.add()
HTMLSelectElement simply defers to its HTMLOptionsCollection.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp7
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl2
3 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
index 9853f60e90..838987857e 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
@@ -34,6 +34,13 @@ RefPtr<HTMLOptionsCollection> const& HTMLSelectElement::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
NonnullRefPtrVector<HTMLOptionElement> HTMLSelectElement::list_of_options() const
{
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
index 1d0f3964dc..c8ad0930a6 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
@@ -23,6 +23,8 @@ public:
RefPtr<HTMLOptionsCollection> const& options();
+ DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> 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 e473f31070..3717993572 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;
};