From 860374fdab25fce3161ee835be0e141a341b9b9b Mon Sep 17 00:00:00 2001 From: Cashew <52880648+Scrub1492@users.noreply.github.com> Date: Wed, 27 Dec 2023 13:41:35 +0700 Subject: switch updates (#459) * switch updates * revert to if-else * revert to if-else * remove empty default --- ext/js/data/json-schema.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ext/js/data') diff --git a/ext/js/data/json-schema.js b/ext/js/data/json-schema.js index 08414164..ee58976e 100644 --- a/ext/js/data/json-schema.js +++ b/ext/js/data/json-schema.js @@ -1343,12 +1343,18 @@ class JsonSchemaProxyHandler { * @returns {?number} */ _getArrayIndex(property) { - if (typeof property === 'string' && this._numberPattern.test(property)) { - return Number.parseInt(property, 10); - } else if (typeof property === 'number' && Math.floor(property) === property && property >= 0) { - return property; - } else { - return null; + switch (typeof property) { + case 'string': + if (this._numberPattern.test(property)) { + return Number.parseInt(property, 10); + } + break; + case 'number': + if (Math.floor(property) === property && property >= 0) { + return property; + } + break; } + return null; } } -- cgit v1.2.3