diff --git a/src/js/core/state_manager.js b/src/js/core/state_manager.js index 6045675f..733fce5e 100644 --- a/src/js/core/state_manager.js +++ b/src/js/core/state_manager.js @@ -69,7 +69,7 @@ export class StateManager { // Remove all references for (const stateKey in this.currentState) { - if (this.currentState.hasOwnProperty(stateKey)) { + if (Object.hasOwn(this.currentState, stateKey)) { delete this.currentState[stateKey]; } } diff --git a/src/js/game/hud/parts/building_placer_logic.js b/src/js/game/hud/parts/building_placer_logic.js index c25f4210..37cf8710 100644 --- a/src/js/game/hud/parts/building_placer_logic.js +++ b/src/js/game/hud/parts/building_placer_logic.js @@ -159,7 +159,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { return this.currentBaseRotationGeneral; } const metaBuilding = this.currentMetaBuilding.get(); - if (metaBuilding && this.preferredBaseRotations.hasOwnProperty(metaBuilding.getId())) { + if (metaBuilding && Object.hasOwn(this.preferredBaseRotations, metaBuilding.getId())) { return this.preferredBaseRotations[metaBuilding.getId()]; } else { return this.currentBaseRotationGeneral; diff --git a/src/js/game/root.js b/src/js/game/root.js index 6f751e73..b41d76c4 100644 --- a/src/js/game/root.js +++ b/src/js/game/root.js @@ -224,8 +224,8 @@ export class GameRoot { } // Finally free all properties - for (let prop in this) { - if (this.hasOwnProperty(prop)) { + for (const prop in this) { + if (Object.hasOwn(this, prop)) { delete this[prop]; } } diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 22133d00..6f98a14c 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -375,7 +375,7 @@ export class ApplicationSettings extends ReadWriteProxy { * @param {string} key */ getSetting(key) { - assert(this.getAllSettings().hasOwnProperty(key), "Setting not known: " + key); + assert(Object.hasOwn(this.getAllSettings(), key), "Setting not known: " + key); return this.getAllSettings()[key]; } diff --git a/src/js/savegame/serialization.js b/src/js/savegame/serialization.js index 542dbdf3..2e587f85 100644 --- a/src/js/savegame/serialization.js +++ b/src/js/savegame/serialization.js @@ -18,11 +18,11 @@ import { TypeNumber, TypePair, TypePositiveInteger, + TypePositiveIntegerOrString, TypePositiveNumber, TypeString, TypeStructuredObject, TypeVector, - TypePositiveIntegerOrString, } from "./serialization_data_types"; /** @@ -239,12 +239,9 @@ export class BasicSerializableObject { */ export function serializeSchema(obj, schema, mergeWith = {}) { for (const key in schema) { - if (!obj.hasOwnProperty(key)) { + if (!Object.hasOwn(obj, key)) { logger.error("Invalid schema, property", key, "does not exist on", obj, "(schema=", schema, ")"); - assert( - obj.hasOwnProperty(key), - "serialization: invalid schema, property does not exist on object: " + key - ); + assert(false, "serialization: invalid schema, property does not exist on object: " + key); } if (!schema[key]) { assert(false, "Invalid schema (bad key '" + key + "'): " + JSON.stringify(schema)); @@ -292,7 +289,7 @@ export function deserializeSchema(obj, schema, data, baseclassErrorResult = null } for (const key in schema) { - if (!data.hasOwnProperty(key)) { + if (!Object.hasOwn(data, key)) { logger.error("Data", data, "does not contain", key, "(schema:", schema, ")"); return "Missing key in schema: " + key + " of class " + obj.constructor.name; } @@ -325,7 +322,7 @@ export function deserializeSchema(obj, schema, data, baseclassErrorResult = null */ export function verifySchema(schema, data) { for (const key in schema) { - if (!data.hasOwnProperty(key)) { + if (!Object.hasOwn(data, key)) { logger.error("Data", data, "does not contain", key, "(schema:", schema, ")"); return "verify: missing key required by schema in stored data: " + key; } @@ -352,7 +349,7 @@ export function extendSchema(base, newOne) { /** @type {Schema} */ const result = Object.assign({}, base); for (const key in newOne) { - if (result.hasOwnProperty(key)) { + if (Object.hasOwn(result, key)) { logger.error("Extend schema got duplicate key:", key); continue; }