🐛 Correction du court-circuit de toutes ces conditions

pull/117/head
mama 2017-10-24 18:30:44 +02:00
parent c31ad502b7
commit 1db38a6910
1 changed files with 17 additions and 1 deletions

View File

@ -222,8 +222,24 @@ export let mecanismAllOf = (recurse, k, v) => {
/>
)
let evaluate = (situationGate, parsedRules, node) => {
let evaluateOne = child => evaluateNode(situationGate, parsedRules, child),
explanation = R.map(evaluateOne, node.explanation),
values = R.pluck('nodeValue', explanation),
nodeValue = R.any(R.equals(false), values)
? false // court-circuit
: R.any(R.equals(null), values) ? null : true
let collectMissing = node =>
node.nodeValue == null
? R.chain(collectNodeMissing, node.explanation)
: []
return rewriteNode(node, nodeValue, explanation, collectMissing)
}
return {
evaluate: evaluateArray(R.and, true),
evaluate: evaluate,
jsx,
explanation,
category: 'mecanism',