History

Sanity-check decaffeinate app.views.SidebarHover

Simon Legner committed 2 years ago

Commit 6df17da1 parent 38b3a951 file · +11 −32Browse files

Unified · Split

assets/javascripts/views/sidebar/sidebar_hover.js+11−32
@@ -1,28 +1,16 @@
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.SidebarHover = class SidebarHover extends app.View {
12− static initClass() {
13− this.itemClass = "_list-hover";
2+ static itemClass = "_list-hover";
143
15− this.events = {
16− focus: "onFocus",
17− blur: "onBlur",
18− mouseover: "onMouseover",
19− mouseout: "onMouseout",
20− scroll: "onScroll",
21− click: "onClick",
22− };
4+ static events = {
5+ focus: "onFocus",
6+ blur: "onBlur",
7+ mouseover: "onMouseover",
8+ mouseout: "onMouseout",
9+ scroll: "onScroll",
10+ click: "onClick",
11+ };
2312
24− this.routes = { after: "onRoute" };
25− }
13+ static routes = { after: "onRoute" };
2614
2715 constructor(el) {
2816 super(el);
@@ -72,9 +60,7 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 43 unmodified lines
7260 }
7361
7462 isTarget(el) {
75− return __guard__(el != null ? el.classList : undefined, (x) =>
76− x.contains(this.constructor.itemClass),
77− );
63+ return el.classList?.contains(this.constructor.itemClass);
7864 }
7965
8066 isSelected(el) {
@@ -129,16 +115,9 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 48 unmodified lines
129115 this.hide();
130116 }
131117 };
132−app.views.SidebarHover.initClass();
133118
134119 var isPointerEventsSupported = function () {
135120 const el = document.createElement("div");
136121 el.style.cssText = "pointer-events: auto";
137122 return el.style.pointerEvents === "auto";
138123 };
139−
140−function __guard__(value, transform) {
141− return typeof value !== "undefined" && value !== null
142− ? transform(value)
143− : undefined;
144−}