fix null ref when updating component root from null to something

This commit is contained in:
Leo Horie 2016-07-08 14:57:10 -04:00
parent a988276e9b
commit abadcfc13a
2 changed files with 28 additions and 1 deletions

View file

@ -54,6 +54,32 @@ o.spec("component", function() {
o(root.firstChild.attributes["id"].nodeValue).equals("c")
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() {
var component = {
view: function(vnode) {