diff --git a/platform/representation/src/MCTRepresentation.js b/platform/representation/src/MCTRepresentation.js index d1937389d2..b68a6ad81e 100644 --- a/platform/representation/src/MCTRepresentation.js +++ b/platform/representation/src/MCTRepresentation.js @@ -96,7 +96,7 @@ define( toClear = [], // Properties to clear out of scope on change counter = 0, couldRepresent = false, - lastId, + lastIdPath = [], lastKey, changeTemplate = templateLinker.link($scope, element); @@ -143,11 +143,24 @@ define( }); } - function unchanged(canRepresent, id, key) { + function unchanged(canRepresent, idPath, key) { return canRepresent && couldRepresent && - id === lastId && - key === lastKey; + key === lastKey && + idPath.length === lastIdPath.length && + idPath.every(function (id, i) { + return id === lastIdPath[i]; + }); + } + + function getIdPath(domainObject) { + if (!domainObject) { + return []; + } + return domainObject.getCapability('context') + .getPath().map(function (pathObject) { + return pathObject.getId(); + }); } // General-purpose refresh mechanism; should set up the scope @@ -159,10 +172,10 @@ define( path = representation && getPath(representation), uses = ((representation || {}).uses || []), canRepresent = !!(path && domainObject), - id = domainObject && domainObject.getId(), + idPath = getIdPath(domainObject), key = $scope.key; - if (unchanged(canRepresent, id, key)) { + if (unchanged(canRepresent, idPath, key)) { return; } @@ -190,7 +203,7 @@ define( // To allow simplified change detection next time around couldRepresent = canRepresent; - lastId = id; + lastIdPath = idPath; lastKey = key; // Populate scope with fields associated with the current