diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index bfa714f7edc..abdfaf46449 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -38,6 +38,14 @@ DOM::Document& HTMLTemplateElement::appropriate_template_contents_owner_document return document; } +// https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-adopt-ext +void HTMLTemplateElement::adopted_from(DOM::Document&) +{ + // NOTE: It seems the spec has been changed since appropriate_template_contents_owner_document was written above. + // That function is now part of document, which ends up returning associated_inert_template_document in the new version anyway. + appropriate_template_contents_owner_document(document()).adopt_node(content()); +} + // https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-clone-ext void HTMLTemplateElement::cloned(Node& copy, bool clone_children) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h index 6c5c3bd7597..28b38a3b72f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h @@ -21,6 +21,7 @@ public: NonnullRefPtr content() { return *m_content; } const NonnullRefPtr content() const { return *m_content; } + virtual void adopted_from(DOM::Document&) override; virtual void cloned(Node& copy, bool clone_children) override; private: