diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
index 5309fe81b7..4965e1f927 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, The SerenityOS developers.
+ * Copyright (c) 2021, Andreas Kling
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include
#include
namespace Web::HTML {
@@ -37,4 +39,14 @@ HTMLSelectElement::~HTMLSelectElement()
{
}
+void HTMLSelectElement::inserted()
+{
+ set_form(first_ancestor_of_type());
+}
+
+void HTMLSelectElement::removed_from(DOM::Node*)
+{
+ set_form(nullptr);
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
index 12253be324..1ca77511ff 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, The SerenityOS developers.
+ * Copyright (c) 2021, Andreas Kling
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,16 +27,23 @@
#pragma once
+#include
#include
namespace Web::HTML {
-class HTMLSelectElement final : public HTMLElement {
+class HTMLSelectElement final
+ : public HTMLElement
+ , public FormAssociatedElement {
public:
using WrapperType = Bindings::HTMLSelectElementWrapper;
HTMLSelectElement(DOM::Document&, QualifiedName);
virtual ~HTMLSelectElement() override;
+
+private:
+ virtual void inserted() override;
+ virtual void removed_from(DOM::Node*) override;
};
}