/* * Copyright (c) 2025-2026, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::DOM { class ElementByIdMap { public: void add(FlyString const& element_id, Element&); void remove(FlyString const& element_id, Element&); GC::Ptr get(FlyString const& element_id, Node const& scope_root) const; void for_each_element_with_id(StringView element_id, Node const& scope_root, Function callback) const; template void for_each_id(Callback callback) { for (auto const& id : m_map.keys()) callback(id); } private: struct MapEntry { GC::Weak cached_first_element; Vector> elements; }; mutable HashMap m_map; }; }