@tempots/dom
Version:
Fully-typed frontend framework alternative to React and Angular
22 lines (21 loc) • 881 B
TypeScript
import { CompiledTemplate, DynamicTextSlot, RenderableSlot } from './types';
import { Clear } from '@tempots/core';
import { DOMContext } from '../dom/dom-context';
/**
* Clone a compiled template and wire up dynamic bindings.
*
* Optimizations vs naive approach:
* - Pre-allocated topNodes array (no Array.from) — minimal allocation
* - Pre-allocated clears array — saves dynamic resizing
* - Dynamic-text onChange stored directly as Clear — no wrapper closure
*
* Returns `{ clear, startCtx }` where startCtx is a DOMContext whose
* reference is the first top-level node of the clone. This lets
* KeyedForEach skip creating a separate Comment start marker.
*
* @internal
*/
export declare function hydrateClone(template: CompiledTemplate, ctx: DOMContext, slots: readonly (DynamicTextSlot | RenderableSlot)[]): {
clear: Clear;
startCtx: DOMContext;
};