Modified ignite template properties function to dynamically change properties. Fixed a few bugs as well.
This commit is contained in:
		| @@ -376,6 +376,17 @@ class IgniteTemplate { | ||||
|  | ||||
|             Object.getOwnPropertyNames(props).forEach(name => this.property(name, props[name], true)); | ||||
|         } | ||||
|         else if (props instanceof IgniteProperty) { | ||||
|             this._callbacks.push(props.attachOnChange((oldValue, newValue) => { | ||||
|                 if (newValue) { | ||||
|                     Object.keys(newValue).forEach(name => this.onPropertyChanged(name, newValue[name])); | ||||
|                 } | ||||
|             })); | ||||
|  | ||||
|             if (props.value) { | ||||
|                 Object.keys(props.value).forEach(name => this.property(name, props[name], false, null)); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             Object.keys(props).forEach(name => this.property(name, props[name], false, null)); | ||||
|         } | ||||
| @@ -1482,7 +1493,11 @@ class IgniteTemplate { | ||||
|             IgniteRendering.leave(); | ||||
|         } | ||||
|  | ||||
|         this._properties[propertyName].value = newValue; | ||||
|         if (!this._properties[propertyName]) { | ||||
|             this._properties[propertyName] = { value: newValue }; | ||||
|         } else { | ||||
|             this._properties[propertyName].value = newValue; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -2538,7 +2553,7 @@ class converter extends IgniteTemplate { | ||||
|  | ||||
|         if (converter instanceof IgniteProperty) { | ||||
|             this._callbacks.push(converter.attachOnChange((oldValue, newValue) => this.onConverterChanged(newValue))); | ||||
|          | ||||
|  | ||||
|             this.converter = converter.value; | ||||
|         } else if (converter instanceof Function) { | ||||
|             this.converter = converter; | ||||
| @@ -2562,7 +2577,7 @@ class converter extends IgniteTemplate { | ||||
|         if (this.converter) { | ||||
|             child = this.converter(this.value); | ||||
|         } | ||||
|          | ||||
|  | ||||
|         if (child instanceof IgniteTemplate) { | ||||
|             this.child = child; | ||||
|         } else if (child) { | ||||
| @@ -2608,8 +2623,8 @@ class converter extends IgniteTemplate { | ||||
|  | ||||
|         if (this.converter) { | ||||
|             child = this.converter(child); | ||||
|         }  | ||||
|          | ||||
|         } | ||||
|  | ||||
|         if (child instanceof IgniteTemplate) { | ||||
|             this.child = child; | ||||
|         } else if (child) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user