mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibWeb: Match spec changes for "custom element registry" concept
Corresponds to https://github.com/whatwg/html/pull/10845 and https://github.com/whatwg/html/pull/10865
This commit is contained in:
parent
97768d8927
commit
5651c6fd9b
Notes:
github-actions[bot]
2024-12-18 19:24:00 +00:00
Author: https://github.com/AtkinsSJ
Commit: 5651c6fd9b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2967
4 changed files with 72 additions and 73 deletions
|
@ -3156,31 +3156,31 @@ void Document::set_window(HTML::Window& window)
|
|||
// https://html.spec.whatwg.org/multipage/custom-elements.html#look-up-a-custom-element-definition
|
||||
GC::Ptr<HTML::CustomElementDefinition> Document::lookup_custom_element_definition(Optional<FlyString> const& namespace_, FlyString const& local_name, Optional<String> const& is) const
|
||||
{
|
||||
// 1. If namespace is not the HTML namespace, return null.
|
||||
// 1. If namespace is not the HTML namespace, then return null.
|
||||
if (namespace_ != Namespace::HTML)
|
||||
return nullptr;
|
||||
|
||||
// 2. If document's browsing context is null, return null.
|
||||
// 2. If document's browsing context is null, then return null.
|
||||
if (!browsing_context())
|
||||
return nullptr;
|
||||
|
||||
// 3. Let registry be document's relevant global object's CustomElementRegistry object.
|
||||
// 3. Let registry be document's relevant global object's custom element registry.
|
||||
auto registry = verify_cast<HTML::Window>(relevant_global_object(*this)).custom_elements();
|
||||
|
||||
// 4. If there is custom element definition in registry with name and local name both equal to localName, return that custom element definition.
|
||||
auto converted_local_name = local_name;
|
||||
auto maybe_definition = registry->get_definition_with_name_and_local_name(converted_local_name.to_string(), converted_local_name.to_string());
|
||||
// 4. If registry's custom element definition set contains an item with name and local name both equal to localName, then return that item.
|
||||
auto converted_local_name = local_name.to_string();
|
||||
auto maybe_definition = registry->get_definition_with_name_and_local_name(converted_local_name, converted_local_name);
|
||||
if (maybe_definition)
|
||||
return maybe_definition;
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
// 6. Return null.
|
||||
|
||||
// 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>)
|
||||
if (!is.has_value())
|
||||
return nullptr;
|
||||
|
||||
return registry->get_definition_with_name_and_local_name(is.value(), converted_local_name.to_string());
|
||||
return registry->get_definition_with_name_and_local_name(is.value(), converted_local_name);
|
||||
}
|
||||
|
||||
CSS::StyleSheetList& Document::style_sheets()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue