mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-06 00:51:51 +00:00
LibWeb/HTML: Signal a type change
Type changes are now signaled to radio buttons. This causes other radio buttons in the group to be unchecked if the input element is a checked radio button after the type change.
This commit is contained in:
parent
5f75558646
commit
d4076ec9fa
Notes:
github-actions[bot]
2025-04-23 06:21:06 +00:00
Author: https://github.com/skyz1
Commit: d4076ec9fa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4410
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 44 additions and 1 deletions
|
@ -1456,7 +1456,8 @@ void HTMLInputElement::type_attribute_changed(TypeAttributeState old_state, Type
|
|||
set_shadow_root(nullptr);
|
||||
create_shadow_tree_if_needed();
|
||||
|
||||
// FIXME: 5. Signal a type change for the element. (The Radio Button state uses this, in particular.)
|
||||
// 5. Signal a type change for the element. (The Radio Button state uses this, in particular.)
|
||||
signal_a_type_change();
|
||||
|
||||
// 6. Invoke the value sanitization algorithm, if one is defined for the type attribute's new state.
|
||||
m_value = value_sanitization_algorithm(m_value);
|
||||
|
@ -1475,6 +1476,23 @@ void HTMLInputElement::type_attribute_changed(TypeAttributeState old_state, Type
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio):signal-a-type-change
|
||||
void HTMLInputElement::signal_a_type_change()
|
||||
{
|
||||
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)
|
||||
// When any of the following phenomena occur, if the element's checkedness state is true after the occurrence,
|
||||
// the checkedness state of all the other elements in the same radio button group must be set to false:
|
||||
// ...
|
||||
// - A type change is signalled for the element.
|
||||
if (type_state() == TypeAttributeState::RadioButton && checked()) {
|
||||
root().for_each_in_inclusive_subtree_of_type<HTMLInputElement>([&](auto& element) {
|
||||
if (element.checked() && &element != this && is_in_same_radio_button_group(*this, element))
|
||||
element.set_checked(false);
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#attr-input-src
|
||||
WebIDL::ExceptionOr<void> HTMLInputElement::handle_src_attribute(String const& value)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue