class / @typed/template/Template

SelfClosingElementNode

Represents a self-closing HTML element (e.g. <br />, <img />).

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

Import

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

Signatures

export declare class SelfClosingElementNode {
    readonly _tag = "self-closing-element";
    readonly tagName: string;
    readonly attributes: Array<Attribute>;
    constructor(tagName: string, attributes: Array<Attribute>);
}

Why

The distinct tag preserves author syntax for compilation and serialization.

Ownership and lifetime

The model owns parsed metadata, not the eventual native Element.

Constructor

Creates a self-closing element AST node.

Constructor: Why

Makes compiler input explicit.

Constructor: Ownership and lifetime

Retains parsed data and creates no DOM.

Property: _tag

Self-closing-element discriminant.

Property: _tag: Why

Preserves author syntax in compilation.

Property: _tag: Ownership and lifetime

Immutable metadata.

Property: attributes

Parsed attributes.

Property: attributes: Why

Retains native directive distinctions.

Property: attributes: Ownership and lifetime

Retained AST array.

Property: tagName

Authored tag name.

Property: tagName: Why

Selects the native element kind.

Property: tagName: Ownership and lifetime

Retained string metadata.

Examples

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

const node = new SelfClosingElementNode("img", [])

Other public imports

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

Source