1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:47:34 +00:00

LibWeb: Add stub implementation of HTMLOptionsCollection

This is a subtype of `DOM::HTMLCollection` that only holds
`HTMLOptionElement`s. In this stub implementation only `item`,
`namedItem` and `length`, inherited from HTMLCollection, are exposed.
This is good enough for applications that only read the collection.
This commit is contained in:
Simon Wanner 2022-03-16 12:58:28 +01:00 committed by Andreas Kling
parent 6f4dde253f
commit 624527f15e
6 changed files with 67 additions and 0 deletions

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/HTML/HTMLOptionsCollection.h>
namespace Web::HTML {
HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
: DOM::HTMLCollection(root, move(filter))
{
}
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/DOM/HTMLCollection.h>
namespace Web::HTML {
class HTMLOptionsCollection final : public DOM::HTMLCollection {
public:
using WrapperType = Bindings::HTMLOptionsCollectionWrapper;
static NonnullRefPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
{
return adopt_ref(*new HTMLOptionsCollection(root, move(filter)));
}
protected:
HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
};
}
namespace Web::Bindings {
HTMLOptionsCollectionWrapper* wrap(JS::GlobalObject&, HTML::HTMLOptionsCollection&);
}

View file

@ -0,0 +1,12 @@
#import <DOM/HTMLCollection.idl>
#import <HTML/HTMLOptionElement.idl>
#import <HTML/HTMLOptGroupElement.idl>
[Exposed=Window]
interface HTMLOptionsCollection : HTMLCollection {
// [CEReactions] attribute unsigned long length; // shadows inherited length
// [CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option);
// [CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
// [CEReactions] undefined remove(long index);
// attribute long selectedIndex;
};