rename node to vnode
This commit is contained in:
parent
09a0464a01
commit
7c736b511a
20 changed files with 60 additions and 56 deletions
16
render/vnode.js
Normal file
16
render/vnode.js
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue