Skip to content

HTMLElement

Types

t

type t = DomTypes.htmlElement

Record fields

namespaceURI
Null.t< string >

Returns the namespace. Read more on MDN

prefix
Null.t< string >

Returns the namespace prefix. Read more on MDN

localName
string

Returns the local name. Read more on MDN

tagName
string

Returns the HTML-uppercased qualified name. Read more on MDN

id
string

Returns the value of element's id content attribute. Can be set to change it. Read more on MDN

className
string

Returns the value of element's class content attribute. Can be set to change it. Read more on MDN

classList
domTokenList

Allows for manipulation of element's class content attribute as a set of whitespace-separated tokens through a DOMTokenList object. Read more on MDN

slot
string

Returns the value of element's slot content attribute. Can be set to change it. Read more on MDN

attributes
namedNodeMap
shadowRoot
Null.t< shadowRoot >

Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. Read more on MDN

part
domTokenList
scrollTop
float
scrollLeft
float
scrollWidth
int
scrollHeight
int
clientTop
int
clientLeft
int
clientWidth
int
clientHeight
int
currentCSSZoom
float
innerHTML
string
outerHTML
string
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
Null.t< document >

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

parentNode
Null.t< node >

Returns the parent. Read more on MDN

parentElement
Null.t< htmlElement >

Returns the parent element. Read more on MDN

childNodes
nodeList< node >

Returns the children. Read more on MDN

firstChild
Null.t< node >

Returns the first child. Read more on MDN

lastChild
Null.t< node >

Returns the last child. Read more on MDN

previousSibling
Null.t< node >

Returns the previous sibling. Read more on MDN

nextSibling
Null.t< node >

Returns the next sibling. Read more on MDN

nodeValue
Null.t< string >
textContent
Null.t< string >
title
string
lang
string
translate
bool
dir
string
hidden
unknown
inert
bool
accessKey
string
accessKeyLabel
string
draggable
bool
spellcheck
bool
autocapitalize
string
innerText
string
outerText
string
popover
Null.t< string >
offsetParent
Null.t< element >
offsetTop
int
offsetLeft
int
offsetWidth
int
offsetHeight
int
style
cssStyleDeclaration
attributeStyleMap
stylePropertyMap
contentEditable
string
enterKeyHint
string
isContentEditable
bool
inputMode
string
dataset
domStringMap
nonce
option< string >
autofocus
bool
tabIndex
int

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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.addEventListenerOptions=?,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener option< EventTypes.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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener

Return type

unit

after

Inserts nodes just after 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 after: (t, DomTypes.node) => unit

Parameters

t DomTypes.node

Return type

unit

after2

Inserts nodes just after 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 after2: (t, string) => unit

Parameters

t string

Return type

unit

animate

let animate: (
t,
~keyframes: unknown,
~options: float=?,
) => DomTypes.animation

Parameters

t unknown option< float >

Return type

DomTypes.animation

animate2

let animate2: (
t,
~keyframes: unknown,
~options: DomTypes.keyframeAnimationOptions=?,
) => DomTypes.animation

Parameters

t unknown option< DomTypes.keyframeAnimationOptions >

Return type

DomTypes.animation

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: (t, DomTypes.node) => unit

Parameters

t DomTypes.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: (t, string) => unit

Parameters

t string

Return type

unit

appendChild

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

asElement

let asElement: t => DomTypes.element

Parameters

t

Return type

DomTypes.element

asEventTarget

let asEventTarget: t => EventTypes.eventTarget

Parameters

t

Return type

EventTypes.eventTarget

asHTMLElement

let asHTMLElement: t => t

Parameters

t

Return type

t

asNode

let asNode: t => DomTypes.node

Parameters

t

Return type

DomTypes.node

attachInternals

let attachInternals: t => DomTypes.elementInternals

Parameters

t

Return type

DomTypes.elementInternals

attachShadow

Creates a shadow root for element and returns it. Read more on MDN

let attachShadow: (t, DomTypes.shadowRootInit) => DomTypes.shadowRoot

Parameters

t DomTypes.shadowRootInit

Return type

DomTypes.shadowRoot

before

Inserts nodes just before 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 before: (t, DomTypes.node) => unit

Parameters

t DomTypes.node

Return type

unit

before2

Inserts nodes just before 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 before2: (t, string) => unit

Parameters

t string

Return type

unit

blur

let blur: t => unit

Parameters

t

Return type

unit

checkVisibility

let checkVisibility: (t, ~options: DomTypes.checkVisibilityOptions=?) => bool

Parameters

t option< DomTypes.checkVisibilityOptions >

Return type

bool

click

let click: t => unit

Parameters

t

Return type

unit

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

t option< bool >

Return type

t

closest

Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. Read more on MDN

let closest: (t, string) => 'e

Parameters

t

Return type

string

compareDocumentPosition

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

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

Parameters

t DomTypes.node

Return type

int

computedStyleMap

let computedStyleMap: t => DomTypes.stylePropertyMapReadOnly

Parameters

t

Return type

DomTypes.stylePropertyMapReadOnly

contains

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

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

Parameters

t DomTypes.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, EventTypes.event) => bool

Parameters

t EventTypes.event

Return type

bool

focus

let focus: (t, ~options: DomTypes.focusOptions=?) => unit

Parameters

t option< DomTypes.focusOptions >

Return type

unit

getAnimations

let getAnimations: (
t,
~options: DomTypes.getAnimationsOptions=?,
) => array<DomTypes.animation>

Parameters

t option< DomTypes.getAnimationsOptions >

Return type

array< DomTypes.animation >

getAttribute

Returns element's first attribute whose qualified name is qualifiedName, and null if there is no such attribute otherwise. Read more on MDN

let getAttribute: (t, string) => null<string>

Parameters

t string

Return type

Stdlib.null< string >

getAttributeNames

Returns the qualified names of all element's attributes. Can contain duplicates. Read more on MDN

let getAttributeNames: t => array<string>

Parameters

t

Return type

array< string >

getAttributeNode

let getAttributeNode: (t, string) => DomTypes.attr

Parameters

t string

Return type

DomTypes.attr

getAttributeNodeNS

let getAttributeNodeNS: (t, ~namespace: string, ~localName: string) => DomTypes.attr

Parameters

t string string

Return type

DomTypes.attr

getAttributeNS

Returns element's attribute whose namespace is namespace and local name is localName, and null if there is no such attribute otherwise. Read more on MDN

let getAttributeNS: (t, ~namespace: string, ~localName: string) => string

Parameters

t string string

Return type

string

getBoundingClientRect

let getBoundingClientRect: t => DomTypes.domRect

Parameters

t

Return type

DomTypes.domRect

getClientRects

let getClientRects: t => DomTypes.domRectList

Parameters

t

Return type

DomTypes.domRectList

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: (t, string) => DomTypes.htmlCollection<DomTypes.element>

Parameters

t string

Return type

DomTypes.htmlCollection< DomTypes.element >

getElementsByTagName

let getElementsByTagName: (t, string) => DomTypes.htmlCollection<DomTypes.element>

Parameters

t string

Return type

DomTypes.htmlCollection< DomTypes.element >

getElementsByTagNameNS

let getElementsByTagNameNS: (
DomTypes.element,
~namespace: string,
~localName: string,
) => DomTypes.htmlCollection<DomTypes.element>

Parameters

DomTypes.element string string

Return type

DomTypes.htmlCollection< DomTypes.element >

getHTML

let getHTML: (t, ~options: DomTypes.getHTMLOptions=?) => string

Parameters

t option< DomTypes.getHTMLOptions >

Return type

string

getRootNode

Returns node's root. Read more on MDN

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

Parameters

t option< DomTypes.getRootNodeOptions >

Return type

DomTypes.node

hasAttribute

Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. Read more on MDN

let hasAttribute: (t, string) => bool

Parameters

t string

Return type

bool

hasAttributeNS

Returns true if element has an attribute whose namespace is namespace and local name is localName. Read more on MDN

let hasAttributeNS: (t, ~namespace: string, ~localName: string) => bool

Parameters

t string string

Return type

bool

hasAttributes

Returns true if element has attributes, and false otherwise. Read more on MDN

let hasAttributes: t => bool

Parameters

t

Return type

bool

hasChildNodes

Returns whether node has children. Read more on MDN

let hasChildNodes: t => bool

Parameters

t

Return type

bool

hasPointerCapture

let hasPointerCapture: (t, int) => bool

Parameters

t int

Return type

bool

hidePopover

let hidePopover: t => unit

Parameters

t

Return type

unit

insertAdjacentElement

let insertAdjacentElement: (
t,
~where: DomTypes.insertPosition,
~element: DomTypes.element,
) => DomTypes.element

Parameters

t DomTypes.insertPosition DomTypes.element

Return type

DomTypes.element

insertAdjacentHTML

let insertAdjacentHTML: (
t,
~position: DomTypes.insertPosition,
~string: string,
) => unit

Parameters

t DomTypes.insertPosition string

Return type

unit

insertAdjacentText

let insertAdjacentText: (t, ~where: DomTypes.insertPosition, ~data: string) => unit

Parameters

t DomTypes.insertPosition string

Return type

unit

insertBefore

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

Parameters

t

Return type

DomTypes.node

isDefaultNamespace

let isDefaultNamespace: (t, string) => bool

Parameters

t string

Return type

bool

isEqualNode

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

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

Parameters

t DomTypes.node

Return type

bool

isSameNode

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

Parameters

t DomTypes.node

Return type

bool

lookupNamespaceURI

let lookupNamespaceURI: (t, string) => string

Parameters

t string

Return type

string

lookupPrefix

let lookupPrefix: (t, string) => string

Parameters

t string

Return type

string

matches

Returns true if matching selectors against element's root yields element, and false otherwise. Read more on MDN

let matches: (t, string) => bool

Parameters

t string

Return type

bool

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

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: (t, DomTypes.node) => unit

Parameters

t DomTypes.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: (t, string) => unit

Parameters

t string

Return type

unit

querySelector

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

let querySelector: (t, string) => Null.t<DomTypes.element>

Parameters

t string

Return type

Stdlib.Null.t< DomTypes.element >

querySelectorAll

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

let querySelectorAll: (t, string) => DomTypes.nodeList<DomTypes.element>

Parameters

t string

Return type

DomTypes.nodeList< DomTypes.element >

releasePointerCapture

let releasePointerCapture: (t, int) => unit

Parameters

t int

Return type

unit

remove

Removes node. Read more on MDN

let remove: t => unit

Parameters

t

Return type

unit

removeAttribute

Removes element's first attribute whose qualified name is qualifiedName. Read more on MDN

let removeAttribute: (t, string) => unit

Parameters

t string

Return type

unit

removeAttributeNode

let removeAttributeNode: (t, DomTypes.attr) => DomTypes.attr

Parameters

t DomTypes.attr

Return type

DomTypes.attr

removeAttributeNS

Removes element's attribute whose namespace is namespace and local name is localName. Read more on MDN

let removeAttributeNS: (t, ~namespace: string, ~localName: string) => unit

Parameters

t string string

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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.eventListenerOptions=?,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener option< EventTypes.eventListenerOptions >

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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener

Return type

unit

replaceChild

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

Parameters

t

Return type

DomTypes.node

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: (t, DomTypes.node) => unit

Parameters

t DomTypes.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: (t, string) => unit

Parameters

t string

Return type

unit

replaceWith

Replaces 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 replaceWith: (t, DomTypes.node) => unit

Parameters

t DomTypes.node

Return type

unit

replaceWith2

Replaces 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 replaceWith2: (t, string) => unit

Parameters

t string

Return type

unit

requestFullscreen

Displays element fullscreen and resolves promise when done.

When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference. Read more on MDN

let requestFullscreen: (t, ~options: DomTypes.fullscreenOptions=?) => promise<unit>

Parameters

t option< DomTypes.fullscreenOptions >

Return type

promise< unit >

requestPointerLock

let requestPointerLock: (
t,
~options: DomTypes.pointerLockOptions=?,
) => promise<unit>

Parameters

t option< DomTypes.pointerLockOptions >

Return type

promise< unit >

scroll

let scroll: (t, ~options: DomTypes.scrollToOptions=?) => unit

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scroll2

let scroll2: (t, ~x: float, ~y: float) => unit

Parameters

t float float

Return type

unit

scrollBy

let scrollBy: (t, ~options: DomTypes.scrollToOptions=?) => unit

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scrollBy2

let scrollBy2: (t, ~x: float, ~y: float) => unit

Parameters

t float float

Return type

unit

scrollIntoView

scrollIntoView()

Scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.

element->Element.scrollIntoView()

Read more on MDN

let scrollIntoView: t => unit

Parameters

t

Return type

unit

scrollIntoViewAlignToTop

scrollIntoView(true)

Scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.

element->Element.scrollIntoView_alignToTop()

Read more on MDN

let scrollIntoViewAlignToTop: t => unit

Parameters

t

Return type

unit

scrollIntoViewWithOptions

scrollIntoView({ behavior: "smooth" })

Scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.

element->Element.scrollIntoViewWithOptions({ behavior: DOMAPI.Smooth })

Read more on MDN

let scrollIntoViewWithOptions: (t, DomTypes.scrollIntoViewOptions) => unit

Parameters

t DomTypes.scrollIntoViewOptions

Return type

unit

scrollTo

let scrollTo: (t, ~options: DomTypes.scrollToOptions=?) => unit

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scrollTo2

let scrollTo2: (t, ~x: float, ~y: float) => unit

Parameters

t float float

Return type

unit

setAttribute

Sets the value of element's first attribute whose qualified name is qualifiedName to value. Read more on MDN

let setAttribute: (t, ~qualifiedName: string, ~value: string) => unit

Parameters

t string string

Return type

unit

setAttributeNode

let setAttributeNode: (t, DomTypes.attr) => DomTypes.attr

Parameters

t DomTypes.attr

Return type

DomTypes.attr

setAttributeNodeNS

let setAttributeNodeNS: (t, DomTypes.attr) => DomTypes.attr

Parameters

t DomTypes.attr

Return type

DomTypes.attr

setAttributeNS

Sets the value of element's attribute whose namespace is namespace and local name is localName to value. Read more on MDN

let setAttributeNS: (
DomTypes.element,
~namespace: string,
~qualifiedName: string,
~value: string,
) => unit

Parameters

DomTypes.element string string string

Return type

unit

setHTMLUnsafe

let setHTMLUnsafe: (t, string) => unit

Parameters

t string

Return type

unit

setPointerCapture

let setPointerCapture: (t, int) => unit

Parameters

t int

Return type

unit

showPopover

let showPopover: t => unit

Parameters

t

Return type

unit

toggleAttribute

If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName.

Returns true if qualifiedName is now present, and false otherwise. Read more on MDN

let toggleAttribute: (t, ~qualifiedName: string, ~force: bool=?) => bool

Parameters

t string option< bool >

Return type

bool

togglePopover

let togglePopover: (t, ~force: bool=?) => bool

Parameters

t option< bool >

Return type

bool