rename node to vnode

This commit is contained in:
Leo Horie 2016-07-29 22:04:04 -04:00
parent 09a0464a01
commit 7c736b511a
20 changed files with 60 additions and 56 deletions

16
render/vnode.js Normal file
View file

@ -0,0 +1,16 @@
function Vnode(tag, key, attrs, children, text, dom) {
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: {}, events: undefined, instance: undefined}
}
Vnode.normalize = function(node) {
if (node instanceof Array) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
else if (node != null && typeof node !== "object") return Vnode("#", undefined, undefined, node, undefined, undefined)
return node
}
Vnode.normalizeChildren = function normalizeChildren(children) {
for (var i = 0; i < children.length; i++) {
children[i] = Vnode.normalize(children[i])
}
return children
}
module.exports = Vnode