Skip to content

Commit 5bbe04e

Browse files
authored
bugfix: PseudoDocuments don't play nice with Adventures (#616)
- work around the Adventure Exporter using BaseItem instead of the world item class
1 parent 02560c8 commit 5bbe04e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

module/documents/pseudo/pseudo-document-enabled-type-data-model.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ export class PseudoDocumentEnabledTypeDataModel extends foundry.abstract.TypeDat
1212
_configure() {
1313
// Construct Embedded Collections
1414
const collections = {};
15+
// Fall back to empty object in case of Adventure, packing adventures uses BaseItem instead of the world item class.
16+
const nestedCollections = this.parent.nestedCollections ?? {};
1517
for (const [fieldName, field] of Object.entries(this.constructor.schema.fields)) {
1618
if (field instanceof PseudoDocumentCollectionField) {
1719
const data = this._source[fieldName];
18-
const collection = this.parent.nestedCollections[fieldName] ?? new field.constructor.implementation(fieldName, this, data);
20+
const collection = nestedCollections[fieldName] ?? new field.constructor.implementation(fieldName, this, data);
1921
collections[fieldName] = collection;
20-
this.parent.nestedCollections[fieldName] = collection;
22+
nestedCollections[fieldName] = collection;
2123
Object.defineProperty(this, fieldName, { value: collection, writable: true });
2224
}
2325
}

0 commit comments

Comments
 (0)