From 2dce650b7275c5eabb078dbda7379979f79fcc06 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 7 Jun 2019 17:18:27 +0200 Subject: [PATCH] FIX: prevents screen-track from leaking object (#7734) --- app/assets/javascripts/discourse/lib/screen-track.js.es6 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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();