Skip to content

Node

Types

getRootNodeOptions

type getRootNodeOptions = {mutable composed?: bool}

Record fields

composed
option<bool>

t

type t = WebAPI.DOMTree.node = {
nodeType: int,
nodeName: string,
baseURI: string,
isConnected: bool,
ownerDocument: Null.t<WebAPI.DOM.document>,
parentNode: Null.t<WebAPI.DOMTree.node>,
parentElement: Null.t<WebAPI.DOMTree.element>,
childNodes: WebAPI.DOM.nodeList<WebAPI.DOMTree.node>,
firstChild: Null.t<WebAPI.DOMTree.node>,
lastChild: Null.t<WebAPI.DOMTree.node>,
previousSibling: Null.t<WebAPI.DOMTree.node>,
nextSibling: Null.t<WebAPI.DOMTree.node>,
mutable nodeValue: Null.t<string>,
mutable textContent: Null.t<string>,
}

Record fields

nodeType
int

Returns the type of node. Read more on MDN

nodeName
string

Returns a string appropriate for the type of node. Read more on MDN

baseURI
string

Returns node's node document's document base URL. Read more on MDN

isConnected
bool

Returns true if node is connected and false otherwise. Read more on MDN

ownerDocument

Returns the node document. Returns null for documents. Read more on MDN

parentNode

Returns the parent. Read more on MDN

parentElement

Returns the parent element. Read more on MDN

firstChild

Returns the first child. Read more on MDN

lastChild

Returns the last child. Read more on MDN

previousSibling

Returns the previous sibling. Read more on MDN

nextSibling

Returns the next sibling. Read more on MDN

nodeValue
Null.t<string>
textContent
Null.t<string>

Values

addEventListener

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. Read more on MDN

let addEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.addEventListenerOptions=?,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.toption<WebAPI.DOM.EventListener.addEventListenerOptions>

Return type

unit

addEventListenerWithCapture

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. Read more on MDN

let addEventListenerWithCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.t

Return type

unit

appendChild

let appendChild: (t, 't) => 't

asEventTarget

let asEventTarget: t => WebAPI.DOM.eventTarget

Parameters

t

Return type

WebAPI.DOM.eventTarget

asNode

let asNode: t => WebAPI.DOMTree.node

Parameters

t

Return type

WebAPI.DOMTree.node

cloneNode

Returns a copy of node. If deep is true, the copy also includes the node's descendants. Read more on MDN

let cloneNode: (t, ~deep: bool=?) => t

Parameters

toption<bool>

Return type

t

compareDocumentPosition

Returns a bitmask indicating the position of other relative to node. Read more on MDN

let compareDocumentPosition: (t, WebAPI.DOMTree.node) => int

Parameters

tWebAPI.DOMTree.node

Return type

int

contains

Returns true if other is an inclusive descendant of node, and false otherwise. Read more on MDN

let contains: (t, WebAPI.DOMTree.node) => bool

Parameters

tWebAPI.DOMTree.node

Return type

bool

dispatchEvent

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. Read more on MDN

let dispatchEvent: (t, WebAPI.DOM.event) => bool

Parameters

tWebAPI.DOM.event

Return type

bool

getRootNode

Returns node's root. Read more on MDN

let getRootNode: (t, ~options: getRootNodeOptions=?) => WebAPI.DOMTree.node

Parameters

toption<getRootNodeOptions>

Return type

WebAPI.DOMTree.node

hasChildNodes

Returns whether node has children. Read more on MDN

let hasChildNodes: t => bool

Parameters

t

Return type

bool

insertBefore

let insertBefore: (t, 't, ~child: WebAPI.DOMTree.node) => 't

Parameters

t

Return type

WebAPI.DOMTree.node

isDefaultNamespace

let isDefaultNamespace: (t, string) => bool

Parameters

tstring

Return type

bool

isEqualNode

Returns whether node and otherNode have the same properties. Read more on MDN

let isEqualNode: (t, WebAPI.DOMTree.node) => bool

Parameters

tWebAPI.DOMTree.node

Return type

bool

isSameNode

let isSameNode: (t, WebAPI.DOMTree.node) => bool

Parameters

tWebAPI.DOMTree.node

Return type

bool

lookupNamespaceURI

let lookupNamespaceURI: (t, string) => Null.t<string>

Parameters

tstring

Return type

Stdlib.Null.t<string>

lookupPrefix

let lookupPrefix: (t, string) => Null.t<string>

Parameters

tstring

Return type

Stdlib.Null.t<string>

normalize

Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes. Read more on MDN

let normalize: t => unit

Parameters

t

Return type

unit

removeChild

let removeChild: (t, 't) => 't

removeEventListener

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.options=?,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.toption<WebAPI.DOM.EventListener.options>

Return type

unit

removeEventListenerUseCapture

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListenerUseCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.t

Return type

unit

replaceChild

let replaceChild: (t, ~node: WebAPI.DOMTree.node, 't) => 't

Parameters

t

Return type

WebAPI.DOMTree.node