From 06ccc451577cc3f55bd10ce4c88f9fdf471e5129 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Mar 2022 00:25:28 +0100 Subject: [PATCH] LibWeb: Don't create HTMLInputElement's UA shadow tree for buttons We don't need an internal editable text node inside buttons. :^) --- .../Libraries/LibWeb/HTML/HTMLInputElement.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 27066a9544..333cde11d6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -159,7 +159,19 @@ void HTMLInputElement::create_shadow_tree_if_needed() if (shadow_root()) return; - // FIXME: This assumes that we want a text box. Is that always true? + // FIXME: This could be better factored. Everything except the below types becomes a text input. + switch (type_state()) { + case TypeAttributeState::RadioButton: + case TypeAttributeState::Checkbox: + case TypeAttributeState::Button: + case TypeAttributeState::SubmitButton: + case TypeAttributeState::ResetButton: + case TypeAttributeState::ImageButton: + return; + default: + break; + } + auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this)); auto initial_value = attribute(HTML::AttributeNames::value); if (initial_value.is_null())