LibWeb: Make select element use option's label, not text content

This commit is contained in:
Psychpsyo 2024-11-16 22:14:42 +01:00 committed by Sam Atkins
parent 8c4e4ec31b
commit 8f11dfc08a
Notes: github-actions[bot] 2025-01-04 11:45:06 +00:00
5 changed files with 28 additions and 4 deletions

View file

@ -114,6 +114,13 @@ String HTMLOptionElement::label() const
void HTMLOptionElement::set_label(String const& label)
{
MUST(set_attribute(HTML::AttributeNames::label, label));
// NOTE: This option's select element may need to show different contents now.
if (selected()) {
if (auto select_element = first_ancestor_of_type<HTMLSelectElement>()) {
select_element->update_inner_text_element({});
}
}
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-option-text