mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
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:
committed by
Tim Abbott
parent
7ae84d5ce1
commit
02004c9b0f
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user