From eed772169f9c23954365a4c872b2c0b69745949e Mon Sep 17 00:00:00 2001 From: Luke Wood Date: Sun, 4 Aug 2024 19:30:09 -0400 Subject: [PATCH] Map schema update --- src/types/custom/MapSchema.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 });