[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
This commit is contained in:
@@ -53,22 +53,15 @@ define(
|
|||||||
* @param element the jqLite-wrapped representation element
|
* @param element the jqLite-wrapped representation element
|
||||||
*/
|
*/
|
||||||
function ConductorRepresenter(conductorService, $compile, views, scope, element) {
|
function ConductorRepresenter(conductorService, $compile, views, scope, element) {
|
||||||
var conductorScope;
|
this.scope = scope;
|
||||||
|
|
||||||
// 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.conductorService = conductorService;
|
this.conductorService = conductorService;
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.$compile = $compile;
|
this.$compile = $compile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Update the time conductor from the scope
|
// Update the time conductor from the scope
|
||||||
function wireScope(conductor, conductorScope, repScope) {
|
function wireScope(conductor, conductorScope, repScope) {
|
||||||
function updateConductorOuter() {
|
function updateConductorOuter() {
|
||||||
@@ -102,6 +95,11 @@ define(
|
|||||||
repScope.$on('telemetry:view', updateConductorInner);
|
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
|
// Handle a specific representation of a specific domain object
|
||||||
ConductorRepresenter.prototype.represent = function represent(representation, representedObject) {
|
ConductorRepresenter.prototype.represent = function represent(representation, representedObject) {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
@@ -112,11 +110,11 @@ define(
|
|||||||
this.hadAbs = this.element.hasClass('abs');
|
this.hadAbs = this.element.hasClass('abs');
|
||||||
|
|
||||||
// Create a new scope for the conductor
|
// Create a new scope for the conductor
|
||||||
this.conductorScope(this.getScope().$new());
|
this.conductorScope(this.scope.$new());
|
||||||
wireScope(
|
wireScope(
|
||||||
this.conductorService.getConductor(),
|
this.conductorService.getConductor(),
|
||||||
this.conductorScope(),
|
this.conductorScope(),
|
||||||
this.getScope()
|
this.scope
|
||||||
);
|
);
|
||||||
this.conductorElement =
|
this.conductorElement =
|
||||||
this.$compile(TEMPLATE)(this.conductorScope());
|
this.$compile(TEMPLATE)(this.conductorScope());
|
||||||
|
|||||||
Reference in New Issue
Block a user