From 0d07c3c289e3a984b28059a483402d0e8ff73d11 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 19 Nov 2015 13:44:06 -0800 Subject: [PATCH] [Status] Clean up classes when destroyed --- platform/status/src/StatusRepresenter.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/platform/status/src/StatusRepresenter.js b/platform/status/src/StatusRepresenter.js index 4bee9d6651..0bab5fd571 100644 --- a/platform/status/src/StatusRepresenter.js +++ b/platform/status/src/StatusRepresenter.js @@ -48,6 +48,17 @@ define( this.lastClasses = []; } + /** + * Remove any status-related classes from this representation. + * @private + */ + StatusRepresenter.prototype.clearClasses = function () { + var element = this.element; + this.lastClasses.forEach(function (c) { + element.removeClass(c); + }); + }; + StatusRepresenter.prototype.represent = function (representation, domainObject) { var self = this, statusCapability = domainObject.getCapability('status'); @@ -57,9 +68,7 @@ define( return STATUS_CLASS_PREFIX + flag; }); - self.lastClasses.forEach(function (c) { - self.element.removeClass(c); - }); + self.clearClasses(); newClasses.forEach(function (c) { self.element.addClass(c); @@ -73,6 +82,7 @@ define( }; StatusRepresenter.prototype.destroy = function () { + this.clearClasses(); if (this.unlisten) { this.unlisten(); this.unlisten = undefined;