mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-04-06 21:40:23 +08:00
fix(validator): fix the bug that property reference is wrong in complex expression
This commit is contained in:
parent
30d335040e
commit
8f53cd83c1
@ -35,6 +35,14 @@ describe('Field test', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('stop member expression when meeting other expression ast node', () => {
|
||||
const field = new FieldModel('{{ Array.from([]).fill() }}');
|
||||
expect(field.isDynamic).toEqual(true);
|
||||
expect(field.refComponentInfos['Array' as ComponentId].refProperties).toEqual([
|
||||
'from',
|
||||
]);
|
||||
});
|
||||
|
||||
it('parse inline variable in expression', () => {
|
||||
const field = new FieldModel('{{ [].length }}');
|
||||
expect(field.isDynamic).toEqual(true);
|
||||
|
@ -196,11 +196,18 @@ export class FieldModel implements IFieldModel {
|
||||
|
||||
break;
|
||||
case 'MemberExpression':
|
||||
this.refComponentInfos[lastIdentifier]?.refProperties.push(
|
||||
this.genPathFromMemberExpressionNode(expressionNode as ExpressionNode)
|
||||
);
|
||||
if (lastIdentifier) {
|
||||
this.refComponentInfos[lastIdentifier]?.refProperties.push(
|
||||
this.genPathFromMemberExpressionNode(expressionNode as ExpressionNode)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'Literal':
|
||||
// do nothing, just stop it from going to default
|
||||
break;
|
||||
default:
|
||||
// clear lastIdentifier when meet other astNode to break the MemberExpression chain
|
||||
lastIdentifier = '' as ComponentId;
|
||||
}
|
||||
},
|
||||
VariableDeclarator: declarator => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user