fix: 修复 visibleOn 新公式用法结果为 undefined 时的依然可见的问题 (#5408)

This commit is contained in:
liaoxuezhi 2022-09-21 16:45:46 +08:00 committed by GitHub
parent 7bd10e3f8b
commit 443ec336ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -68,7 +68,7 @@ export function evalExpression(expression: string, data?: object): boolean {
expression[expression.length - 1] === '}'
) {
// 启用新版本的公式表达式
return evalFormula(expression, data);
return !!evalFormula(expression, data);
}
// 后续改用 FormulaExec['js']

View File

@ -62,6 +62,9 @@ test('formula:expression3', () => {
// expect(evalFormual('${a} === "b"', {a: 'b'})).toBe(true);
expect(evalFormual('b === "b"')).toBe(false);
// expect(evalFormual('${a}', {a: 'b'})).toBe('b');
expect(evalFormual('obj.x.a', {obj: {x: {a: 1}}})).toBe(1);
expect(evalFormual('obj.y.a', {obj: {x: {a: 1}}})).toBe(undefined);
});
test('formula:if', () => {