fix diff bugs when there are null components in list
This commit is contained in:
parent
7227cc546f
commit
276184484d
4 changed files with 100 additions and 31 deletions
|
|
@ -640,10 +640,11 @@ o.spec("component", function() {
|
|||
})
|
||||
})
|
||||
o.spec("state", function() {
|
||||
o("deep copies state", function() {
|
||||
o("copies state", function() {
|
||||
var called = 0
|
||||
var data = {a: 1}
|
||||
var component = {
|
||||
data: [{a: 1}],
|
||||
data: data,
|
||||
oninit: init,
|
||||
view: function() {
|
||||
return ""
|
||||
|
|
@ -653,7 +654,27 @@ o.spec("component", function() {
|
|||
render(root, [{tag: component}])
|
||||
|
||||
function init(vnode) {
|
||||
o(vnode.state.data).deepEquals([{a: 1}])
|
||||
o(vnode.state.data).deepEquals(data)
|
||||
o(vnode.state.data).equals(data)
|
||||
}
|
||||
})
|
||||
o("state copy is shallow", function() {
|
||||
var called = 0
|
||||
var body = {a: 1}
|
||||
var data = [body]
|
||||
var component = {
|
||||
data: data,
|
||||
oninit: init,
|
||||
view: function() {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
function init(vnode) {
|
||||
o(vnode.state.data).equals(data)
|
||||
o(vnode.state.data[0]).equals(body)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -813,4 +813,36 @@ o.spec("updateNodes", function() {
|
|||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeName).equals("B")
|
||||
})
|
||||
o("fragment child toggles from null when followed by null component then tag", function() {
|
||||
var component = {view: function() {return null}}
|
||||
var vnodes = [{tag: "[", children: [{tag: "a"}, {tag: component}, {tag: "b"}]}]
|
||||
var temp = [{tag: "[", children: [null, {tag: component}, {tag: "b"}]}]
|
||||
var updated = [{tag: "[", children: [{tag: "a"}, {tag: component}, {tag: "b"}]}]
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeName).equals("B")
|
||||
})
|
||||
o("fragment child toggles from null in component when followed by null component then tag", function() {
|
||||
var flag = true
|
||||
var a = {view: function() {return flag ? {tag: "a"} : null}}
|
||||
var b = {view: function() {return null}}
|
||||
var vnodes = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]
|
||||
var temp = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]
|
||||
var updated = [{tag: "[", children: [{tag: a}, {tag: b}, {tag: "s"}]}]
|
||||
|
||||
render(root, vnodes)
|
||||
flag = false
|
||||
render(root, temp)
|
||||
flag = true
|
||||
render(root, updated)
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeName).equals("S")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue