Prevent self-composition in layouts (#2287)

This commit is contained in:
Andrew Henry
2019-02-13 11:42:43 -08:00
committed by Deep Tailor
parent a1aa99837b
commit 21e08709cb
3 changed files with 33 additions and 3 deletions

View File

@ -215,6 +215,19 @@ define([
return utils.makeKeyString(identifier);
};
/**
* Given any number of identifiers, will return true if they are all equal, otherwise false.
* @param {module:openmct.ObjectAPI~Identifier[]} identifiers
*/
ObjectAPI.prototype.areIdsEqual = function (...identifiers) {
return identifiers.map(utils.parseKeyString)
.every(identifier => {
return identifier === identifiers[0] ||
(identifier.namespace === identifiers[0].namespace &&
identifier.key === identifiers[0].key);
});
}
/**
* Uniquely identifies a domain object.
*