LibWeb: Check for empty name in is_in_same_radio_button_group()

I missed this check in #18046 (though it was covered in one case
by an optimization).
This commit is contained in:
MacDue 2023-03-26 18:53:55 +01:00 committed by Linus Groh
parent 32653f34f9
commit 17d23590bf
Notes: sideshowbarker 2024-07-17 05:21:12 +09:00

View file

@ -794,6 +794,9 @@ void HTMLInputElement::form_associated_element_was_inserted()
// https://html.spec.whatwg.org/multipage/input.html#radio-button-group
static bool is_in_same_radio_button_group(HTML::HTMLInputElement const& a, HTML::HTMLInputElement const& b)
{
auto non_empty_equals = [](auto const& value_a, auto const& value_b) {
return !value_a.is_empty() && value_a == value_b;
};
// The radio button group that contains an input element a also contains all the
// other input elements b that fulfill all of the following conditions:
return (
@ -807,7 +810,7 @@ static bool is_in_same_radio_button_group(HTML::HTMLInputElement const& a, HTML:
// value of a's name attribute equals the value of b's name attribute.
&& a.has_attribute(HTML::AttributeNames::name)
&& b.has_attribute(HTML::AttributeNames::name)
&& a.name() == b.name());
&& non_empty_equals(a.name(), b.name()));
}
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)