fix out-of-order issue when mixing new and old elements

This commit is contained in:
Leo Horie 2014-04-09 09:12:14 -04:00
parent 08dd1cd62d
commit b972607c8d
8 changed files with 64 additions and 22 deletions

View file

@ -10,6 +10,12 @@ mock.window = new function() {
appendChild: window.document.appendChild,
removeChild: window.document.removeChild,
replaceChild: window.document.replaceChild,
insertBefore: function(node, reference) {
node.parentNode = this
var index = this.childNodes.indexOf(reference)
if (index < 0) this.childNodes.push(node)
else this.childNodes.splice(index, 0, node)
},
setAttribute: function(name, value) {
this[name] = value.toString()
},