diff --git a/Tests/LibWeb/Text/expected/html-form-controls-collection.txt b/Tests/LibWeb/Text/expected/html-form-controls-collection.txt
new file mode 100644
index 0000000000..1fcbce521a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/html-form-controls-collection.txt
@@ -0,0 +1,8 @@
+ HTMLFormControlsCollection
+RadioNodeList
+2
+button
+text
+null
+HTMLInputElement
+text
diff --git a/Tests/LibWeb/Text/input/html-form-controls-collection.html b/Tests/LibWeb/Text/input/html-form-controls-collection.html
new file mode 100644
index 0000000000..8e28c16c96
--- /dev/null
+++ b/Tests/LibWeb/Text/input/html-form-controls-collection.html
@@ -0,0 +1,24 @@
+
+
+
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
index 033509500f..89bc6de3ed 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp
@@ -11,6 +11,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -406,10 +407,10 @@ static bool is_form_control(DOM::Element const& element)
}
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-elements
-JS::NonnullGCPtr HTMLFormElement::elements() const
+JS::NonnullGCPtr HTMLFormElement::elements() const
{
if (!m_elements) {
- m_elements = DOM::HTMLCollection::create(const_cast(*this), DOM::HTMLCollection::Scope::Descendants, [](Element const& element) {
+ m_elements = DOM::HTMLFormControlsCollection::create(const_cast(*this), DOM::HTMLCollection::Scope::Descendants, [](Element const& element) {
return is_form_control(element);
});
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h
index b91c91c970..204413a0f8 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h
@@ -67,7 +67,7 @@ public:
ErrorOr>> get_submittable_elements();
- JS::NonnullGCPtr elements() const;
+ JS::NonnullGCPtr elements() const;
unsigned length() const;
WebIDL::ExceptionOr check_validity();
@@ -110,7 +110,7 @@ private:
Vector> m_associated_elements;
- JS::GCPtr mutable m_elements;
+ JS::GCPtr mutable m_elements;
bool m_constructing_entry_list { false };
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl
index 6371af33e8..30b95985e9 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl
+++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl
@@ -1,4 +1,4 @@
-#import
+#import
#import
// https://html.spec.whatwg.org/multipage/semantics.html#htmlformelement
@@ -20,8 +20,7 @@ interface HTMLFormElement : HTMLElement {
boolean checkValidity();
boolean reportValidity();
- // FIXME: Should be a HTMLFormControlsCollection
- [SameObject] readonly attribute HTMLCollection elements;
+ [SameObject] readonly attribute HTMLFormControlsCollection elements;
readonly attribute unsigned long length;