Trilium Backend API
    Preparing search index...

    Class Element

    An element within the DOM.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • name: string

        Name of the tag, eg. div, span.

      • attribs: { [name: string]: string }

        Object mapping attribute names to attribute values.

      • Optionalchildren: ChildNode[]

        Children of the node.

      • Optionaltype: Script | Style | Tag

      Returns Element

    Properties

    attribs: { [name: string]: string }
    children: ChildNode[]
    endIndex: number

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

    name: string
    namespace?: string

    Element namespace (parse5 only).

    next: ChildNode

    Next sibling

    parent: ParentNode

    Parent of the node

    prev: ChildNode

    Previous sibling

    sourceCodeLocation?: TagSourceCodeLocation

    parse5 source code location info, with start & end tags.

    Available if parsing with parse5 and location info is enabled.

    startIndex: number

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

    type: Script | Style | Tag

    The type of the node.

    "x-attribsNamespace"?: Record<string, string>

    Element attribute namespaces (parse5 only).

    "x-attribsPrefix"?: Record<string, string>

    Element attribute namespace-related prefixes (parse5 only).

    Accessors

    • get attributes(): Attribute[]

      Returns Attribute[]

    • get childNodes(): ChildNode[]

      Same as children. DOM spec-compatible alias.

      Returns ChildNode[]

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

      Parameters

      Returns void

    • get firstChild(): ChildNode

      First child of the node.

      Returns ChildNode

    • get lastChild(): ChildNode

      Last child of the node.

      Returns ChildNode

    • get nextSibling(): ChildNode

      Same as next. DOM spec-compatible alias.

      Returns ChildNode

    • set nextSibling(next: ChildNode): void

      Parameters

      Returns void

    • get nodeType(): 1

      DOM spec-compatible node type.

      Returns 1

    • get parentNode(): ParentNode

      Same as parent. DOM spec-compatible alias.

      Returns ParentNode

    • set parentNode(parent: ParentNode): void

      Parameters

      Returns void

    • get previousSibling(): ChildNode

      Same as prev. DOM spec-compatible alias.

      Returns ChildNode

    • set previousSibling(prev: ChildNode): void

      Parameters

      Returns void

    • get tagName(): string

      Same as name. DOM spec-compatible alias.

      Returns string

    • set tagName(name: string): void

      Parameters

      • name: string

      Returns void

    Methods

    • Clone this node, and optionally its children.

      Type Parameters

      Parameters

      • this: T
      • Optionalrecursive: boolean

        Clone child nodes as well.

      Returns T

      A clone of the node.