Skip to content

Commit

Permalink
Tests for #1990, #1991 and 2003 (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed Nov 22, 2017
1 parent 58e5466 commit df027f4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions render/tests/test-onremove.js
Expand Up @@ -101,6 +101,7 @@ o.spec("onremove", function() {
render(root, temp)
render(root, updated)

o(vnodes[0].dom).equals(updated[0].dom)
o(remove.callCount).equals(1)
})
o("does not recycle when there's an onremove", function() {
Expand Down Expand Up @@ -191,6 +192,19 @@ o.spec("onremove", function() {
o(spy.callCount).equals(0)
o(threw).equals(false)
})
o("doesn't fire when removing the children of a node that's brought back from the pool (#1991 part 2)", function() {
var onremove = o.spy()
var vnode = {tag: "div", key: 1, children: [{tag: "div", attrs: {onremove: onremove}}]}
var temp = {tag: "div", key: 2}
var updated = {tag: "div", key: 1, children: [{tag: "p"}]}

render(root, [vnode])
render(root, [temp])
render(root, [updated])

o(vnode.dom).equals(updated.dom)
o(onremove.callCount).equals(1)
})
})
})
})
19 changes: 19 additions & 0 deletions render/tests/test-updateNodes.js
Expand Up @@ -983,6 +983,25 @@ o.spec("updateNodes", function() {

o(vnode.dom).notEquals(updated.dom)
})
o("don't add back elements from fragments that have been removed #1991", function() {
render(root, [
{tag: "[", children: []},
{tag: "[", children: []}
])
render(root, [
{tag: "[", children: []},
{tag: "[", children: [{tag: "div"}]}
])
render(root, [
{tag: "[", children: [null]}
])
render(root, [
{tag: "[", children: []},
{tag: "[", children: []}
])

o(root.childNodes.length).equals(0)
})
components.forEach(function(cmp){
o.spec(cmp.kind, function(){
var createComponent = cmp.create
Expand Down

0 comments on commit df027f4

Please sign in to comment.