1
0
Эх сурвалжийг харах

Fix constructor(el) instanceof HTMLElement

Simon Legner 1 жил өмнө
parent
commit
63472e840e

+ 3 - 4
assets/javascripts/views/list/paginated_list.js

@@ -19,11 +19,10 @@
 
     constructor(data) {
       super();
-      this.onClick = this.onClick.bind(this);
-      let base = this.constructor.events || (this.constructor.events = {});
       this.data = data;
-      if (base.click == null) {
-        base.click = "onClick";
+      this.constructor.events = this.constructor.events || {};
+      if (this.constructor.events.click == null) {
+        this.constructor.events.click = "onClick";
       }
     }
 

+ 6 - 5
assets/javascripts/views/misc/notice.js

@@ -3,7 +3,6 @@
 /*
  * decaffeinate suggestions:
  * DS002: Fix invalid constructor
- * DS101: Remove unnecessary use of Array.from
  * DS206: Consider reworking classes to avoid initClass
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  */
@@ -13,13 +12,15 @@ app.views.Notice = class Notice extends app.View {
     this.attributes = { role: "alert" };
   }
 
-  constructor(type, ...rest) {
+  constructor(type, ...args) {
     super();
     this.type = type;
-    [...this.args] = Array.from(rest);
+    this.args = args || [];
+    this.init0(); // needs this.args
+    this.refreshElements();
   }
 
-  init() {
+  init0() {
     this.activate();
   }
 
@@ -36,7 +37,7 @@ app.views.Notice = class Notice extends app.View {
   }
 
   show() {
-    this.html(this.tmpl(`${this.type}Notice`, ...Array.from(this.args)));
+    this.html(this.tmpl(`${this.type}Notice`, ...this.args));
     this.prependTo(app.el);
   }
 

+ 3 - 1
assets/javascripts/views/sidebar/entry_list.js

@@ -18,9 +18,11 @@ app.views.EntryList = class EntryList extends app.views.PaginatedList {
   constructor(entries) {
     super(...arguments);
     this.entries = entries;
+    this.init0(); // needs this.data from PaginatedList
+    this.refreshElements();
   }
 
-  init() {
+  init0() {
     this.renderPaginated();
     this.activate();
   }

+ 1 - 1
assets/javascripts/views/sidebar/results.js

@@ -21,7 +21,7 @@ app.views.Results = class Results extends app.View {
     super();
     this.sidebar = sidebar;
     this.search = search;
-    this.init0();
+    this.init0(); // needs this.search
     this.refreshElements();
   }
 

+ 3 - 1
assets/javascripts/views/sidebar/type_list.js

@@ -23,9 +23,11 @@ app.views.TypeList = class TypeList extends app.View {
   constructor(doc) {
     super();
     this.doc = doc;
+    this.init0(); // needs this.doc
+    this.refreshElements();
   }
 
-  init() {
+  init0() {
     this.lists = {};
     this.render();
     this.activate();