make sure element is child of correct parent if child is recycled but parent is not

This commit is contained in:
Leo Horie 2014-04-01 14:40:02 -04:00
parent 1385fc6268
commit 49dffe7e0e
7 changed files with 32 additions and 5 deletions

View file

@ -73,6 +73,7 @@ new function(window) {
setAttributes(node, data.attrs, cached.attrs)
cached.children = build(node, data.children, cached.children)
cached.nodes.intact = true
parent.appendChild(node)
}
if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew)
}
@ -621,6 +622,12 @@ function testMithril(mock) {
m.render(root, m("div", [undefined]))
return root.childNodes[0].childNodes.length === 0
})
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("div.classname", [m("a", {href: "/first"})]))
m.render(root, m("div", [m("a", {href: "/second"})]))
return root.childNodes[0].childNodes.length == 1
})
//m.redraw
test(function() {