mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 15:19:16 +00:00
LibWeb: Add select and options collection remove method
This commit is contained in:
parent
5decf4b33c
commit
7372c01786
Notes:
sideshowbarker
2024-07-17 14:36:19 +09:00
Author: https://github.com/bplaat
Commit: 7372c01786
Pull-request: https://github.com/SerenityOS/serenity/pull/23895
Reviewed-by: https://github.com/shannonbooth
8 changed files with 62 additions and 3 deletions
|
@ -111,6 +111,24 @@ WebIDL::ExceptionOr<void> HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement
|
|||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-htmloptionscollection-remove
|
||||
void HTMLOptionsCollection::remove(WebIDL::Long index)
|
||||
{
|
||||
// 1. If the number of nodes represented by the collection is zero, return.
|
||||
if (length() == 0)
|
||||
return;
|
||||
|
||||
// 2. If index is not a number greater than or equal to 0 and less than the number of nodes represented by the collection, return.
|
||||
if (index < 0 || static_cast<WebIDL::UnsignedLong>(index) >= length())
|
||||
return;
|
||||
|
||||
// 3. Let element be the indexth element in the collection.
|
||||
auto* element = this->item(index);
|
||||
|
||||
// 4. Remove element from its parent node.
|
||||
element->remove();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-htmloptionscollection-selectedindex
|
||||
WebIDL::Long HTMLOptionsCollection::selected_index() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue