Skip to content

Commit 8ca4833

Browse files
AtkinsSJgmta
authored andcommitted
LibWeb/HTML: Update spec text in create_element_for()
No behaviour changes.
1 parent 6e2f816 commit 8ca4833

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -790,25 +790,26 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins
790790
// https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
791791
GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Optional<FlyString> const& namespace_, DOM::Node& intended_parent)
792792
{
793-
// FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
794-
// FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
793+
// FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, token's tag name, and token's attributes.
794+
// FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, token's tag name, and token's attributes.
795795

796-
// 3. Let document be intended parent's node document.
796+
// 3. Let document be intendedParent's node document.
797797
GC::Ref<DOM::Document> document = intended_parent.document();
798798

799-
// 4. Let local name be the tag name of the token.
799+
// 4. Let localName be token's tag name.
800800
auto const& local_name = token.tag_name();
801801

802-
// 5. Let is be the value of the "is" attribute in the given token, if such an attribute exists, or null otherwise.
802+
// 5. Let is be the value of the "is" attribute in token, if such an attribute exists; otherwise null.
803803
auto is_value = token.attribute(AttributeNames::is);
804804

805-
// 6. Let definition be the result of looking up a custom element definition given document, given namespace, local name, and is.
805+
// FIXME: 6. Let registry be the result of looking up a custom element registry given intendedParent.
806+
// 7. Let definition be the result of looking up a custom element definition given registry, namespace, localName, and is.
806807
auto definition = document->lookup_custom_element_definition(namespace_, local_name, is_value);
807808

808-
// 7. Let willExecuteScript be true if definition is non-null and the parser was not created as part of the HTML fragment parsing algorithm; otherwise false.
809+
// 8. Let willExecuteScript be true if definition is non-null and the parser was not created as part of the HTML fragment parsing algorithm; otherwise false.
809810
bool will_execute_script = definition && !m_parsing_fragment;
810811

811-
// 8. If willExecuteScript is true:
812+
// 9. If willExecuteScript is true:
812813
if (will_execute_script) {
813814
// 1. Increment document's throw-on-dynamic-markup-insertion counter.
814815
document->increment_throw_on_dynamic_markup_insertion_counter({});
@@ -822,7 +823,8 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
822823
relevant_similar_origin_window_agent(document).custom_element_reactions_stack.element_queue_stack.append({});
823824
}
824825

825-
// 9. Let element be the result of creating an element given document, localName, given namespace, null, is, and willExecuteScript.
826+
// 10. Let element be the result of creating an element given document, localName, namespace, null, is, willExecuteScript, and registry.
827+
// FIXME: and registry.
826828
auto element = create_element(*document, local_name, namespace_, {}, is_value, will_execute_script).release_value_but_fixme_should_propagate_errors();
827829

828830
// AD-HOC: See AD-HOC comment on Element.m_had_duplicate_attribute_during_tokenization about why this is done.
@@ -838,7 +840,7 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
838840
link_element.set_was_enabled_when_created_by_parser({}, !token.has_attribute(HTML::AttributeNames::disabled));
839841
}
840842

841-
// 10. Append each attribute in the given token to element.
843+
// 11. Append each attribute in the given token to element.
842844
token.for_each_attribute([&](auto const& attribute) {
843845
DOM::QualifiedName qualified_name { attribute.local_name, attribute.prefix, attribute.namespace_ };
844846
auto dom_attribute = realm().create<DOM::Attr>(*document, move(qualified_name), attribute.value, element);
@@ -857,9 +859,10 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
857859
}
858860
}
859861

860-
// 11. If willExecuteScript is true:
862+
// 12. If willExecuteScript is true:
861863
if (will_execute_script) {
862-
// 1. Let queue be the result of popping from document's relevant agent's custom element reactions stack. (This will be the same element queue as was pushed above.)
864+
// 1. Let queue be the result of popping from document's relevant agent's custom element reactions stack.
865+
// (This will be the same element queue as was pushed above.)
863866
auto queue = relevant_similar_origin_window_agent(document).custom_element_reactions_stack.element_queue_stack.take_last();
864867

865868
// 2. Invoke custom element reactions in queue.
@@ -869,14 +872,16 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
869872
document->decrement_throw_on_dynamic_markup_insertion_counter({});
870873
}
871874

872-
// FIXME: 12. If element has an xmlns attribute in the XMLNS namespace whose value is not exactly the same as the element's namespace, that is a parse error.
875+
// FIXME: 13. If element has an xmlns attribute in the XMLNS namespace whose value is not exactly the same as the element's namespace, that is a parse error.
873876
// Similarly, if element has an xmlns:xlink attribute in the XMLNS namespace whose value is not the XLink Namespace, that is a parse error.
874877

875-
// FIXME: 13. If element is a resettable element and not a form-associated custom element, then invoke its reset algorithm. (This initializes the element's value and checkedness based on the element's attributes.)
878+
// FIXME: 14. If element is a resettable element and not a form-associated custom element, then invoke its reset algorithm. (This initializes the element's value and checkedness based on the element's attributes.)
876879

877-
// 14. If element is a form-associated element and not a form-associated custom element, the form element pointer is not null, there is no template element on the stack of open elements,
878-
// element is either not listed or doesn't have a form attribute, and the intended parent is in the same tree as the element pointed to by the form element pointer,
879-
// then associate element with the form element pointed to by the form element pointer and set element's parser inserted flag.
880+
// 15. If element is a form-associated element and not a form-associated custom element, the form element pointer
881+
// is not null, there is no template element on the stack of open elements, element is either not listed or
882+
// doesn't have a form attribute, and the intendedParent is in the same tree as the element pointed to by the
883+
// form element pointer, then associate element with the form element pointed to by the form element pointer
884+
// and set element's parser inserted flag.
880885
// FIXME: Check if the element is not a form-associated custom element.
881886
if (auto* form_associated_element = as_if<FormAssociatedElement>(*element)) {
882887
auto& html_element = form_associated_element->form_associated_element_to_html_element();
@@ -890,7 +895,7 @@ GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Opt
890895
}
891896
}
892897

893-
// 15. Return element.
898+
// 16. Return element.
894899
return element;
895900
}
896901

0 commit comments

Comments
 (0)