Module Note_brr.ElrSource
Reactive 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.
Children
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.
Attributes and properties
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.
Classes
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.
Style
val set_inline_style :
?important:bool ->
Brr.El.Style.prop ->
on:Jstr.t Note.event ->
Brr.El.t ->
unitset_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 ->
unitdef_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
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.
Life-cycle callbacks
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.
on_rem f e references f until e is removed from the HTML DOM, at which point f () is invoked.
Note loggers
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.