diff --git a/platform/core/src/capabilities/ContextualDomainObject.js b/platform/core/src/capabilities/ContextualDomainObject.js index eeb5b9cf3d..3c25c7082a 100644 --- a/platform/core/src/capabilities/ContextualDomainObject.js +++ b/platform/core/src/capabilities/ContextualDomainObject.js @@ -9,14 +9,28 @@ define( "use strict"; /** + * Wraps a domain object, such that it exposes a `context` capability. + * A domain object may be contained by multiple other domain objects; + * the `context` capability allows two instances of the same domain + * object to be distinguished from one another based on which + * specific instance of a containing object exposed them (by way of a + * `composition` capability.) + * + * @param {DomainObject} domainObject the domain object for which + * context should be exposed + * @param {DomainObject} parentObject the domain object from which + * the wrapped object was retrieved * * @constructor */ function ContextualDomainObject(domainObject, parentObject) { + // Prototypally inherit from the domain object, and + // instantiate its context capability ahead of time. var contextualObject = Object.create(domainObject), contextCapability = new ContextCapability(parentObject, domainObject); + // Intercept requests for a context capability. contextualObject.getCapability = function (name) { return name === "context" ? contextCapability :