summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-11-05 04:51:42 +0000
committerAndreas Kling <kling@serenityos.org>2022-11-07 14:10:41 +0100
commitc4ee43c5b41770ef69402269c6efa92ad5ded2be (patch)
tree3c311f059a7d93411534e2489e016c31b84e6a4b
parentc247fefee72201732a579dcbd5c414a84bfbc350 (diff)
downloadserenity-c4ee43c5b41770ef69402269c6efa92ad5ded2be.zip
LibWeb: Implement HTMLSelectElement.type
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp13
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h2
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl2
3 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
index 73dc93c6f3..f5e8845e54 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
@@ -129,4 +129,17 @@ i32 HTMLSelectElement::default_tab_index_value() const
return 0;
}
+// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-type
+String const& HTMLSelectElement::type() const
+{
+ // The type IDL attribute, on getting, must return the string "select-one" if the multiple attribute is absent, and the string "select-multiple" if the multiple attribute is present.
+ static String select_one = "select-one"sv;
+ static String select_multiple = "select-multiple"sv;
+
+ if (!has_attribute(AttributeNames::multiple))
+ return select_one;
+
+ return select_multiple;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
index cde0d812e7..0d50f14510 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
@@ -56,6 +56,8 @@ public:
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
+ String const& type() const;
+
private:
HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl
index c1a1297d64..b7801b6811 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.idl
@@ -10,6 +10,8 @@ interface HTMLSelectElement : HTMLElement {
[Reflect] attribute boolean required;
[SameObject] readonly attribute HTMLOptionsCollection options;
+ readonly attribute DOMString type;
+
readonly attribute unsigned long length;
getter Element? item(unsigned long index);
getter Element? namedItem(DOMString name);