HTMLElement
Types
t
type t = DomTypes.htmlElementRecord fields
id
Returns the value of element's id content attribute. Can be set to change it. Read more on MDN
className
Returns the value of element's class content attribute. Can be set to change it. Read more on MDN
classList
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
Returns the value of element's slot content attribute. Can be set to change it. Read more on MDN
shadowRoot
Returns element's shadow root, if any, and if shadow root's mode is "open", and null otherwise. Read more on MDN
ownerDocument
Returns the node document. Returns null for documents. Read more on MDN
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=?,) => unitParameters
t EventTypes.eventType EventTypes.eventListener option< EventTypes.addEventListenerOptions >Return type
unitaddEventListenerWithCapture
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>,) => unitafter
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) => unitafter2
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) => unitanimate
let animate: ( t, ~keyframes: unknown, ~options: float=?,) => DomTypes.animationanimate2
let animate2: ( t, ~keyframes: unknown, ~options: DomTypes.keyframeAnimationOptions=?,) => DomTypes.animationappend
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) => unitappend2
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) => unitasEventTarget
let asEventTarget: t => EventTypes.eventTargetattachInternals
let attachInternals: t => DomTypes.elementInternalsattachShadow
Creates a shadow root for element and returns it. Read more on MDN
let attachShadow: (t, DomTypes.shadowRootInit) => DomTypes.shadowRootbefore
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) => unitbefore2
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) => unitcheckVisibility
let checkVisibility: (t, ~options: DomTypes.checkVisibilityOptions=?) => boolcloneNode
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=?) => tclosest
Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. Read more on MDN
let closest: (t, string) => 'ecompareDocumentPosition
Returns a bitmask indicating the position of other relative to node. Read more on MDN
let compareDocumentPosition: (t, DomTypes.node) => intcomputedStyleMap
let computedStyleMap: t => DomTypes.stylePropertyMapReadOnlycontains
Returns true if other is an inclusive descendant of node, and false otherwise. Read more on MDN
let contains: (t, DomTypes.node) => booldispatchEvent
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) => boolfocus
let focus: (t, ~options: DomTypes.focusOptions=?) => unitgetAnimations
let getAnimations: ( t, ~options: DomTypes.getAnimationsOptions=?,) => 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>getAttributeNames
Returns the qualified names of all element's attributes. Can contain duplicates. Read more on MDN
let getAttributeNames: t => array<string>getAttributeNode
let getAttributeNode: (t, string) => DomTypes.attrgetAttributeNodeNS
let getAttributeNodeNS: (t, ~namespace: string, ~localName: string) => DomTypes.attrgetAttributeNS
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) => stringgetBoundingClientRect
let getBoundingClientRect: t => DomTypes.domRectgetClientRects
let getClientRects: t => DomTypes.domRectListgetElementsByClassName
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>getElementsByTagName
let getElementsByTagName: (t, string) => DomTypes.htmlCollection<DomTypes.element>getElementsByTagNameNS
let getElementsByTagNameNS: ( DomTypes.element, ~namespace: string, ~localName: string,) => DomTypes.htmlCollection<DomTypes.element>Parameters
DomTypes.element string stringReturn type
DomTypes.htmlCollection< DomTypes.element >getHTML
let getHTML: (t, ~options: DomTypes.getHTMLOptions=?) => stringgetRootNode
Returns node's root. Read more on MDN
let getRootNode: ( t, ~options: DomTypes.getRootNodeOptions=?,) => DomTypes.nodehasAttribute
Returns true if element has an attribute whose qualified name is qualifiedName, and false otherwise. Read more on MDN
let hasAttribute: (t, string) => boolhasAttributeNS
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) => boolhasAttributes
Returns true if element has attributes, and false otherwise. Read more on MDN
let hasAttributes: t => boolhasPointerCapture
let hasPointerCapture: (t, int) => boolinsertAdjacentElement
let insertAdjacentElement: ( t, ~where: DomTypes.insertPosition, ~element: DomTypes.element,) => DomTypes.elementinsertAdjacentHTML
let insertAdjacentHTML: ( t, ~position: DomTypes.insertPosition, ~string: string,) => unitinsertAdjacentText
let insertAdjacentText: (t, ~where: DomTypes.insertPosition, ~data: string) => unitinsertBefore
let insertBefore: (t, 't, ~child: DomTypes.node) => 'tisDefaultNamespace
let isDefaultNamespace: (t, string) => boolisEqualNode
Returns whether node and otherNode have the same properties. Read more on MDN
let isEqualNode: (t, DomTypes.node) => boolisSameNode
let isSameNode: (t, DomTypes.node) => boollookupNamespaceURI
let lookupNamespaceURI: (t, string) => stringlookupPrefix
let lookupPrefix: (t, string) => stringmatches
Returns true if matching selectors against element's root yields element, and false otherwise. Read more on MDN
let matches: (t, string) => boolnormalize
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 => unitprepend
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) => unitprepend2
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) => unitquerySelector
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>querySelectorAll
Returns all element descendants of node that match selectors. Read more on MDN
let querySelectorAll: (t, string) => DomTypes.nodeList<DomTypes.element>releasePointerCapture
let releasePointerCapture: (t, int) => unitremoveAttribute
Removes element's first attribute whose qualified name is qualifiedName. Read more on MDN
let removeAttribute: (t, string) => unitremoveAttributeNode
let removeAttributeNode: (t, DomTypes.attr) => DomTypes.attrremoveAttributeNS
Removes element's attribute whose namespace is namespace and local name is localName. Read more on MDN
let removeAttributeNS: (t, ~namespace: string, ~localName: string) => unitremoveEventListener
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=?,) => unitParameters
t EventTypes.eventType EventTypes.eventListener option< EventTypes.eventListenerOptions >Return type
unitremoveEventListenerUseCapture
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>,) => unitreplaceChild
let replaceChild: (t, ~node: DomTypes.node, 't) => 'treplaceChildren
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) => unitreplaceChildren2
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) => unitreplaceWith
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) => unitreplaceWith2
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) => unitrequestFullscreen
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>requestPointerLock
let requestPointerLock: ( t, ~options: DomTypes.pointerLockOptions=?,) => promise<unit>scroll
let scroll: (t, ~options: DomTypes.scrollToOptions=?) => unitscroll2
let scroll2: (t, ~x: float, ~y: float) => unitscrollBy
let scrollBy: (t, ~options: DomTypes.scrollToOptions=?) => unitscrollBy2
let scrollBy2: (t, ~x: float, ~y: float) => unitscrollIntoView
scrollIntoView()
Scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.
element->Element.scrollIntoView()
let scrollIntoView: t => unitscrollIntoViewAlignToTop
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()
let scrollIntoViewAlignToTop: t => unitscrollIntoViewWithOptions
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 })
let scrollIntoViewWithOptions: (t, DomTypes.scrollIntoViewOptions) => unitscrollTo
let scrollTo: (t, ~options: DomTypes.scrollToOptions=?) => unitscrollTo2
let scrollTo2: (t, ~x: float, ~y: float) => unitsetAttribute
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) => unitsetAttributeNode
let setAttributeNode: (t, DomTypes.attr) => DomTypes.attrsetAttributeNodeNS
let setAttributeNodeNS: (t, DomTypes.attr) => DomTypes.attrsetAttributeNS
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,) => unitParameters
DomTypes.element string string stringReturn type
unitsetHTMLUnsafe
let setHTMLUnsafe: (t, string) => unitsetPointerCapture
let setPointerCapture: (t, int) => unittoggleAttribute
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=?) => booltogglePopover
let togglePopover: (t, ~force: bool=?) => bool