mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
LibWeb/HTML: Update radio group when a checked radio button is connected
Corresponds to https://github.com/whatwg/html/pull/10917
This commit is contained in:
parent
01044cbf1f
commit
b6fc4ec892
Notes:
github-actions[bot]
2025-02-13 14:50:25 +00:00
Author: https://github.com/AtkinsSJ
Commit: b6fc4ec892
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3406
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/tcl3
1 changed files with 15 additions and 0 deletions
|
@ -1680,6 +1680,21 @@ void HTMLInputElement::clear_algorithm()
|
||||||
void HTMLInputElement::form_associated_element_was_inserted()
|
void HTMLInputElement::form_associated_element_was_inserted()
|
||||||
{
|
{
|
||||||
create_shadow_tree_if_needed();
|
create_shadow_tree_if_needed();
|
||||||
|
|
||||||
|
if (is_connected()) {
|
||||||
|
// 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:
|
||||||
|
// ...
|
||||||
|
// - The element becomes connected.
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLInputElement::form_associated_element_was_removed(DOM::Node*)
|
void HTMLInputElement::form_associated_element_was_removed(DOM::Node*)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue