mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Fix property existence checks on AugmentObject (#6842)
Fixes https://community.n8n.io/t/code-node-returns-full-item-object-on-node-all/28823
This commit is contained in:
parent
e4f041815a
commit
732416f52f
|
@ -33,7 +33,7 @@ export function augmentArray<T>(data: T[]): T[] {
|
|||
return Reflect.deleteProperty(getData(), key);
|
||||
},
|
||||
get(target, key: string, receiver): unknown {
|
||||
const value = Reflect.get(newData !== undefined ? newData : target, key, receiver) as unknown;
|
||||
const value = Reflect.get(newData ?? target, key, receiver) as unknown;
|
||||
const newValue = augment(value);
|
||||
if (newValue !== value) {
|
||||
newData = getData();
|
||||
|
@ -54,10 +54,10 @@ export function augmentArray<T>(data: T[]): T[] {
|
|||
return Object.getOwnPropertyDescriptor(data, key) ?? defaultPropertyDescriptor;
|
||||
},
|
||||
has(target, key) {
|
||||
return Reflect.has(newData !== undefined ? newData : target, key);
|
||||
return Reflect.has(newData ?? target, key);
|
||||
},
|
||||
ownKeys(target) {
|
||||
return Reflect.ownKeys(newData !== undefined ? newData : target);
|
||||
return Reflect.ownKeys(newData ?? target);
|
||||
},
|
||||
set(target, key: string, newValue: unknown) {
|
||||
// Always proxy all objects. Like that we can check in get simply if it
|
||||
|
@ -134,8 +134,7 @@ export function augmentObject<T extends object>(data: T): T {
|
|||
},
|
||||
has(target, key) {
|
||||
if (deletedProperties.indexOf(key) !== -1) return false;
|
||||
const newKeys = Object.keys(newData);
|
||||
return Reflect.has(newKeys.length ? newData : target, key);
|
||||
return Reflect.has(newData, key) || Reflect.has(target, key);
|
||||
},
|
||||
ownKeys(target) {
|
||||
const originalKeys = Reflect.ownKeys(target);
|
||||
|
|
|
@ -570,6 +570,7 @@ describe('AugmentObject', () => {
|
|||
|
||||
augmentedObject.x.z = 5;
|
||||
expect('z' in augmentedObject.x).toBe(true);
|
||||
expect('y' in augmentedObject.x).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue