UNPKG

rvx

Version:

A signal based rendering library

183 lines (182 loc) 5.76 kB
import { Context } from "../core/context.js"; import { WINDOW_MARKER } from "./internals/window-marker.js"; declare const NODE_LENGTH: unique symbol; declare const NODE_APPEND_HTML_TO: unique symbol; export declare class NodeList { #private; constructor(node: Node); get length(): number; forEach(cb: (node: Node, index: number, list: NodeList) => void, thisArg?: unknown): void; [Symbol.iterator](): Iterator<Node>; values(): Iterator<Node>; } export declare class Event { } /** * @deprecated Use {@link Event} instead. */ export declare const NoopEvent: typeof Event; export declare class EventTarget { addEventListener(): void; removeEventListener(): void; dispatchEvent(): void; } /** * @deprecated Use {@link EventTarget} instead. */ export declare const NoopEventTarget: typeof EventTarget; export declare class Document extends EventTarget { get body(): Element | null; get activeElement(): Element | null; createTextNode(data: string): Text; createComment(data: string): Comment; createDocumentFragment(): DocumentFragment; createElementNS(namespaceURI: string, tagName: string): Element; createElement(tagName: string): Element; } export declare class Node extends EventTarget { #private; get parentNode(): Node | null; get firstChild(): Node | null; get lastChild(): Node | null; get previousSibling(): Node | null; get nextSibling(): Node | null; get childNodes(): NodeList; /** * Get the direct number of child nodes. */ [NODE_LENGTH](): number; /** * Append the HTML representation of this node to the specified HTML string. * * @param html An existing HTML string. * @returns The concatenated HTML string. */ [NODE_APPEND_HTML_TO](html: string): string; contains(node: Node | null): boolean; hasChildNodes(): boolean; removeChild(node: Node): Node; appendChild(node: Node): Node; insertBefore(node: Node, ref: Node): Node; replaceChild(node: Node, ref: Node): Node; remove(): void; append(...nodes: (Node | string)[]): void; replaceChildren(...nodes: (Node | string)[]): void; get textContent(): string; get outerHTML(): string; } export interface Node { nodeType: number; nodeName: string; } export declare class DocumentFragment extends Node { } /** * A context that controls if newly created comment nodes are visible in rendered html. * * **SECURITY:** Comment data is not escaped when rendering and can be used to produce invalid or malicious HTML. * * @default false */ export declare const VISIBLE_COMMENTS: Context<boolean>; export declare class Comment extends Node { #private; constructor(data: string); /** * Get or set comment data. * * **SECURITY:** Comment data is not escaped when rendering and can be used to produce invalid or malicious HTML. */ get textContent(): string; set textContent(data: string); [NODE_APPEND_HTML_TO](html: string): string; } /** * @deprecated Use {@link Comment} instead. */ export declare const NoopComment: typeof Comment; export declare class Text extends Node { #private; constructor(data: string); get textContent(): string; set textContent(data: string); [NODE_APPEND_HTML_TO](html: string): string; } declare const ATTR_CHANGED: unique symbol; interface Attribute { name: string; value: string; stale: boolean; } export declare class ElementClassList { #private; constructor(attrs: Attribute[]); get length(): number; get value(): string; [ATTR_CHANGED](attr: Attribute | null): void; add(...tokens: string[]): void; contains(token: string): boolean; remove(...tokens: string[]): void; replace(oldToken: string, newToken: string): boolean; toggle(token: string, force?: boolean): boolean; values(): IterableIterator<string>; [Symbol.iterator](): IterableIterator<string>; } export declare class ElementStyles { #private; constructor(attrs: Attribute[]); get cssText(): string; [ATTR_CHANGED](attr: Attribute | null): void; setProperty(name: string, value: string, priority?: "" | "important"): void; removeProperty(name: string): string; getPropertyValue(name: string): string; } export declare class Element extends Node { #private; constructor(namespaceURI: string, tagName: string); get tagName(): string; get nodeName(): string; get namespaceURI(): string; /** * Get or set inner HTML of this element. * * When set to a non-empty string, all children are replaced with a {@link RawHTML} node. */ get innerHTML(): string; set innerHTML(html: string); get classList(): ElementClassList; get style(): ElementStyles; focus(): void; blur(): void; setAttribute(name: string, value: string): void; removeAttribute(name: string): void; toggleAttribute(name: string, force?: boolean): void; getAttribute(name: string): string | null; hasAttribute(name: string): boolean; [NODE_APPEND_HTML_TO](html: string): string; } export declare class RawHTML extends Node { #private; constructor(html: string); [NODE_APPEND_HTML_TO](html: string): string; } export declare class Window extends EventTarget { window: this; document: Document; } export interface Window { [WINDOW_MARKER]: boolean; Comment: typeof Comment; CustomEvent: typeof Event; Document: typeof Document; DocumentFragment: typeof DocumentFragment; Element: typeof Element; Event: typeof Event; Node: typeof Node; Text: typeof Text; } /** * A global default rvxdom window instance. */ export declare const WINDOW: Window; export {};