Skip to content

Commit

Permalink
Use numeric sort when removing dom-repeat instances
Browse files Browse the repository at this point in the history
Fixes #2297
  • Loading branch information
dfreedm committed Aug 19, 2015
1 parent a42ca09 commit fccbd8a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/template/dom-repeat.html
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fccbd8a

Please sign in to comment.