Skip to content

Commit

Permalink
update scopedEval to return the result
Browse files Browse the repository at this point in the history
We want to use scopedEval to evaluate boolean expressions. It executes the code but doesn't return back the result unless we include 'return ...' in the body.
With this quick change it returns the result of the evaluation and works on our inline conditionals.
  • Loading branch information
JGreenlee committed Mar 1, 2024
1 parent 5c9b307 commit 82df443
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion www/js/survey/enketo/conditionalSurveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const conditionalSurveyFunctions = {
* @example scopedEval('console.log(foo)', { foo: 'bar' })
*/
const scopedEval = (script: string, scope: { [k: string]: any }) =>
Function(...Object.keys(scope), script)(...Object.values(scope));
Function(...Object.keys(scope), `return ${script}`)(...Object.values(scope));

// the first survey in the list that passes its condition will be returned
export function getSurveyForTimelineEntry(
Expand Down

0 comments on commit 82df443

Please sign in to comment.