diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-11 17:33:58 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-11 17:33:58 -0400 |
commit | edad98e0408571e4c6cabceaa5234510cefaaea5 (patch) | |
tree | 39811827bca3a2ba1b93640a6c9dac635f68d991 | |
parent | 7a30ec426d9cb4049c663441a510bd1525deed40 (diff) |
reverse: bindTo 'wikiData'
-rw-r--r-- | src/find-reverse.js | 16 | ||||
-rw-r--r-- | src/reverse.js | 4 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/find-reverse.js b/src/find-reverse.js index 1e897a5c..f31d3c45 100644 --- a/src/find-reverse.js +++ b/src/find-reverse.js @@ -108,20 +108,24 @@ export function bind(wikiData, opts1, { if (!spec.bindTo) continue; const behavior = prepareBehavior(spec); - const thingData = wikiData[spec.bindTo]; + + const data = + (spec.bindTo === 'wikiData' + ? wikiData + : wikiData[spec.bindTo]); bound[key] = (opts1 ? (ref, opts2) => (opts2 - ? behavior(ref, thingData, {...opts1, ...opts2}) - : behavior(ref, thingData, opts1)) + ? behavior(ref, data, {...opts1, ...opts2}) + : behavior(ref, data, opts1)) : (ref, opts2) => (opts2 - ? behavior(ref, thingData, opts2) - : behavior(ref, thingData))); + ? behavior(ref, data, opts2) + : behavior(ref, data))); - bound[key][boundData] = thingData; + bound[key][boundData] = data; bound[key][boundOptions] = opts1 ?? {}; } diff --git a/src/reverse.js b/src/reverse.js index 9cab5ef8..59790219 100644 --- a/src/reverse.js +++ b/src/reverse.js @@ -22,7 +22,9 @@ function reverseHelper(spec) { // one reverse spec is different from another. const referencingThings = - data.flatMap(thing => spec.referencing(thing)); + (spec.bindTo === 'wikiData' + ? spec.referencing(data) + : data.flatMap(thing => spec.referencing(thing))); const referencedThings = referencingThings.map(thing => spec.referenced(thing)); |