Use JavaScript Optional chaining

This commit is contained in:
the-djmaze 2022-09-02 11:52:07 +02:00
parent d9bc435e2c
commit 732b6eb641
55 changed files with 169 additions and 199 deletions

View file

@ -50,8 +50,7 @@ export class AbstractModel {
// forEachObjectEntry(this, (key, value) => {
forEachObjectValue(this, value => {
/** clear CollectionModel */
let arr = ko.isObservableArray(value) ? value() : value;
arr && arr.onDestroy && arr.onDestroy();
(ko.isObservableArray(value) ? value() : value)?.onDestroy?.();
/** destroy ko.observable/ko.computed? */
// dispose(value);
/** clear object value */
@ -76,7 +75,7 @@ export class AbstractModel {
*/
static reviveFromJson(json) {
let obj = this.validJson(json) ? new this() : null;
obj && obj.revivePropertiesFromJson(json);
obj?.revivePropertiesFromJson(json);
return obj;
}