Adding null check for the properties getter.

This commit is contained in:
Matt Mo 2020-08-23 17:06:18 -07:00
parent 7c0dfd9f7f
commit c7529f1efc

View File

@ -36,26 +36,28 @@ class IgniteElement extends HTMLElement {
createProperties() { createProperties() {
var props = this.properties; var props = this.properties;
var keys = Object.keys(props); if (props != null) {
for (var i = 0; i < keys.length; i++) { var keys = Object.keys(props);
let prop = new IgniteProperty(props[keys[i]]); for (var i = 0; i < keys.length; i++) {
this[`_${keys[i]}`] = prop; let prop = new IgniteProperty(props[keys[i]]);
this[`_${keys[i]}`] = prop;
((propName) => { ((propName) => {
Object.defineProperty(this, propName, { Object.defineProperty(this, propName, {
get: function () { get: function () {
if (IgniteRenderingContext.rendering == false) { if (IgniteRenderingContext.rendering == false) {
return this[`_${propName}`].value; return this[`_${propName}`].value;
} else { } else {
return this[`_${propName}`]; return this[`_${propName}`];
}
},
set: function (value) {
this[`_${propName}`].value = value;
} }
}, });
})(keys[i]);
set: function (value) { }
this[`_${propName}`].value = value;
}
});
})(keys[i]);
} }
} }
@ -66,9 +68,11 @@ class IgniteElement extends HTMLElement {
resetProperties() { resetProperties() {
var props = this.properties; var props = this.properties;
var keys = Object.keys(props); if (props != null) {
for (var i = 0; i < keys.length; i++) { var keys = Object.keys(props);
this[keys[i]] = props[keys[i]]; for (var i = 0; i < keys.length; i++) {
this[keys[i]] = props[keys[i]];
}
} }
} }