fix ordering issue in subchilds

This commit is contained in:
Leo Horie 2014-04-14 11:06:41 -04:00
parent d7b64ceab2
commit e65db40116
62 changed files with 7011 additions and 13 deletions

View file

@ -283,6 +283,27 @@ function testMithril(mock) {
m.render(root, m("#foo", [["a", "b"], "test"]))
return root.childNodes[0].childNodes[1].nodeValue === "b" && root.childNodes[0].childNodes[2].nodeValue === "test"
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/51
var root = mock.document.createElement("div")
m.render(root, m("main", [m("button"), m("article", [m("section"), m("nav")])]))
m.render(root, m("main", [m("button"), m("article", [m("span"), m("nav")])]))
return root.childNodes[0].childNodes[1].childNodes[0].nodeName === "SPAN"
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/51
var root = mock.document.createElement("div")
m.render(root, m("main", [m("button"), m("article", [m("section"), m("nav")])]))
m.render(root, m("main", [m("button"), m("article", ["test", m("nav")])]))
return root.childNodes[0].childNodes[1].childNodes[0].nodeValue === "test"
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/51
var root = mock.document.createElement("div")
m.render(root, m("main", [m("button"), m("article", [m("section"), m("nav")])]))
m.render(root, m("main", [m("button"), m("article", [m.trust("test"), m("nav")])]))
return root.childNodes[0].childNodes[1].childNodes[0].nodeValue === "test"
})
//end m.render
//m.redraw

View file

@ -16,6 +16,15 @@ mock.window = new function() {
if (index < 0) this.childNodes.push(node)
else this.childNodes.splice(index, 0, node)
},
insertAdjacentHTML: function(position, html) {
//todo: accept markup
if (position == "beforebegin") {
this.parentNode.insertBefore(window.document.createTextNode(html), this)
}
else if (position == "beforeend") {
this.appendChild(window.document.createTextNode(html))
}
},
setAttribute: function(name, value) {
this[name] = value.toString()
},