A platform for community discussion. Free, open, simple.
DEV: refactor JS files to not use `self = this` in code. (#15095)
Vinoth Kannan37b6fa7a1b8c
diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.jsindex 90a7ff07a14..67357e44699 100644--- a/app/assets/javascripts/discourse/app/components/topic-list.js+++ b/app/assets/javascripts/discourse/app/components/topic-list.js@@ -170,12 +170,11 @@ export default Component.extend(LoadMore, {},click(e) {- let self = this;- let onClick = function (sel, callback) {+ const onClick = (sel, callback) => {let target = $(e.target).closest(sel);if (target.length === 1) {- callback.apply(self, [target]);+ callback.apply(this, [target]);}};diff --git a/app/assets/javascripts/discourse/app/lib/debounce.js b/app/assets/javascripts/discourse/app/lib/debounce.jsindex 61592205631..15ad64a2d69 100644--- a/app/assets/javascripts/discourse/app/lib/debounce.js+++ b/app/assets/javascripts/discourse/app/lib/debounce.js@@ -5,13 +5,12 @@ import { debounce } from "@ember/runloop";Original function will be called with the context and arguments from the last call made.**/export default function (func, wait) {- let self, args;- const later = function () {- func.apply(self, args);+ let args;+ const later = () => {+ func.apply(this, args);};return function () {- self = this;args = arguments;debounce(null, later, wait);