mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-23 17:49:49 +08:00
fix(validator): don't count keys of array destructuring assignment in property refs
This commit is contained in:
parent
a1c2730fc5
commit
81028bbf42
@ -106,6 +106,12 @@ describe('Field test', () => {
|
||||
expect(field.refComponentInfos).toEqual({});
|
||||
});
|
||||
|
||||
it('should not count keys of array destructuring assignment in refs', () => {
|
||||
const field = new FieldModel('{{ ([bar]) => bar }}');
|
||||
expect(field.isDynamic).toEqual(true);
|
||||
expect(field.refComponentInfos).toEqual({});
|
||||
});
|
||||
|
||||
it('get value by path', () => {
|
||||
const field = new FieldModel({ foo: [{}, { bar: { baz: 'Hello, world!' } }] });
|
||||
expect(field.getPropertyByPath('foo.1.bar.baz')?.getValue()).toEqual('Hello, world!');
|
||||
|
@ -22,6 +22,7 @@ import { JSONSchema7 } from 'json-schema';
|
||||
export type FunctionNode = ASTNode & { params: ASTNode[] };
|
||||
export type DeclaratorNode = ASTNode & { id: ASTNode };
|
||||
export type ObjectPatternNode = ASTNode & { properties: PropertyNode[] };
|
||||
export type ArrayPatternNode = ASTNode & { elements: ASTNode[] };
|
||||
export type PropertyNode = ASTNode & { value: ASTNode };
|
||||
export type LiteralNode = ASTNode & { raw: string };
|
||||
export type SequenceExpressionNode = ASTNode & { expressions: LiteralNode[] };
|
||||
@ -224,6 +225,9 @@ export class FieldModel implements IFieldModel {
|
||||
whiteList.push(property.value);
|
||||
});
|
||||
},
|
||||
ArrayPattern: arrayPatternNode => {
|
||||
whiteList = [...whiteList, ...(arrayPatternNode as ArrayPatternNode).elements];
|
||||
},
|
||||
VariableDeclarator: declarator => {
|
||||
whiteList.push((declarator as DeclaratorNode).id);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user