aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/json-schema.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index b059d757..3238bc3e 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -352,8 +352,13 @@ class JsonSchemaProxyHandler {
}
}
- if (type === 'object') {
- value = JsonSchemaProxyHandler.populateObjectDefaults(value, schema);
+ switch (type) {
+ case 'object':
+ value = JsonSchemaProxyHandler.populateObjectDefaults(value, schema);
+ break;
+ case 'array':
+ value = JsonSchemaProxyHandler.populateArrayDefaults(value, schema);
+ break;
}
return value;
@@ -384,6 +389,16 @@ class JsonSchemaProxyHandler {
return value;
}
+
+ static populateArrayDefaults(value, schema) {
+ for (let i = 0, ii = value.length; i < ii; ++i) {
+ const propertySchema = JsonSchemaProxyHandler.getPropertySchema(schema, i);
+ if (propertySchema === null) { continue; }
+ value[i] = JsonSchemaProxyHandler.getValidValueOrDefault(propertySchema, value[i]);
+ }
+
+ return value;
+ }
}
class JsonSchema {