Skip to content

Commit 5bb9ec7

Browse files
committed
fix: prop should return undefined when all items are undefined
1 parent c54f369 commit 5bb9ec7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/designer/src/document/node/props/prop.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class Prop implements IPropParent {
159159
const v = prop.export(stage);
160160
if (v != null) {
161161
maps = maps || {};
162-
maps[prop.key || key] = prop.export(stage);
162+
maps[prop.key || key] = v;
163163
}
164164
}
165165
});
@@ -170,9 +170,13 @@ export class Prop implements IPropParent {
170170
if (!this._items) {
171171
return this._value;
172172
}
173-
return this.items!.map((prop) => {
173+
const values = this.items!.map((prop) => {
174174
return prop.export(stage);
175175
});
176+
if (values.every(val => val === undefined)) {
177+
return undefined;
178+
}
179+
return values;
176180
}
177181
}
178182

packages/designer/tests/document/node/props/prop.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ describe('Prop 类测试', () => {
430430
// illegal
431431
// expect(prop.set(5, 1)).toBeNull();
432432
});
433+
434+
it('should return undefined when all items are undefined', () => {
435+
prop = new Prop(mockedPropsInst, [undefined, undefined], '___loopArgs___');
436+
expect(prop.getValue()).toBeUndefined();
437+
});
433438
});
434439
});
435440

0 commit comments

Comments
 (0)