summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-26 11:06:03 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-02 10:12:01 -0500
commit0b474751b5fb994d402caf3d0515d95680684b60 (patch)
tree42014ae58ae94c9b0b1dae940c057402e764e69c /ext
parentf23e0c9c95a7c0803694ea91b0ea55079e8f52d6 (diff)
Add simplified isObject test
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/json-schema.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index 5d596a8b..2b7c9f27 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -131,19 +131,19 @@ class JsonSchemaProxyHandler {
case 'object':
{
const properties = schema.properties;
- if (properties !== null && typeof properties === 'object' && !Array.isArray(properties)) {
+ if (JsonSchemaProxyHandler.isObject(properties)) {
if (Object.prototype.hasOwnProperty.call(properties, property)) {
return properties[property];
}
}
const additionalProperties = schema.additionalProperties;
- return (additionalProperties !== null && typeof additionalProperties === 'object' && !Array.isArray(additionalProperties)) ? additionalProperties : null;
+ return JsonSchemaProxyHandler.isObject(additionalProperties) ? additionalProperties : null;
}
case 'array':
{
const items = schema.items;
- return (items !== null && typeof items === 'object' && !Array.isArray(items)) ? items : null;
+ return JsonSchemaProxyHandler.isObject(items) ? items : null;
}
default:
return null;
@@ -399,6 +399,10 @@ class JsonSchemaProxyHandler {
return value;
}
+
+ static isObject(value) {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
+ }
}
class JsonSchema {