mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
🐛 Fix bug with null in ObservableObject
This commit is contained in:
parent
1d2c286b88
commit
50e16de270
|
@ -13,7 +13,7 @@ export function create(target: IDataObject, parent?: IObservableObject, option?:
|
|||
|
||||
// Make all the children of target also observeable
|
||||
for (const key in target) {
|
||||
if (typeof target[key] === 'object') {
|
||||
if (typeof target[key] === 'object' && target[key] !== null) {
|
||||
target[key] = create(target[key] as IDataObject, (parent || target) as IObservableObject, option, depth + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,15 @@ describe('ObservableObject', () => {
|
|||
expect(testObject).toEqual({ a: {} });
|
||||
});
|
||||
|
||||
test('should recognize that item on second child level changed with null (init data exists)', () => {
|
||||
const testObject = ObservableObject.create({ a: { b: { c: null } } });
|
||||
expect(testObject.__dataChanged).toBeFalsy();
|
||||
expect((testObject.a! as IDataObject).b).toEqual({ c: null });
|
||||
expect(((testObject.a! as IDataObject).b! as IDataObject).c).toEqual(null);
|
||||
((testObject.a! as IDataObject).b! as IDataObject).c = 2;
|
||||
expect(testObject.__dataChanged).toBeTruthy();
|
||||
expect((testObject.a! as IDataObject).b).toEqual({ c: 2 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue