Merge branch 'next' into es6-promise

Conflicts:
	docs/mithril.deferred.md
This commit is contained in:
Leo Horie 2014-09-15 21:32:39 -04:00
commit fe17009bc9
6 changed files with 21 additions and 5 deletions

View file

@ -584,6 +584,17 @@ function testMithril(mock) {
var fifthAfter = root.childNodes[1]
return firstBefore === firstAfter && secondBefore === secondAfter && thirdBefore === thirdAfter && fourthBefore === fourthAfter && fifthBefore === fifthAfter
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/246
//insert at beginning with non-keyed in the middle
var root = mock.document.createElement("div")
m.render(root, [m("a", {key: 1})])
var firstBefore = root.childNodes[0]
m.render(root, [m("a", {key: 2}), m("br"), m("a", {key: 1})])
var firstAfter = root.childNodes[2]
console.log(root.childNodes)
return firstBefore == firstAfter && root.childNodes[0].key == 2 && root.childNodes.length == 3
})
test(function() {
//https://github.com/lhorie/mithril.js/issues/134
var root = mock.document.createElement("div")

View file

@ -15,7 +15,11 @@ mock.window = new function() {
insertBefore: function(node, reference) {
node.parentNode = this
var referenceIndex = this.childNodes.indexOf(reference)
if (referenceIndex < 0) this.childNodes.push(node)
if (referenceIndex < 0) {
var index = this.childNodes.indexOf(node)
if (index > -1) this.childNodes.splice(index, 1)
this.childNodes.push(node)
}
else {
var index = this.childNodes.indexOf(node)
if (index > -1) this.childNodes.splice(index, 1)