1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 20:32:12 +00:00

LibWeb: Fix incompatibility of attribute "contenteditable"

The previous behavior of mapping a missing value to the "inherit"
state is incompatible. Now, a missing value maps to the "true" state,
which is the expected behavior.
This commit is contained in:
SeekingBlues 2021-07-28 22:07:58 +08:00 committed by Andreas Kling
parent 3cfb1787b8
commit a13a5315a5

View file

@ -33,13 +33,13 @@ HTMLElement::~HTMLElement()
HTMLElement::ContentEditableState HTMLElement::content_editable_state() const
{
auto contenteditable = attribute(HTML::AttributeNames::contenteditable);
// "true" and the empty string map to the "true" state.
if ((!contenteditable.is_null() && contenteditable.is_empty()) || contenteditable.equals_ignoring_case("true"))
// "true", an empty string or a missing value map to the "true" state.
if (contenteditable.is_empty() || contenteditable.equals_ignoring_case("true"))
return ContentEditableState::True;
// "false" maps to the "false" state.
if (contenteditable.equals_ignoring_case("false"))
return ContentEditableState::False;
// "inherit", an invalid value, and a missing value all map to the "inherit" state.
// An invalid value maps to the "inherit" state.
return ContentEditableState::Inherit;
}