From 5eda2359ccba7f611eebe316cdd36077a02911e4 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 15 Jul 2015 18:41:46 -0700 Subject: [PATCH] Replace placeholders backwards to simplify. --- src/lib/template/dom-repeat.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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);