Skip to content

Document

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: (
WebAPI.DOMAPI.document,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
~options: WebAPI.EventAPI.addEventListenerOptions=?,
) => unit

addEventListener_useCapture

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_useCapture: (
WebAPI.DOMAPI.document,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
) => unit

adoptNode

Moves node from another document and returns it.

If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException. Read more on MDN

let adoptNode: (WebAPI.DOMAPI.document, 't) => 't

append

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

let append: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => unit

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

unit

append2

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

let append2: (WebAPI.DOMAPI.document, string) => unit

Parameters

WebAPI.DOMAPI.document string

Return type

unit

appendChild

let appendChild: (WebAPI.DOMAPI.document, 't) => 't

asEventTarget

let asEventTarget: WebAPI.DOMAPI.document => WebAPI.EventAPI.eventTarget

asNode

let asNode: WebAPI.DOMAPI.document => WebAPI.DOMAPI.node

caretPositionFromPoint

let caretPositionFromPoint: (
WebAPI.DOMAPI.document,
~x: float,
~y: float,
~options: WebAPI.DOMAPI.caretPositionFromPointOptions=?,
) => WebAPI.DOMAPI.caretPosition

cloneNode

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

let cloneNode: (
WebAPI.DOMAPI.document,
~deep: bool=?,
) => WebAPI.DOMAPI.document

Parameters

WebAPI.DOMAPI.document option< bool >

Return type

WebAPI.DOMAPI.document

close

Closes an output stream and forces the sent data to display. Read more on MDN

let close: WebAPI.DOMAPI.document => unit

Parameters

WebAPI.DOMAPI.document

Return type

unit

compareDocumentPosition

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

let compareDocumentPosition: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => int

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

int

contains

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

let contains: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => bool

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

bool

createAttribute

Creates an attribute object with a specified name. @param name String that sets the attribute object's name. Read more on MDN

let createAttribute: (WebAPI.DOMAPI.document, string) => WebAPI.DOMAPI.attr

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.attr

createAttributeNS

let createAttributeNS: (
WebAPI.DOMAPI.document,
~namespace: string,
~qualifiedName: string,
) => WebAPI.DOMAPI.attr

Parameters

WebAPI.DOMAPI.document string string

Return type

WebAPI.DOMAPI.attr

createCDATASection

Returns a CDATASection node whose data is data. Read more on MDN

let createCDATASection: (
WebAPI.DOMAPI.document,
string,
) => WebAPI.DOMAPI.cdataSection

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.cdataSection

createComment

Creates a comment object with the specified data. @param data Sets the comment object's data. Read more on MDN

let createComment: (WebAPI.DOMAPI.document, string) => WebAPI.DOMAPI.comment

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.comment

createDocumentFragment

Creates a new document. Read more on MDN

let createDocumentFragment: WebAPI.DOMAPI.document => WebAPI.DOMAPI.documentFragment

createElement

Creates an instance of the element for the specified tag. @param tagName The name of an element. Read more on MDN

let createElement: (
WebAPI.DOMAPI.document,
~localName: string,
~options: string=?,
) => WebAPI.DOMAPI.element

Parameters

WebAPI.DOMAPI.document string option< string >

Return type

WebAPI.DOMAPI.element

createElement2

Creates an instance of the element for the specified tag. @param tagName The name of an element. Read more on MDN

let createElement2: (
WebAPI.DOMAPI.document,
~localName: string,
~options: WebAPI.DOMAPI.elementCreationOptions=?,
) => WebAPI.DOMAPI.element

createElementNS

Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName.

If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown.

If one of the following conditions is true a "NamespaceError" DOMException will be thrown:

localName does not match the QName production. Namespace prefix is not null and namespace is the empty string. Namespace prefix is "xml" and namespace is not the XML namespace. qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".

When supplied, options's is can be used to create a customized built-in element. Read more on MDN

let createElementNS: (
WebAPI.DOMAPI.document,
~namespace: string,
~qualifiedName: string,
~options: string=?,
) => WebAPI.DOMAPI.element

Parameters

WebAPI.DOMAPI.document string string option< string >

Return type

WebAPI.DOMAPI.element

createElementNS2

Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName.

If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown.

If one of the following conditions is true a "NamespaceError" DOMException will be thrown:

localName does not match the QName production. Namespace prefix is not null and namespace is the empty string. Namespace prefix is "xml" and namespace is not the XML namespace. qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".

When supplied, options's is can be used to create a customized built-in element. Read more on MDN

let createElementNS2: (
WebAPI.DOMAPI.document,
~namespace: string,
~qualifiedName: string,
~options: WebAPI.DOMAPI.elementCreationOptions=?,
) => WebAPI.DOMAPI.element

createEvent

let createEvent: (WebAPI.DOMAPI.document, string) => WebAPI.EventAPI.event

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.EventAPI.event

createExpression

let createExpression: (
WebAPI.DOMAPI.document,
~expression: string,
~resolver: WebAPI.DOMAPI.xPathNSResolver=?,
) => WebAPI.DOMAPI.xPathExpression

createNodeIterator

Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. @param root The root element or node to start traversing on. @param whatToShow The type of nodes or elements to appear in the node list @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. Read more on MDN

let createNodeIterator: (
WebAPI.DOMAPI.document,
~root: WebAPI.DOMAPI.node,
~whatToShow: int=?,
~filter: WebAPI.DOMAPI.nodeFilter=?,
) => WebAPI.DOMAPI.nodeIterator

createProcessingInstruction

Returns a ProcessingInstruction node whose target is target and data is data. If target does not match the Name production an "InvalidCharacterError" DOMException will be thrown. If data contains "?>" an "InvalidCharacterError" DOMException will be thrown. Read more on MDN

let createProcessingInstruction: (
WebAPI.DOMAPI.document,
~target: string,
~data: string,
) => WebAPI.DOMAPI.processingInstruction

Parameters

WebAPI.DOMAPI.document string string

Return type

WebAPI.DOMAPI.processingInstruction

createRange

Returns an empty range object that has both of its boundary points positioned at the beginning of the document. Read more on MDN

let createRange: WebAPI.DOMAPI.document => WebAPI.DOMAPI.range

createTextNode

Creates a text string from the specified value. @param data String that specifies the nodeValue property of the text node. Read more on MDN

let createTextNode: (WebAPI.DOMAPI.document, string) => WebAPI.DOMAPI.text

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.text

createTreeWalker

Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. @param root The root element or node to start traversing on. @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. @param filter A custom NodeFilter function to use. Read more on MDN

let createTreeWalker: (
WebAPI.DOMAPI.document,
~root: WebAPI.DOMAPI.node,
~whatToShow: int=?,
~filter: WebAPI.DOMAPI.nodeFilter=?,
) => WebAPI.DOMAPI.treeWalker

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: (WebAPI.DOMAPI.document, WebAPI.EventAPI.event) => bool

Parameters

WebAPI.DOMAPI.document WebAPI.EventAPI.event

Return type

bool

evaluate

let evaluate: (
WebAPI.DOMAPI.document,
~expression: string,
~contextNode: WebAPI.DOMAPI.node,
~resolver: WebAPI.DOMAPI.xPathNSResolver=?,
~type_: int=?,
~result: WebAPI.DOMAPI.xPathResult=?,
) => WebAPI.DOMAPI.xPathResult

exitFullscreen

Stops document's fullscreen element from being displayed fullscreen and resolves promise when done. Read more on MDN

let exitFullscreen: WebAPI.DOMAPI.document => Promise.t<unit>

Parameters

WebAPI.DOMAPI.document

Return type

Promise.t< unit >

exitPictureInPicture

let exitPictureInPicture: WebAPI.DOMAPI.document => Promise.t<unit>

Parameters

WebAPI.DOMAPI.document

Return type

Promise.t< unit >

exitPointerLock

let exitPointerLock: WebAPI.DOMAPI.document => unit

Parameters

WebAPI.DOMAPI.document

Return type

unit

getAnimations

let getAnimations: WebAPI.DOMAPI.document => array<WebAPI.DOMAPI.animation>

Parameters

WebAPI.DOMAPI.document

Return type

array< WebAPI.DOMAPI.animation >

getElementById

Returns the first element within node's descendants whose ID is elementId. Read more on MDN

let getElementById: (WebAPI.DOMAPI.document, string) => WebAPI.DOMAPI.element

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.element

getElementsByClassName

Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. Read more on MDN

let getElementsByClassName: (
WebAPI.DOMAPI.document,
string,
) => WebAPI.DOMAPI.htmlCollectionOf<WebAPI.DOMAPI.element>

getElementsByName

Gets a collection of objects based on the value of the NAME or ID attribute. @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. Read more on MDN

let getElementsByName: (
WebAPI.DOMAPI.document,
string,
) => WebAPI.DOMAPI.nodeListOf<WebAPI.DOMAPI.htmlElement>

getElementsByTagName

Retrieves a collection of objects based on the specified element name. @param name Specifies the name of an element. Read more on MDN

let getElementsByTagName: (
WebAPI.DOMAPI.document,
string,
) => WebAPI.DOMAPI.htmlCollection

getElementsByTagNameNS

If namespace and localName are "*" returns a HTMLCollection of all descendant elements.

If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName.

If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace.

Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. Read more on MDN

let getElementsByTagNameNS: (
WebAPI.DOMAPI.document,
~namespace: string,
~localName: string,
) => WebAPI.DOMAPI.htmlCollectionOf<WebAPI.DOMAPI.element>

getRootNode

Returns node's root. Read more on MDN

let getRootNode: (
WebAPI.DOMAPI.document,
~options: WebAPI.DOMAPI.getRootNodeOptions=?,
) => WebAPI.DOMAPI.node

getSelection

Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. Read more on MDN

let getSelection: WebAPI.DOMAPI.document => WebAPI.DOMAPI.selection

hasChildNodes

Returns whether node has children. Read more on MDN

let hasChildNodes: WebAPI.DOMAPI.document => bool

Parameters

WebAPI.DOMAPI.document

Return type

bool

hasFocus

Gets a value indicating whether the object currently has focus. Read more on MDN

let hasFocus: WebAPI.DOMAPI.document => bool

Parameters

WebAPI.DOMAPI.document

Return type

bool

hasStorageAccess

let hasStorageAccess: WebAPI.DOMAPI.document => Promise.t<bool>

Parameters

WebAPI.DOMAPI.document

Return type

Promise.t< bool >

importNode

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

If node is a document or a shadow root, throws a "NotSupportedError" DOMException. Read more on MDN

let importNode: (WebAPI.DOMAPI.document, 't, ~deep: bool=?) => 't

Parameters

WebAPI.DOMAPI.document

Return type

option< bool >

insertBefore

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

isDefaultNamespace

let isDefaultNamespace: (WebAPI.DOMAPI.document, string) => bool

Parameters

WebAPI.DOMAPI.document string

Return type

bool

isEqualNode

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

let isEqualNode: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => bool

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

bool

isSameNode

let isSameNode: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => bool

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

bool

lookupNamespaceURI

let lookupNamespaceURI: (WebAPI.DOMAPI.document, string) => string

Parameters

WebAPI.DOMAPI.document string

Return type

string

lookupPrefix

let lookupPrefix: (WebAPI.DOMAPI.document, string) => string

Parameters

WebAPI.DOMAPI.document string

Return type

string

make

let make: unit => WebAPI.DOMAPI.document

Parameters

unit

Return type

WebAPI.DOMAPI.document

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: WebAPI.DOMAPI.document => unit

Parameters

WebAPI.DOMAPI.document

Return type

unit

open_

Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. @param url Specifies a MIME type for the document. @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. @param replace Specifies whether the existing entry for the document is replaced in the history list. Read more on MDN

let open_: (
WebAPI.DOMAPI.document,
~unused1: string=?,
~unused2: string=?,
) => WebAPI.DOMAPI.document

Parameters

WebAPI.DOMAPI.document option< string > option< string >

Return type

WebAPI.DOMAPI.document

open2

Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. @param url Specifies a MIME type for the document. @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. @param replace Specifies whether the existing entry for the document is replaced in the history list. Read more on MDN

let open2: (
WebAPI.DOMAPI.document,
~url: string,
~name: string,
~features: string,
) => WebAPI.DOMAPI.window

Parameters

WebAPI.DOMAPI.document string string string

Return type

WebAPI.DOMAPI.window

parseHTMLUnsafe

let parseHTMLUnsafe: string => WebAPI.DOMAPI.document

Parameters

string

Return type

WebAPI.DOMAPI.document

prepend

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

let prepend: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => unit

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

unit

prepend2

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

let prepend2: (WebAPI.DOMAPI.document, string) => unit

Parameters

WebAPI.DOMAPI.document string

Return type

unit

querySelector

Returns the first element that is a descendant of node that matches selectors. Read more on MDN

let querySelector: (
WebAPI.DOMAPI.document,
string,
) => Null.t<WebAPI.DOMAPI.element>

Parameters

WebAPI.DOMAPI.document string

Return type

Null.t< WebAPI.DOMAPI.element >

querySelectorAll

Returns all element descendants of node that match selectors. Read more on MDN

let querySelectorAll: (WebAPI.DOMAPI.document, string) => WebAPI.DOMAPI.nodeList

Parameters

WebAPI.DOMAPI.document string

Return type

WebAPI.DOMAPI.nodeList

removeChild

let removeChild: (WebAPI.DOMAPI.document, '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: (
WebAPI.DOMAPI.document,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
~options: WebAPI.EventAPI.eventListenerOptions=?,
) => unit

removeEventListener_useCapture

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

let removeEventListener_useCapture: (
WebAPI.DOMAPI.document,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
) => unit

replaceChild

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

replaceChildren

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

let replaceChildren: (WebAPI.DOMAPI.document, WebAPI.DOMAPI.node) => unit

Parameters

WebAPI.DOMAPI.document WebAPI.DOMAPI.node

Return type

unit

replaceChildren2

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

let replaceChildren2: (WebAPI.DOMAPI.document, string) => unit

Parameters

WebAPI.DOMAPI.document string

Return type

unit

requestStorageAccess

let requestStorageAccess: WebAPI.DOMAPI.document => Promise.t<unit>

Parameters

WebAPI.DOMAPI.document

Return type

Promise.t< unit >

startViewTransition

let startViewTransition: (
WebAPI.DOMAPI.document,
~callbackOptions: WebAPI.ViewTransitionsAPI.viewTransitionUpdateCallback=?,
) => WebAPI.ViewTransitionsAPI.viewTransition

write

Writes one or more HTML expressions to a document in the specified window. @param content Specifies the text and HTML tags to write. Read more on MDN

let write: (WebAPI.DOMAPI.document, string) => unit

Parameters

WebAPI.DOMAPI.document string

Return type

unit

writeln

Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. @param content The text and HTML tags to write. Read more on MDN

let writeln: (WebAPI.DOMAPI.document, string) => unit

Parameters

WebAPI.DOMAPI.document string

Return type

unit