对undefined属性的处理
This commit is contained in:
parent
a55005abe4
commit
b9d58b84c2
|
|
@ -784,13 +784,22 @@ class ListNode extends Node {
|
|||
*/
|
||||
updateItem(lsn, data, id, action) {
|
||||
// 如果数据键值是一个空字符串则更新成null
|
||||
const undefinedAttrs = [];
|
||||
// 如果数据键值是一个空字符串则更新成null,undefined则unset掉
|
||||
for (const k in data) {
|
||||
if (data[k] === '') {
|
||||
Object.assign(data, {
|
||||
[k]: null,
|
||||
});
|
||||
}
|
||||
else if (data[k] === undefined) {
|
||||
undefinedAttrs.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
undefinedAttrs.forEach(
|
||||
(attr) => unset(data, attr)
|
||||
);
|
||||
this.ulManager.push(lsn, {
|
||||
action: action || 'update',
|
||||
data,
|
||||
|
|
@ -1210,6 +1219,7 @@ class SingleNode extends Node {
|
|||
update(lsn, data, action) {
|
||||
// 如果数据键值是一个空字符串则更新成null,如果是undefined则取消此键值
|
||||
const undefinedAttrs = [];
|
||||
// 如果数据键值是一个空字符串则更新成null,undefined则unset掉
|
||||
for (const k in data) {
|
||||
if (data[k] === '') {
|
||||
Object.assign(data, {
|
||||
|
|
@ -1220,6 +1230,10 @@ class SingleNode extends Node {
|
|||
undefinedAttrs.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
undefinedAttrs.forEach(
|
||||
(attr) => unset(data, attr)
|
||||
);
|
||||
this.ulManager.push(lsn, {
|
||||
action: action || 'update',
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -969,14 +969,22 @@ class ListNode<
|
|||
id: string,
|
||||
action?: ED[T]['Action']
|
||||
) {
|
||||
// 如果数据键值是一个空字符串则更新成null
|
||||
const undefinedAttrs: string[] = [];
|
||||
// 如果数据键值是一个空字符串则更新成null,undefined则unset掉
|
||||
for (const k in data) {
|
||||
if (data[k] === '') {
|
||||
Object.assign(data, {
|
||||
[k]: null,
|
||||
});
|
||||
}
|
||||
else if (data[k] === undefined) {
|
||||
undefinedAttrs.push(k);
|
||||
}
|
||||
}
|
||||
|
||||
undefinedAttrs.forEach(
|
||||
(attr) => unset(data, attr)
|
||||
);
|
||||
this.ulManager.push(lsn, {
|
||||
action: action || 'update',
|
||||
data,
|
||||
|
|
@ -1494,6 +1502,10 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
undefinedAttrs.push(k);
|
||||
}
|
||||
}
|
||||
undefinedAttrs.forEach(
|
||||
(attr) => unset(data, attr)
|
||||
);
|
||||
|
||||
this.ulManager.push(lsn, {
|
||||
action: action || 'update',
|
||||
data,
|
||||
|
|
|
|||
Loading…
Reference in New Issue