class / @typed/template/Template

ElementNode

Represents an HTML, SVG, MathML, or foreign-content element with children.

Package version
1.0.0-beta.13
Category
Element structure
Since
1.0.0

Import

import { ElementNode } from "@typed/template/Template";

Signatures

export declare class ElementNode {
    readonly _tag = "element";
    readonly tagName: string;
    readonly attributes: Array<Attribute>;
    readonly children: Array<Node>;
    constructor(tagName: string, attributes: Array<Attribute>, children: Array<Node>);
}

Why

Keeping the authored tag, attributes, and children explicit lets DOM compilation apply native namespace rules and SSR preserve author markup.

Ownership and lifetime

The model owns only parsed arrays and strings, never the eventual Element.

Constructor

Creates an element AST node.

Constructor: Why

Renderer tooling can construct native element syntax explicitly.

Constructor: Ownership and lifetime

Retains supplied data and creates no Element.

Property: _tag

Element-node discriminant.

Property: _tag: Why

Enables exhaustive compilation.

Property: _tag: Ownership and lifetime

Immutable AST metadata.

Property: attributes

Parsed attributes in author order.

Property: attributes: Why

Keeps distinct native directive semantics.

Property: attributes: Ownership and lifetime

Retained AST array; no Attr ownership.

Property: children

Parsed child structure.

Property: children: Why

Defines the element’s compile-time subtree.

Property: children: Ownership and lifetime

Retained AST array; no DOM ownership.

Property: tagName

Authored qualified tag name.

Property: tagName: Why

Preserves native namespace-sensitive creation.

Property: tagName: Ownership and lifetime

Retained string metadata.

Examples

import { ElementNode } from "@typed/template/Template"

const node = new ElementNode("section", [], [])

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source