mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
inline variable has no identifier and should not cause runtime error
This commit is contained in:
parent
b36dfddeb5
commit
da033ab695
@ -15,6 +15,12 @@ describe('Field test', () => {
|
||||
expect(field.rawValue).toEqual('{{input.value}} + {{list[0].text}}');
|
||||
});
|
||||
|
||||
it('parse inline variable in expression', () => {
|
||||
const field = new FieldModel('{{ [].length }}');
|
||||
expect(field.isDynamic).toEqual(true);
|
||||
expect(field.refs).toEqual({});
|
||||
});
|
||||
|
||||
it('parse object property', () => {
|
||||
const field = new FieldModel({ raw: '{{input.value}}', format: 'md' });
|
||||
expect(field.isDynamic).toEqual(false);
|
||||
@ -47,11 +53,11 @@ describe('Field test', () => {
|
||||
const field = new FieldModel({ data: ['A', 'B'] });
|
||||
|
||||
expect(field.rawValue).toEqual({ data: ['A', 'B'] });
|
||||
field.update({data: ['B']});
|
||||
field.update({ data: ['B'] });
|
||||
expect(field.rawValue).toEqual({ data: ['B'] });
|
||||
field.update({data: ['C']});
|
||||
field.update({ data: ['C'] });
|
||||
expect(field.rawValue).toEqual({ data: ['C'] });
|
||||
})
|
||||
});
|
||||
|
||||
it('update object property', () => {
|
||||
const field = new FieldModel({ data: { a: 1, b: 2 }, value: '' });
|
||||
@ -63,5 +69,5 @@ describe('Field test', () => {
|
||||
expect(field.rawValue).toEqual({ data: { a: 2 }, value: '' });
|
||||
field.update({ value: 'text' });
|
||||
expect(field.rawValue).toEqual({ data: { a: 2 }, value: 'text' });
|
||||
})
|
||||
});
|
||||
});
|
||||
|
@ -125,7 +125,7 @@ export class FieldModel implements IFieldModel {
|
||||
if (path.startsWith('.')) {
|
||||
path = path.slice(1, path.length);
|
||||
}
|
||||
this.refs[lastIdentifier].push(path);
|
||||
this.refs[lastIdentifier]?.push(path);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user