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;