DEV: teardown event listeners in click-interceptor

DEV: teardown event listeners in click-interceptor

diff --git a/app/assets/javascripts/discourse/app/initializers/click-interceptor.js b/app/assets/javascripts/discourse/app/initializers/click-interceptor.js
index 9f8adfd..35eaa87 100644
--- a/app/assets/javascripts/discourse/app/initializers/click-interceptor.js
+++ b/app/assets/javascripts/discourse/app/initializers/click-interceptor.js
@@ -5,8 +5,15 @@ export default {
   name: "click-interceptor",
   initialize() {
     $("#main").on("click.discourse", "a", interceptClick);
-    $(window).on("hashchange", () =>
-      DiscourseURL.routeTo(document.location.hash)
-    );
+    window.addEventListener("hashchange", this.hashChanged);
+  },
+
+  hashChanged() {
+    DiscourseURL.routeTo(document.location.hash);
+  },
+
+  teardown() {
+    $("#main").off("click.discourse", "a", interceptClick);
+    window.removeEventListener("hashchange", this.hashChanged);
   },
 };

GitHub sha: 8af0674b68c0369681e770440f0d5d3e8207c230

This commit appears in #14745 which was approved by CvX and jjaffeux. It was merged by davidtaylorhq.