mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
LibWeb: Recreate the <input> shadow tree when the type attribute changes
This is often used on login forms, for example, to toggle the visibility of a password. The site will change the <input> element's type to "text" to allow the password to show.
This commit is contained in:
committed by
Andreas Kling
parent
06a3ca734e
commit
0e774fe780
Notes:
sideshowbarker
2024-07-17 01:46:43 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0e774fe780 Pull-request: https://github.com/SerenityOS/serenity/pull/23838
@@ -612,6 +612,14 @@ void HTMLInputElement::update_placeholder_visibility()
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLInputElement::update_text_input_shadow_tree()
|
||||
{
|
||||
if (m_text_node) {
|
||||
m_text_node->set_data(m_value);
|
||||
update_placeholder_visibility();
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:attr-input-readonly-3
|
||||
static bool is_allowed_to_be_readonly(HTML::HTMLInputElement::TypeAttributeState state)
|
||||
{
|
||||
@@ -746,6 +754,7 @@ void HTMLInputElement::update_shadow_tree()
|
||||
update_slider_thumb_element();
|
||||
break;
|
||||
default:
|
||||
update_text_input_shadow_tree();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1073,6 +1082,9 @@ void HTMLInputElement::form_associated_element_attribute_changed(FlyString const
|
||||
}
|
||||
} else if (name == HTML::AttributeNames::type) {
|
||||
m_type = parse_type_attribute(value.value_or(String {}));
|
||||
|
||||
set_shadow_root(nullptr);
|
||||
create_shadow_tree_if_needed();
|
||||
} else if (name == HTML::AttributeNames::value) {
|
||||
if (!m_dirty_value) {
|
||||
if (!value.has_value()) {
|
||||
@@ -1081,7 +1093,6 @@ void HTMLInputElement::form_associated_element_attribute_changed(FlyString const
|
||||
m_value = value_sanitization_algorithm(*value);
|
||||
}
|
||||
|
||||
update_placeholder_visibility();
|
||||
update_shadow_tree();
|
||||
}
|
||||
} else if (name == HTML::AttributeNames::placeholder) {
|
||||
|
||||
Reference in New Issue
Block a user