diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-23 19:01:05 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-05 21:02:50 -0300 |
commit | 8dd100d04fdd13b4ab8348d61378de5fd74f72d4 (patch) | |
tree | 99837807501ab4b9be2264480855ba88ba6a211b | |
parent | 0f4e27426384536c179583a8ffaf3dd9f121766b (diff) |
data: Thing.composite.withResolvedReference: fix null refs
The `earlyExitIfNotFound` flag is only supposed to exit if the reference really existed and failed to match anything. If it was null in the first place, withResolvedReferences should always just pass null ahead.
-rw-r--r-- | src/data/things/thing.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js index c1f969b2..798a057a 100644 --- a/src/data/things/thing.js +++ b/src/data/things/thing.js @@ -866,8 +866,9 @@ export default class Thing extends CacheableObject { // within the provided thingData dependency. This will early exit if the // data dependency is null, or, if earlyExitIfNotFound is set to true, // if the find function doesn't match anything for the reference. - // Otherwise, the data object (or null, if not found) is provided on - // the output dependency. + // Otherwise, the data object is provided on the output dependency; + // or null, if the reference doesn't match anything or itself was null + // to begin with. withResolvedReference({ ref: refDependency, data: dataDependency, @@ -883,6 +884,8 @@ export default class Thing extends CacheableObject { dependencies: [refDependency, dataDependency], compute({[refDependency]: ref, [dataDependency]: data}, continuation) { + if (!ref) return continuation({[outputDependency]: null}); + if (data === null) return null; const match = findFunction(ref, data, {mode: 'quiet'}); |