Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ module.exports = function($window) {

if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)
initLifecycle(vnode.state, vnode, hooks)
vnode.instance = Vnode.normalize(vnode.state.view(vnode))
var output = vnode.state.view(vnode)
if (!Array.isArray(output)) output = [output]
vnode.instance = Vnode.normalize(output)
sentinel.$$reentrantLock$$ = null
}
function createComponent(parent, vnode, hooks, ns, nextSibling) {
initComponent(vnode, hooks)
if (vnode.instance != null) {
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
if (vnode.instance[0] === vnode) throw Error("A view cannot return the vnode it received as arguments")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't passing the associated tests. Any insights appreciated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd... it should work... Looking into it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vnode.normalize() turns the array into a fragment, it should be vnode.instance.children[0].

Note that this is the kind of change that will most likely affect perf negatively (adding one updateNodes() per component to the call stack), even if we define vnode.instance = Vnode.normalize(output).children and change downstream methods to deal with it.

var element = createNode(parent, vnode.instance, hooks, ns, nextSibling)
vnode.dom = vnode.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
Expand Down Expand Up @@ -317,7 +319,9 @@ module.exports = function($window) {
if (recycling) {
initComponent(vnode, hooks)
} else {
vnode.instance = Vnode.normalize(vnode.state.view(vnode))
var output = vnode.state.view(vnode)
if (!Array.isArray(output)) output = [output]
vnode.instance = Vnode.normalize(output)
if (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks)
updateLifecycle(vnode.state, vnode, hooks)
}
Expand Down