Closed ghost closed 9 years ago
I don't think it's a good solution. All virtual nodes should share a common interface imo. If you add methods to the Tag
virtual node, you will require to type check virtual nodes to know what kind of method are available. And I don't see the point to update a virtual tree directly. The strategy of virtual dom implementations is to compare two virtual trees together. I don't see the point to have one updated virtual tree. Cloning the tree, updating the clone and then make the diff doesn't make sense for me since. Generaly the virtual tree is generated from a render()
function, so you are dealing virtual trees as a whole. Im you don't really need to have fancy updates methods which will be useless.
I was just thinking. What if you move all hooks to the Tag prototype? Then you can get options like attr, prop, add class etc directly. As you can use in a higher level.
See js blocks and it's virtual dom.
https://github.com/astoilkov/jsblocks/blob/master/src/query/VirtualElement.js