/** * Provides an interface compatible with the browser `HTMLElement` - at least * in so much as it provides the capabilities Wafer requires. The actual * implementation is proxied to node-html-parser implementation of * `HTMLElement`. It should be relatively straight forward to swap this * implementation out for an alternative one if required. */ export class ServerElement { /** * @param {string} tagName - the tag name of this element * @param {Object.} attrs - Object of initial attribute name/value pairs */ constructor(tagName: string, attrs?: { [x: string]: string; }); /** * Element containing reference to underlying `HTMLElement` implementation. * The element is proxied in this class to: * * - avoid clashes with `HTMLElement` implementation details * * - make it easy to swap out for alternative implementations */ _element: ServerElement; /** * Update the underlying element to new element * @param {ServerElement} element */ setElement(element: ServerElement): void; /** * Retrieve the underlying element * * @returns {ServerElement} */ getElement(): ServerElement; /** * Does this element have an attribute set with named `key` * * @param {string} key - Attribute name * @returns {boolean} */ hasAttribute(key: string): boolean; /** * Return the current value of names attribute * * @param {string} key - Attribute name * @returns {string} */ getAttribute(key: string): string; /** * Sets the value for the name attribute * * @param {string} key - Attribute name * @param {string} value - Value to set * @returns */ setAttribute(key: string, value: string): void; /** * Sets all attributes at once * * @param {Object.} attrs - Value to set * @returns */ setAttributes(attrs: { [x: string]: string; }): void; /** * Remove names attribute * * @param {string} key - Attribute name */ removeAttribute(key: string): void; /** * Append a child to the underlying element implementation * * @param {ServerElement} el - Element to append * @returns {void} */ appendChild(el: ServerElement): void; /** * Query underlying element for single match * * @param {string} selector - CSS3 selector * @returns {ServerElement} */ querySelector(selector: string): ServerElement; /** * Query underlying element for all matches * * @param {string} selector * @returns {ServerElement[]} */ querySelectorAll(selector: string): ServerElement[]; /** * The element's tag name * * @returns {string} */ get tagName(): string; /** * Object containing the element's attributes * * @returns {Object.} */ get attributes(): { [x: string]: string; }; /** * The first child of this element * * @returns {ServerElement} */ get firstChild(): ServerElement; /** * Set the child nodes of this element * * @returns */ set childNodes(arg: ServerElement[]); /** * The child nodes of this element * * @returns {ServerElement[]} */ get childNodes(): ServerElement[]; /** * The parent of this element * * @returns {ServerElement} */ set parentNode(arg: ServerElement); /** * The parent of this element * * @returns {ServerElement} */ get parentNode(): ServerElement; /** * Element's node type * * @returns {import('node-html-parser').NodeType} */ get nodeType(): import("node-html-parser/dist/nodes/type").default; /** * The tag name of the original element. This is used internally by * node-html-parser and needs to br proxied here so a ServerElement can * be used everywhere node-html-parser's HTMLElement is * * @returns {string} */ get rawTagName(): string; /** * Set the text content of underlying element * @param {string} content */ set textContent(arg: string); /** * Get the text content of underlying element * * @returns {string} */ get textContent(): string; /** * Set the innerHTML of underlying element * * @param {string} html */ set innerHTML(arg: string); /** * Render this element to an HTML string * * @returns {string} */ toString(): string; /** * Promise resolves when all pending updates have been processed * * @param {import("../types").Registry} registry - registry of tag names to Wafer component definitions * * @returns {Promise} */ updateDone(registry: import("../types").Registry): Promise; } /** * Render an HTML string as a tree of `ServerElement`s * * @param {string} htmlString - string to parse * @param {import("../types").Registry} registry - registry of tag names to Wafer component definitions * * @returns {Promise} */ declare function waferParse(htmlString: string, registry?: import("../types").Registry): Promise; export { waferParse as parse };