Skip to content

Commit

Permalink
Fix array serializeDiff and resetDiff for null or undefined values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Madeorsk committed Oct 15, 2022
1 parent fb118bd commit dfecfd1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Model/Types/ArrayType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser

serializeDiff(value: SharkitekValueType[]): any
{
if (value === undefined) return undefined;
if (value === null) return null;

// Serializing diff of all elements.
return value.map((value) => this.valueType.serializeDiff(value));
}

resetDiff(value: SharkitekValueType[]): void
{
// Do nothing if it is not an array.
if (!Array.isArray(value)) return;

// Reset diff of all elements.
value.forEach((value) => this.valueType.resetDiff(value));
}
Expand Down

0 comments on commit dfecfd1

Please sign in to comment.