Interface HtmlNodeLike

A node of a parsed HTML or XHTML document, by the properties the HTML reader reads. A browser's Node satisfies it, and so does an Element, whose attribute methods the reader calls on the element itself.

interface HtmlNodeLike {
    nodeType: number;
    nodeName: string;
    childNodes: ArrayLike<HtmlNodeLike>;
    textContent: null | string;
    getAttribute?(name): null | string;
    hasAttribute?(name): boolean;
}

Methods

  • An element's attribute by its name, or null; a node that is no element need not have it.

    Parameters

    • name: string

    Returns null | string

  • Whether an element has an attribute by its name; a node that is no element need not have it.

    Parameters

    • name: string

    Returns boolean

Properties

nodeType: number

1 for an element, 3 for text, 4 for a CDATA section, 8 for a comment, 9 for a document, 11 for a fragment.

nodeName: string

An element's name: in upper case in an HTML document, in lower case in an XHTML one; read in either.

childNodes: ArrayLike<HtmlNodeLike>

The node's children, in document order, as an array-like list, so a browser's own NodeList passes as it is.

textContent: null | string

A text node's characters; the reader reads it from text and CDATA nodes alone.