NodeList.cpp 659 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/DOM/Node.h>
  8. #include <LibWeb/DOM/NodeList.h>
  9. namespace Web::DOM {
  10. NodeList::NodeList(JS::Realm& realm)
  11. : LegacyPlatformObject(Bindings::cached_web_prototype(realm, "NodeList"))
  12. {
  13. }
  14. NodeList::~NodeList() = default;
  15. JS::Value NodeList::item_value(size_t index) const
  16. {
  17. auto* node = item(index);
  18. if (!node)
  19. return JS::js_undefined();
  20. return const_cast<Node*>(node);
  21. }
  22. bool NodeList::is_supported_property_index(u32 index) const
  23. {
  24. return index < length();
  25. }
  26. }