Class: Element
An element within the DOM.
Extends
NodeWithChildren
Constructors
new Element()
new Element(
name
,attribs
,children
?,type
?):Element
Parameters
• name: string
Name of the tag, eg. div
, span
.
• attribs
Object mapping attribute names to attribute values.
• children?: ChildNode
[]
Children of the node.
• type?: Script
| Style
| Tag
The type of the node.
Returns
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
The type of the node.
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.
set
childNodes(children
):void
Parameters
• children: ChildNode
[]
Returns
Inherited from
NodeWithChildren.childNodes
Defined in
node_modules/domhandler/lib/node.d.ts:139
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.
set
nextSibling(next
):void
Parameters
• next: null
| ChildNode
Returns
null
| ChildNode
Inherited from
NodeWithChildren.nextSibling
Defined in
node_modules/domhandler/lib/node.d.ts:67
nodeType
get
nodeType():1
DOM spec-compatible node type.
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.
set
parentNode(parent
):void
Parameters
• parent: null
| ParentNode
Returns
null
| ParentNode
Inherited from
NodeWithChildren.parentNode
Defined in
node_modules/domhandler/lib/node.d.ts:55
previousSibling
get
previousSibling():null
|ChildNode
Same as prev. DOM spec-compatible alias.
set
previousSibling(prev
):void
Parameters
• prev: null
| ChildNode
Returns
null
| ChildNode
Inherited from
NodeWithChildren.previousSibling
Defined in
node_modules/domhandler/lib/node.d.ts:61
tagName
get
tagName():string
Same as name. DOM spec-compatible alias.
set
tagName(name
):void
Parameters
• name: string
Returns
string
Defined in
node_modules/domhandler/lib/node.d.ts:192
Methods
cloneNode()
cloneNode<
T
>(this
,recursive
?):T
Clone this node, and optionally its children.
Type Parameters
• T extends Node
Parameters
• this: T
• recursive?: boolean
Clone 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