ladybird/Userland/Libraries/LibWeb/DOM/NodeList.cpp

42 lines
872 B
C++
Raw Normal View History

2022-09-01 16:30:26 +02:00
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/Intrinsics.h>
2022-09-01 16:30:26 +02:00
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/NodeList.h>
namespace Web::DOM {
NodeList::NodeList(JS::Realm& realm)
: LegacyPlatformObject(realm)
2022-09-01 16:30:26 +02:00
{
}
NodeList::~NodeList() = default;
JS::ThrowCompletionOr<void> NodeList::initialize(JS::Realm& realm)
{
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::NodeListPrototype>(realm, "NodeList"));
return {};
}
WebIDL::ExceptionOr<JS::Value> NodeList::item_value(size_t index) const
2022-09-01 16:30:26 +02:00
{
auto* node = item(index);
if (!node)
return JS::js_undefined();
return const_cast<Node*>(node);
}
bool NodeList::is_supported_property_index(u32 index) const
{
return index < length();
}
}