LibWeb/HTML: Avoid double lookup of size attribute

This commit is contained in:
Shannon Booth 2025-01-27 12:08:36 +13:00 committed by Andrew Kaster
parent 319b447fdd
commit c647ac407d
Notes: github-actions[bot] 2025-01-30 20:57:15 +00:00

View file

@ -297,11 +297,9 @@ Optional<ARIA::Role> HTMLSelectElement::default_role() const
// https://www.w3.org/TR/html-aria/#el-select-multiple-or-size-greater-1
if (has_attribute(AttributeNames::multiple))
return ARIA::Role::listbox;
if (has_attribute(AttributeNames::size)) {
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
if (auto size = size_string->to_number<int>(); size.has_value() && *size > 1)
return ARIA::Role::listbox;
}
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
if (auto size = size_string->to_number<int>(); size.has_value() && *size > 1)
return ARIA::Role::listbox;
}
// https://www.w3.org/TR/html-aria/#el-select
return ARIA::Role::combobox;