Header menu logo Sutil

DomHelpers Module

Utilities to help with browser DOM API

Types and nested modules

Type/Module Description

ClassHelpers

DomEdit

CustomDispatch<'T>

Custom events

Functions and values

Function or value Description

anyof events target fn

Full Usage: anyof events target fn

Parameters:

Listen for the first occurrence of a list of events. fn will be called for the winning event

events : string list
target : EventTarget
fn : Event -> Unit

asElement target

Full Usage: asElement target

Parameters:
Returns: 'T

Downcast EventTarget to Node or subtype of Node

target : EventTarget
Returns: 'T

children node

Full Usage: children node

Parameters:
Returns: Node seq

Child nodes of node

node : Node
Returns: Node seq

clear node

Full Usage: clear node

Parameters:

Remove all children of this node, cleaning up Sutil resources and dispatching "unmount" events

node : Node

computedStyleTransform node

Full Usage: computedStyleTransform node

Parameters:
Returns: string
node : Element
Returns: string

descendants node

Full Usage: descendants node

Parameters:
Returns: Node seq

Descendants of node in breadth-first order

node : Node
Returns: Node seq

interval handler delayMs

Full Usage: interval handler delayMs

Parameters:
    handler : unit -> unit
    delayMs : int

Returns: unit -> unit

Call handler every delayMs. Return value is a function that will cancel the timer.

handler : unit -> unit
delayMs : int
Returns: unit -> unit

isElementNode n

Full Usage: isElementNode n

Parameters:
Returns: bool

Return true if n is an Element node (nodeType = 1)

n : Node
Returns: bool

isTextNode n

Full Usage: isTextNode n

Parameters:
Returns: bool

Return true if n is a Text node (nodeType = 3)

n : Node
Returns: bool

listen event e fn

Full Usage: listen event e fn

Parameters:
Returns: unit -> unit

Add event listener using e.addEventListener. Return value is a (unit -> unit) function that will remove the event listener

event : string
e : EventTarget
fn : Event -> unit
Returns: unit -> unit

nodeStrShort node

Full Usage: nodeStrShort node

Parameters:
Returns: string
node : Node
Returns: string

once event target fn

Full Usage: once event target fn

Parameters:

Listen for the given event, and remove the listener after the first occurrence of the evening firing.

event : string
target : EventTarget
fn : Event -> Unit

raf f

Full Usage: raf f

Parameters:
    f : float -> unit

Returns: float

Wrapper for Window.requestAnimationFrame

f : float -> unit
Returns: float

rafu f

Full Usage: rafu f

Parameters:
    f : unit -> unit

Wrapper for Window.requestAnimationFrame, ignoring the timestamp.

f : unit -> unit

setHeadEmbedScript doc source

Full Usage: setHeadEmbedScript doc source

Parameters:
doc : Document
source : string

setHeadScript doc url

Full Usage: setHeadScript doc url

Parameters:
doc : Document
url : string

setHeadStylesheet doc url

Full Usage: setHeadStylesheet doc url

Parameters:
doc : Document
url : string

setHeadTitle doc title

Full Usage: setHeadTitle doc title

Parameters:
doc : Document
title : string

timeout handler delayMs

Full Usage: timeout handler delayMs

Parameters:
    handler : unit -> unit
    delayMs : int

Returns: unit -> unit

Call handler after delayMs. Return value is a function that will cancel the timeout (if it hasn't occurred yet)

handler : unit -> unit
delayMs : int
Returns: unit -> unit

viewportHeight ()

Full Usage: viewportHeight ()

Parameters:
    () : unit

Returns: float

The height of the browser viewport

() : unit
Returns: float

viewportWidth ()

Full Usage: viewportWidth ()

Parameters:
    () : unit

Returns: float

The width of the browser viewport

() : unit
Returns: float

Type extensions

Type extension Description

this.asHtmlElement ()

Full Usage: this.asHtmlElement ()

Parameters:
    () : unit

Returns: HTMLElement option

Extended Type: Node

() : unit
Returns: HTMLElement option

this.asHtmlElement

Full Usage: this.asHtmlElement

Returns: HTMLElement option
Modifiers: abstract

Extended Type: Node

Returns: HTMLElement option

this.asTextNode ()

Full Usage: this.asTextNode ()

Parameters:
    () : unit

Returns: Text option

Extended Type: Node

() : unit
Returns: Text option

this.asTextNode

Full Usage: this.asTextNode

Returns: Text option
Modifiers: abstract

Extended Type: Node

Returns: Text option

this.toSeq ()

Full Usage: this.toSeq ()

Parameters:
    () : unit

Returns: 'T seq

Produce a seq<'T> from a NodeListOf<'T>. This is useful when working with document.querySelectorAll, for example

Extended Type: NodeListOf

() : unit
Returns: 'T seq

this.toSeq ()

Full Usage: this.toSeq ()

Parameters:
    () : unit

Returns: Node seq

Produce a seq from a NodeList. This is useful when working with document.querySelectorAll, for example

Extended Type: NodeList

() : unit
Returns: Node seq

Type something to start searching.