fix bug when mixing keyed and unkeyed elements

This commit is contained in:
Leo Horie 2014-09-15 15:53:52 -04:00
parent 6949676e4f
commit 5a134ecf5b
3 changed files with 18 additions and 3 deletions

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)