diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
index 87fdf1ac5df..d4854f24030 100644
--- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
@@ -574,6 +574,16 @@ void HTMLSelectElement::form_associated_element_was_inserted()
create_shadow_tree_if_needed();
}
+void HTMLSelectElement::form_associated_element_attribute_changed(FlyString const& name, Optional const& value, Optional const&)
+{
+ if (name == HTML::AttributeNames::multiple) {
+ // If the multiple attribute is absent then update the selectedness of the option elements.
+ if (!value.has_value()) {
+ update_selectedness();
+ }
+ }
+}
+
void HTMLSelectElement::computed_properties_changed()
{
// Hide chevron icon when appearance is none
diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Libraries/LibWeb/HTML/HTMLSelectElement.h
index f43abea356a..8f7aad95e65 100644
--- a/Libraries/LibWeb/HTML/HTMLSelectElement.h
+++ b/Libraries/LibWeb/HTML/HTMLSelectElement.h
@@ -98,6 +98,7 @@ public:
virtual void activation_behavior(DOM::Event const&) override;
virtual void form_associated_element_was_inserted() override;
+ virtual void form_associated_element_attribute_changed(FlyString const&, Optional const&, Optional const&) override;
void did_select_item(Optional const& id);
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-select-element/select-multiple.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-select-element/select-multiple.txt
index 96371cc2c98..ab20a8330e2 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-select-element/select-multiple.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/forms/the-select-element/select-multiple.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 3 tests
-2 Pass
-1 Fail
+3 Pass
Pass multiple selected options exist, both set from markup
Pass multiple selected options exist, one set from script
-Fail Removing multiple attribute reduces the number of selected OPTIONs to 1
\ No newline at end of file
+Pass Removing multiple attribute reduces the number of selected OPTIONs to 1
\ No newline at end of file