variable / @typed/template/Wire

persistent

Creates a Wire from a DocumentFragment.

If the fragment has only one child, that child is returned directly. If it has multiple children, they are wrapped in a Wire structure (bounded by comments) to allow them to be treated as a single unit.

Package version
1.0.0-beta.7
Category
Persistent DOM ranges
Since
1.0.0

Import

import { persistent } from "@typed/template/Wire";

Signatures

export declare const persistent: (document: Document, templateHash: string, fragment: DocumentFragment) => DocumentFragment | Node | Wire;

Why

The renderer can move multi-node output without adding a layout-affecting wrapper and without losing identity after fragment insertion.

Ownership and lifetime

The returned Node, fragment, or Wire contains the exact input children. The caller’s render Scope owns later insertion and removal.

Examples

import { persistent } from "@typed/template/Wire"

const templateIdentity = "unique-template-id-or-hash"
const output = persistent(document, templateIdentity, document.createDocumentFragment())

Other public imports

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

Source