Skip to content

Commit fccbd8a

Browse files
committed
Use numeric sort when removing dom-repeat instances
Fixes #2297
1 parent a42ca09 commit fccbd8a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/lib/template/dom-repeat.html‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@
402402
return this.collection.getKey(a) - this.collection.getKey(b);
403403
},
404404

405+
_numericSort: function(a, b) {
406+
return a - b;
407+
},
408+
405409
// Render method 2: incremental update using splices with user sort applied
406410
// ----
407411
// Removed/added keys are deduped, all removed rows are detached and pooled
@@ -438,7 +442,8 @@
438442
if (removedIdxs.length) {
439443
// Sort removed instances idx's then remove backwards,
440444
// so we don't invalidate instance index
441-
removedIdxs.sort();
445+
// use numeric sort, default .sort is alphabetic
446+
removedIdxs.sort(this._numericSort);
442447
for (var i=removedIdxs.length-1; i>=0 ; i--) {
443448
var idx = removedIdxs[i];
444449
// Removed idx may be undefined if item was previously filtered out

0 commit comments

Comments
 (0)