fix diff for other null component root cases
This commit is contained in:
parent
abadcfc13a
commit
ffa9736151
2 changed files with 43 additions and 2 deletions
|
|
@ -248,6 +248,10 @@ module.exports = function($window) {
|
||||||
vnode.dom = vnode.instance.dom
|
vnode.dom = vnode.instance.dom
|
||||||
vnode.domSize = vnode.instance.domSize
|
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) {
|
function isRecyclable(old, vnodes) {
|
||||||
if (old.pool != null && Math.abs(old.pool.length - vnodes.length) <= Math.abs(old.length - vnodes.length)) {
|
if (old.pool != null && Math.abs(old.pool.length - vnodes.length) <= Math.abs(old.length - vnodes.length)) {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ 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() {
|
o("updates root from null", function() {
|
||||||
var visible = false
|
var visible = false
|
||||||
var component = {
|
var component = {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
|
|
@ -67,7 +67,7 @@ o.spec("component", function() {
|
||||||
|
|
||||||
o(root.firstChild.nodeName).equals("DIV")
|
o(root.firstChild.nodeName).equals("DIV")
|
||||||
})
|
})
|
||||||
o("updates from primitive", function() {
|
o("updates root from primitive", function() {
|
||||||
var visible = false
|
var visible = false
|
||||||
var component = {
|
var component = {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
|
|
@ -80,6 +80,43 @@ o.spec("component", function() {
|
||||||
|
|
||||||
o(root.firstChild.nodeName).equals("DIV")
|
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() {
|
o("removes", function() {
|
||||||
var component = {
|
var component = {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue