From fccbd8a333c6ff49faab9a03062180d29c74144d Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 19 Aug 2015 11:41:14 -0700 Subject: [PATCH] Use numeric sort when removing dom-repeat instances Fixes #2297 --- src/lib/template/dom-repeat.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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