Module

Bonsai.DOM.Primitive

Package
purescript-bonsai
Repository
grmble/purescript-bonsai

Primitive DOM Helpers

This module is used from Bonsai.VirtualDom, so it can't depend on anything except Bonsai.Types

Since the VirtualDom does most of the DOM handling, only some functionality is needed in addition to that (e.g. elementById, setting the focus, ...)

This module does not distinguish DOM nodes and elements. If you need additional functionaliy, Element is just a newtype on a foreign - just use it with a different DOM module.

#Element Source

newtype Element

A DOM Element

Constructors

#ElementId Source

newtype ElementId

The ID of an element in the DOM

Constructors

#RequestAnimationFrameId Source

newtype RequestAnimationFrameId

The ID of a request animation frame

Constructors

#appendChild Source

appendChild :: forall eff. Element -> Element -> Eff (bonsai :: BONSAI | eff) Unit

Append the child

The container/parent is the second argument!

#clearElement Source

clearElement :: forall eff. Element -> Eff (bonsai :: BONSAI | eff) Unit

Clear the element.

Removes all child nodes of the element.

#document Source

document :: forall eff. Window -> Eff (bonsai :: BONSAI | eff) Document

Get the global javascript Document object

#elementById Source

elementById :: forall eff. ElementId -> Document -> Eff (bonsai :: BONSAI | eff) (Maybe Element)

Get the element identified by id.

#focusElement Source

focusElement :: forall eff. Element -> Eff (bonsai :: BONSAI | eff) Unit

Focus the element

#requestAnimationFrame Source

requestAnimationFrame :: forall eff. Eff (bonsai :: BONSAI | eff) Unit -> Window -> Eff (bonsai :: BONSAI | eff) RequestAnimationFrameId

Request an animation frame.

#selectInputElementText Source

selectInputElementText :: forall eff. Element -> Eff (bonsai :: BONSAI | eff) Unit

Select the input elements text.

#textContent Source

textContent :: forall eff. Element -> Eff (bonsai :: BONSAI | eff) String

Get the element's text content

#window Source

window :: forall eff. Eff (bonsai :: BONSAI | eff) Window

Get the global javascript Window object