mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-30 16:34:45 +08:00
Allow Attribute.Collection to have unspecified / basic type e.g. string
This commit is contained in:
parent
6b070aa9dc
commit
1a36bec6fc
1 changed files with 2 additions and 2 deletions
|
@ -47,7 +47,7 @@ export default class AttributeCollection extends Attribute {
|
|||
}
|
||||
|
||||
return vals.map((val) => {
|
||||
if (!(val instanceof this.ItemClass)) {
|
||||
if (this.ItemClass && !(val instanceof this.ItemClass)) {
|
||||
throw new Error(`AttributeCollection::toJSON: Value \`${val}\` in ${this.modelKey} is not an ${this.ItemClass.name}`);
|
||||
}
|
||||
return (val.toJSON !== undefined) ? val.toJSON() : val;
|
||||
|
@ -59,7 +59,7 @@ export default class AttributeCollection extends Attribute {
|
|||
return [];
|
||||
}
|
||||
return json.map((objJSON) => {
|
||||
if (!objJSON || objJSON instanceof this.ItemClass) {
|
||||
if (!objJSON || !this.ItemClass || objJSON instanceof this.ItemClass) {
|
||||
return objJSON;
|
||||
}
|
||||
return new this.ItemClass(objJSON);
|
||||
|
|
Loading…
Add table
Reference in a new issue