class / @typed/template

TextOnlyElement

Represents an element that contains only text (e.g. <script>, <style>).

Package version
1.0.0-beta.7
Category
Text contexts
Since
1.0.0

Import

import { TextOnlyElement } from "@typed/template";

Signatures

export declare class TextOnlyElement {
    readonly _tag = "text-only-element";
    readonly tagName: string;
    readonly attributes: Array<Attribute>;
    readonly textContent: Text | null;
    constructor(tagName: string, attributes: Array<Attribute>, textContent: Text | null);
}

Why

Script, style, textarea, title, and related contexts require dedicated parsing and context-aware closing-tag neutralization during SSR.

Ownership and lifetime

This is parsed data; it owns no live element or executable script.

Constructor

Creates a text-only element AST node.

Constructor: Why

Renderer tooling can model special text contexts.

Constructor: Ownership and lifetime

Retains parsed data and creates no DOM.

Property: _tag

Text-only-element discriminant.

Property: _tag: Why

Selects special parsing and escaping.

Property: _tag: Ownership and lifetime

Immutable metadata.

Property: attributes

Parsed attributes.

Property: attributes: Why

Preserves native attribute semantics.

Property: attributes: Ownership and lifetime

Retained AST array.

Property: tagName

Authored tag name.

Property: tagName: Why

Determines script/style/textarea/title serialization rules.

Property: tagName: Ownership and lifetime

Retained string metadata.

Property: textContent

Parsed text content or absence.

Property: textContent: Why

Keeps text-only context distinct from child nodes.

Property: textContent: Ownership and lifetime

Retained AST value.

Examples

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

const node = new TextOnlyElement("style", [], null)

Other public imports

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

Source