Skip to content

Truly independent web browser

LibWeb: Test for select and option last in the editable subtree flag

Andreas Kling3dded6da4112
diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp
index 521a2f56f3b..bff6e1a1343 100644
--- a/Libraries/LibWeb/DOM/Node.cpp
+++ b/Libraries/LibWeb/DOM/Node.cpp
@@ -2335,10 +2335,6 @@ bool Node::recompute_editable_subtree_flag()
bool new_value;
if (is_document()) {
new_value = as<Document>(*this).design_mode_enabled_state();
- } else if (is<HTML::HTMLSelectElement>(*this) || is<HTML::HTMLOptGroupElement>(*this) || is<HTML::HTMLOptionElement>(*this)) {
- // INTEROP: Browsers do not let editing modify the content of select, optgroup and option elements, even if
- // they are in an editing host or have a contenteditable attribute. Their descendants are not editable.
- new_value = false;
} else if (auto const* html_element = as_if<HTML::HTMLElement>(*this)) {
auto state = html_element->content_editable_state();
if (state == HTML::ContentEditableState::True || state == HTML::ContentEditableState::PlaintextOnly)
@@ -2347,6 +2343,11 @@ bool Node::recompute_editable_subtree_flag()
new_value = false;
else
new_value = parent() && parent()->m_in_editable_subtree;
+
+ // INTEROP: Browsers do not let editing modify the content of select, optgroup and option elements, even if
+ // they are in an editing host or have a contenteditable attribute. Their descendants are not editable.
+ if (new_value && (is<HTML::HTMLSelectElement>(*this) || is<HTML::HTMLOptGroupElement>(*this) || is<HTML::HTMLOptionElement>(*this)))
+ new_value = false;
} else {
new_value = parent() && parent()->m_in_editable_subtree;
}