diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index 39ba2b6fcfa..7915b0d9646 100644
--- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -1660,9 +1660,11 @@ void HTMLInputElement::apply_presentational_hints(GC::Ref HTMLInputElement::cloned(DOM::Node& copy, bool)
+WebIDL::ExceptionOr HTMLInputElement::cloned(DOM::Node& copy, bool subtree)
{
- // The cloning steps for input elements must propagate the value, dirty value flag, checkedness, and dirty checkedness flag from the node being cloned to the copy.
+ TRY(Base::cloned(copy, subtree));
+
+ // The cloning steps for input elements given node, copy, and subtree are to propagate the value, dirty value flag, checkedness, and dirty checkedness flag from node to copy.
auto& input_clone = verify_cast(copy);
input_clone.m_value = m_value;
input_clone.m_dirty_value = m_dirty_value;
diff --git a/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp b/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp
index a8111b36cab..efa1e8070b8 100644
--- a/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLOrSVGElement.cpp
@@ -56,7 +56,7 @@ void HTMLOrSVGElement::blur()
// User agents may selectively or uniformly ignore calls to this method for usability reasons.
}
-// https://html.spec.whatwg.org/#dom-noncedelement-nonce
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
template
void HTMLOrSVGElement::attribute_changed(FlyString const& local_name, Optional const&, Optional const& value, Optional const& namespace_)
{
@@ -76,17 +76,17 @@ void HTMLOrSVGElement::attribute_changed(FlyString const& local_nam
}
}
-// https://html.spec.whatwg.org/#dom-noncedelement-nonce
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
template
WebIDL::ExceptionOr HTMLOrSVGElement::cloned(DOM::Node& copy, bool)
{
- // The cloning steps for elements that include HTMLOrSVGElement must set the
- // [[CryptographicNonce]] slot on the copy to the value of the slot on the element being cloned.
+ // The cloning steps for elements that include HTMLOrSVGElement given node, copy, and subtree
+ // are to set copy's [[CryptographicNonce]] to node's [[CryptographicNonce]].
static_cast(copy).m_cryptographic_nonce = m_cryptographic_nonce;
return {};
}
-// https://html.spec.whatwg.org/#dom-noncedelement-nonce
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#dom-noncedelement-nonce
template
void HTMLOrSVGElement::inserted()
{
diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
index fbf8572c485..edaf25bb443 100644
--- a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp
@@ -46,20 +46,24 @@ void HTMLTemplateElement::adopted_from(DOM::Document&)
}
// https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-clone-ext
-WebIDL::ExceptionOr HTMLTemplateElement::cloned(Node& copy, bool clone_children)
+WebIDL::ExceptionOr HTMLTemplateElement::cloned(Node& copy, bool subtree)
{
- // 1. If the clone children flag is not set in the calling clone algorithm, return.
- if (!clone_children)
+ TRY(Base::cloned(copy, subtree));
+
+ // The cloning steps for template elements given node, copy, and subtree are:
+
+ // 1. If subtree is false, then return.
+ if (!subtree)
return {};
- // 2. Let copied contents be the result of cloning all the children of node's template contents,
- // with document set to copy's template contents's node document, and with the clone children flag set.
- // 3. Append copied contents to copy's template contents.
- auto& template_clone = verify_cast(copy);
+ // 2. For each child of node's template contents's children, in tree order:
+ // clone a node given child with document set to copy's template contents's node document,
+ // subtree set to true, and parent set to copy's template contents.
+ auto& template_copy = verify_cast(copy);
for (auto child = content()->first_child(); child; child = child->next_sibling()) {
- auto cloned_child = TRY(child->clone_node(&template_clone.content()->document(), true));
- TRY(template_clone.content()->append_child(cloned_child));
+ TRY(child->clone_node(&template_copy.content()->document(), true, template_copy.content()));
}
+
return {};
}
diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
index e601e02f19e..d5d4bb5f280 100644
--- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
@@ -136,9 +136,11 @@ void HTMLTextAreaElement::clear_algorithm()
}
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-node-clone-ext
-WebIDL::ExceptionOr HTMLTextAreaElement::cloned(DOM::Node& copy, bool)
+WebIDL::ExceptionOr HTMLTextAreaElement::cloned(DOM::Node& copy, bool subtree)
{
- // The cloning steps for textarea elements must propagate the raw value and dirty value flag from the node being cloned to the copy.
+ TRY(Base::cloned(copy, subtree));
+
+ // The cloning steps for textarea elements given node, copy, and subtree are to propagate the raw value and dirty value flag from node to copy.
auto& textarea_copy = verify_cast(copy);
textarea_copy.m_raw_value = m_raw_value;
textarea_copy.m_dirty_value = m_dirty_value;