mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-27 10:07:56 +00:00
LibWeb: Fix select element state update in three ways
1. We were not propagating selectedness updates from option to select if the option was inside an optgroup. 2. When two or more options were selected, we were always favoring the last one in tree order, instead of the last one that got checked. 3. We were neglecting to return in the `display size is 1` case when all elements were disabled. This was covered by some of the :has() selector tests. :^)
This commit is contained in:
committed by
Andreas Kling
parent
6dad8ea584
commit
6c75a93ec0
@@ -558,7 +558,7 @@ void HTMLSelectElement::update_inner_text_element()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#selectedness-setting-algorithm
|
||||
void HTMLSelectElement::update_selectedness()
|
||||
void HTMLSelectElement::update_selectedness(JS::GCPtr<HTML::HTMLOptionElement> last_selected_option)
|
||||
{
|
||||
if (has_attribute(AttributeNames::multiple))
|
||||
return;
|
||||
@@ -581,9 +581,10 @@ void HTMLSelectElement::update_selectedness()
|
||||
if (!option_element->disabled()) {
|
||||
option_element->set_selected_internal(true);
|
||||
update_inner_text_element();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,6 +602,8 @@ void HTMLSelectElement::update_selectedness()
|
||||
// then set the selectedness of all but the last option element with its selectedness set to true
|
||||
// in the list of options in tree order to false.
|
||||
for (auto const& option_element : list_of_options()) {
|
||||
if (option_element == last_selected_option)
|
||||
continue;
|
||||
if (number_of_selected == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user