summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-02-20 00:43:08 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-20 09:14:19 +0100
commit4e1de093407ff07d7783c939cb0a99004179d0e2 (patch)
tree2868a7b50b676c11bac41be76e05615cbfe0ab3f /Userland/Libraries/LibWeb/HTML/HTMLElement.cpp
parentdd621cc6503d97e8759dab24ed22606e23314b27 (diff)
downloadserenity-4e1de093407ff07d7783c939cb0a99004179d0e2.zip
LibWeb: Use DOMException in HTMLElement::set_content_editable()
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLElement.cpp13
1 files changed, 8 insertions, 5 deletions
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 <LibJS/Interpreter.h>
#include <LibJS/Parser.h>
#include <LibJS/Runtime/ScriptFunction.h>
+#include <LibWeb/DOM/DOMException.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/EventListener.h>
+#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/HTML/HTMLElement.h>
@@ -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<void> 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)