Note_brr.Elr
SourceReactive DOM elements.
Warning. Reactive DOM element mutators (Elr.set_at
, Elr.set_children
, etc.) and definers (Elr.def_at
, Elr.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.
set_children e ~on
sets e
's children with the value of on
whenever it occurs.
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.
set_at 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.
def_at 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.
set_prop p ~on e
sets property p
of e
to the value of on
whenever it occurs.
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.
set_class a ~on e
sets the membership of e
to class e
with the value of on
whenever it occurs.
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.
val set_inline_style :
?important:bool ->
Brr.El.Style.prop ->
on:Jstr.t Note.event ->
Brr.El.t ->
unit
set_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_inline_style :
?important:bool ->
Brr.El.Style.prop ->
Jstr.t Note.signal ->
Brr.El.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.
set_focus e ~on
sets e
's focus with the value of on
whenever it occurs.
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.
The browser document is watched for changes via a global MutationObserver. Whenever an element is added in the HTML DOM, its on_add
callbacks get called and disposed. Whenever an element is removed from the HTML DOM, on_rem
callbacks get called and disposed. A element is deemed part of the HTML DOM if its root node is the browser document.
on_add f e
references f
until e
is inserted in the HTML DOM, at which point f ()
is invoked.
call f ~on e
calls f
on e
with the value of e
whenever on
occurs. The underlying logger is held by e
.
hold_logr e l
lets e
hold logger l
and destroy it via on_rem
once e
is removed from the document.
may_hold_logr e l
is like hold_logr
but does nothing on None
.