Skip to content
Browse files

Always use placeholders; fix insertion reference bug.

  • Loading branch information...
1 parent 4eda393 commit 4a45d4f7e0eb16a094058bf1482fe095895271bc @kevinpschaaf kevinpschaaf committed
Showing with 20 additions and 12 deletions.
  1. +20 −12 src/lib/template/dom-repeat.html
View
32 src/lib/template/dom-repeat.html
@@ -341,6 +341,9 @@
},
// Render method 1: full refesh
+ // ----
+ // Full list of keys is pulled from the collection, then sorted, filtered,
+ // and interated to create (or reuse) existing instances
_applyFullRefresh: function() {
var c = this.collection;
// Start with unordered keys for view sort,
@@ -391,6 +394,10 @@
return this.collection.getKey(a) - this.collection.getKey(b);
},
+ // Render method 2: incremental update using splices with user sort applied
+ // ----
+ // Removed/added keys are deduped, all removed rows are detached and pooled
+ // first, and added rows are insertion-sorted into place using user sort
_applySplicesUserSort: function(splices) {
var c = this.collection;
var keys = this._keys;
@@ -484,6 +491,12 @@
return idx;
},
+ // Render method 3: incremental update using splices with array sort
+ // ----
+ // Splices are processed in order; removed rows are pooled, and added
+ // rows are inserted based on splice index; placeholders are used when
+ // inserting rows when pool is empty, and placeholders are updated to
+ // actual rows at the end to take full advantage of removed rows
_applySplicesArrayOrder: function(splices) {
var keys = this._keys;
var pool = [];
@@ -500,19 +513,14 @@
}
}
this._instances.splice(s.index, s.removed.length);
- // Insert new instances (from pool or placeholder)
+ // Insert placeholders for new rows
for (var i=0; i<s.added.length; i++) {
- var inst;
- if (pool.length) {
- inst = this._insertRow(s.index + i, pool, s.added[i]);
- } else {
- var beforeRow = this._instances[s.index + i];
- inst = {
- isPlaceholder: true,
- key: s.added[i],
- _children: [beforeRow ? beforeRow._children[0] : null]
- };
- }
+ var beforeRow = this._instances[s.index + i];
+ var inst = {
+ isPlaceholder: true,
+ key: s.added[i],
+ _children: [beforeRow ? beforeRow._children[0] : this]
+ };
this._instances.splice(s.index + i, 0, inst);
}
}, this);

0 comments on commit 4a45d4f

Please sign in to comment.
Something went wrong with that request. Please try again.