From 5a479ec157a2b0e346c2f64e60e34af136e4a67b Mon Sep 17 00:00:00 2001 From: Luciano Vernaschi Date: Fri, 3 Jan 2025 13:09:07 +0100 Subject: [PATCH] Make sure default value is read correctly --- packages/ts/lit-form/src/BinderNode.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ts/lit-form/src/BinderNode.ts b/packages/ts/lit-form/src/BinderNode.ts index cc3776ebb1..5a20213d0b 100644 --- a/packages/ts/lit-form/src/BinderNode.ts +++ b/packages/ts/lit-form/src/BinderNode.ts @@ -160,7 +160,7 @@ export class BinderNode extends EventTa */ get defaultValue(): Value | undefined { const key = this.model[_key]; - const parentDefaultValue = this.parent!.defaultValue as { readonly [key in typeof key]?: Value }; + const parentDefaultValue = (this.parent!.defaultValue ?? {}) as { readonly [key in typeof key]?: Value }; if (this.#isArrayItem() && !(key in parentDefaultValue)) { if (defaultArrayItemCache.has(this.parent)) { @@ -499,7 +499,7 @@ export class BinderNode extends EventTa ? (this.parent.value as { [key in typeof key]: Value })[this.model[_key]] : undefined; - const defaultValue: Value | undefined = this.parent + const defaultValue: Value | undefined = this.parent?.defaultValue ? (this.parent.defaultValue as { readonly [key in typeof key]: Value })[this.model[_key]] : undefined;