Merge branch 'next' of https://github.com/lhorie/mithril.js into e2e_tests
This commit is contained in:
commit
1141af3bad
2 changed files with 19 additions and 3 deletions
|
|
@ -53,9 +53,10 @@ Mithril = m = new function app(window) {
|
||||||
cached[cacheCount++] = item
|
cached[cacheCount++] = item
|
||||||
}
|
}
|
||||||
if (!intact) {
|
if (!intact) {
|
||||||
if (nodes.length < cached.nodes.length) cached.nodes = cached.nodes.filter(function(node) {return node.parentNode !== null})
|
|
||||||
for (var i = 0; i < data.length; i++) if (cached[i] !== undefined) nodes = nodes.concat(cached[i].nodes)
|
for (var i = 0; i < data.length; i++) if (cached[i] !== undefined) nodes = nodes.concat(cached[i].nodes)
|
||||||
for (var i = nodes.length, node; node = cached.nodes[i]; i++) if (node.parentNode !== null) node.parentNode.removeChild(node)
|
for (var i = nodes.length, node; node = cached.nodes[i]; i++) {
|
||||||
|
if (node.parentNode !== null && node.parentNode.childNodes.length != nodes.length) node.parentNode.removeChild(node)
|
||||||
|
}
|
||||||
for (var i = cached.nodes.length, node; node = nodes[i]; i++) if (node.parentNode === null) parentElement.appendChild(node)
|
for (var i = cached.nodes.length, node; node = nodes[i]; i++) if (node.parentNode === null) parentElement.appendChild(node)
|
||||||
if (data.length < cached.length) cached.length = data.length
|
if (data.length < cached.length) cached.length = data.length
|
||||||
cached.nodes = nodes
|
cached.nodes = nodes
|
||||||
|
|
|
||||||
|
|
@ -378,10 +378,25 @@ function testMithril(mock) {
|
||||||
return unloaded === true
|
return unloaded === true
|
||||||
})
|
})
|
||||||
test(function() {
|
test(function() {
|
||||||
|
//https://github.com/lhorie/mithril.js/issues/87
|
||||||
var root = mock.document.createElement("div")
|
var root = mock.document.createElement("div")
|
||||||
m.render(root, m("div", [[m("a"), m("a")], m("button")]))
|
m.render(root, m("div", [[m("a"), m("a")], m("button")]))
|
||||||
m.render(root, m("div", [[m("a")], m("button")]))
|
m.render(root, m("div", [[m("a")], m("button")]))
|
||||||
return root.childNodes[0].childNodes.length == 2
|
return root.childNodes[0].childNodes.length == 2 && root.childNodes[0].childNodes[1].nodeName == "BUTTON"
|
||||||
|
})
|
||||||
|
test(function() {
|
||||||
|
//https://github.com/lhorie/mithril.js/issues/87
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
m.render(root, m("div", [m("a"), m("b"), m("button")]))
|
||||||
|
m.render(root, m("div", [m("a"), m("button")]))
|
||||||
|
return root.childNodes[0].childNodes.length == 2 && root.childNodes[0].childNodes[1].nodeName == "BUTTON"
|
||||||
|
})
|
||||||
|
test(function() {
|
||||||
|
//https://github.com/lhorie/mithril.js/issues/99
|
||||||
|
var root = mock.document.createElement("div")
|
||||||
|
m.render(root, m("div", [m("img"), m("h1")]))
|
||||||
|
m.render(root, m("div", [m("a")]))
|
||||||
|
return root.childNodes[0].childNodes.length == 1 && root.childNodes[0].childNodes[0].nodeName == "A"
|
||||||
})
|
})
|
||||||
//end m.render
|
//end m.render
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue