UNPKG

europa-core

Version:

Europa core engine for converting HTML into valid Markdown

65 lines (64 loc) 1.84 kB
import { DomElement } from "./DomElement"; import { DomRoot } from "./DomRoot"; /** * A cross-platform wrapper for a DOM node that exists within a {@link Dom}. */ export interface DomNode { /** * Returns all child DOM nodes contained within this DOM node wrapper. * * @return The children DOM node wrappers. */ children(): DomNode[]; /** * Checks whether this wrapper is for a DOM element. * * @return `true` if this {@link DomNode} is a {@link DomElement}; otherwise `false`. */ isElement(): this is DomElement; /** * Checks whether this wrapper is for the DOM root. * * @return `true` if this {@link DomNode} is a {@link DomRoot}; otherwise `false`. */ isRoot(): this is DomRoot; /** * Checks whether this wrapper is for a DOM text node. * * @return `true` if this {@link DomNode} is for a DOM text node; otherwise `false`. */ isText(): boolean; /** * Returns the wrapped DOM node. * * @return The wrapped DOM node. */ node(): any; /** * Returns the parent of this DOM wrapper. * * The DOM root wrapper should be returned if this wrapper has no parent or if this wrapper is for the DOM root. * * @return A wrapper for the parent DOM node. */ parent(): DomNode; /** * Returns the DOM root wrapper in which this DOM node wrapper exists. * * @return The DOM root wrapper. */ root(): DomRoot; /** * Returns the text contents of the wrapped DOM node or an empty string if not applicable to the wrapped DOM node's * type. * * @return The text contents. */ text(): string; /** * Returns the type of the wrapped DOM node. * * @return The DOM node type. */ type(): number; }