diff options
author | bobzel <zzzman@gmail.com> | 2022-12-23 17:12:45 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-12-23 17:12:45 -0500 |
commit | 04c961b163e90a9da2bad07d1ac241ea57a61094 (patch) | |
tree | 7c5a420e14014debfbfa21051f7a8f52e6907f85 | |
parent | 35f3c5467d03ab82a1220f1a36c67933492db718 (diff) |
fixed list lastElement() to return real field value, not proxy. fixed getField to only query proto if value is undefined, not just falsy
-rw-r--r-- | src/fields/List.ts | 2 | ||||
-rw-r--r-- | src/fields/util.ts | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/fields/List.ts b/src/fields/List.ts index 809173ddf..9c7794813 100644 --- a/src/fields/List.ts +++ b/src/fields/List.ts @@ -128,7 +128,7 @@ const listHandlers: any = { return this[Self].__fields.map(toRealField).join(separator); }, lastElement() { - return this[Self].__fields.lastElement(); + return this[Self].__realFields().lastElement(); }, lastIndexOf(valueToFind: any, fromIndex: number) { if (valueToFind instanceof RefField) { diff --git a/src/fields/util.ts b/src/fields/util.ts index 285cbb4c6..dc0b41276 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -368,7 +368,7 @@ function getFieldImpl(target: any, prop: string | number, proxy: any, ignoreProt const field = target.__fields[prop]; const value = field?.[ToValue]?.(proxy); // converts ComputedFields to values, or unpacks ProxyFields into Proxys if (value) return value.value; - if (!field && !ignoreProto && prop !== 'proto') { + if (field === undefined && !ignoreProto && prop !== 'proto') { const proto = getFieldImpl(target, 'proto', proxy, true); //TODO tfs: instead of proxy we could use target[SelfProxy]... I don't which semantics we want or if it really matters if (proto instanceof Doc && GetEffectiveAcl(proto) !== AclPrivate) { return getFieldImpl(proto, prop, proxy, ignoreProto); |