package virtual_dom

  1. Overview
  2. Docs

Module Vdom.NodeSource

Sourcemodule Element : sig ... end

The values associated with an Element and element like nodes. (that is in practice all nodes that aren't just text).

Sourcetype t =
  1. | None
  2. | Text of Base.string
  3. | Element of Element.t
  4. | Widget of Widget.t
Sourcetype node_creator = ?key:Base.string -> Virtual_dom__.Attr.t Base.list -> t Base.list -> t
Sourcetype node_creator_childless = ?key:Base.string -> Virtual_dom__.Attr.t Base.list -> t
Sourceval none : t
Sourceval text : Base.string -> t
Sourceval textf : ('a, Base.unit, Base.string, t) Base.format4 -> 'a
Sourceval button : node_creator
Sourceval header : node_creator
Sourceval input : node_creator
Sourceval textarea : node_creator
Sourceval select : node_creator
Sourceval option : node_creator
Sourceval label : node_creator
Sourceval section : node_creator
Sourceval strong : node_creator
Sourceval table : node_creator
Sourceval tbody : node_creator
Sourceval thead : node_creator
Sourceval create : Base.string -> ?key:Base.string -> Virtual_dom__.Attr.t Base.list -> t Base.list -> t

key is used by Virtual_dom as a hint during diffing/patching

Sourceval create_svg : Base.string -> ?key:Base.string -> Virtual_dom__.Attr.t Base.list -> t Base.list -> t

Like create but for svg nodes (i.e. all to be placed inside <svg> tag). This is needed as browsers maintain separate namespaces for html and svg, and failing to use the correct one may result in delayed redraws.

Sourceval unsafe_to_js : t -> Js_of_ocaml.Js.Unsafe.any
Sourceval widget : ?destroy: ('s -> (Js_of_ocaml.Dom_html.element as 'e) Js_of_ocaml.Js.t -> Base.unit) -> ?update:('s -> 'e Js_of_ocaml.Js.t -> 's * 'e Js_of_ocaml.Js.t) -> id:('s * 'e Js_of_ocaml.Js.t) Base.Type_equal.Id.t -> init:(Base.unit -> 's * 'e Js_of_ocaml.Js.t) -> Base.unit -> t

Creates a Node.t that has fine-grained control over the Browser DOM node.

Callbacks =========

init: Returns a Browser DOM Node and a widget state object. The Browser DOM node is mounted into the dom in the location where the Node.t object would otherwise be.

update: Given the previous Browser DOM Node and state, makes any changes necessary to either and returns a new state and Browser DOM Node.

destroy: Called when this Node.t is removed from the Virtual_dom. Performs any necessary cleanup.

Other =====

The id is used to compare widgets, and is used to make sure that the state from one widget doesn't get interpreted as the state for another. Otherwise, you would be able to implement Obj.magic using this API.

WARNING: While other Virtual_dom APIs shield the application from script injection attacks, the Widget.create function allows a developer to bypass these safeguards and manually create DOM nodes which could allow an attacker to change the behavior of the application or exfiltrate data.

In using this API, you are being trusted to understand and follow security best-practices.

Sourcemodule Patch : sig ... end
OCaml

Innovation. Community. Security.