Bugfix: TypeError curValue is null

This commit is contained in:
djmaze 2021-09-03 09:30:53 +02:00
parent d71b36f09e
commit b65b77f518

View file

@ -7,6 +7,7 @@ function dispose(disposable) {
}
function typeCast(curValue, newValue) {
if (null != curValue) {
switch (typeof curValue)
{
case 'boolean': return 0 != newValue && !!newValue;
@ -19,6 +20,7 @@ function typeCast(curValue, newValue) {
if (isArray(curValue) && !isArray(newValue))
return [];
}
}
return newValue;
}
@ -84,12 +86,11 @@ export class AbstractModel {
revivePropertiesFromJson(json) {
let model = this.constructor;
try {
if (!model.validJson(json)) {
return false;
}
Object.entries(json).forEach(([key, value]) => {
if ('@' !== key[0]) {
if ('@' !== key[0]) try {
key = key[0].toLowerCase() + key.substr(1);
switch (typeof this[key])
{
@ -111,12 +112,11 @@ export class AbstractModel {
default:
// console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived');
}
}
});
} catch (e) {
console.log(model.name);
console.log(model.name + '.' + key);
console.error(e);
}
});
return true;
}