1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:18:12 +00:00

LibWeb: Make NodeList GC-allocated

This commit is contained in:
Andreas Kling 2022-09-01 16:30:26 +02:00
parent 8f4ea4e308
commit 48e0066371
16 changed files with 128 additions and 57 deletions

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/NodeListPrototype.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/NodeList.h>
#include <LibWeb/HTML/Window.h>
namespace Web::DOM {
NodeList::NodeList(HTML::Window& window)
: LegacyPlatformObject(window.ensure_web_prototype<Bindings::NodeListPrototype>("NodeList"))
{
}
NodeList::~NodeList() = default;
JS::Value NodeList::item_value(size_t index) const
{
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();
}
}