diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index c3de44efe2c..8d705de62dd 100644 --- a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -76,6 +76,16 @@ WebIDL::ExceptionOr HTMLTemplateElement::cloned(Node& copy, bool subtree) return {}; } +// https://html.spec.whatwg.org/multipage/scripting.html#dom-template-content +GC::Ref HTMLTemplateElement::content_for_bindings() const +{ + // 1. Assert: this's template contents is not a ShadowRoot node. + VERIFY(!m_content->is_shadow_root()); + + // 2. Return this's template contents. + return *m_content; +} + void HTMLTemplateElement::set_template_contents(GC::Ref contents) { m_content = contents; diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.h b/Libraries/LibWeb/HTML/HTMLTemplateElement.h index 9b5f910ba7c..5a0dfbcc9ff 100644 --- a/Libraries/LibWeb/HTML/HTMLTemplateElement.h +++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.h @@ -21,6 +21,8 @@ public: GC::Ref content() { return *m_content; } GC::Ref const content() const { return *m_content; } + GC::Ref content_for_bindings() const; + void set_template_contents(GC::Ref); virtual void adopted_from(DOM::Document&) override; diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.idl b/Libraries/LibWeb/HTML/HTMLTemplateElement.idl index 3301ba68d05..49d24a7c499 100644 --- a/Libraries/LibWeb/HTML/HTMLTemplateElement.idl +++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.idl @@ -7,7 +7,7 @@ interface HTMLTemplateElement : HTMLElement { [HTMLConstructor] constructor(); - readonly attribute DocumentFragment content; + [ImplementedAs=content_for_bindings] readonly attribute DocumentFragment content; [Reflect=shadowrootmode, Enumerated=ShadowRootMode, CEReactions] attribute DOMString shadowRootMode; [Reflect=shadowrootdelegatesfocus, CEReactions] attribute boolean shadowRootDelegatesFocus; [Reflect=shadowrootclonable, CEReactions] attribute boolean shadowRootClonable;