localization plugin no longer mishandling schema type String as an array

This commit is contained in:
Dan Ribbens
2019-10-22 21:38:55 -04:00
parent e2012b205c
commit 4b1e1682c8
2 changed files with 4 additions and 6 deletions

View File

@@ -149,13 +149,11 @@ export default function localizationPlugin(schema, options) {
}
this.fallbackLocale = fallbackLocale;
this.schema.eachPath((path, schemaType) => {
const isArrayOfReferences = schemaType.options.type && schemaType.options.type[0];
const isReference = schemaType.options.ref;
if (isArrayOfReferences) {
if (schemaType.options.type instanceof Array) {
this[path].forEach(doc => doc.setLocale && doc.setLocale(locale, fallbackLocale));
}
if (isReference && this[path]) {
if (schemaType.options.ref && this[path]) {
this[path].setLocale && this[path].setLocale(locale, fallbackLocale);
}
})