From 493dafadb112094974ea28e083fdf11dad906034 Mon Sep 17 00:00:00 2001 From: Jeff Heiges Date: Tue, 11 Mar 2025 08:28:47 +0000 Subject: Automated script replaced OBJECT.hasOwnProperty(PROPERTY) with Object.prototype.hasOwnProperty.call(OBJECT, PROPERTY) --- diplomacy/web/src/diplomacy/client/connection.js | 2 +- diplomacy/web/src/diplomacy/communication/notifications.js | 8 ++++---- diplomacy/web/src/diplomacy/communication/requests.js | 2 +- diplomacy/web/src/diplomacy/communication/responses.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'diplomacy/web') diff --git a/diplomacy/web/src/diplomacy/client/connection.js b/diplomacy/web/src/diplomacy/client/connection.js index c1f8bfd..1e40ed8 100644 --- a/diplomacy/web/src/diplomacy/client/connection.js +++ b/diplomacy/web/src/diplomacy/client/connection.js @@ -262,7 +262,7 @@ export class Connection { } catch (error) { context.future.setException(error); } - } else if (jsonMessage.hasOwnProperty('notification_id') && jsonMessage.notification_id) + } else if (Object.prototype.hasOwnProperty.call(jsonMessage, 'notification_id') && jsonMessage.notification_id) NOTIFICATION_MANAGERS.handleNotification(this, NOTIFICATIONS.parse(jsonMessage)); else Diplog.error('Unknown socket message received.'); diff --git a/diplomacy/web/src/diplomacy/communication/notifications.js b/diplomacy/web/src/diplomacy/communication/notifications.js index 149df09..5b66783 100644 --- a/diplomacy/web/src/diplomacy/communication/notifications.js +++ b/diplomacy/web/src/diplomacy/communication/notifications.js @@ -39,16 +39,16 @@ export const NOTIFICATIONS = { vote_updated: STRINGS.GAME, }, parse: function (jsonObject) { - if (!jsonObject.hasOwnProperty('name')) + if (!Object.prototype.hasOwnProperty.call(jsonObject, 'name')) throw new Error('No name field in expected notification object.'); - if (!jsonObject.hasOwnProperty('token')) + if (!Object.prototype.hasOwnProperty.call(jsonObject, 'token')) throw new Error('No token field in expected notification object.'); if (!NOTIFICATIONS.levels.hasOwnProperty(jsonObject.name)) throw new Error('Invalid notification name ' + jsonObject.name); if (NOTIFICATIONS.levels[jsonObject.name] === STRINGS.GAME) { - if (!jsonObject.hasOwnProperty('game_id')) + if (!Object.prototype.hasOwnProperty.call(jsonObject, 'game_id')) throw new Error('No game_id field in expected game notification object.'); - if (!jsonObject.hasOwnProperty('game_role')) + if (!Object.prototype.hasOwnProperty.call(jsonObject, 'game_role')) throw new Error('No game_role field in expected game notification object.'); } return jsonObject; diff --git a/diplomacy/web/src/diplomacy/communication/requests.js b/diplomacy/web/src/diplomacy/communication/requests.js index a4a140e..5963827 100644 --- a/diplomacy/web/src/diplomacy/communication/requests.js +++ b/diplomacy/web/src/diplomacy/communication/requests.js @@ -82,7 +82,7 @@ export const REQUESTS = { if (!REQUESTS.models.hasOwnProperty(name)) throw new Error('Unknown request name ' + name); const model = REQUESTS.models[name]; - return (model.level === STRINGS.GAME && (!model.hasOwnProperty('phase_dependent') || model.phase_dependent)); + return (model.level === STRINGS.GAME && (!Object.prototype.hasOwnProperty.call(model, 'phase_dependent') || model.phase_dependent)); }, /** Return request level for given request name. Either null, 'channel' or 'game'. **/ diff --git a/diplomacy/web/src/diplomacy/communication/responses.js b/diplomacy/web/src/diplomacy/communication/responses.js index 7c87c67..2ee15f3 100644 --- a/diplomacy/web/src/diplomacy/communication/responses.js +++ b/diplomacy/web/src/diplomacy/communication/responses.js @@ -24,7 +24,7 @@ export const RESPONSES = { 'data_game_schedule', 'data_saved_game' ]), parse: function (jsonObject) { - if (!jsonObject.hasOwnProperty('name')) + if (!Object.prototype.hasOwnProperty.call(jsonObject, 'name')) throw new Error('No name field in expected response object'); if (!RESPONSES.names.has(jsonObject.name)) throw new Error('Invalid response name ' + jsonObject.name); @@ -37,6 +37,6 @@ export const RESPONSES = { }, isUniqueData: function (response) { // Expected only 3 fields: name, request_id, data. - return (response.hasOwnProperty('data') && Object.keys(response).length === 3); + return (Object.prototype.hasOwnProperty.call(response, 'data') && Object.keys(response).length === 3); } }; -- cgit v1.2.3