Skip to main content

Document

The root node of the document.

Hierarchy

Index

Constructors

constructor

  • Parameters

    • children: ChildNode[]

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

    Returns Document

Properties

publicchildren

children: ChildNode[]

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

endIndex

endIndex: null | number = null

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

next

next: null | ChildNode = null

Next sibling

parent

parent: null | ParentNode = null

Parent of the node

prev

prev: null | ChildNode = null

Previous sibling

optionalsourceCodeLocation

sourceCodeLocation?: null | SourceCodeLocation

parse5 source code location info.

Available if parsing with parse5 and location info is enabled.

startIndex

startIndex: null | number = null

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

type

type: Root = ElementType.Root

The type of the node.

optionalx-mode

x-mode?: no-quirks | quirks | limited-quirks

Document mode (parse5 only).

Accessors

childNodes

  • Same as children. DOM spec-compatible alias.


    Returns ChildNode[]

  • Parameters

    Returns void

close

  • Node close tag details. Can be null for self closing tag


    Returns undefined | CharValue

  • Parameters

    Returns void

firstChild

  • First child of the node.


    Returns null | ChildNode

lastChild

  • Last child of the node.


    Returns null | ChildNode

loc

  • Node position in document


    Returns Range

  • Parameters

    Returns void

nextSibling

  • Same as next. DOM spec-compatible alias.


    Returns null | ChildNode

  • Parameters

    Returns void

nodeType

  • get nodeType(): 9
  • DOM spec-compatible node type.


    Returns 9

open

  • Node open tag details


    Returns CharValue

  • Parameters

    Returns void

parentNode

  • Same as parent. DOM spec-compatible alias.


    Returns null | ParentNode

  • Parameters

    Returns void

previousSibling

  • Same as prev. DOM spec-compatible alias.


    Returns null | ChildNode

  • Parameters

    Returns void

Methods

cloneNode

  • cloneNode<T>(this: T, recursive?: boolean): T
  • Clone this node, and optionally its children.


    Type parameters

    Parameters

    • this: T
    • recursive: boolean = false

      Clone child nodes as well.

    Returns T

    A clone of the node.