NodeList.cpp 785 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Bindings/NodeListPrototype.h>
  8. #include <LibWeb/DOM/Node.h>
  9. #include <LibWeb/DOM/NodeList.h>
  10. namespace Web::DOM {
  11. NodeList::NodeList(JS::Realm& realm)
  12. : PlatformObject(realm)
  13. {
  14. m_legacy_platform_object_flags = LegacyPlatformObjectFlags { .supports_indexed_properties = true };
  15. }
  16. NodeList::~NodeList() = default;
  17. void NodeList::initialize(JS::Realm& realm)
  18. {
  19. Base::initialize(realm);
  20. WEB_SET_PROTOTYPE_FOR_INTERFACE(NodeList);
  21. }
  22. Optional<JS::Value> NodeList::item_value(size_t index) const
  23. {
  24. auto* node = item(index);
  25. if (!node)
  26. return {};
  27. return const_cast<Node*>(node);
  28. }
  29. }