mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-13 12:13:10 +00:00
fix: prop should return undefined when all items are undefined
This commit is contained in:
parent
c54f369e18
commit
5bb9ec7a1d
@ -159,7 +159,7 @@ export class Prop implements IPropParent {
|
||||
const v = prop.export(stage);
|
||||
if (v != null) {
|
||||
maps = maps || {};
|
||||
maps[prop.key || key] = prop.export(stage);
|
||||
maps[prop.key || key] = v;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -170,9 +170,13 @@ export class Prop implements IPropParent {
|
||||
if (!this._items) {
|
||||
return this._value;
|
||||
}
|
||||
return this.items!.map((prop) => {
|
||||
const values = this.items!.map((prop) => {
|
||||
return prop.export(stage);
|
||||
});
|
||||
if (values.every(val => val === undefined)) {
|
||||
return undefined;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -430,6 +430,11 @@ describe('Prop 类测试', () => {
|
||||
// illegal
|
||||
// expect(prop.set(5, 1)).toBeNull();
|
||||
});
|
||||
|
||||
it('should return undefined when all items are undefined', () => {
|
||||
prop = new Prop(mockedPropsInst, [undefined, undefined], '___loopArgs___');
|
||||
expect(prop.getValue()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user