Hi,
I ran into an issue that I tracked down to a bug(?) in gojs-angular.js library.
static mergeChanges(component, kvchanges, str) {
// helper function
/**
* @param {?} obj1
* @param {?} obj2
* @return {?}
*/
function compareObjs(obj1, obj2) {
// Loop through properties in object 1
for (const p in obj1) {
// Check property exists on both objects
if (obj1.hasOwnProperty(p) !== obj2.hasOwnProperty(p))
return false;
switch (typeof (obj1[p])) {
// Deep compare objects
case 'object':
if (!compareObjs(obj1[p], obj2[p]))
return false;
break;
// Compare values
default:
if (obj1[p] !== obj2[p])
return false;
}
}
// Check object 2 for any extra properties
for (const p in obj2) {
if (typeof (obj1[p]) === 'undefined')
return false;
}
return true;
}
....
}
In the above code the line
if (obj1.hasOwnProperty(p) !== obj2.hasOwnProperty(p))
fails if obj2 is null or undefined.
it should be a valid compare, no? Basically what it means is that a nested object was deleted or created (become null or not null)
Thanks,
Nuno