Modified InnerHTMLChanged to support array changes.

This commit is contained in:
Matt Mo 2021-02-03 10:15:04 -08:00
parent 2c9879a937
commit 4bbdf4865d

View File

@ -287,7 +287,13 @@ class IgniteTemplate {
IgniteRenderingContext.push();
if (value instanceof IgniteProperty) {
this._callbacks.push(value.attachOnChange((oldValue, newValue) => this.onInnerHTMLChanged(oldValue, newValue, converter)));
this._callbacks.push(value.attachOnChange((oldValue, newValue) => this.onInnerHTMLChanged((converter != null ? converter(oldValue) : oldValue), (converter != null ? converter(newValue) : newValue))));
this._callbacks.push(value.attachOnPush((list, items) => this.onInnerHTMLChanged((converter != null ? converter(list) : list), (converter != null ? converter(list) : null))));
this._callbacks.push(value.attachOnUnshift((list, items) => this.onInnerHTMLChanged((converter != null ? converter(list) : list), (converter != null ? converter(list) : null))));
this._callbacks.push(value.attachOnPop((list) => this.onInnerHTMLChanged((converter != null ? converter(list) : list), (converter != null ? converter(list) : null))));
this._callbacks.push(value.attachOnShift((list) => this.onInnerHTMLChanged((converter != null ? converter(list) : list), (converter != null ? converter(list) : null))));
this._callbacks.push(value.attachOnSplice((list, start, deleteCount, items) => this.onInnerHTMLChanged((converter != null ? converter(list) : list), (converter != null ? converter(list) : null))));
this._elementInnerHTML = (converter != null ? converter(value.value) : value.value);
} else {
this._elementInnerHTML = (converter != null ? converter(value) : value);
@ -1026,16 +1032,9 @@ class IgniteTemplate {
* on the template's element.
* @param {any} oldValue
* @param {any} newValue
* @param {Function} converter
* @ignore
*/
onInnerHTMLChanged(oldValue, newValue, converter) {
if (converter !== null) {
IgniteRenderingContext.push();
newValue = converter(newValue);
IgniteRenderingContext.pop();
}
onInnerHTMLChanged(oldValue, newValue) {
if (this.element) {
this.element.innerHTML = newValue;
}