diff --git a/src/core/store/serialize.ts b/src/core/store/serialize.ts index 8adc27c6..450468d2 100644 --- a/src/core/store/serialize.ts +++ b/src/core/store/serialize.ts @@ -84,6 +84,7 @@ import { import { type FlatItem, makeFlatItem } from '../properties/listItems'; import { coerceValue, + initialOf, isValidFieldName, isValidVariableName, type PropertyDef, @@ -771,7 +772,9 @@ function normalizeBag(raw: unknown, schema: PropertySchema, sparse: boolean): Pr for (const def of schema) { const value = r[def.key]; if (value === undefined || value === null) { - if (!sparse) bag[def.key] = def.default; + // A key with its own `initial` stays missing: written out, the old reading would count as + // a deviation from what a new asset starts with, and mark every older asset gold. + if (!sparse && initialOf(def) === def.default) bag[def.key] = def.default; continue; } bag[def.key] = coerceValue(def, value as PropertyValue); diff --git a/tests/core/serialize.test.ts b/tests/core/serialize.test.ts index 1c0f1e1d..fd08acb3 100644 --- a/tests/core/serialize.test.ts +++ b/tests/core/serialize.test.ts @@ -177,7 +177,6 @@ describe('serialize', () => { rotation: 0, mirrorX: false, mirrorY: false, - sortWithParent: false, width: 10, height: 100, color: 0xffffff, diff --git a/tests/viewport/sort-with-parent.test.ts b/tests/viewport/sort-with-parent.test.ts index ca613f09..aa079ab0 100644 --- a/tests/viewport/sort-with-parent.test.ts +++ b/tests/viewport/sort-with-parent.test.ts @@ -65,6 +65,9 @@ describe('a child sorted with its parent (#232)', () => { delete weapon.props[SORT_WITH_PARENT_KEY]; const loaded = findAsset(roundTrip(s.f.project), s.weaponId)!; expect(resolveAssetProps(s.f.project, loaded)[SORT_WITH_PARENT_KEY]).toBe(false); + // Loading must not write the old reading out, or every older asset would be marked. + expect(loaded.props[SORT_WITH_PARENT_KEY]).toBeUndefined(); + expect(isModified(s.f.project, loaded, SORT_WITH_PARENT_KEY)).toBe(false); }); it('marks an asset only once it is switched off, and Reset switches it on again', () => {