2022-09-01 11:30:26 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-09-01 11:30:26 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-25 19:15:49 -03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2026-04-18 05:54:06 -03:00
|
|
|
#include <LibWeb/Bindings/NodeList.h>
|
2022-09-01 11:30:26 -03:00
|
|
|
#include <LibWeb/DOM/Node.h>
|
|
|
|
|
#include <LibWeb/DOM/NodeList.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
2022-09-25 19:15:49 -03:00
|
|
|
NodeList::NodeList(JS::Realm& realm)
|
2024-01-09 20:05:03 -03:00
|
|
|
: PlatformObject(realm)
|
2022-09-01 11:30:26 -03:00
|
|
|
{
|
2024-01-09 20:05:03 -03:00
|
|
|
m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = true };
|
2022-09-01 11:30:26 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NodeList::~NodeList() = default;
|
|
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
void NodeList::initialize(JS::Realm& realm)
|
2023-01-10 08:56:59 -03:00
|
|
|
{
|
2024-03-16 09:13:08 -03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(NodeList);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2023-01-10 08:56:59 -03:00
|
|
|
}
|
|
|
|
|
|
2024-07-25 03:15:51 -03:00
|
|
|
Optional<JS::Value> NodeList::item_value(size_t index) const
|
2022-09-01 11:30:26 -03:00
|
|
|
{
|
|
|
|
|
auto* node = item(index);
|
|
|
|
|
if (!node)
|
2024-07-25 03:15:51 -03:00
|
|
|
return {};
|
2022-09-01 11:30:26 -03:00
|
|
|
return const_cast<Node*>(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|