Table of Contents

Class HTMLTemplateElement

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The HTMLTemplateElement interface enables access to the contents of an HTML template element.

[Value("HTMLTemplateElement")]
public class HTMLTemplateElement : HTMLElement, Region, GeometryUtils, ParentNode, NonDocumentTypeChildNode, ChildNode, Slottable, ARIAMixin, Animatable, ElementCSSInlineStyle, GlobalEventHandlers, ElementContentEditable, HTMLOrSVGElement
Inheritance
HTMLTemplateElement
Implements
Inherited Members

Remarks

NOTE

An HTML parser can create either an HTMLTemplateElement or a ShadowRoot when it parses a {{HTMLElement("template")}} element, depending on the <template> attributes.
If an HTMLTemplateElement is created the "shadow" attributes are reflected from the template.
However these are not useful, because an HTMLTemplateElement is not a shadow root and cannot subsequently be changed to a shadow root.

See also on MDN

Constructors

HTMLTemplateElement()

public HTMLTemplateElement()

Properties

Content

The content property of the HTMLTemplateElement interface returns the <template> element's template contents as a DocumentFragment. This content's NodeownerDocument is a separate Document from the one that contains the <template> element itself — unless the containing document is itself constructed for the purpose of holding template content.

[Value("content")]
public DocumentFragment Content { get; }

Property Value

DocumentFragment

A DocumentFragment.

Remarks

The CloneNode(bool) and ImportNode(Node, bool) methods both create a copy of a node. The difference is that importNode() clones the node in the context of the calling document, whereas cloneNode() uses the document of the node being cloned. The document context determines the CustomElementRegistry for constructing any custom elements. For this reason, use document.importNode() to clone the content fragment so that custom element descendants are constructed using the definitions in the current document, rather than the separate document that owns the template content. See the CloneNode(bool) page's examples for more details.

-HTMLTemplateElement

See also on MDN

ShadowRootClonable

The shadowRootClonable property reflects the value of the shadowrootclonable attribute of the associated <template> element.

[Value("shadowRootClonable")]
public bool ShadowRootClonable { get; set; }

Property Value

bool

Reflects the value of the shadowrootclonable attribute of the associated <template> element.

Remarks

Note that this property is not useful for developers.
If a <template> element is used to declaratively create a ShadowRoot, then this object and property do not exist.
Otherwise, if an HTMLTemplateElement is created, the value of this property is irrelevant because the object is not a shadow root and cannot subsequently be changed to a shadow root.

-shadowrootclonable attribute of the <template> element
-ShadowRoot.clonable

See also on MDN

ShadowRootDelegatesFocus

The shadowRootDelegatesFocus property of the HTMLTemplateElement interface reflects the value of the shadowrootdelegatesfocus attribute of the associated <template> element.

[Value("shadowRootDelegatesFocus")]
public bool ShadowRootDelegatesFocus { get; set; }

Property Value

bool

Reflects the value of the shadowrootdelegatesfocus attribute of the associated <template> element.

Remarks

Note that this property is not useful for developers.
If a <template> element is used to declaratively create a ShadowRoot, then this object and property do not exist.
Otherwise, if an HTMLTemplateElement is created, the value of this property is irrelevant because the object is not a shadow root and cannot subsequently be changed to a shadow root.

-shadowrootdelegatesfocus attribute of the <template> element
-ShadowRoot.delegatesFocus

See also on MDN

ShadowRootMode

The shadowRootMode property of the HTMLTemplateElement interface reflects the value of the shadowrootmode attribute of the associated <template> element.

[Value("shadowRootMode")]
public string ShadowRootMode { get; set; }

Property Value

string

Reflects the value of the shadowrootmode attribute of the associated <template> element.

Remarks

Note that this property is not useful for developers.
If a <template> element is used to declaratively create a ShadowRoot, then this object and property do not exist.
Otherwise, if an HTMLTemplateElement is created, the value of this property is irrelevant because the object is not a shadow root and cannot subsequently be changed to a shadow root.

-shadowrootmode attribute of the <template> element
-ShadowRoot.mode

See also on MDN

ShadowRootSerializable

The shadowRootSerializable property reflects the value of the shadowrootserializable attribute of the associated <template> element.

[Value("shadowRootSerializable")]
public bool ShadowRootSerializable { get; set; }

Property Value

bool

Reflects the value of the shadowrootserializable attribute of the associated <template> element.

Remarks

Note that this property is not useful for developers.
If a <template> element is used to declaratively create a ShadowRoot, then this object and property do not exist.
Otherwise, if an HTMLTemplateElement is created, the value of this property is irrelevant because the object is not a shadow root and cannot subsequently be changed to a shadow root.

-shadowrootserializable attribute of the <template> element
-ShadowRoot.serializable

See also on MDN