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 */
11app.views.SidebarHover = class SidebarHover extends app.View {1app.views.SidebarHover = class SidebarHover extends app.View {
12 static initClass() {2 static itemClass = "_list-hover";
13 this.itemClass = "_list-hover";
14 3
15 this.events = {4 static events = {
16 focus: "onFocus",5 focus: "onFocus",
17 blur: "onBlur",6 blur: "onBlur",
18 mouseover: "onMouseover",7 mouseover: "onMouseover",
19 mouseout: "onMouseout",8 mouseout: "onMouseout",
20 scroll: "onScroll",9 scroll: "onScroll",
21 click: "onClick",10 click: "onClick",
22 };11 };
23 12
24 this.routes = { after: "onRoute" };13 static routes = { after: "onRoute" };
25 }
26 14
27 constructor(el) {15 constructor(el) {
28 super(el);16 super(el);
@@ -72,9 +60,7 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 43 unmodified lines
72 }60 }
73 61
74 isTarget(el) {62 isTarget(el) {
75 return __guard__(el != null ? el.classList : undefined, (x) =>63 return el.classList?.contains(this.constructor.itemClass);
76 x.contains(this.constructor.itemClass),
77 );
78 }64 }
79 65
80 isSelected(el) {66 isSelected(el) {
@@ -129,16 +115,9 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 48 unmodified lines
129 this.hide();115 this.hide();
130 }116 }
131};117};
132app.views.SidebarHover.initClass();
133 118
134var isPointerEventsSupported = function () {119var isPointerEventsSupported = function () {
135 const el = document.createElement("div");120 const el = document.createElement("div");
136 el.style.cssText = "pointer-events: auto";121 el.style.cssText = "pointer-events: auto";
137 return el.style.pointerEvents === "auto";122 return el.style.pointerEvents === "auto";
138};123};
139
140function __guard__(value, transform) {
141 return typeof value !== "undefined" && value !== null
142 ? transform(value)
143 : undefined;
144}