diff --git a/src/lib/template/dom-repeat.html b/src/lib/template/dom-repeat.html
index 9e5923deae..1de919a267 100644
--- a/src/lib/template/dom-repeat.html
+++ b/src/lib/template/dom-repeat.html
@@ -374,11 +374,11 @@
for (var i=0; i=0; i--) {
+ var inst = this._instances[i];
if (inst.isPlaceholder) {
- this._instances[idx] = this._insertRow(idx, inst.key, pool);
+ this._instances[i] = this._insertRow(i, inst.key, pool, true);
}
- }, this);
+ }
},
_detachRow: function(idx) {
@@ -534,7 +534,7 @@
return inst;
},
- _insertRow: function(idx, key, pool) {
+ _insertRow: function(idx, key, pool, replace) {
var inst;
if (inst = pool && pool.pop()) {
inst.__setProperty(this.as, this.collection.getItem(key), true);
@@ -542,7 +542,7 @@
} else {
inst = this._generateRow(idx, key);
}
- var beforeRow = this._instances[idx];
+ var beforeRow = this._instances[replace ? idx + 1 : idx];
var beforeNode = beforeRow ? beforeRow._children[0] : this;
var parentNode = Polymer.dom(this).parentNode;
Polymer.dom(parentNode).insertBefore(inst.root, beforeNode);