Skip to content

Commit ac44cdb

Browse files
committed
Look up the view and hooks on the state object (paves the way for MithrilJS#618).
1 parent db16145 commit ac44cdb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

render/render.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ module.exports = function($window) {
9595
if (!vnode.state) vnode.state = {}
9696
assign(vnode.state, vnode.tag)
9797

98-
initLifecycle(vnode.tag, vnode, hooks)
99-
vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
98+
initLifecycle(vnode.state, vnode, hooks)
99+
vnode.instance = Vnode.normalize(vnode.state.view.call(vnode.state, vnode))
100100
if (vnode.instance != null) {
101101
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
102102
var element = createNode(vnode.instance, hooks, ns)
@@ -257,8 +257,8 @@ module.exports = function($window) {
257257
}
258258
}
259259
function updateComponent(parent, old, vnode, hooks, nextSibling, recycling, ns) {
260-
vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
261-
updateLifecycle(vnode.tag, vnode, hooks, recycling)
260+
vnode.instance = Vnode.normalize(vnode.state.view.call(vnode.state, vnode))
261+
updateLifecycle(vnode.state, vnode, hooks, recycling)
262262
if (vnode.instance != null) {
263263
if (old.instance == null) insertNode(parent, createNode(vnode.instance, hooks, ns), nextSibling)
264264
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)
@@ -347,9 +347,9 @@ module.exports = function($window) {
347347
expected++
348348
vnode.attrs.onbeforeremove.call(vnode.state, vnode, once(continuation))
349349
}
350-
if (typeof vnode.tag !== "string" && vnode.tag.onbeforeremove) {
350+
if (typeof vnode.tag !== "string" && vnode.state.onbeforeremove) {
351351
expected++
352-
vnode.tag.onbeforeremove.call(vnode.state, vnode, once(continuation))
352+
vnode.state.onbeforeremove.call(vnode.state, vnode, once(continuation))
353353
}
354354
continuation()
355355
function continuation() {
@@ -374,7 +374,7 @@ module.exports = function($window) {
374374
}
375375
function onremove(vnode) {
376376
if (vnode.attrs && vnode.attrs.onremove) vnode.attrs.onremove.call(vnode.state, vnode)
377-
if (typeof vnode.tag !== "string" && vnode.tag.onremove) vnode.tag.onremove.call(vnode.state, vnode)
377+
if (typeof vnode.tag !== "string" && vnode.state.onremove) vnode.state.onremove.call(vnode.state, vnode)
378378
if (vnode.instance != null) onremove(vnode.instance)
379379
else {
380380
var children = vnode.children
@@ -500,7 +500,7 @@ module.exports = function($window) {
500500
function shouldUpdate(vnode, old) {
501501
var forceVnodeUpdate, forceComponentUpdate
502502
if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") forceVnodeUpdate = vnode.attrs.onbeforeupdate.call(vnode.state, vnode, old)
503-
if (typeof vnode.tag !== "string" && typeof vnode.tag.onbeforeupdate === "function") forceComponentUpdate = vnode.tag.onbeforeupdate.call(vnode.state, vnode, old)
503+
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeupdate === "function") forceComponentUpdate = vnode.state.onbeforeupdate.call(vnode.state, vnode, old)
504504
if (!(forceVnodeUpdate === undefined && forceComponentUpdate === undefined) && !forceVnodeUpdate && !forceComponentUpdate) {
505505
vnode.dom = old.dom
506506
vnode.domSize = old.domSize

0 commit comments

Comments
 (0)