From 2ec9956d44a43ba6dcbe2d235852d08117d9c048 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 10 Sep 2015 10:16:28 -0700 Subject: [PATCH] [Time Conductor] Incorporate feedback from code review Retain reference to scope in ConductorRepresenter directly via this, instead of revealing via a closure-bound function. This approach is not necessary to avoid https://docs.angularjs.org/error/ng/cpws in this circumstance. WTD-1515 --- .../conductor/src/ConductorRepresenter.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 0617c771b1..f858810db1 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -53,22 +53,15 @@ define( * @param element the jqLite-wrapped representation element */ function ConductorRepresenter(conductorService, $compile, views, scope, element) { - var conductorScope; - - // Angular doesn't like objects to retain references to scopes - this.getScope = function () { - return scope; - }; - this.conductorScope = function (s) { - return (conductorScope = arguments.length > 0 ? s : conductorScope); - }; - + this.scope = scope; this.conductorService = conductorService; this.element = element; this.views = views; this.$compile = $compile; } + + // Update the time conductor from the scope function wireScope(conductor, conductorScope, repScope) { function updateConductorOuter() { @@ -102,6 +95,11 @@ define( repScope.$on('telemetry:view', updateConductorInner); } + ConductorRepresenter.prototype.conductorScope = function (s) { + return (this.cScope = arguments.length > 0 ? + s : this.cScope); + }; + // Handle a specific representation of a specific domain object ConductorRepresenter.prototype.represent = function represent(representation, representedObject) { this.destroy(); @@ -112,11 +110,11 @@ define( this.hadAbs = this.element.hasClass('abs'); // Create a new scope for the conductor - this.conductorScope(this.getScope().$new()); + this.conductorScope(this.scope.$new()); wireScope( this.conductorService.getConductor(), this.conductorScope(), - this.getScope() + this.scope ); this.conductorElement = this.$compile(TEMPLATE)(this.conductorScope());