Class Document

The root node of the document.

Hierarchy

  • NodeWithChildren
    • Document

Constructors

  • Parameters

    • children: ChildNode[]

      Children of the node. Only certain node types can have children.

    Returns Document

Properties

children: ChildNode[]
endIndex: null | number

The end index of the node. Requires withEndIndices on the handler to be `true.

next: null | ChildNode

Next sibling

parent: null | ParentNode

Parent of the node

prev: null | ChildNode

Previous sibling

sourceCodeLocation?: null | SourceCodeLocation

parse5 source code location info.

Available if parsing with parse5 and location info is enabled.

startIndex: null | number

The start index of the node. Requires withStartIndices on the handler to be `true.

type: Root
x-mode?: "no-quirks" | "quirks" | "limited-quirks"

Document mode (parse5 only).

Accessors

  • get childNodes(): ChildNode[]
  • Same as children. DOM spec-compatible alias.

    Returns ChildNode[]

  • set childNodes(children: ChildNode[]): void
  • Parameters

    • children: ChildNode[]

    Returns void

  • get firstChild(): null | ChildNode
  • First child of the node.

    Returns null | ChildNode

  • get lastChild(): null | ChildNode
  • Last child of the node.

    Returns null | ChildNode

  • get nextSibling(): null | ChildNode
  • Same as next. DOM spec-compatible alias.

    Returns null | ChildNode

  • set nextSibling(next: null | ChildNode): void
  • Parameters

    • next: null | ChildNode

    Returns void

  • get nodeType(): 9
  • Returns 9

  • get parentNode(): null | ParentNode
  • Same as parent. DOM spec-compatible alias.

    Returns null | ParentNode

  • set parentNode(parent: null | ParentNode): void
  • Parameters

    Returns void

  • get previousSibling(): null | ChildNode
  • Same as prev. DOM spec-compatible alias.

    Returns null | ChildNode

  • set previousSibling(prev: null | ChildNode): void
  • Parameters

    • prev: null | ChildNode

    Returns void

Methods

  • Clone this node, and optionally its children.

    Returns

    A clone of the node.

    Type Parameters

    Parameters

    • this: T
    • Optional recursive: boolean

      Clone child nodes as well.

    Returns T