diff --git a/src/lib/template/dom-repeat.html b/src/lib/template/dom-repeat.html index a1537efc68..ee3e99ed18 100644 --- a/src/lib/template/dom-repeat.html +++ b/src/lib/template/dom-repeat.html @@ -402,6 +402,10 @@ return this.collection.getKey(a) - this.collection.getKey(b); }, + _numericSort: function(a, b) { + return a - b; + }, + // Render method 2: incremental update using splices with user sort applied // ---- // Removed/added keys are deduped, all removed rows are detached and pooled @@ -438,7 +442,8 @@ if (removedIdxs.length) { // Sort removed instances idx's then remove backwards, // so we don't invalidate instance index - removedIdxs.sort(); + // use numeric sort, default .sort is alphabetic + removedIdxs.sort(this._numericSort); for (var i=removedIdxs.length-1; i>=0 ; i--) { var idx = removedIdxs[i]; // Removed idx may be undefined if item was previously filtered out diff --git a/test/unit/dom-repeat-elements.html b/test/unit/dom-repeat-elements.html index cb1366b4e9..274294dae0 100644 --- a/test/unit/dom-repeat-elements.html +++ b/test/unit/dom-repeat-elements.html @@ -386,4 +386,28 @@ } }); - \ No newline at end of file + + + + + + diff --git a/test/unit/dom-repeat.html b/test/unit/dom-repeat.html index 56757561d1..65de283c22 100644 --- a/test/unit/dom-repeat.html +++ b/test/unit/dom-repeat.html @@ -68,6 +68,9 @@

inDocumentRepeater

+

x-primitive-large

+ +
@@ -1267,6 +1270,17 @@

inDocumentRepeater

}); }); + test('large splice', function(done) { + primitiveLarge.splice('items', 0, 10); + setTimeout(function() { + var stamped = + Polymer.dom(primitiveLarge.root).querySelectorAll('*:not(template)'); + assert.equal(stamped.length, 1, 'total stamped count incorrect'); + assert.equal(stamped[0].textContent, '10'); + done(); + }); + }); + test('css scoping retained when re-ordering', function(done) { if (!Polymer.Settings.useShadow) { // Confirm initial scoping