Fix array serializeDiff and resetDiff for null or undefined values.
This commit is contained in:
parent
fb118bd584
commit
dfecfd141c
1 changed files with 6 additions and 0 deletions
|
@ -38,12 +38,18 @@ export class ArrayType<SerializedValueType, SharkitekValueType> extends Type<Ser
|
||||||
|
|
||||||
serializeDiff(value: SharkitekValueType[]): any
|
serializeDiff(value: SharkitekValueType[]): any
|
||||||
{
|
{
|
||||||
|
if (value === undefined) return undefined;
|
||||||
|
if (value === null) return null;
|
||||||
|
|
||||||
// Serializing diff of all elements.
|
// Serializing diff of all elements.
|
||||||
return value.map((value) => this.valueType.serializeDiff(value));
|
return value.map((value) => this.valueType.serializeDiff(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
resetDiff(value: SharkitekValueType[]): void
|
resetDiff(value: SharkitekValueType[]): void
|
||||||
{
|
{
|
||||||
|
// Do nothing if it is not an array.
|
||||||
|
if (!Array.isArray(value)) return;
|
||||||
|
|
||||||
// Reset diff of all elements.
|
// Reset diff of all elements.
|
||||||
value.forEach((value) => this.valueType.resetDiff(value));
|
value.forEach((value) => this.valueType.resetDiff(value));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue