LibWeb/HTML: Check all radio buttons in group for required attribute

This fixes a bug in the algorithm for determining if radio buttons are
missing their value. Previously it was only checked if the button
itself is required. Now the algorithm checks if the radio button group
contains a required radio button in order to determine if the value is
required.
This commit is contained in:
Glenn Skrzypczak 2025-08-17 16:46:45 +02:00 committed by Jelle Raaijmakers
commit c01dc5900a
Notes: github-actions[bot] 2025-08-17 20:28:15 +00:00
2 changed files with 5 additions and 5 deletions

View file

@ -7,6 +7,7 @@
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
* Copyright (c) 2024, Fernando Kiotheka <fer@k6a.dev>
* Copyright (c) 2025, Felipe Muñoz Mazur <felipe.munoz.mazur@protonmail.com>
* Copyright (c) 2025, Glenn Skrzypczak <glenn.skrzypczak@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -3323,7 +3324,7 @@ bool HTMLInputElement::suffering_from_being_missing() const
if (is_in_same_radio_button_group(*this, element)) {
if (element.checked())
has_checkedness_false_for_all_elements_in_group = false;
if (has_attribute(HTML::AttributeNames::required))
if (element.has_attribute(HTML::AttributeNames::required))
has_required_element_in_group = true;
}
return TraversalDecision::Continue;

View file

@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
4 Pass
2 Fail
6 Pass
Pass The required attribute is not set
Fail One of the radios is required, but none checked
Pass One of the radios is required, but none checked
Pass One of the radios is required and checked
Pass One of the radios is required and another one is checked
Fail One of the radios is required and disabled, but none checked
Pass One of the radios is required and disabled, but none checked
Pass One of the radios is required, checked and disabled