mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Set the first added <option> element under <select> as selected
This commit is contained in:
parent
d1a7caa35d
commit
afb2e063b7
Notes:
github-actions[bot]
2024-07-25 14:59:20 +00:00
Author: https://github.com/TSultanov Commit: https://github.com/LadybirdBrowser/ladybird/commit/afb2e063b7c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/812
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue