Fix constructor(el) instanceof HTMLElement

pull/1441/head
Simon Legner 1 year ago
parent 5e0b6a4e59
commit 63472e840e

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

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

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

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

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

Loading…
Cancel
Save