Skip to content

Commit 6d58fbd

Browse files
authored
Merge pull request #20 from formio/FIO-10822-fixed-evaluations-for-logic-with-var-not-in-function-start
FIO-10822: fixed an issue where evaluations donot work if returned variable is in middle of the custom logic or is not 'value'
2 parents f12ce5d + ff59499 commit 6d58fbd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ProtectedEvaluator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ export class Evaluator extends DefaultEvaluator {
3131
return baseEvaluate(func, args, ...rest);
3232
}
3333

34+
3435
if (func.indexOf(' return ') === -1) {
35-
func = `result = (function() { value = ${func}; return value; })()`;
36+
const returnedVariable = rest[0] || 'value';
37+
func = `result = (function() { var ${returnedVariable}; ${func}; return ${returnedVariable}; })()`;
3638
}
3739
else {
3840
func = `result = (function() { ${func} })()`;

0 commit comments

Comments
 (0)