From b90a4008f9be55baabcd0f6a07595bff7dbce858 Mon Sep 17 00:00:00 2001 From: James Kerr Date: Thu, 2 Nov 2023 12:15:14 -0700 Subject: [PATCH] Records can have null fields. (#2875) --- apps/zui/src/app/features/inspector/views/record-view.ts | 4 ++-- packages/zed-js/src/values/record.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/zui/src/app/features/inspector/views/record-view.ts b/apps/zui/src/app/features/inspector/views/record-view.ts index be68e2f88e..87137c9492 100644 --- a/apps/zui/src/app/features/inspector/views/record-view.ts +++ b/apps/zui/src/app/features/inspector/views/record-view.ts @@ -8,7 +8,7 @@ export class RecordView extends ContainerView { } count() { - return this.value.fields.length + return this.value.fields?.length || 0 } openToken() { @@ -20,7 +20,7 @@ export class RecordView extends ContainerView { } *iterate(n?: number) { - const fields = this.value.fields + const fields = this.value.fields || [] const length = n ? Math.min(n, fields.length) : fields.length for (let i = 0; i < fields.length; ++i) { diff --git a/packages/zed-js/src/values/record.ts b/packages/zed-js/src/values/record.ts index 8d56882417..adedbca6d4 100644 --- a/packages/zed-js/src/values/record.ts +++ b/packages/zed-js/src/values/record.ts @@ -134,7 +134,7 @@ export class Record implements Value { } isUnset() { - return this.fields === null; + return false; } toJS(opts: JSOptions = {}) {