Module Brr.El

module El: sig .. end
DOM elements.

Warning. Reactive DOM element mutators (Brr.El.rset_att, Brr.El.rset_children, etc.) and definers (Brr.El.def_att, Brr.El.def_children, etc.) use Note loggers to perform their action. To prevent memory leaks, these loggers, and thus their action, automatically get destroyed whenever the element is removed from the HTML DOM.



Elements


type name = Brr.Jstr.t 
The type for element names.
type el 
The type for elements.
type t = [ `El of el ] 
The type for elements.
type child = [ `El of el | `Txt of Brr.Jstr.t ] 
The type for element children.
val v : ?atts:Brr.Att.t list -> name -> child list -> [> t ]
v ?atts name cs is an element name with attribute atts (defaults to []) and children cs. If atts specifies an attribute more than once, the last one takes over with the exception of Att.klass, whose occurences accumulate to define the final value.
val el : t -> Dom_html.element Js.t
el (`El e) is e.
val tag_name : t -> Brr.Jstr.t
tag_name e is the tag name of the element.
val find_id : Brr.Jstr.t -> [> t ] option
find_id id is the element with id id in the browser document (if any).
val find_class : Brr.Jstr.t -> [> t ] list
find_class cl are the element with class cs in the browser document.
val document : unit -> [> t ]
document is the document's element of the current browser document.
val document_body : unit -> [> t ]
document_body is the Brr.El.body element of the current browser document.
val document_active : unit -> [> t ] option
document_active is the element of the DOM that currently has focus (if any).

Children


val set_children : t -> child list -> unit
set_children e children sets e's children to children
val rset_children : t -> on:child list Note.event -> unit
rset_children e ~on sets e's children with the value of on whenever it occurs.
val def_children : t -> child list Note.signal -> unit
def_children e cs defines e's children over time with the value of signal cs. Warning. This assumes cs is the only entity interacting with the children.

Attributes


val get_att : Brr.Att.name -> t -> Brr.Jstr.t option
get_att a e is the value of the attribute a of e (if any).
val set_att : Brr.Att.name -> Brr.Jstr.t option -> t -> unit
set_att a v e sets the value of attribute a of e to v. If v is None this removes the attribute.
val rset_att : Brr.Att.name -> on:Brr.Jstr.t option Note.event -> t -> unit
rset_att a ~on e sets attribute a of e with the value of e whenever it occurs. If the value is None this removes the attribute.
val def_att : Brr.Att.name -> Brr.Jstr.t option Note.signal -> t -> unit
def_att a v e defines the attribute a of e over time with the value of v. Whenever the signal value is None, the attribute is removed. Warning. This assumes v is the only entity interacting with that attribute.

Classes


val get_class : Brr.Jstr.t -> t -> bool
get_class c e is the membership of e to class c.
val set_class : Brr.Jstr.t -> bool -> t -> unit
set_class c b e sets the membership of e to class c according to b.
val rset_class : Brr.Jstr.t -> on:bool Note.event -> t -> unit
rset_class a ~on e sets the membership of e to class e with the value of on whenever it occurs.
val def_class : Brr.Jstr.t -> bool Note.signal -> t -> unit
rdef_class a b e defines the membership of e to class e over time with the value of b. Warning. This assumes b is the only entity interacting with that class.

Properties


val get_prop : 'a Brr.Prop.t -> t -> 'a
get_prop p e is the property p of element e if defined and p's undefined value otherwise.
val set_prop : 'a Brr.Prop.t -> 'a -> t -> unit
set_prop p v o sets property p of element e to v.
val rset_prop : 'a Brr.Prop.t -> on:'a Note.event -> t -> unit
rset_prop p ~on e sets property p of e to the value of on whenever it occurs.
val def_prop : 'a Brr.Prop.t -> 'a Note.signal -> t -> unit
def_prop p v e defines the property p of e over time with the value of v. Warning. This assumes v is the only entity interacting with that property.

Style


module Style: sig .. end
Style property names.
val get_computed_style : Style.prop -> t -> Brr.Jstr.t
get_computed_style p e is the computed style property p of e.
val get_style : Style.prop -> t -> Brr.Jstr.t
get_style p e is the inline style property p of e.
val set_style : ?important:bool -> Style.prop -> Brr.Jstr.t -> t -> unit
set_style ~important p v e sets the inline style property p of e to v with priority important (defaults to false).
val rset_style : ?important:bool ->
Style.prop -> on:Brr.Jstr.t Note.event -> t -> unit
rset_style ~important p ~on e sets the inline style property p of e to the value of on whenever it occurs with priority important (defaults to false).
val def_style : ?important:bool ->
Style.prop -> Brr.Jstr.t Note.signal -> t -> unit
def_style p v e sets the inline style property p of e over time with the value of v. Warning. This assumes v is the only entity interacting with that property.

Focus


val set_focus : bool -> t -> unit
focus b e sets the focus of e to b.
val rset_focus : on:bool Note.event -> t -> unit
rset_focus e ~on sets e's focus with the value of on whenever it occurs.
val def_focus : bool Note.signal -> t -> unit
def_focus e v defines the focus of e over time with the value of v. Warning. This asumes v is the only entity interacting with e's focus.

Click simulation


val click : t -> unit
click e simulates a click on e.
val select_txt : t -> unit
select_txt e selects the textual contents of e. If the DOM element e has no select method this does nothing.

Life-cycle callbacks

The browser document is watched for changes via a global MutationObserver. Whenever an element is added in the HTML DOM, its Brr.El.on_add callbacks get called and disposed. Whenever an element is removed from the HTML DOM, Brr.El.on_rem callbacks get called and disposed. A element is deemed part of the HTML DOM if its root node is the browser document.

val on_add : (unit -> unit) -> t -> unit
on_add f e references f until e is inserted in the HTML DOM, at which point f () is invoked.
val on_rem : (unit -> unit) -> t -> unit
on_rem f e references f until e is removed from the HTML DOM, at which point f () is invoked.

Note loggers


val call : ('a -> t -> unit) -> on:'a Note.event -> t -> unit
call f ~on e calls f on e with the value of e whenever on occurs. The underlying logger is held by e.
val hold_logr : t -> Note.Logr.t -> unit
hold_logr e l lets e hold logger l and destroy it via Brr.El.on_rem once e is removed from the document.
val may_hold_logr : t -> Note.Logr.t option -> unit
may_hold_logr e l is like Brr.El.hold_logr but does nothing on None.

Element constructors

Convention. Whenever an element name conflicts with an OCaml keyword we prime it, see for example Brr.El.object'.

module Name: sig .. end
Element names.
type [> t ] cons = ?atts:Brr.Att.t list -> child list -> ([> t ] as 'a) 
The type for element constructors. This is simply Brr.El.v with a pre-applied element name.
val a : [> t ] cons
a
val abbr : [> t ] cons
abbr
val address : [> t ] cons
address
val area : [> t ] cons
area
val article : [> t ] cons
article
val aside : [> t ] cons
aside
val audio : [> t ] cons
audio
val b : [> t ] cons
b
val base : [> t ] cons
base
val bdi : [> t ] cons
bdi
val bdo : [> t ] cons
bdo
val blockquote : [> t ] cons
blockquote
val body : [> t ] cons
body
val br : [> t ] cons
br
val button : [> t ] cons
button
val canvas : [> t ] cons
canvas
val caption : [> t ] cons
caption
val cite : [> t ] cons
cite
val code : [> t ] cons
code
val col : [> t ] cons
col
val colgroup : [> t ] cons
colgroup
val command : [> t ] cons
command
val datalist : [> t ] cons
datalist
val dd : [> t ] cons
dd
val del : [> t ] cons
del
val details : [> t ] cons
details
val dfn : [> t ] cons
dfn
val div : [> t ] cons
div
val dl : [> t ] cons
dl
val dt : [> t ] cons
dt
val em : [> t ] cons
em
val embed : [> t ] cons
embed
val fieldset : [> t ] cons
fieldset
val figcaption : [> t ] cons
figcaption
val figure : [> t ] cons
figure
val footer : [> t ] cons
footer
val form : [> t ] cons
form
val h1 : [> t ] cons
h1
val h2 : [> t ] cons
h2
val h3 : [> t ] cons
h3
val h4 : [> t ] cons
h4
val h5 : [> t ] cons
h5
val h6 : [> t ] cons
h6
val head : [> t ] cons
head
val header : [> t ] cons
header
val hgroup : [> t ] cons
hgroup
val hr : [> t ] cons
hr
val html : [> t ] cons
html
val i : [> t ] cons
i
val iframe : [> t ] cons
iframe
val img : [> t ] cons
img
val input : [> t ] cons
input
val ins : [> t ] cons
ins
val kbd : [> t ] cons
kbd
val keygen : [> t ] cons
keygen
val label : [> t ] cons
label
val legend : [> t ] cons
legend
val li : [> t ] cons
li
val link : [> t ] cons
link
val map : [> t ] cons
map
val mark : [> t ] cons
mark
val menu : [> t ] cons
menu
val meta : [> t ] cons
meta
val meter : [> t ] cons
meter
val nav : [> t ] cons
nav
val noscript : [> t ] cons
noscript
val object' : [> t ] cons
object
val ol : [> t ] cons
ol
val optgroup : [> t ] cons
optgroup
val option : [> t ] cons
option
val output : [> t ] cons
output
val p : [> t ] cons
p
val param : [> t ] cons
param
val pre : [> t ] cons
pre
val progress : [> t ] cons
progress
val q : [> t ] cons
q
val rp : [> t ] cons
rp
val rt : [> t ] cons
rt
val ruby : [> t ] cons
ruby
val s : [> t ] cons
s
val samp : [> t ] cons
samp
val script : [> t ] cons
script
val section : [> t ] cons
section
val select : [> t ] cons
select
val small : [> t ] cons
small
val source : [> t ] cons
source
val span : [> t ] cons
span
val strong : [> t ] cons
strong
val style : [> t ] cons
style
val sub : [> t ] cons
sub
val summary : [> t ] cons
summary
val sup : [> t ] cons
sup
val table : [> t ] cons
table
val tbody : [> t ] cons
tbody
val td : [> t ] cons
td
val textarea : [> t ] cons
textarea
val tfoot : [> t ] cons
tfoot
val th : [> t ] cons
th
val thead : [> t ] cons
thead
val time : [> t ] cons
time
val title : [> t ] cons
title
val tr : [> t ] cons
tr
val track : [> t ] cons
track
val u : [> t ] cons
u
val ul : [> t ] cons
ul
val var : [> t ] cons
var
val video : [> t ] cons
video
val wbr : [> t ] cons
wbr