diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
index c2dbce6bdd..36fff8b52c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
@@ -28,8 +28,10 @@
#include
#include
#include
+#include
#include
#include
+#include
#include
#include
#include
@@ -89,21 +91,22 @@ String HTMLElement::content_editable() const
}
}
-void HTMLElement::set_content_editable(const String& content_editable)
+// https://html.spec.whatwg.org/multipage/interaction.html#contenteditable
+DOM::ExceptionOr HTMLElement::set_content_editable(const String& content_editable)
{
if (content_editable.equals_ignoring_case("inherit")) {
remove_attribute(HTML::AttributeNames::contenteditable);
- return;
+ return {};
}
if (content_editable.equals_ignoring_case("true")) {
set_attribute(HTML::AttributeNames::contenteditable, "true");
- return;
+ return {};
}
if (content_editable.equals_ignoring_case("false")) {
set_attribute(HTML::AttributeNames::contenteditable, "false");
- return;
+ return {};
}
- // FIXME: otherwise the attribute setter must throw a "SyntaxError" DOMException.
+ return DOM::SyntaxError::create("Invalid contentEditable value, must be 'true', 'false', or 'inherit'");
}
void HTMLElement::set_inner_text(StringView text)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
index af6fa8cdbe..f498d6c781 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h
@@ -45,7 +45,7 @@ public:
virtual bool is_editable() const final;
String content_editable() const;
- void set_content_editable(const String&);
+ DOM::ExceptionOr set_content_editable(const String&);
String inner_text();
void set_inner_text(StringView);