LibWeb/HTML: Correctly compute whether element is mutable

This adapts the implementation of `is_mutable` to align more closely
with the spec. Specifically, it is now also taken into account whether
the element is enabled.
This commit is contained in:
Glenn Skrzypczak 2025-08-10 00:29:35 +02:00 committed by Tim Flynn
commit cac2ee41b9
Notes: github-actions[bot] 2025-08-14 15:07:22 +00:00
10 changed files with 171 additions and 63 deletions

View file

@ -429,7 +429,7 @@ void HTMLSelectElement::show_the_picker_if_applicable()
return;
// 2. If element is not mutable, then return.
if (!enabled())
if (!is_mutable())
return;
// 3. Consume user activation given element's relevant global object.
@ -494,7 +494,7 @@ WebIDL::ExceptionOr<void> HTMLSelectElement::show_picker()
// The showPicker() method steps are:
// 1. If this is not mutable, then throw an "InvalidStateError" DOMException.
if (!enabled())
if (!is_mutable())
return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_utf16);
// 2. If this's relevant settings object's origin is not same origin with this's relevant settings object's top-level origin,
@ -740,4 +740,11 @@ bool HTMLSelectElement::suffering_from_being_missing() const
return has_attribute(HTML::AttributeNames::required) && (selected_options->length() == 0 || (selected_options->length() == 1 && selected_options->item(0) == placeholder_label_option()));
}
// https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element:concept-fe-mutable
bool HTMLSelectElement::is_mutable() const
{
// A select element that is not disabled is mutable.
return enabled();
}
}