mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 21:10:30 +00:00
LibWeb: Implement the cloning steps for <template> elements
This commit is contained in:
parent
5897bc5c1f
commit
a7fa757dd1
Notes:
sideshowbarker
2024-07-18 10:24:13 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/a7fa757dd14 Pull-request: https://github.com/SerenityOS/serenity/pull/8449
2 changed files with 18 additions and 0 deletions
|
@ -38,4 +38,20 @@ DOM::Document& HTMLTemplateElement::appropriate_template_contents_owner_document
|
|||
return document;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#the-template-element:concept-node-clone-ext
|
||||
void HTMLTemplateElement::cloned(Node& copy, bool clone_children)
|
||||
{
|
||||
if (!clone_children)
|
||||
return;
|
||||
|
||||
auto& template_clone = verify_cast<HTMLTemplateElement>(copy);
|
||||
|
||||
content()->for_each_child([&](auto& child) {
|
||||
auto cloned_child = child.clone_node(&template_clone.content()->document(), true);
|
||||
|
||||
// FIXME: Should this use TreeNode::append_child instead?
|
||||
template_clone.content()->append_child(cloned_child);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
NonnullRefPtr<DOM::DocumentFragment> content() { return *m_content; }
|
||||
const NonnullRefPtr<DOM::DocumentFragment> content() const { return *m_content; }
|
||||
|
||||
virtual void cloned(Node& copy, bool clone_children) override;
|
||||
|
||||
private:
|
||||
DOM::Document& appropriate_template_contents_owner_document(DOM::Document&);
|
||||
|
||||
|
|
Loading…
Reference in a new issue