idom-adapter
v0.0.2
Published
Incremental DOM adaptors
Downloads
2
Readme
idom-adaptor
It provides very simple adaptors for Incremental DOM.
Abstract classes (interfaces)
There are few abstract classes which in fact provide usefull interfaces for further patches.
AttachableNode
is an abstract class that has one empty methodattach
AbstractEl
implementsAttachableNode
and has following methods:patch
- empty method that should be implemented in concrete elements,attach
- implementation of AttachableNode'sattach
method,beforeAttach
andafterAttach
- life-cicle hooks are being invoked before and after element rendering respectively.
Concrete classes
These classes are just tiny wrappers over Incremental DOM's elementOpen
/elementClose
, elementVoid
and text
new El(el, attrs, children, id)
- adaptor for non-empty elements. It takes following arguments:el
- tag name (required),attrs
-{staticAttrs: [], dynamicAttrs: []}
(optional),children
- array that can contain any class that implementsAttachableNode
(optional),id
- Incrementa DOM's key (optional). It implementsAbstractEl
.new ElVoid(el, attrs, id)
- adaptor forelementVoid
. It takes following arguments:el
- tag name (required),attrs
-{staticAttrs: [], dynamicAttrs: []}
(optional),id
- Incrementa DOM's key (optional). On attach it attaches chilred recursively. It implementsAbstractEl
.new Text(text)
- adaptor fortext
. It takes only one argument the text that will be rendered. ImplementsAttachableNode
interface.
Helpers
ipatch(hostEl, el, data)
- wrapper over Incremental DOM's patch.hostEl
- HTML element whereel
will be rendered,el
is an adaptor that implementsAttachableNode
interface. Data is a data that will be passed topatch
function as a third argument.
Get from JSX
More details about JSX itself can be found in specification
There is a Babel plugin that converts JSX into plain JavaScript + idom adaptors.