@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
19 lines (18 loc) • 981 B
TypeScript
import type { TRenderContent, TRenderOptions, TRenderTarget } from "../types.js";
/**
* Renders content into a target element in the DOM
* @param target - Element or selector to render content into
* @param content - Content to render (can be Node, string, HTMLElement, Promise<HTMLElement>, or array)
* @param options - Optional rendering configuration
*
* @example
* ```ts
* render('#app', 'Hello'); // Replaces content
* render(element, 'World', { insert: 'append' }); // Appends content
* render('#app', [el1, el2], { insert: 'prepend' }); // Prepends multiple elements
* render('#app', [el1, null, undefined, el2]); // Handles null/undefined values in arrays
* render('#old-element', newElement, { replace: true }); // Replaces the target element itself
* await render('#app', asyncElement); // Handles Promise<HTMLElement>
* ```
*/
export declare function render(target: TRenderTarget, content: TRenderContent, options?: TRenderOptions): void | Promise<void>;