Fix constructor(el) instanceof HTMLElement

pull/1441/head
Simon Legner 1 year ago
parent 81c0551d35
commit 864e45e6fb

@ -54,8 +54,7 @@ app.views.Mobile = class Mobile extends app.View {
} }
constructor() { constructor() {
super(...arguments); super(document.documentElement);
this.el = document.documentElement;
} }
init() { init() {

@ -25,8 +25,7 @@ app.views.ListFocus = class ListFocus extends app.View {
} }
constructor(el) { constructor(el) {
super(...arguments); super(el);
this.el = el;
this.focusOnNextFrame = $.framify(this.focus, this); this.focusOnNextFrame = $.framify(this.focus, this);
} }

@ -22,11 +22,6 @@ app.views.ListFold = class ListFold extends app.View {
}; };
} }
constructor(el) {
super(...arguments);
this.el = el;
}
open(el) { open(el) {
if (el && !el.classList.contains(this.constructor.activeClass)) { if (el && !el.classList.contains(this.constructor.activeClass)) {
el.classList.add(this.constructor.activeClass); el.classList.add(this.constructor.activeClass);

@ -15,11 +15,6 @@ app.views.ListSelect = class ListSelect extends app.View {
this.events = { click: "onClick" }; this.events = { click: "onClick" };
} }
constructor(el) {
super(...arguments);
this.el = el;
}
deactivate() { deactivate() {
if (super.deactivate(...arguments)) { if (super.deactivate(...arguments)) {
this.deselect(); this.deselect();

@ -18,16 +18,13 @@
} }
constructor(data) { constructor(data) {
let base; super();
this.onClick = this.onClick.bind(this); this.onClick = this.onClick.bind(this);
let base = this.constructor.events || (this.constructor.events = {});
this.data = data; this.data = data;
if ( if (base.click == null) {
(base = this.constructor.events || (this.constructor.events = {}))
.click == null
) {
base.click = "onClick"; base.click = "onClick";
} }
super(...arguments);
} }
renderPaginated() { renderPaginated() {

@ -14,9 +14,9 @@ app.views.Notice = class Notice extends app.View {
} }
constructor(type, ...rest) { constructor(type, ...rest) {
super();
this.type = type; this.type = type;
[...this.args] = Array.from(rest); [...this.args] = Array.from(rest);
super(...arguments);
} }
init() { init() {

@ -19,7 +19,7 @@ app.views.Notif = class Notif extends app.View {
} }
constructor(type, options) { constructor(type, options) {
super(...arguments); super();
this.type = type; this.type = type;
this.options = $.extend({}, this.constructor.defaultOptions, options || {}); this.options = $.extend({}, this.constructor.defaultOptions, options || {});
} }

@ -10,8 +10,7 @@
*/ */
app.views.BasePage = class BasePage extends app.View { app.views.BasePage = class BasePage extends app.View {
constructor(el, entry) { constructor(el, entry) {
super(...arguments); super(el);
this.el = el;
this.entry = entry; this.entry = entry;
} }

@ -12,8 +12,7 @@ app.views.HiddenPage = class HiddenPage extends app.View {
} }
constructor(el, entry) { constructor(el, entry) {
super(...arguments); super(el);
this.el = el;
this.entry = entry; this.entry = entry;
} }

@ -32,11 +32,6 @@
HASH_RGX = new RegExp(`^#${SEARCH_PARAM}=(.+?) .`); HASH_RGX = new RegExp(`^#${SEARCH_PARAM}=(.+?) .`);
} }
constructor(el) {
super(...arguments);
this.el = el;
}
init() { init() {
this.placeholder = this.input.getAttribute("placeholder"); this.placeholder = this.input.getAttribute("placeholder");

@ -16,8 +16,8 @@ app.views.EntryList = class EntryList extends app.views.PaginatedList {
} }
constructor(entries) { constructor(entries) {
this.entries = entries;
super(...arguments); super(...arguments);
this.entries = entries;
} }
init() { init() {

@ -18,9 +18,11 @@ app.views.Results = class Results extends app.View {
} }
constructor(sidebar, search) { constructor(sidebar, search) {
super(...arguments); super();
this.sidebar = sidebar; this.sidebar = sidebar;
this.search = search; this.search = search;
this.init0();
this.refreshElements();
} }
deactivate() { deactivate() {
@ -29,7 +31,7 @@ app.views.Results = class Results extends app.View {
} }
} }
init() { init0() {
this.addSubview((this.listFocus = new app.views.ListFocus(this.el))); this.addSubview((this.listFocus = new app.views.ListFocus(this.el)));
this.addSubview((this.listSelect = new app.views.ListSelect(this.el))); this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));

@ -26,8 +26,7 @@ app.views.SidebarHover = class SidebarHover extends app.View {
} }
constructor(el) { constructor(el) {
super(...arguments); super(el);
this.el = el;
if (!isPointerEventsSupported()) { if (!isPointerEventsSupported()) {
delete this.constructor.events.mouseover; delete this.constructor.events.mouseover;
} }

@ -21,7 +21,7 @@ app.views.TypeList = class TypeList extends app.View {
} }
constructor(doc) { constructor(doc) {
super(...arguments); super();
this.doc = doc; this.doc = doc;
} }

@ -13,7 +13,10 @@ app.View = class View {
$.extend(this.prototype, Events); $.extend(this.prototype, Events);
} }
constructor() { constructor(el) {
if (el instanceof HTMLElement) {
this.el = el;
}
this.setupElement(); this.setupElement();
if (this.el.className) { if (this.el.className) {
this.originalClassName = this.el.className; this.originalClassName = this.el.className;

Loading…
Cancel
Save