mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
LibWeb: Set the first added <option> element under <select> as selected
This commit is contained in:
committed by
Andreas Kling
parent
d1a7caa35d
commit
afb2e063b7
@@ -133,7 +133,16 @@ HTMLOptionElement* HTMLSelectElement::named_item(FlyString const& name)
|
||||
WebIDL::ExceptionOr<void> HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before)
|
||||
{
|
||||
// Similarly, the add(element, before) method must act like its namesake method on that same options collection.
|
||||
return const_cast<HTMLOptionsCollection&>(*options()).add(move(element), move(before));
|
||||
TRY(const_cast<HTMLOptionsCollection&>(*options()).add(move(element), move(before)));
|
||||
|
||||
// If the inserted element is the first and only element, mark it as selected
|
||||
auto options = list_of_options();
|
||||
if (options.size() == 1) {
|
||||
options.at(0)->set_selected(true);
|
||||
update_inner_text_element();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-remove
|
||||
|
||||
Reference in New Issue
Block a user