Skip to content

ShadowRoot

Types

getRootNodeOptions

type getRootNodeOptions = {mutable composed?: bool}

Record fields

composed
option<bool>

t

type t = WebAPI.DOMTree.shadowRoot = {
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.htmlElement>,
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>,
mode: WebAPI.DOMTree.shadowRootMode,
delegatesFocus: bool,
slotAssignment: WebAPI.DOMTree.slotAssignmentMode,
clonable: bool,
serializable: bool,
host: WebAPI.DOMTree.element,
mutable innerHTML: string,
styleSheets: WebAPI.StyleSheetList.t,
mutable adoptedStyleSheets: array<
WebAPI.StyleSheet.cssStyleSheet,
>,
fullscreenElement: Null.t<WebAPI.DOMTree.element>,
activeElement: Null.t<WebAPI.DOMTree.element>,
pictureInPictureElement: Null.t<WebAPI.DOMTree.element>,
pointerLockElement: Null.t<WebAPI.DOMTree.element>,
}

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>
delegatesFocus
bool
clonable
bool
serializable
bool
innerHTML
string
styleSheets

Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. Read more on MDN

fullscreenElement

Returns document's fullscreen element. Read more on MDN

activeElement

Returns the deepest element in the document through which or to which key events are being routed. This is, roughly speaking, the focused element in the document.

For the purposes of this API, when a child browsing context is focused, its container is focused in the parent browsing context. For example, if the user moves the focus to a text control in an iframe, the iframe is the element returned by the activeElement API in the iframe's node document.

Similarly, when the focused element is in a different node tree than documentOrShadowRoot, the element returned will be the host that's located in the same node tree as documentOrShadowRoot if documentOrShadowRoot is a shadow-including inclusive ancestor of the focused element, and null if not. Read more on MDN

pictureInPictureElement
pointerLockElement

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

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, WebAPI.DOMTree.node) => unit

Parameters

tWebAPI.DOMTree.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

tstring

Return type

unit

appendChild

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

asDocumentFragment

let asDocumentFragment: t => WebAPI.DOMTree.documentFragment

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

getAnimations

let getAnimations: WebAPI.DOMTree.shadowRoot => array<WebAPI.Animation.t>

getElementById

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

let getElementById: (t, string) => Null.t<WebAPI.DOMTree.element>

Parameters

tstring

Return type

Stdlib.Null.t<WebAPI.DOMTree.element>

getHTML

let getHTML: (
WebAPI.DOMTree.shadowRoot,
~options: WebAPI.HTML.getHTMLOptions=?,
) => string

Parameters

WebAPI.DOMTree.shadowRootoption<WebAPI.HTML.getHTMLOptions>

Return type

string

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

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, WebAPI.DOMTree.node) => unit

Parameters

tWebAPI.DOMTree.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

tstring

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<WebAPI.DOMTree.element>

Parameters

tstring

Return type

Stdlib.Null.t<WebAPI.DOMTree.element>

querySelectorAll

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

let querySelectorAll: (t, string) => WebAPI.DOM.nodeList<WebAPI.DOMTree.element>

Parameters

tstring

Return type

WebAPI.DOM.nodeList<WebAPI.DOMTree.element>

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

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, WebAPI.DOMTree.node) => unit

Parameters

tWebAPI.DOMTree.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

tstring

Return type

unit

setHTMLUnsafe

let setHTMLUnsafe: (WebAPI.DOMTree.shadowRoot, string) => unit

Parameters

WebAPI.DOMTree.shadowRootstring

Return type

unit