diff --git a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp index 005f862272..614ad80b62 100644 --- a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp +++ b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp @@ -41,6 +41,8 @@ void CustomElementRegistry::visit_edges(Visitor& visitor) Base::visit_edges(visitor); for (auto& definition : m_custom_element_definitions) visitor.visit(definition); + for (auto& [name, promise] : m_when_defined_promise_map) + visitor.visit(promise); } // https://webidl.spec.whatwg.org/#es-callback-function @@ -310,7 +312,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We auto promise_when_defined_iterator = m_when_defined_promise_map.find(name); if (promise_when_defined_iterator != m_when_defined_promise_map.end()) { // 1. Let promise be the value of that entry. - auto* promise = promise_when_defined_iterator->value.cell(); + auto promise = promise_when_defined_iterator->value; // 2. Resolve promise with constructor. promise->fulfill(constructor->callback); @@ -369,10 +371,10 @@ WebIDL::ExceptionOr> CustomElementRegistry::when_d auto existing_promise_iterator = m_when_defined_promise_map.find(name); if (existing_promise_iterator != m_when_defined_promise_map.end()) { - promise = existing_promise_iterator->value.cell(); + promise = existing_promise_iterator->value; } else { promise = JS::Promise::create(realm); - m_when_defined_promise_map.set(name, JS::make_handle(promise)); + m_when_defined_promise_map.set(name, *promise); } // 5. Return promise. diff --git a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.h b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.h index 3271429728..6ac0ed9022 100644 --- a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.h +++ b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.h @@ -47,7 +47,7 @@ private: // https://html.spec.whatwg.org/multipage/custom-elements.html#when-defined-promise-map // Every CustomElementRegistry also has a when-defined promise map, mapping valid custom element names to promises. It is used to implement the whenDefined() method. - OrderedHashMap> m_when_defined_promise_map; + OrderedHashMap> m_when_defined_promise_map; }; }