Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(binder): make sure default value is read correctly #3116

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ts/lit-form/src/BinderNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class BinderNode<M extends AbstractModel = AbstractModel> extends EventTa
*/
get defaultValue(): Value<M> | undefined {
const key = this.model[_key];
const parentDefaultValue = this.parent!.defaultValue as { readonly [key in typeof key]?: Value<M> };
const parentDefaultValue = (this.parent!.defaultValue ?? {}) as { readonly [key in typeof key]?: Value<M> };

if (this.#isArrayItem() && !(key in parentDefaultValue)) {
if (defaultArrayItemCache.has(this.parent)) {
Expand Down Expand Up @@ -499,7 +499,7 @@ export class BinderNode<M extends AbstractModel = AbstractModel> extends EventTa
? (this.parent.value as { [key in typeof key]: Value<M> })[this.model[_key]]
: undefined;

const defaultValue: Value<M> | undefined = this.parent
const defaultValue: Value<M> | undefined = this.parent?.defaultValue
? (this.parent.defaultValue as { readonly [key in typeof key]: Value<M> })[this.model[_key]]
: undefined;

Expand Down
Loading