Skip to content

Commit 7aef8c9

Browse files
committed
LibWeb: Match spec changes for "custom element registry" concept
Corresponds to whatwg/html#10845 and whatwg/html#10865
1 parent ce65457 commit 7aef8c9

File tree

4 files changed

+72
-73
lines changed

4 files changed

+72
-73
lines changed

Libraries/LibWeb/DOM/Document.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,31 +3156,31 @@ void Document::set_window(HTML::Window& window)
31563156
// https://html.spec.whatwg.org/multipage/custom-elements.html#look-up-a-custom-element-definition
31573157
GC::Ptr<HTML::CustomElementDefinition> Document::lookup_custom_element_definition(Optional<FlyString> const& namespace_, FlyString const& local_name, Optional<String> const& is) const
31583158
{
3159-
// 1. If namespace is not the HTML namespace, return null.
3159+
// 1. If namespace is not the HTML namespace, then return null.
31603160
if (namespace_ != Namespace::HTML)
31613161
return nullptr;
31623162

3163-
// 2. If document's browsing context is null, return null.
3163+
// 2. If document's browsing context is null, then return null.
31643164
if (!browsing_context())
31653165
return nullptr;
31663166

3167-
// 3. Let registry be document's relevant global object's CustomElementRegistry object.
3167+
// 3. Let registry be document's relevant global object's custom element registry.
31683168
auto registry = verify_cast<HTML::Window>(relevant_global_object(*this)).custom_elements();
31693169

3170-
// 4. If there is custom element definition in registry with name and local name both equal to localName, return that custom element definition.
3171-
auto converted_local_name = local_name;
3172-
auto maybe_definition = registry->get_definition_with_name_and_local_name(converted_local_name.to_string(), converted_local_name.to_string());
3170+
// 4. If registry's custom element definition set contains an item with name and local name both equal to localName, then return that item.
3171+
auto converted_local_name = local_name.to_string();
3172+
auto maybe_definition = registry->get_definition_with_name_and_local_name(converted_local_name, converted_local_name);
31733173
if (maybe_definition)
31743174
return maybe_definition;
31753175

3176-
// 5. If there is a custom element definition in registry with name equal to is and local name equal to localName, return that custom element definition.
3176+
// 5. If registry's custom element definition set contains an item with name equal to is and local name equal to localName, then return that item.
31773177
// 6. Return null.
31783178

31793179
// NOTE: If `is` has no value, it can never match as custom element definitions always have a name and localName (i.e. not stored as Optional<String>)
31803180
if (!is.has_value())
31813181
return nullptr;
31823182

3183-
return registry->get_definition_with_name_and_local_name(is.value(), converted_local_name.to_string());
3183+
return registry->get_definition_with_name_and_local_name(is.value(), converted_local_name);
31843184
}
31853185

31863186
CSS::StyleSheetList& Document::style_sheets()

0 commit comments

Comments
 (0)