mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
🐛 Fix bug with null in ObservableObject
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user