mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +00:00
LibWeb: Convert HTMLCollection to use IDL special operations
This commit is contained in:
parent
41ae0c0216
commit
37347cbcb6
6 changed files with 72 additions and 42 deletions
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/HTMLCollectionWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapper.h>
|
||||
#include <LibWeb/Bindings/NodeWrapperFactory.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS::Value HTMLCollectionWrapper::internal_get(JS::PropertyName const& property_name, JS::Value receiver) const
|
||||
{
|
||||
if (property_name.is_symbol())
|
||||
return Base::internal_get(property_name, receiver);
|
||||
DOM::Element* item = nullptr;
|
||||
if (property_name.is_string())
|
||||
item = const_cast<DOM::HTMLCollection&>(impl()).named_item(property_name.to_string());
|
||||
else if (property_name.is_number())
|
||||
item = const_cast<DOM::HTMLCollection&>(impl()).item(property_name.as_number());
|
||||
if (!item)
|
||||
return Base::internal_get(property_name, receiver);
|
||||
return wrap(global_object(), *item);
|
||||
}
|
||||
|
||||
}
|
|
@ -56,6 +56,8 @@
|
|||
#include <LibWeb/Bindings/HTMLButtonElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLCanvasElementConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLCanvasElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLCollectionConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLCollectionPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLDListElementConstructor.h>
|
||||
#include <LibWeb/Bindings/HTMLDListElementPrototype.h>
|
||||
#include <LibWeb/Bindings/HTMLDataElementConstructor.h>
|
||||
|
@ -278,6 +280,7 @@
|
|||
ADD_WINDOW_OBJECT_INTERFACE(HTMLBRElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLButtonElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLCanvasElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLCollection) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLDataElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLDataListElement) \
|
||||
ADD_WINDOW_OBJECT_INTERFACE(HTMLDetailsElement) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue