mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-24 19:28:48 +00:00
LibWeb: Match spec changes to "create an element" algorithm
Corresponds to https://github.com/whatwg/html/pull/10857 No code changes, only comments.
This commit is contained in:
parent
aa29a3ff6b
commit
4c5a40579a
Notes:
github-actions[bot]
2024-12-18 19:23:42 +00:00
Author: https://github.com/AtkinsSJ
Commit: 4c5a40579a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2967
12 changed files with 25 additions and 25 deletions
|
@ -101,7 +101,8 @@ void Attr::handle_attribute_changes(Element& element, Optional<String> const& ol
|
|||
// 1. Queue a mutation record of "attributes" for element with attribute’s local name, attribute’s namespace, oldValue, « », « », null, and null.
|
||||
element.queue_mutation_record(MutationType::attributes, local_name(), namespace_uri(), old_value, {}, {}, nullptr, nullptr);
|
||||
|
||||
// 2. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback", and an argument list containing attribute’s local name, oldValue, newValue, and attribute’s namespace.
|
||||
// 2. If element is custom, then enqueue a custom element callback reaction with element, callback name "attributeChangedCallback",
|
||||
// and « attribute’s local name, oldValue, newValue, attribute’s namespace ».
|
||||
if (element.is_custom()) {
|
||||
auto& vm = this->vm();
|
||||
|
||||
|
|
|
@ -106,17 +106,17 @@ GC::Ref<Document> DOMImplementation::create_html_document(Optional<String> const
|
|||
doctype->set_name("html"_string);
|
||||
MUST(html_document->append_child(*doctype));
|
||||
|
||||
// 4. Append the result of creating an element given doc, html, and the HTML namespace, to doc.
|
||||
// 4. Append the result of creating an element given doc, "html", and the HTML namespace, to doc.
|
||||
auto html_element = create_element(html_document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(html_document->append_child(html_element));
|
||||
|
||||
// 5. Append the result of creating an element given doc, head, and the HTML namespace, to the html element created earlier.
|
||||
// 5. Append the result of creating an element given doc, "head", and the HTML namespace, to the html element created earlier.
|
||||
auto head_element = create_element(html_document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(html_element->append_child(head_element));
|
||||
|
||||
// 6. If title is given:
|
||||
if (title.has_value()) {
|
||||
// 1. Append the result of creating an element given doc, title, and the HTML namespace, to the head element created earlier.
|
||||
// 1. Append the result of creating an element given doc, "title", and the HTML namespace, to the head element created earlier.
|
||||
auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(head_element->append_child(title_element));
|
||||
|
||||
|
@ -125,7 +125,7 @@ GC::Ref<Document> DOMImplementation::create_html_document(Optional<String> const
|
|||
MUST(title_element->append_child(*text_node));
|
||||
}
|
||||
|
||||
// 7. Append the result of creating an element given doc, body, and the HTML namespace, to the html element created earlier.
|
||||
// 7. Append the result of creating an element given doc, "body", and the HTML namespace, to the html element created earlier.
|
||||
auto body_element = create_element(html_document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(html_element->append_child(body_element));
|
||||
|
||||
|
|
|
@ -442,13 +442,13 @@ void Document::initialize(JS::Realm& realm)
|
|||
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#populate-with-html/head/body
|
||||
WebIDL::ExceptionOr<void> Document::populate_with_html_head_and_body()
|
||||
{
|
||||
// 1. Let html be the result of creating an element given document, html, and the HTML namespace.
|
||||
// 1. Let html be the result of creating an element given document, "html", and the HTML namespace.
|
||||
auto html = TRY(DOM::create_element(*this, HTML::TagNames::html, Namespace::HTML));
|
||||
|
||||
// 2. Let head be the result of creating an element given document, head, and the HTML namespace.
|
||||
// 2. Let head be the result of creating an element given document, "head", and the HTML namespace.
|
||||
auto head = TRY(DOM::create_element(*this, HTML::TagNames::head, Namespace::HTML));
|
||||
|
||||
// 3. Let body be the result of creating an element given document, body, and the HTML namespace.
|
||||
// 3. Let body be the result of creating an element given document, "body", and the HTML namespace.
|
||||
auto body = TRY(DOM::create_element(*this, HTML::TagNames::body, Namespace::HTML));
|
||||
|
||||
// 4. Append html to document.
|
||||
|
@ -930,7 +930,7 @@ WebIDL::ExceptionOr<void> Document::set_title(String const& title)
|
|||
}
|
||||
// 2. Otherwise:
|
||||
else {
|
||||
// 1. Let element be the result of creating an element given the document element's node document, title,
|
||||
// 1. Let element be the result of creating an element given the document element's node document, "title",
|
||||
// and the SVG namespace.
|
||||
element = TRY(DOM::create_element(*this, HTML::TagNames::title, Namespace::SVG));
|
||||
|
||||
|
@ -959,7 +959,7 @@ WebIDL::ExceptionOr<void> Document::set_title(String const& title)
|
|||
}
|
||||
// 3. Otherwise:
|
||||
else {
|
||||
// 1. Let element be the result of creating an element given the document element's node document, title,
|
||||
// 1. Let element be the result of creating an element given the document element's node document, "title",
|
||||
// and the HTML namespace.
|
||||
element = TRY(DOM::create_element(*this, HTML::TagNames::title, Namespace::HTML));
|
||||
|
||||
|
|
|
@ -1520,7 +1520,7 @@ WebIDL::ExceptionOr<void> Element::set_outer_html(String const& value)
|
|||
if (parent->is_document())
|
||||
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot set outer HTML on document"_string);
|
||||
|
||||
// 5. If parent is a DocumentFragment, set parent to the result of creating an element given this's node document, body, and the HTML namespace.
|
||||
// 5. If parent is a DocumentFragment, set parent to the result of creating an element given this's node document, "body", and the HTML namespace.
|
||||
if (parent->is_document_fragment())
|
||||
parent = TRY(create_element(document(), HTML::TagNames::body, Namespace::HTML));
|
||||
|
||||
|
@ -2084,7 +2084,7 @@ JS::ThrowCompletionOr<void> Element::upgrade_element(GC::Ref<HTML::CustomElement
|
|||
set_custom_element_state(CustomElementState::Failed);
|
||||
|
||||
// 4. For each attribute in element's attribute list, in order, enqueue a custom element callback reaction with element, callback name "attributeChangedCallback",
|
||||
// and an argument list containing attribute's local name, null, attribute's value, and attribute's namespace.
|
||||
// and « attribute's local name, null, attribute's value, attribute's namespace ».
|
||||
for (size_t attribute_index = 0; attribute_index < m_attributes->length(); ++attribute_index) {
|
||||
auto const* attribute = m_attributes->item(attribute_index);
|
||||
VERIFY(attribute);
|
||||
|
@ -2099,7 +2099,7 @@ JS::ThrowCompletionOr<void> Element::upgrade_element(GC::Ref<HTML::CustomElement
|
|||
enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::attributeChangedCallback, move(arguments));
|
||||
}
|
||||
|
||||
// 5. If element is connected, then enqueue a custom element callback reaction with element, callback name "connectedCallback", and an empty argument list.
|
||||
// 5. If element is connected, then enqueue a custom element callback reaction with element, callback name "connectedCallback", and « ».
|
||||
if (is_connected()) {
|
||||
GC::MarkedVector<JS::Value> empty_arguments { vm.heap() };
|
||||
enqueue_a_custom_element_callback_reaction(HTML::CustomElementReactionNames::connectedCallback, move(empty_arguments));
|
||||
|
|
|
@ -1275,7 +1275,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment
|
|||
// - element's namespace is the HTML namespace;
|
||||
if (!element || is<HTML::HTMLHtmlElement>(*element)) {
|
||||
// then set element to the result of creating an element given this's node document,
|
||||
// body, and the HTML namespace.
|
||||
// "body", and the HTML namespace.
|
||||
element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, Namespace::HTML));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue