Skip to content

Commit

Permalink
perf. improvements on repeater for splice-like
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed May 15, 2017
1 parent 93f1410 commit bc315b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,22 @@ Slim.__initRepeater = function () {
if (this.clones && sourceData.length === this.clones.length && this.clones.length !== 0) {
this.clones.forEach(function (clone, idx) {
clone[targetPropName] = sourceData[idx];
Slim.selectorToArr(clone, '*').forEach(function (child) {
child[targetPropName] = sourceData[idx];
});
});
this._executeBindings(targetPropName);
return;
} else if (this.clones && sourceData.length < this.clones.length) {
this.sourceData.forEach(function (dataItem, idx) {
_this7.clones[idx][targetPropName] = dataItem;
Slim.selectorToArr(_this7.clones[idx], '*').forEach(function (child) {
child[targetPropName] = sourceData[idx];
});
});
var clonesToBeRemoved = this.clones.splice(sourceData.length);
clonesToBeRemoved.forEach(function (cloneToBeRemoved) {
Slim.removeChild(cloneToBeRemoved);
});
this._executeBindings(targetPropName);
return;
Expand Down
Loading

0 comments on commit bc315b7

Please sign in to comment.