Skip to content

A platform for community discussion. Free, open, simple.

FIX: prevents screen-track from leaking object (#7734)

Joffrey JAFFEUX2dce650b7275
diff --git a/app/assets/javascripts/discourse/lib/screen-track.js.es6 b/app/assets/javascripts/discourse/lib/screen-track.js.es6
index 363454e1e95..c7a451356d2 100644
--- a/app/assets/javascripts/discourse/lib/screen-track.js.es6
+++ b/app/assets/javascripts/discourse/lib/screen-track.js.es6
@@ -26,7 +26,8 @@ export default class {
// Create an interval timer if we don't have one.
if (!this._interval) {
this._interval = setInterval(() => this.tick(), 1000);
- $(window).on("scroll.screentrack", this.scrolled.bind(this));
+ this._boundScrolled = Ember.run.bind(this, this.scrolled);
+ $(window).on("scroll.screentrack", this._boundScrolled);
}
this._topicId = topicId;
@@ -39,7 +40,10 @@ export default class {
return;
}
- $(window).off("scroll.screentrack", this.scrolled);
+ if (this._boundScrolled) {
+ $(window).off("scroll.screentrack", this._boundScrolled);
+ }
+
this.tick();
this.flush();
this.reset();