crysalead-js / dom-layer

Virtual DOM implementation.
MIT License
30 stars 1 forks source link

method for updating children? #41

Closed ghost closed 9 years ago

ghost commented 9 years ago

I saw Kivi, and CitoJS have API methods for updating children only. How is this to be done from dom-layer?

jails commented 9 years ago

API ? what kind of API ?

ghost commented 9 years ago

If you can call it an API, anyway this is what CitoJS expose to the global namespace: https://github.com/joelrich/citojs/blob/master/dist/cito.js#L1238-L1269

So: citojs.vdom.updateChildren can be reached from everywhere.

I just took this as an example, because CitoJS took most of it's code from Kivi/Mithril.

jails commented 9 years ago

Ah, in dom-layer you can deal with either a single node or an array of virtual nodes. Both methods work which is not the case for many virtual dom implementations which requires a single virtual node as root element. The following is for example possible:

var mountId = tree.mount("#mount-point", [ new Tag("div"), new Tag("span") ]);
tree.update(mountId, [ new Tag("span"), new Tag("div") ]);

Anyhow the update method is exposed here https://github.com/crysalead-js/dom-layer/blob/master/index.js#L20 however you shouldn't need it. Since all updates can be done through a Tree instance.

ghost commented 9 years ago

Got it !! Btw. What is the roadmap for dom-layer now? And what changes will come next? A component layer?

jails commented 9 years ago

I think I'm almost done with this library. So yeah the next step is to build a component library on top of it. So I'll probably need to adjust some missing stuff I'm not aware of right now but will when I'll need them for the component library. However I'll probably add some more specs around to chase some potential bugs.