diff --git a/src/types/custom/MapSchema.ts b/src/types/custom/MapSchema.ts index 4f85b8d..661618e 100644 --- a/src/types/custom/MapSchema.ts +++ b/src/types/custom/MapSchema.ts @@ -26,10 +26,12 @@ export class MapSchema implements Map, C * - Then, the encoder iterates over all "owned" properties per instance and encodes them. */ static [$filter] (ref: MapSchema, index: number, view: StateView) { + const exists = ref[$getByIndex](index) !== undefined; + const existsAndChanges = exists && view.items.has(ref[$getByIndex](index)[$changes]) return ( !view || typeof (ref[$childType]) === "string" || - view.items.has(ref[$getByIndex](index)[$changes]) + existsAndChanges ); } @@ -253,4 +255,4 @@ export class MapSchema implements Map, C } -registerType("map", { constructor: MapSchema }); \ No newline at end of file +registerType("map", { constructor: MapSchema });