fix diff for other null component root cases

This commit is contained in:
Leo Horie 2016-07-08 15:08:56 -04:00
parent abadcfc13a
commit ffa9736151
2 changed files with 43 additions and 2 deletions

View file

@ -248,6 +248,10 @@ module.exports = function($window) {
vnode.dom = vnode.instance.dom
vnode.domSize = vnode.instance.domSize
}
else if (old.instance != null) {
removeNode(parent, old.instance, null, false)
vnode.dom = vnode.domSize = undefined
}
}
function isRecyclable(old, vnodes) {
if (old.pool != null && Math.abs(old.pool.length - vnodes.length) <= Math.abs(old.length - vnodes.length)) {

View file

@ -54,7 +54,7 @@ o.spec("component", function() {
o(root.firstChild.attributes["id"].nodeValue).equals("c")
o(root.firstChild.firstChild.nodeValue).equals("d")
})
o("updates from null", function() {
o("updates root from null", function() {
var visible = false
var component = {
view: function(vnode) {
@ -67,7 +67,7 @@ o.spec("component", function() {
o(root.firstChild.nodeName).equals("DIV")
})
o("updates from primitive", function() {
o("updates root from primitive", function() {
var visible = false
var component = {
view: function(vnode) {
@ -80,6 +80,43 @@ o.spec("component", function() {
o(root.firstChild.nodeName).equals("DIV")
})
o("updates root to null", function() {
var visible = true
var component = {
view: function(vnode) {
return visible ? {tag: "div"} : null
}
}
render(root, [{tag: component}])
visible = false
render(root, [{tag: component}])
o(root.childNodes.length).equals(0)
})
o("updates root to primitive", function() {
var visible = true
var component = {
view: function(vnode) {
return visible ? {tag: "div"} : false
}
}
render(root, [{tag: component}])
visible = false
render(root, [{tag: component}])
o(root.firstChild.nodeValue).equals("false")
})
o("updates root from null to null", function() {
var component = {
view: function(vnode) {
return null
}
}
render(root, [{tag: component}])
render(root, [{tag: component}])
o(root.childNodes.length).equals(0)
})
o("removes", function() {
var component = {
view: function(vnode) {