Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed May 25, 2017
1 parent 72f1d23 commit 13fbfa8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions Slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ var Slim = function (_CustomElement2) {
targets = descriptor.target.repeater.clones;
}
if (targets) {
var sourceRef = descriptor.target._boundRepeaterParent;
var sourceRef = descriptor.target._boundRepeaterParent || descriptor.target._boundParent;
var value = Slim.__lookup(sourceRef || source, prop).obj || Slim.__lookup(descriptor.target, prop).obj;
var attrName = Slim.__dashToCamel(descriptor.attribute);
targets.forEach(function (target) {
Expand Down Expand Up @@ -527,7 +527,8 @@ var Slim = function (_CustomElement2) {
};
} else if (descriptor.type === 'R') {
executor = function executor() {
descriptor.repeater.renderList();
descriptor.repeater.registerForRender();
// !descriptor.repeater.isRendering && descriptor.repeater.renderList()
};
} else if (descriptor.type === 'W') {
executor = function executor() {
Expand Down Expand Up @@ -1306,7 +1307,7 @@ Slim.__initRepeater = function () {
if (!this.uq_index) {
this.createdCallback();
}
this.renderList();
this.checkoutRender();
}
}, {
key: 'onRemoved',
Expand Down Expand Up @@ -1353,18 +1354,23 @@ Slim.__initRepeater = function () {
element[targetPropName] = sourceData[idx];
element.data_index = idx;
element.data_source = sourceData;
if (element.isSlim) {
element.update();
}
});
if (clone.isSlim) {
clone.update();
}
});
this.clones[0]._boundProperties && Object.keys(this.clones[0]._boundProperties).forEach(function (prop) {
try {
_this7.clones[0]._boundParent._executeBindings(prop.split('.')[0]);
_this7._boundParent._executeBindings(prop.split('.')[0]);
} catch (err) {/* swallow error */}
});
Slim.selectorToArr(this.clones[0], '*').forEach(function (element) {
try {
element._boundParent._executeBindings(prop.split('.')[0]);
_this7._boundParent._executeBindings(prop.split('.')[0]);
} catch (err) {/* swallow error */}
});
Expand All @@ -1373,11 +1379,17 @@ Slim.__initRepeater = function () {
}, {
key: 'renderList',
value: function renderList() {
if (!this.sourceNode) return;
if (this.isRendering) return;
this.isRendering = true;
if (!this.sourceNode) {
this.isRendering = false;
return;
}
this.sourceData.registerSlimRepeater(this);

if (this.clones && this.clones.length === this.sourceData.length && this.sourceData.length > 0) {
this.updateExistingList();
this.isRendering = false;
return;
}

Expand All @@ -1387,16 +1399,19 @@ Slim.__initRepeater = function () {
Slim.removeChild(leftover);
});
this.updateExistingList();
this.isRendering = false;
return;
}
if (this.clones && this.clones.length < this.sourceData.length && this.clones.length > 0) {
this.updateExistingList();
var remaining = this.sourceData.slice(this.clones.length);
this.createItems(remaining);
this.isRendering = false;
return;
}
this.clearList();
this.createItems(this.sourceData);
this.isRendering = false;
}
}, {
key: 'createItems',
Expand Down
Loading

0 comments on commit 13fbfa8

Please sign in to comment.