diff --git a/Tests/LibWeb/Text/expected/DOM/DOMStringMap-setter-with-invalid-name.txt b/Tests/LibWeb/Text/expected/DOM/DOMStringMap-setter-with-invalid-name.txt
new file mode 100644
index 00000000000..05600d9cef4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/DOM/DOMStringMap-setter-with-invalid-name.txt
@@ -0,0 +1 @@
+Setting DOMStringMap with an invalid name key throws? true
diff --git a/Tests/LibWeb/Text/input/DOM/DOMStringMap-setter-with-invalid-name.html b/Tests/LibWeb/Text/input/DOM/DOMStringMap-setter-with-invalid-name.html
new file mode 100644
index 00000000000..f5bd116db20
--- /dev/null
+++ b/Tests/LibWeb/Text/input/DOM/DOMStringMap-setter-with-invalid-name.html
@@ -0,0 +1,12 @@
+
+
diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp
index cea0e51cbc5..1c7532860d5 100644
--- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp
+++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp
@@ -165,7 +165,7 @@ WebIDL::ExceptionOr DOMStringMap::set_value_of_new_named_property(String c
// FIXME: 4. If name does not match the XML Name production, throw an "InvalidCharacterError" DOMException.
// 5. Set an attribute value for the DOMStringMap's associated element using name and value.
- MUST(m_associated_element->set_attribute(data_name, value));
+ TRY(m_associated_element->set_attribute(data_name, value));
return {};
}