0.0.1 • Published 10 years ago
inc-dom v0.0.1
Inc DOM(Demoed in CirruScript and Todolist)
Demo:
Usage
Also a small wrapper on incremental-dom API.
npm i --save inc-domIncDOM = require 'inc-dom'
onclick = (event) -> console.log :event
{div, text} = IncDOM
br = IncDOM.createFactory 'br'
data = [] # which changes
IncDOM.render document.body, ->
IncDOM.div (key: 'keyed'), (style: {color: 'red'}), onclick: onclick, ->
IncDOM.div null, (style: {width: "#{data.length * 40}px"}), ->
br()
IncDOM.textpatch:IncrementalDOM.patchtext:IncrementalDOM.patchcreateFactory:(tagName) -> (staticAttrs, properties, cb) -> undefinedcreateElement:(tagName, staticAttrs, properties, cb) -> undefineddiv:createFactory('div')span:createFactory('span')
Read demo code in src/app/page for details.
On incremental-dom API
incremental-domAPI useskeyfor elements in an array.inc-domputskeyinstaticAttrs, which is like in React.when called with 1 less arguments,
propertieswill be omitted.the difference between
staticAttrsandpropertiesis the name asincremental-dom.staticAttrswill not change after setting on DOM,propertieswill.cbis a function to ensure the excution order or children elements.
This package is expertimental. Extend it if you want to create components.
Wallpaper
Credit http://img.wallpapergang.com/139processed/Creative%20House%20Stair%20Design%20%20HD%20wallpaper.jpg
Usage
- Development
npm i
gulp html
webpack-dev-server --hot- Production
gulp buld
gulp rsyncLicense
MIT
0.0.1
10 years ago