mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 06:59:47 +00:00
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:
parent
1228063a85
commit
cac2ee41b9
Notes:
github-actions[bot]
2025-08-14 15:07:22 +00:00
Author: https://github.com/skyz1
Commit: cac2ee41b9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5812
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/trflynn89
10 changed files with 171 additions and 63 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue