fix null ref when updating component root from null to something
This commit is contained in:
parent
a988276e9b
commit
abadcfc13a
2 changed files with 28 additions and 1 deletions
|
|
@ -243,7 +243,8 @@ module.exports = function($window) {
|
||||||
vnode.instance = Node.normalize(vnode.tag.view.call(vnode.state, vnode))
|
vnode.instance = Node.normalize(vnode.tag.view.call(vnode.state, vnode))
|
||||||
updateLifecycle(vnode.tag, vnode, hooks, recycling)
|
updateLifecycle(vnode.tag, vnode, hooks, recycling)
|
||||||
if (vnode.instance != null) {
|
if (vnode.instance != null) {
|
||||||
updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)
|
if (old.instance == null) insertNode(parent, createNode(vnode.instance, hooks, ns), nextSibling)
|
||||||
|
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)
|
||||||
vnode.dom = vnode.instance.dom
|
vnode.dom = vnode.instance.dom
|
||||||
vnode.domSize = vnode.instance.domSize
|
vnode.domSize = vnode.instance.domSize
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,32 @@ o.spec("component", function() {
|
||||||
o(root.firstChild.attributes["id"].nodeValue).equals("c")
|
o(root.firstChild.attributes["id"].nodeValue).equals("c")
|
||||||
o(root.firstChild.firstChild.nodeValue).equals("d")
|
o(root.firstChild.firstChild.nodeValue).equals("d")
|
||||||
})
|
})
|
||||||
|
o("updates from null", function() {
|
||||||
|
var visible = false
|
||||||
|
var component = {
|
||||||
|
view: function(vnode) {
|
||||||
|
return visible ? {tag: "div"} : null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
visible = true
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
|
||||||
|
o(root.firstChild.nodeName).equals("DIV")
|
||||||
|
})
|
||||||
|
o("updates from primitive", function() {
|
||||||
|
var visible = false
|
||||||
|
var component = {
|
||||||
|
view: function(vnode) {
|
||||||
|
return visible ? {tag: "div"} : false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
visible = true
|
||||||
|
render(root, [{tag: component}])
|
||||||
|
|
||||||
|
o(root.firstChild.nodeName).equals("DIV")
|
||||||
|
})
|
||||||
o("removes", function() {
|
o("removes", function() {
|
||||||
var component = {
|
var component = {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue