History

Sanity-check decaffeinate app.views.Sidebar

Simon Legner committed 2 years ago

Commit 978d4a91 parent 49dbba31 file · +12 −41Browse files

Unified · Split

assets/javascripts/views/sidebar/sidebar.js+12−41
@@ -1,30 +1,18 @@
1−// TODO: This file was created by bulk-decaffeinate.
2−// Sanity-check the conversion and remove this comment.
3−/*
4− * decaffeinate suggestions:
5− * DS102: Remove unnecessary code created because of implicit returns
6− * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
7− * DS206: Consider reworking classes to avoid initClass
8− * DS207: Consider shorter variations of null checks
9− * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10− */
111 app.views.Sidebar = class Sidebar extends app.View {
12− static initClass() {
13− this.el = "._sidebar";
2+ static el = "._sidebar";
143
15− this.events = {
16− focus: "onFocus",
17− select: "onSelect",
18− click: "onClick",
19− };
4+ static events = {
5+ focus: "onFocus",
6+ select: "onSelect",
7+ click: "onClick",
8+ };
209
21− this.routes = { after: "afterRoute" };
10+ static routes = { after: "afterRoute" };
2211
23− this.shortcuts = {
24− altR: "onAltR",
25− escape: "onEscape",
26− };
27− }
12+ static shortcuts = {
13+ altR: "onAltR",
14+ escape: "onEscape",
15+ };
2816
2917 init() {
3018 if (!app.isMobile()) {
@@ -179,11 +167,7 @@ app.views.Sidebar = class Sidebar extends app.View { · 148 unmodified lines
179167 if (event.which !== 1) {
180168 return;
181169 }
182− if (
183− __guardMethod__($.eventTarget(event), "hasAttribute", (o) =>
184− o.hasAttribute("data-reset-list"),
185− )
186− ) {
170+ if ($.eventTarget(event).hasAttribute?.("data-reset-list")) {
187171 $.stopEvent(event);
188172 this.onAltR();
189173 }
@@ -225,16 +209,3 @@ app.views.Sidebar = class Sidebar extends app.View { · 35 unmodified lines
225209 this.resetDisplay();
226210 }
227211 };
228−app.views.Sidebar.initClass();
229−
230−function __guardMethod__(obj, methodName, transform) {
231− if (
232− typeof obj !== "undefined" &&
233− obj !== null &&
234− typeof obj[methodName] === "function"
235− ) {
236− return transform(obj, methodName);
237− } else {
238− return undefined;
239− }
240−}