跳到主要内容

Class: Element

An element within the DOM.

Hierarchy

  • NodeWithChildren

    Element

Constructors

constructor

new Element(name, attribs, children?, type?): Element

Parameters

NameTypeDescription
namestringName of the tag, eg. div, span.
attribsObjectObject mapping attribute names to attribute values.
children?ChildNode[]Children of the node.
type?Script | Style | Tag-

Returns

Element

Overrides

NodeWithChildren.constructor

Defined in

node_modules/domhandler/lib/node.d.ts:178

Properties

attribs

attribs: Object

Index signature

▪ [name: string]: string

Defined in

node_modules/domhandler/lib/node.d.ts:169


children

children: ChildNode[]

Inherited from

NodeWithChildren.children

Defined in

node_modules/domhandler/lib/node.d.ts:126


endIndex

endIndex: null | number

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

Inherited from

NodeWithChildren.endIndex

Defined in

node_modules/domhandler/lib/node.d.ts:39


name

name: string

Defined in

node_modules/domhandler/lib/node.d.ts:168


namespace

Optional namespace: string

Element namespace (parse5 only).

Defined in

node_modules/domhandler/lib/node.d.ts:196


next

next: null | ChildNode

Next sibling

Inherited from

NodeWithChildren.next

Defined in

node_modules/domhandler/lib/node.d.ts:35


parent

parent: null | ParentNode

Parent of the node

Inherited from

NodeWithChildren.parent

Defined in

node_modules/domhandler/lib/node.d.ts:31


prev

prev: null | ChildNode

Previous sibling

Inherited from

NodeWithChildren.prev

Defined in

node_modules/domhandler/lib/node.d.ts:33


sourceCodeLocation

Optional sourceCodeLocation: null | TagSourceCodeLocation

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

Available if parsing with parse5 and location info is enabled.

Overrides

NodeWithChildren.sourceCodeLocation

Defined in

node_modules/domhandler/lib/node.d.ts:187


startIndex

startIndex: null | number

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

Inherited from

NodeWithChildren.startIndex

Defined in

node_modules/domhandler/lib/node.d.ts:37


type

type: Script | Style | Tag

Overrides

NodeWithChildren.type

Defined in

node_modules/domhandler/lib/node.d.ts:172


x-attribsNamespace

Optional x-attribsNamespace: Record<string, string>

Element attribute namespaces (parse5 only).

Defined in

node_modules/domhandler/lib/node.d.ts:198


x-attribsPrefix

Optional x-attribsPrefix: Record<string, string>

Element attribute namespace-related prefixes (parse5 only).

Defined in

node_modules/domhandler/lib/node.d.ts:200

Accessors

attributes

get attributes(): Attribute[]

Returns

Attribute[]

Defined in

node_modules/domhandler/lib/node.d.ts:194


childNodes

get childNodes(): ChildNode[]

Same as children. DOM spec-compatible alias.

Returns

ChildNode[]

Inherited from

NodeWithChildren.childNodes

Defined in

node_modules/domhandler/lib/node.d.ts:139

set childNodes(children): void

Parameters

NameType
childrenChildNode[]

Returns

void

Inherited from

NodeWithChildren.childNodes

Defined in

node_modules/domhandler/lib/node.d.ts:140


firstChild

get firstChild(): null | ChildNode

First child of the node.

Returns

null | ChildNode

Inherited from

NodeWithChildren.firstChild

Defined in

node_modules/domhandler/lib/node.d.ts:132


lastChild

get lastChild(): null | ChildNode

Last child of the node.

Returns

null | ChildNode

Inherited from

NodeWithChildren.lastChild

Defined in

node_modules/domhandler/lib/node.d.ts:134


nextSibling

get nextSibling(): null | ChildNode

Same as next. DOM spec-compatible alias.

Returns

null | ChildNode

Inherited from

NodeWithChildren.nextSibling

Defined in

node_modules/domhandler/lib/node.d.ts:67

set nextSibling(next): void

Parameters

NameType
nextnull | ChildNode

Returns

void

Inherited from

NodeWithChildren.nextSibling

Defined in

node_modules/domhandler/lib/node.d.ts:68


nodeType

get nodeType(): 1

Returns

1

Overrides

NodeWithChildren.nodeType

Defined in

node_modules/domhandler/lib/node.d.ts:181


parentNode

get parentNode(): null | ParentNode

Same as parent. DOM spec-compatible alias.

Returns

null | ParentNode

Inherited from

NodeWithChildren.parentNode

Defined in

node_modules/domhandler/lib/node.d.ts:55

set parentNode(parent): void

Parameters

NameType
parentnull | ParentNode

Returns

void

Inherited from

NodeWithChildren.parentNode

Defined in

node_modules/domhandler/lib/node.d.ts:56


previousSibling

get previousSibling(): null | ChildNode

Same as prev. DOM spec-compatible alias.

Returns

null | ChildNode

Inherited from

NodeWithChildren.previousSibling

Defined in

node_modules/domhandler/lib/node.d.ts:61

set previousSibling(prev): void

Parameters

NameType
prevnull | ChildNode

Returns

void

Inherited from

NodeWithChildren.previousSibling

Defined in

node_modules/domhandler/lib/node.d.ts:62


tagName

get tagName(): string

Same as name. DOM spec-compatible alias.

Returns

string

Defined in

node_modules/domhandler/lib/node.d.ts:192

set tagName(name): void

Parameters

NameType
namestring

Returns

void

Defined in

node_modules/domhandler/lib/node.d.ts:193

Methods

cloneNode

cloneNode<T>(this, recursive?): T

Clone this node, and optionally its children.

Type parameters

NameType
Textends Node

Parameters

NameTypeDescription
thisT-
recursive?booleanClone child nodes as well.

Returns

T

A clone of the node.

Inherited from

NodeWithChildren.cloneNode

Defined in

node_modules/domhandler/lib/node.d.ts:75