LibWeb: Add HTMLElement::is_content_editable()

This commit is contained in:
Aliaksandr Kalenik 2024-02-25 07:00:04 +01:00 committed by Andreas Kling
parent 934aa6af6a
commit e3c75d7b6f
Notes: sideshowbarker 2024-07-16 23:54:15 +09:00
5 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1 @@
true

View File

@ -0,0 +1,7 @@
<script src="../include.js"></script>
<div contenteditable="true" id="contenteditable"></div>
<script>
test(() => {
println(document.getElementById("contenteditable").isContentEditable);
});
</script>

View File

@ -98,6 +98,14 @@ bool HTMLElement::is_focusable() const
return m_content_editable_state == ContentEditableState::True;
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-iscontenteditable
bool HTMLElement::is_content_editable() const
{
// The isContentEditable IDL attribute, on getting, must return true if the element is either an editing host or
// editable, and false otherwise.
return is_editable();
}
StringView HTMLElement::content_editable() const
{
switch (m_content_editable_state) {

View File

@ -35,6 +35,7 @@ public:
virtual bool is_editable() const final;
virtual bool is_focusable() const override;
bool is_content_editable() const;
StringView content_editable() const;
WebIDL::ExceptionOr<void> set_content_editable(StringView);

View File

@ -53,7 +53,7 @@ HTMLElement includes HTMLOrSVGElement;
interface mixin ElementContentEditable {
[CEReactions] attribute DOMString contentEditable;
// FIXME: [CEReactions] attribute DOMString enterKeyHint;
// FIXME: readonly attribute boolean isContentEditable;
readonly attribute boolean isContentEditable;
// FIXME: [CEReactions] attribute DOMString inputMode;
};