浏览代码

Sanity-check decaffeinate app.views.ListSelect

Simon Legner 1 年之前
父节点
当前提交
9073fa20cb
共有 1 个文件被更改,包括 3 次插入23 次删除
  1. 3 23
      assets/javascripts/views/list/list_select.js

+ 3 - 23
assets/javascripts/views/list/list_select.js

@@ -1,18 +1,7 @@
-// TODO: This file was created by bulk-decaffeinate.
-// Sanity-check the conversion and remove this comment.
-/*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
- * DS206: Consider reworking classes to avoid initClass
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
- */
 app.views.ListSelect = class ListSelect extends app.View {
-  static initClass() {
-    this.activeClass = "active";
+  static activeClass = "active";
 
-    this.events = { click: "onClick" };
-  }
+  static events = { click: "onClick" };
 
   deactivate() {
     if (super.deactivate(...arguments)) {
@@ -37,9 +26,7 @@ app.views.ListSelect = class ListSelect extends app.View {
   }
 
   selectByHref(href) {
-    if (
-      __guard__(this.getSelection(), (x) => x.getAttribute("href")) !== href
-    ) {
+    if (this.getSelection()?.getAttribute("href") !== href) {
       this.select(this.find(`a[href='${href}']`));
     }
   }
@@ -62,10 +49,3 @@ app.views.ListSelect = class ListSelect extends app.View {
     }
   }
 };
-app.views.ListSelect.initClass();
-
-function __guard__(value, transform) {
-  return typeof value !== "undefined" && value !== null
-    ? transform(value)
-    : undefined;
-}