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.