DocumentFragment
Defined in: src/full-types.d.ts:481
Source
Section titled “Source”obsidian-typings/src/global/augmentations/DocumentFragment.d.ts
Extends
Section titled “Extends”Node
.NonElementParentNode
.ParentNode
Properties
Section titled “Properties”ATTRIBUTE_NODE
Section titled “ATTRIBUTE_NODE”
readonly
ATTRIBUTE_NODE:2
Defined in: lib.dom.d.ts:17158
Inherited from
Section titled “Inherited from”ParentNode.ATTRIBUTE_NODE
baseURI
Section titled “baseURI”
readonly
baseURI:string
Defined in: lib.dom.d.ts:17027
Returns node’s node document’s document base URL.
Inherited from
Section titled “Inherited from”ParentNode.baseURI
CDATA_SECTION_NODE
Section titled “CDATA_SECTION_NODE”
readonly
CDATA_SECTION_NODE:4
Defined in: lib.dom.d.ts:17162
node is a CDATASection node.
Inherited from
Section titled “Inherited from”ParentNode.CDATA_SECTION_NODE
childElementCount
Section titled “childElementCount”
readonly
childElementCount:number
Defined in: lib.dom.d.ts:17745
Inherited from
Section titled “Inherited from”ParentNode.childElementCount
childNodes
Section titled “childNodes”
readonly
childNodes:NodeListOf
<ChildNode
>
Defined in: lib.dom.d.ts:17033
Returns the children.
Inherited from
Section titled “Inherited from”ParentNode.childNodes
children
Section titled “children”
readonly
children:HTMLCollection
Defined in: lib.dom.d.ts:17751
Returns the child elements.
Inherited from
Section titled “Inherited from”ParentNode.children
COMMENT_NODE
Section titled “COMMENT_NODE”
readonly
COMMENT_NODE:8
Defined in: lib.dom.d.ts:17168
node is a Comment node.
Inherited from
Section titled “Inherited from”ParentNode.COMMENT_NODE
constructorWin
Section titled “constructorWin”constructorWin:
Window
Defined in: src/full-types.d.ts:1257
Global window object.
Inherited from
Section titled “Inherited from”doc:
Document
Defined in: src/full-types.d.ts:1263
The document this node belongs to, or the global document.
Inherited from
Section titled “Inherited from”DOCUMENT_FRAGMENT_NODE
Section titled “DOCUMENT_FRAGMENT_NODE”
readonly
DOCUMENT_FRAGMENT_NODE:11
Defined in: lib.dom.d.ts:17174
node is a DocumentFragment node.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_FRAGMENT_NODE
DOCUMENT_NODE
Section titled “DOCUMENT_NODE”
readonly
DOCUMENT_NODE:9
Defined in: lib.dom.d.ts:17170
node is a document.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_NODE
DOCUMENT_POSITION_CONTAINED_BY
Section titled “DOCUMENT_POSITION_CONTAINED_BY”
readonly
DOCUMENT_POSITION_CONTAINED_BY:16
Defined in: lib.dom.d.ts:17185
Set when other is a descendant of node.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_CONTAINED_BY
DOCUMENT_POSITION_CONTAINS
Section titled “DOCUMENT_POSITION_CONTAINS”
readonly
DOCUMENT_POSITION_CONTAINS:8
Defined in: lib.dom.d.ts:17183
Set when other is an ancestor of node.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_CONTAINS
DOCUMENT_POSITION_DISCONNECTED
Section titled “DOCUMENT_POSITION_DISCONNECTED”
readonly
DOCUMENT_POSITION_DISCONNECTED:1
Defined in: lib.dom.d.ts:17177
Set when node and other are not in the same tree.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_DISCONNECTED
DOCUMENT_POSITION_FOLLOWING
Section titled “DOCUMENT_POSITION_FOLLOWING”
readonly
DOCUMENT_POSITION_FOLLOWING:4
Defined in: lib.dom.d.ts:17181
Set when other is following node.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_FOLLOWING
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
Section titled “DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC”
readonly
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32
Defined in: lib.dom.d.ts:17186
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
DOCUMENT_POSITION_PRECEDING
Section titled “DOCUMENT_POSITION_PRECEDING”
readonly
DOCUMENT_POSITION_PRECEDING:2
Defined in: lib.dom.d.ts:17179
Set when other is preceding node.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_POSITION_PRECEDING
DOCUMENT_TYPE_NODE
Section titled “DOCUMENT_TYPE_NODE”
readonly
DOCUMENT_TYPE_NODE:10
Defined in: lib.dom.d.ts:17172
node is a doctype.
Inherited from
Section titled “Inherited from”ParentNode.DOCUMENT_TYPE_NODE
ELEMENT_NODE
Section titled “ELEMENT_NODE”
readonly
ELEMENT_NODE:1
Defined in: lib.dom.d.ts:17157
node is an element.
Inherited from
Section titled “Inherited from”ParentNode.ELEMENT_NODE
ENTITY_NODE
Section titled “ENTITY_NODE”
readonly
ENTITY_NODE:6
Defined in: lib.dom.d.ts:17164
Inherited from
Section titled “Inherited from”ParentNode.ENTITY_NODE
ENTITY_REFERENCE_NODE
Section titled “ENTITY_REFERENCE_NODE”
readonly
ENTITY_REFERENCE_NODE:5
Defined in: lib.dom.d.ts:17163
Inherited from
Section titled “Inherited from”ParentNode.ENTITY_REFERENCE_NODE
firstChild
Section titled “firstChild”
readonly
firstChild:null
|ChildNode
Defined in: lib.dom.d.ts:17039
Returns the first child.
Inherited from
Section titled “Inherited from”ParentNode.firstChild
firstElementChild
Section titled “firstElementChild”
readonly
firstElementChild:null
|Element
Defined in: lib.dom.d.ts:17757
Returns the first child that is an element, and null otherwise.
Inherited from
Section titled “Inherited from”ParentNode.firstElementChild
isConnected
Section titled “isConnected”
readonly
isConnected:boolean
Defined in: lib.dom.d.ts:17045
Returns true if node is connected and false otherwise.
Inherited from
Section titled “Inherited from”ParentNode.isConnected
lastChild
Section titled “lastChild”
readonly
lastChild:null
|ChildNode
Defined in: lib.dom.d.ts:17051
Returns the last child.
Inherited from
Section titled “Inherited from”ParentNode.lastChild
lastElementChild
Section titled “lastElementChild”
readonly
lastElementChild:null
|Element
Defined in: lib.dom.d.ts:17763
Returns the last child that is an element, and null otherwise.
Inherited from
Section titled “Inherited from”ParentNode.lastElementChild
nextSibling
Section titled “nextSibling”
readonly
nextSibling:null
|ChildNode
Defined in: lib.dom.d.ts:17057
Returns the next sibling.
Inherited from
Section titled “Inherited from”ParentNode.nextSibling
nodeName
Section titled “nodeName”
readonly
nodeName:string
Defined in: lib.dom.d.ts:17063
Returns a string appropriate for the type of node.
Inherited from
Section titled “Inherited from”ParentNode.nodeName
nodeType
Section titled “nodeType”
readonly
nodeType:number
Defined in: lib.dom.d.ts:17069
Returns the type of node.
Inherited from
Section titled “Inherited from”ParentNode.nodeType
nodeValue
Section titled “nodeValue”nodeValue:
null
|string
Defined in: lib.dom.d.ts:17071
Inherited from
Section titled “Inherited from”ParentNode.nodeValue
NOTATION_NODE
Section titled “NOTATION_NODE”
readonly
NOTATION_NODE:12
Defined in: lib.dom.d.ts:17175
Inherited from
Section titled “Inherited from”ParentNode.NOTATION_NODE
ownerDocument
Section titled “ownerDocument”
readonly
ownerDocument:null
|Document
Defined in: lib.dom.d.ts:17077
Returns the node document. Returns null for documents.
Inherited from
Section titled “Inherited from”ParentNode.ownerDocument
parentElement
Section titled “parentElement”
readonly
parentElement:null
|HTMLElement
Defined in: lib.dom.d.ts:17083
Returns the parent element.
Inherited from
Section titled “Inherited from”ParentNode.parentElement
parentNode
Section titled “parentNode”
readonly
parentNode:null
|ParentNode
Defined in: lib.dom.d.ts:17089
Returns the parent.
Inherited from
Section titled “Inherited from”ParentNode.parentNode
previousSibling
Section titled “previousSibling”
readonly
previousSibling:null
|ChildNode
Defined in: lib.dom.d.ts:17095
Returns the previous sibling.
Inherited from
Section titled “Inherited from”ParentNode.previousSibling
PROCESSING_INSTRUCTION_NODE
Section titled “PROCESSING_INSTRUCTION_NODE”
readonly
PROCESSING_INSTRUCTION_NODE:7
Defined in: lib.dom.d.ts:17166
node is a ProcessingInstruction node.
Inherited from
Section titled “Inherited from”ParentNode.PROCESSING_INSTRUCTION_NODE
TEXT_NODE
Section titled “TEXT_NODE”
readonly
TEXT_NODE:3
Defined in: lib.dom.d.ts:17160
node is a Text node.
Inherited from
Section titled “Inherited from”ParentNode.TEXT_NODE
textContent
Section titled “textContent”textContent:
null
|string
Defined in: lib.dom.d.ts:17097
Inherited from
Section titled “Inherited from”ParentNode.textContent
win:
Window
Defined in: src/full-types.d.ts:1269
The window object this node belongs to, or the global window.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addEventListener()
Section titled “addEventListener()”addEventListener(
type
,callback
,options?
):void
Defined in: lib.dom.d.ts:8876
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options’s capture.
When set to true, options’s capture prevents callback from being invoked when the event’s eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event’s eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event’s eventPhase attribute value is AT_TARGET.
When set to true, options’s passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options’s once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options’s signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target’s event listener list and is not appended if it has the same type, callback, and capture.
Parameters
Section titled “Parameters”string
callback
Section titled “callback”null
| EventListenerOrEventListenerObject
options?
Section titled “options?”boolean
| AddEventListenerOptions
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.addEventListener
append()
Section titled “append()”append(…
nodes
):void
Defined in: lib.dom.d.ts:17771
Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes.
Throws a “HierarchyRequestError” DOMException if the constraints of the node tree are violated.
Parameters
Section titled “Parameters”…(string
| Node
)[]
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.append
appendChild()
Section titled “appendChild()”appendChild<
T
>(node
):T
Defined in: lib.dom.d.ts:17099
Type Parameters
Section titled “Type Parameters”T
extends Node
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T
Inherited from
Section titled “Inherited from”ParentNode.appendChild
appendText()
Section titled “appendText()”appendText(
val
):void
Defined in: src/full-types.d.ts:1284
Appends a text node to the node.
Parameters
Section titled “Parameters”string
The text to append.
Returns
Section titled “Returns”void
Example
Section titled “Example”const parent = createEl('p');parent.createEl('strong', { text: 'foo' });parent.appendText('bar');console.log(parent); // <p><strong>foo</strong>bar</p>
Inherited from
Section titled “Inherited from”cloneNode()
Section titled “cloneNode()”cloneNode(
subtree?
):Node
Defined in: lib.dom.d.ts:17105
Returns a copy of node. If deep is true, the copy also includes the node’s descendants.
Parameters
Section titled “Parameters”subtree?
Section titled “subtree?”boolean
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”ParentNode.cloneNode
compareDocumentPosition()
Section titled “compareDocumentPosition()”compareDocumentPosition(
other
):number
Defined in: lib.dom.d.ts:17111
Returns a bitmask indicating the position of other relative to node.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”ParentNode.compareDocumentPosition
contains()
Section titled “contains()”contains(
other
):boolean
Defined in: lib.dom.d.ts:17117
Returns true if other is an inclusive descendant of node, and false otherwise.
Parameters
Section titled “Parameters”null
| Node
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.contains
createDiv()
Section titled “createDiv()”createDiv(
o?
,callback?
):HTMLDivElement
Defined in: src/full-types.d.ts:1300
Creates a new <div>
element.
Parameters
Section titled “Parameters”The options object.
string
| DomElementInfo
callback?
Section titled “callback?”(el
) => void
A callback function to be called when the element is created.
Returns
Section titled “Returns”The created element.
Example
Section titled “Example”document.body.createDiv({ text: 'foo' }, (div) => { div.createEl('strong', { text: 'bar' });});
Inherited from
Section titled “Inherited from”createEl()
Section titled “createEl()”createEl<
K
>(tag
,o?
,callback?
):HTMLElementTagNameMap
[K
]
Defined in: src/full-types.d.ts:1318
Create an element and append it to this node.
Type Parameters
Section titled “Type Parameters”K
extends keyof HTMLElementTagNameMap
The type of the element to create.
Parameters
Section titled “Parameters”K
The tag name of the element to create.
The options object.
string
| DomElementInfo
callback?
Section titled “callback?”(el
) => void
A callback function to be called when the element is created.
Returns
Section titled “Returns”HTMLElementTagNameMap
[K
]
The created element.
Example
Section titled “Example”document.body.createEl('p', { text: 'foo' }, (div) => { div.createEl('strong', { text: 'bar' });});
Inherited from
Section titled “Inherited from”createSpan()
Section titled “createSpan()”createSpan(
o?
,callback?
):HTMLSpanElement
Defined in: src/full-types.d.ts:1338
Creates a new <span>
element.
Parameters
Section titled “Parameters”The options object.
string
| DomElementInfo
callback?
Section titled “callback?”(el
) => void
A callback function to be called when the element is created.
Returns
Section titled “Returns”The created element.
Example
Section titled “Example”document.body.createSpan({ text: 'foo' }, (span) => { span.createEl('strong', { text: 'bar' });});
Inherited from
Section titled “Inherited from”createSvg()
Section titled “createSvg()”createSvg<
K
>(tag
,o?
,callback?
):SVGElementTagNameMap
[K
]
Defined in: src/full-types.d.ts:1355
Creates a new svg element such as <svg>
, <circle>
, <rect>
, etc.
Type Parameters
Section titled “Type Parameters”K
extends keyof SVGElementTagNameMap
The type of the element to create.
Parameters
Section titled “Parameters”K
The tag name of the element to create.
The options object.
string
| SvgElementInfo
callback?
Section titled “callback?”(el
) => void
A callback function to be called when the element is created.
Returns
Section titled “Returns”SVGElementTagNameMap
[K
]
The created element.
Example
Section titled “Example”document.body.createSvg('svg', { cls: 'foo bar' }, (svg) => { svg.createSvg('circle');});@official
#### Inherited from
[`Node`](/obsidian-typings/api/obsidian-typings/namespaces/global/interfaces/node/).[`createSvg`](/obsidian-typings/api/obsidian-typings/namespaces/global/interfaces/node/#createsvg)
***
### detach()
> **detach**(): `void`
Defined in: src/full-types.d.ts:1373
Detaches the node from the DOM.
#### Returns
`void`
#### Example
```tsconst node = document.body.createEl('p');console.log(document.body.contains(node)); // truenode.detach();console.log(document.body.contains(node)); // false
Inherited from
Section titled “Inherited from”dispatchEvent()
Section titled “dispatchEvent()”dispatchEvent(
event
):boolean
Defined in: lib.dom.d.ts:8882
Dispatches a synthetic event event to target and returns true if either event’s cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.dispatchEvent
empty()
Section titled “empty()”empty():
void
Defined in: src/full-types.d.ts:1388
Empties the node.
Returns
Section titled “Returns”void
Example
Section titled “Example”const parent = createEl('p');parent.createEl('strong');console.log(parent.childNodes.length); // 1parent.empty();console.log(parent.childNodes.length); // 0
Inherited from
Section titled “Inherited from”find()
Section titled “find()”find(
selector
):null
|Element
Defined in: src/full-types.d.ts:497
Finds the first descendant element that matches the selector.
Parameters
Section titled “Parameters”selector
Section titled “selector”string
The selector to find the element with.
Returns
Section titled “Returns”null
| Element
The first descendant element that matches the selector, or null
if no match is found.
Example
Section titled “Example”const fragment = createFragment();fragment.createEl('strong', { cls: 'foo' });console.log(fragment.find('.foo')); // <strong class="foo"></strong>console.log(fragment.find('.bar')); // null
Remarks
Section titled “Remarks”See bug https://forum.obsidian.md/t/bug-find-findall-findallself/98108.
findAll()
Section titled “findAll()”findAll(
selector
):Element
[]
Defined in: src/full-types.d.ts:515
Finds all descendant elements that match the selector.
Parameters
Section titled “Parameters”selector
Section titled “selector”string
The selector to find the elements with.
Returns
Section titled “Returns”Element
[]
An array of all descendant elements that match the selector.
Example
Section titled “Example”const fragment = createFragment();fragment.createEl('strong', { cls: 'foo' });fragment.createEl('strong', { cls: 'foo' });console.log(fragment.findAll('.foo')); // [<strong class="foo"></strong>, <strong class="foo"></strong>]console.log(fragment.findAll('.bar')); // []
Remarks
Section titled “Remarks”See bug https://forum.obsidian.md/t/bug-find-findall-findallself/98108.
getElementById()
Section titled “getElementById()”getElementById(
elementId
):null
|Element
Defined in: lib.dom.d.ts:17322
Returns the first element within node’s descendants whose ID is elementId.
Parameters
Section titled “Parameters”elementId
Section titled “elementId”string
Returns
Section titled “Returns”null
| Element
Inherited from
Section titled “Inherited from”NonElementParentNode.getElementById
getRootNode()
Section titled “getRootNode()”getRootNode(
options?
):Node
Defined in: lib.dom.d.ts:17123
Returns node’s root.
Parameters
Section titled “Parameters”options?
Section titled “options?”GetRootNodeOptions
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”ParentNode.getRootNode
hasChildNodes()
Section titled “hasChildNodes()”hasChildNodes():
boolean
Defined in: lib.dom.d.ts:17129
Returns whether node has children.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.hasChildNodes
indexOf()
Section titled “indexOf()”indexOf(
other
):number
Defined in: src/full-types.d.ts:1397
Returns the index of the node or -1
if the node is not found.
Parameters
Section titled “Parameters”The node to find.
Returns
Section titled “Returns”number
The index of the node or -1
if the node is not found.
Inherited from
Section titled “Inherited from”insertAfter()
Section titled “insertAfter()”insertAfter<
T
>(node
,child
):T
Defined in: src/full-types.d.ts:1418
Inserts a child node after the current node.
Type Parameters
Section titled “Type Parameters”T
extends Node
The type of the node to insert.
Parameters
Section titled “Parameters”T
The node to insert.
The child node to insert after.
null
| Node
Returns
Section titled “Returns”T
The inserted node.
Example
Section titled “Example”const parent = createEl('p');const child1 = parent.createEl('strong', { text: '1' });const child2 = parent.createEl('strong', { text: '2' });const child3 = parent.createEl('strong', { text: '3' });const newNode = createEl('em', { text: '4' });parent.insertAfter(newNode, child2);console.log(parent); // <p><strong>1</strong><strong>2</strong><em>4</em><strong>3</strong></p>
Inherited from
Section titled “Inherited from”insertBefore()
Section titled “insertBefore()”insertBefore<
T
>(node
,child
):T
Defined in: lib.dom.d.ts:17131
Type Parameters
Section titled “Type Parameters”T
extends Node
Parameters
Section titled “Parameters”T
null
| Node
Returns
Section titled “Returns”T
Inherited from
Section titled “Inherited from”ParentNode.insertBefore
instanceOf()
Section titled “instanceOf()”instanceOf<
T
>(type
):this is T
Defined in: src/full-types.d.ts:1436
Cross-window capable instanceof check, a drop-in replacement. for instanceof checks on DOM Nodes. Remember to also check for nulls when necessary.
Type Parameters
Section titled “Type Parameters”T
The type of the instance.
Parameters
Section titled “Parameters”() => T
The type to check.
Returns
Section titled “Returns”this is T
true
if the node is of the given type, false
otherwise.
Example
Section titled “Example”const node = createEl('p');console.log(node.instanceOf(HTMLParagraphElement)); // trueconsole.log(node.instanceOf(HTMLSpanElement)); // false
Inherited from
Section titled “Inherited from”isDefaultNamespace()
Section titled “isDefaultNamespace()”isDefaultNamespace(
namespace
):boolean
Defined in: lib.dom.d.ts:17133
Parameters
Section titled “Parameters”namespace
Section titled “namespace”null
| string
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.isDefaultNamespace
isEqualNode()
Section titled “isEqualNode()”isEqualNode(
otherNode
):boolean
Defined in: lib.dom.d.ts:17139
Returns whether node and otherNode have the same properties.
Parameters
Section titled “Parameters”otherNode
Section titled “otherNode”null
| Node
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.isEqualNode
isSameNode()
Section titled “isSameNode()”isSameNode(
otherNode
):boolean
Defined in: lib.dom.d.ts:17141
Parameters
Section titled “Parameters”otherNode
Section titled “otherNode”null
| Node
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”ParentNode.isSameNode
lookupNamespaceURI()
Section titled “lookupNamespaceURI()”lookupNamespaceURI(
prefix
):null
|string
Defined in: lib.dom.d.ts:17143
Parameters
Section titled “Parameters”prefix
Section titled “prefix”null
| string
Returns
Section titled “Returns”null
| string
Inherited from
Section titled “Inherited from”ParentNode.lookupNamespaceURI
lookupPrefix()
Section titled “lookupPrefix()”lookupPrefix(
namespace
):null
|string
Defined in: lib.dom.d.ts:17145
Parameters
Section titled “Parameters”namespace
Section titled “namespace”null
| string
Returns
Section titled “Returns”null
| string
Inherited from
Section titled “Inherited from”ParentNode.lookupPrefix
normalize()
Section titled “normalize()”normalize():
void
Defined in: lib.dom.d.ts:17151
Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.normalize
prepend()
Section titled “prepend()”prepend(…
nodes
):void
Defined in: lib.dom.d.ts:17779
Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
Throws a “HierarchyRequestError” DOMException if the constraints of the node tree are violated.
Parameters
Section titled “Parameters”…(string
| Node
)[]
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.prepend
querySelector()
Section titled “querySelector()”Call Signature
Section titled “Call Signature”querySelector<
K
>(selectors
):null
|HTMLElementTagNameMap
[K
]
Defined in: lib.dom.d.ts:17785
Returns the first element that is a descendant of node that matches selectors.
Type Parameters
Section titled “Type Parameters”K
extends keyof HTMLElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”null
| HTMLElementTagNameMap
[K
]
Inherited from
Section titled “Inherited from”ParentNode.querySelector
Call Signature
Section titled “Call Signature”querySelector<
K
>(selectors
):null
|SVGElementTagNameMap
[K
]
Defined in: lib.dom.d.ts:17786
Type Parameters
Section titled “Type Parameters”K
extends keyof SVGElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”null
| SVGElementTagNameMap
[K
]
Inherited from
Section titled “Inherited from”ParentNode.querySelector
Call Signature
Section titled “Call Signature”querySelector<
K
>(selectors
):null
|MathMLElementTagNameMap
[K
]
Defined in: lib.dom.d.ts:17787
Type Parameters
Section titled “Type Parameters”K
extends keyof MathMLElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”null
| MathMLElementTagNameMap
[K
]
Inherited from
Section titled “Inherited from”ParentNode.querySelector
Call Signature
Section titled “Call Signature”querySelector<
K
>(selectors
):null
|HTMLElementDeprecatedTagNameMap
[K
]
Defined in: lib.dom.d.ts:17789
Type Parameters
Section titled “Type Parameters”K
extends keyof HTMLElementDeprecatedTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”null
| HTMLElementDeprecatedTagNameMap
[K
]
Inherited from
Section titled “Inherited from”ParentNode.querySelector
Call Signature
Section titled “Call Signature”querySelector<
E
>(selectors
):null
|E
Defined in: lib.dom.d.ts:17790
Type Parameters
Section titled “Type Parameters”Parameters
Section titled “Parameters”selectors
Section titled “selectors”string
Returns
Section titled “Returns”null
| E
Inherited from
Section titled “Inherited from”ParentNode.querySelector
querySelectorAll()
Section titled “querySelectorAll()”Call Signature
Section titled “Call Signature”querySelectorAll<
K
>(selectors
):NodeListOf
<HTMLElementTagNameMap
[K
]>
Defined in: lib.dom.d.ts:17796
Returns all element descendants of node that match selectors.
Type Parameters
Section titled “Type Parameters”K
extends keyof HTMLElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”NodeListOf
<HTMLElementTagNameMap
[K
]>
Inherited from
Section titled “Inherited from”ParentNode.querySelectorAll
Call Signature
Section titled “Call Signature”querySelectorAll<
K
>(selectors
):NodeListOf
<SVGElementTagNameMap
[K
]>
Defined in: lib.dom.d.ts:17797
Type Parameters
Section titled “Type Parameters”K
extends keyof SVGElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”NodeListOf
<SVGElementTagNameMap
[K
]>
Inherited from
Section titled “Inherited from”ParentNode.querySelectorAll
Call Signature
Section titled “Call Signature”querySelectorAll<
K
>(selectors
):NodeListOf
<MathMLElementTagNameMap
[K
]>
Defined in: lib.dom.d.ts:17798
Type Parameters
Section titled “Type Parameters”K
extends keyof MathMLElementTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”NodeListOf
<MathMLElementTagNameMap
[K
]>
Inherited from
Section titled “Inherited from”ParentNode.querySelectorAll
Call Signature
Section titled “Call Signature”querySelectorAll<
K
>(selectors
):NodeListOf
<HTMLElementDeprecatedTagNameMap
[K
]>
Defined in: lib.dom.d.ts:17800
Type Parameters
Section titled “Type Parameters”K
extends keyof HTMLElementDeprecatedTagNameMap
Parameters
Section titled “Parameters”selectors
Section titled “selectors”K
Returns
Section titled “Returns”NodeListOf
<HTMLElementDeprecatedTagNameMap
[K
]>
Inherited from
Section titled “Inherited from”ParentNode.querySelectorAll
Call Signature
Section titled “Call Signature”querySelectorAll<
E
>(selectors
):NodeListOf
<E
>
Defined in: lib.dom.d.ts:17801
Type Parameters
Section titled “Type Parameters”Parameters
Section titled “Parameters”selectors
Section titled “selectors”string
Returns
Section titled “Returns”NodeListOf
<E
>
Inherited from
Section titled “Inherited from”ParentNode.querySelectorAll
removeChild()
Section titled “removeChild()”removeChild<
T
>(child
):T
Defined in: lib.dom.d.ts:17153
Type Parameters
Section titled “Type Parameters”T
extends Node
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T
Inherited from
Section titled “Inherited from”ParentNode.removeChild
removeEventListener()
Section titled “removeEventListener()”removeEventListener(
type
,callback
,options?
):void
Defined in: lib.dom.d.ts:8888
Removes the event listener in target’s event listener list with the same type, callback, and options.
Parameters
Section titled “Parameters”string
callback
Section titled “callback”null
| EventListenerOrEventListenerObject
options?
Section titled “options?”boolean
| EventListenerOptions
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.removeEventListener
replaceChild()
Section titled “replaceChild()”replaceChild<
T
>(node
,child
):T
Defined in: lib.dom.d.ts:17155
Type Parameters
Section titled “Type Parameters”T
extends Node
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T
Inherited from
Section titled “Inherited from”ParentNode.replaceChild
replaceChildren()
Section titled “replaceChildren()”replaceChildren(…
nodes
):void
Defined in: lib.dom.d.ts:17809
Replace all children of node with nodes, while replacing strings in nodes with equivalent Text nodes.
Throws a “HierarchyRequestError” DOMException if the constraints of the node tree are violated.
Parameters
Section titled “Parameters”…(string
| Node
)[]
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”ParentNode.replaceChildren
setChildrenInPlace()
Section titled “setChildrenInPlace()”setChildrenInPlace(
children
):void
Defined in: src/full-types.d.ts:1455
Sets the children of the node.
Parameters
Section titled “Parameters”children
Section titled “children”Node
[]
The children to set.
Returns
Section titled “Returns”void
Example
Section titled “Example”const parent = createEl('p');const child1 = parent.createEl('strong', { text: '1' });const child2 = parent.createEl('strong', { text: '2' });const child3 = createEl('strong', { text: '3' });parent.setChildrenInPlace([child1, child3]);console.log(parent); // <p><strong>1</strong><strong>3</strong></p>