Simplified callbacks into a single class with a detach function option so we can use them generically. Patached arrays can have multiple on push/on pop callbacks and moved over to this new model. Needs more testing and cleanup.

This commit is contained in:
2020-08-22 18:11:37 -07:00
parent 56530fc966
commit d4df41e427
3 changed files with 75 additions and 75 deletions

View File

@ -600,13 +600,15 @@ class list extends IgniteTemplate {
}
onListChanged(oldValue, newValue) {
console.log("On List changed:", newValue);
this.list = newValue;
IgniteRenderingContext.enter();
try {
this.construct(null); //The list changed, reconstruct this template.
} catch { }
} catch (error) { console.error(error); }
IgniteRenderingContext.leave();
}
@ -616,7 +618,12 @@ class list extends IgniteTemplate {
try {
var template = this.forEach(this.list[this.list.length - 1]);
template.construct(this.element.parentElement, this.elements[this.elements.length - 1].nextSibling);
if (this.elements.length > 0) {
template.construct(this.element.parentElement, this.elements[this.elements.length - 1].nextSibling);
} else {
template.construct(this.element.parentElement, null);
}
this.children.push(template);
this.elements.push(template.element);