Updated documentation and added the ability to specify if properties should be reflected or not when using the properties function.

This commit is contained in:
2025-10-19 14:46:57 -07:00
parent f1bff47ae7
commit d6329bfc4c

View File

@@ -262,8 +262,8 @@ class IgniteTemplate {
* Sets a property on the element this template will construct.
* @param {String} name Name of the property to set.
* @param {Any|IgniteProperty|IgniteProperty[]} value Value of the property to use. If a Property is passed the value will auto update.
* @param {Boolean} reflect If true whenever this property is changed it's value will be passed back to the Property that was passed as value if one was passed.
* @param {Function} converter Optional function that can be used to convert the value if needed.
* @param {Boolean} reflect If true whenever this property is changed it's value will be passed back to the Property that was passed as value if one was passed. Default is false.
* @param {Function} converter Optional function that can be used to convert the value if needed. Default is null.
* @returns {IgniteTemplate} This ignite template so function calls can be chained.
*/
property(name, value, reflect = false, converter = null) {
@@ -384,9 +384,10 @@ class IgniteTemplate {
/**
* Adds a set of properties from an object to be added to this template once it's constructed.
* @param {Object|IgniteObject} props The object value that property names/values will be pulled from.
* @param {boolean} reflect Whether or not to relfect the values from the properties passed in. Default is false.
* @returns {IgniteTemplate} This ignite template so function calls can be chained.
*/
properties(props) {
properties(props, reflect = false) {
//Make sure we have a valid props.
if (props == null || props == undefined) {
return;
@@ -398,7 +399,7 @@ class IgniteTemplate {
if (props instanceof IgniteObject) {
props.update();
Object.getOwnPropertyNames(props).forEach(name => this.property(name, props[name], true));
Object.getOwnPropertyNames(props).forEach(name => this.property(name, props[name], reflect));
}
else if (props instanceof IgniteProperty) {
this._callbacks.push(props.attachOnChange((oldValue, newValue) => {
@@ -408,11 +409,11 @@ class IgniteTemplate {
}));
if (props.value) {
Object.keys(props.value).forEach(name => this.property(name, props[name], false, null));
Object.keys(props.value).forEach(name => this.property(name, props[name], reflect, null));
}
}
else {
Object.keys(props).forEach(name => this.property(name, props[name], false, null));
Object.keys(props).forEach(name => this.property(name, props[name], reflect, null));
}
return this;