mirror of https://github.com/zulip/zulip.git
js: Convert self-referential vars to const.
ESLint won’t convert these automatically because it can’t rule out a behavior difference arising from an access to a self-referential var before it’s initialized: > var x = (f => f())(() => x); undefined > let y = (f => f())(() => y); Thrown: ReferenceError: Cannot access 'y' before initialization at repl:1:26 at repl:1:15 Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
7ae84d5ce1
commit
02004c9b0f
|
@ -140,7 +140,7 @@ exports.make_new_elem = function (selector, opts) {
|
|||
var classes = new Dict();
|
||||
var event_store = exports.make_event_store(selector);
|
||||
|
||||
var self = {
|
||||
const self = {
|
||||
addClass: function (class_name) {
|
||||
classes.set(class_name, true);
|
||||
return self;
|
||||
|
|
|
@ -26,7 +26,7 @@ var meta = {
|
|||
opened: false,
|
||||
};
|
||||
|
||||
var animate = {
|
||||
const animate = {
|
||||
maybe_close: function () {
|
||||
if (!meta.opened) {
|
||||
return;
|
||||
|
|
|
@ -44,7 +44,7 @@ exports.create = function (opts) {
|
|||
// a dictionary of internal functions. Some of these are exposed as well,
|
||||
// and nothing in here should be assumed to be private (due to the passing)
|
||||
// of the `this` arg in the `Function.prototype.bind` use in the prototype.
|
||||
var funcs = {
|
||||
const funcs = {
|
||||
// return the value of the contenteditable input form.
|
||||
value: function (input_elem) {
|
||||
return input_elem.innerText.trim();
|
||||
|
|
|
@ -29,7 +29,7 @@ window.onload = function () {
|
|||
});
|
||||
};
|
||||
|
||||
var funcs = {
|
||||
const funcs = {
|
||||
setZoom: function (meta, zoom) {
|
||||
// condition to handle zooming event by zoom hotkeys
|
||||
if (zoom === '+') {
|
||||
|
|
|
@ -56,7 +56,7 @@ exports.create = function ($container, list, opts) {
|
|||
opts.filter = {};
|
||||
}
|
||||
|
||||
var prototype = {
|
||||
const prototype = {
|
||||
// Reads the provided list (in the scope directly above)
|
||||
// and renders the next block of messages automatically
|
||||
// into the specified contianer.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var ls = {
|
||||
const ls = {
|
||||
// parse JSON without throwing an error.
|
||||
parseJSON: function (str) {
|
||||
try {
|
||||
|
|
|
@ -375,7 +375,7 @@ function edit_message(row, raw_content) {
|
|||
// Do this right away, rather than waiting for the timer to do its first update,
|
||||
// since otherwise there is a noticeable lag
|
||||
message_edit_countdown_timer.text(timer_text(seconds_left));
|
||||
var countdown_timer = setInterval(function () {
|
||||
const countdown_timer = setInterval(function () {
|
||||
seconds_left -= 1;
|
||||
if (seconds_left <= 0) {
|
||||
clearInterval(countdown_timer);
|
||||
|
|
Loading…
Reference in New Issue