fix: 兼容原来 PropStash 的 export 数据结构, 去除 undefined 等值

This commit is contained in:
lihao.ylh 2021-09-29 21:43:34 +08:00
parent 621e66dca2
commit ef5dd50bc8
2 changed files with 12 additions and 8 deletions

View File

@ -152,10 +152,15 @@ export class Prop implements IPropParent {
if (!this._items) {
return this._value;
}
const maps: any = {};
let maps: any;
this.items!.forEach((prop, key) => {
const v = prop.export(stage);
maps[prop.key == null ? key : prop.key] = v;
if (!prop.isUnset()) {
const v = prop.export(stage);
if (v != null) {
maps = maps || {};
maps[prop.key || key] = prop.export(stage);
}
}
});
return maps;
}

View File

@ -129,12 +129,11 @@ export class Props implements IPropParent {
} else {
this.items.forEach(item => {
let name = item.key as string;
if (name == null) {
// todo ...spread
return;
}
if (name == null || item.isUnset() || item.isVirtual()) return;
let value = item.export(stage);
allProps[name] = value;
if (value != null) {
allProps[name] = value;
}
});
// compatible vision
const transformedProps = this.transformToStatic(allProps);