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:
@@ -262,8 +262,8 @@ class IgniteTemplate {
|
|||||||
* Sets a property on the element this template will construct.
|
* Sets a property on the element this template will construct.
|
||||||
* @param {String} name Name of the property to set.
|
* @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 {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 {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.
|
* @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.
|
* @returns {IgniteTemplate} This ignite template so function calls can be chained.
|
||||||
*/
|
*/
|
||||||
property(name, value, reflect = false, converter = null) {
|
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.
|
* 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 {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.
|
* @returns {IgniteTemplate} This ignite template so function calls can be chained.
|
||||||
*/
|
*/
|
||||||
properties(props) {
|
properties(props, reflect = false) {
|
||||||
//Make sure we have a valid props.
|
//Make sure we have a valid props.
|
||||||
if (props == null || props == undefined) {
|
if (props == null || props == undefined) {
|
||||||
return;
|
return;
|
||||||
@@ -398,7 +399,7 @@ class IgniteTemplate {
|
|||||||
if (props instanceof IgniteObject) {
|
if (props instanceof IgniteObject) {
|
||||||
props.update();
|
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) {
|
else if (props instanceof IgniteProperty) {
|
||||||
this._callbacks.push(props.attachOnChange((oldValue, newValue) => {
|
this._callbacks.push(props.attachOnChange((oldValue, newValue) => {
|
||||||
@@ -408,11 +409,11 @@ class IgniteTemplate {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (props.value) {
|
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 {
|
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;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user