Let render() create the state rather than vnode()
This commit is contained in:
parent
1ffa4cf183
commit
74cbd4c17b
3 changed files with 9 additions and 3 deletions
|
|
@ -21,6 +21,7 @@ module.exports = function($window) {
|
|||
function createNode(parent, vnode, hooks, ns, nextSibling) {
|
||||
var tag = vnode.tag
|
||||
if (typeof tag === "string") {
|
||||
vnode.state = {}
|
||||
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
|
||||
switch (tag) {
|
||||
case "#": return createText(parent, vnode, nextSibling)
|
||||
|
|
@ -238,7 +239,10 @@ module.exports = function($window) {
|
|||
if (!recycling && shouldNotUpdate(vnode, old)) return
|
||||
if (typeof oldTag === "string") {
|
||||
if (vnode.attrs != null) {
|
||||
if (recycling) initLifecycle(vnode.attrs, vnode, hooks)
|
||||
if (recycling) {
|
||||
vnode.state = {}
|
||||
initLifecycle(vnode.attrs, vnode, hooks)
|
||||
}
|
||||
else updateLifecycle(vnode.attrs, vnode, hooks)
|
||||
}
|
||||
switch (oldTag) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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, skip: false}
|
||||
return {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined, skip: false}
|
||||
}
|
||||
Vnode.normalize = function(node) {
|
||||
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue