package vdom
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=bda1424d08f483a19e242a0c5cff2cfa
sha512=4fbeda115659049798b84b58ce385619bace99740384844eb5a453e2448496e85b304713d1c86d5479b2c3450d17defd1e1f8fa5859ba1e493226c178a6f4cbe
doc/vdom.base/Vdom/index.html
Module VdomSource
Virtual DOM
A "Virtual application" (or "Elm-like" application) is described by two types:
- model: the current state of the UI,
- msg ("messages"): possible state transitions;
and by the following values:
- init: the initial state of the application, plus some initial commands to be spawned;
- view: a function mapping the current state to a "virtual" DOM tree (vdom);
- update: a function that processes messages to update the current state, and potentially spawns some commands.
Commands represents (typically) asynchronous operations, such as querying a server, or waiting for some timer.
Messages can be generated either by a VDOM tree (to encapsulate DOM events) or by commands (to notify their outcome).
Commands
Custom elements
Properties and event handlers
type +'msg event_handler = | Decoder : {event_type : string;decoder : 'a msg_options Decoder.t;map : 'a option -> 'msg option;
} -> 'msg event_handler| CustomEvent of Custom.event -> 'msg option
type 'msg attribute = | Property of string * prop_val| Style of string * string| Handler of 'msg event_handler| Attribute of string * string
Event handlers
val onmousedown :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onmousedown_cancel :
?stop_propagation:unit ->
(mouse_event -> 'msg option) ->
'msg attributeval onmouseup :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onclick :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval ondblclick :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval oninput :
?prevent_default:unit ->
?stop_propagation:unit ->
(string -> 'msg) ->
'msg attributePass the value property of the event target.
val onchange_checked :
?prevent_default:unit ->
?stop_propagation:unit ->
(bool -> 'msg) ->
'msg attributePass the checked property of the event targer.
val onchange :
?prevent_default:unit ->
?stop_propagation:unit ->
(string -> 'msg) ->
'msg attributePass the value property of the event target.
val onchange_index :
?prevent_default:unit ->
?stop_propagation:unit ->
(int -> 'msg) ->
'msg attributePass the selected_index property of the event target.
val onmousemove :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onmouseenter :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onmouseleave :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onmouseover :
?prevent_default:unit ->
?stop_propagation:unit ->
(mouse_event -> 'msg) ->
'msg attributeval onpaste :
?prevent_default:unit ->
?stop_propagation:unit ->
(paste_event -> 'msg option) ->
'msg attributeGeneric DOM properties
Generic DOM properties correspond to actual properties on DOM objects. The name of these properties is usually the same as the corresponding HTML attribute, but not always (e.g. "class" attribute, but "className" property).
Common DOM properties
Pseudo-attributes
Pseudo-attributes are interpreted in a special way by the infrastructure.
When this pseudo-attribute is first applied to an element, its parent is automatically scrolled (vertically) to show the element.
When this pseudo-attribute is first applied to an element, the element gets focused.
When this pseudo-attribute is first applied to an element, the element gets focused if the element is visible in the viewport.
When this pseudo-attribute is first applied to an element, or applied with a different counter as the previous time, the element gets focused.
When this pseudo-attribute is first applied to an input or textarea element, select the content.
When this pseudo_attribute is first applied to a form element, it will be submitted automatically.
VDOM
Generic VDOM constructors
A generic element.
A generic element in the SVG namespace.
A fragment node (not appearing in the dom).
Map attributes of a vdom element
Wrap all messages generated by a VDOM tree with the provided function.
Apply the function to generate a VDOM tree only if the function or its argument have changed (physically) from the previous synchronization.
Note that physical equality is used both for the function and its argument. In particular, this is unlikely to behave as expected if the function is defined inline (as an abstraction) or obtained by a (partial) function application. Instead, the functional argument should be a simple reference to a globally defined function.
TODO: n-ary versions.
val custom :
?key:string ->
?a:'msg attribute list ->
?propagate_events:unit ->
Custom.t ->
'msg vdomA custom kind of node. Usually not used directly.