From 864e45e6fb68232888a29a0cbd95b3352932c90d Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 6 Jan 2024 13:02:28 +0100 Subject: [PATCH] Fix constructor(el) instanceof HTMLElement --- assets/javascripts/views/layout/mobile.js | 3 +-- assets/javascripts/views/list/list_focus.js | 3 +-- assets/javascripts/views/list/list_fold.js | 5 ----- assets/javascripts/views/list/list_select.js | 5 ----- assets/javascripts/views/list/paginated_list.js | 9 +++------ assets/javascripts/views/misc/notice.js | 2 +- assets/javascripts/views/misc/notif.js | 2 +- assets/javascripts/views/pages/base.js | 3 +-- assets/javascripts/views/pages/hidden.js | 3 +-- assets/javascripts/views/search/search_scope.js | 5 ----- assets/javascripts/views/sidebar/entry_list.js | 2 +- assets/javascripts/views/sidebar/results.js | 6 ++++-- assets/javascripts/views/sidebar/sidebar_hover.js | 3 +-- assets/javascripts/views/sidebar/type_list.js | 2 +- assets/javascripts/views/view.js | 5 ++++- 15 files changed, 20 insertions(+), 38 deletions(-) diff --git a/assets/javascripts/views/layout/mobile.js b/assets/javascripts/views/layout/mobile.js index 75b9280c..ffb5fdbe 100644 --- a/assets/javascripts/views/layout/mobile.js +++ b/assets/javascripts/views/layout/mobile.js @@ -54,8 +54,7 @@ app.views.Mobile = class Mobile extends app.View { } constructor() { - super(...arguments); - this.el = document.documentElement; + super(document.documentElement); } init() { diff --git a/assets/javascripts/views/list/list_focus.js b/assets/javascripts/views/list/list_focus.js index 486e64ea..ece364aa 100644 --- a/assets/javascripts/views/list/list_focus.js +++ b/assets/javascripts/views/list/list_focus.js @@ -25,8 +25,7 @@ app.views.ListFocus = class ListFocus extends app.View { } constructor(el) { - super(...arguments); - this.el = el; + super(el); this.focusOnNextFrame = $.framify(this.focus, this); } diff --git a/assets/javascripts/views/list/list_fold.js b/assets/javascripts/views/list/list_fold.js index 5ced1b2d..565a7700 100644 --- a/assets/javascripts/views/list/list_fold.js +++ b/assets/javascripts/views/list/list_fold.js @@ -22,11 +22,6 @@ app.views.ListFold = class ListFold extends app.View { }; } - constructor(el) { - super(...arguments); - this.el = el; - } - open(el) { if (el && !el.classList.contains(this.constructor.activeClass)) { el.classList.add(this.constructor.activeClass); diff --git a/assets/javascripts/views/list/list_select.js b/assets/javascripts/views/list/list_select.js index b991e443..5be1cc86 100644 --- a/assets/javascripts/views/list/list_select.js +++ b/assets/javascripts/views/list/list_select.js @@ -15,11 +15,6 @@ app.views.ListSelect = class ListSelect extends app.View { this.events = { click: "onClick" }; } - constructor(el) { - super(...arguments); - this.el = el; - } - deactivate() { if (super.deactivate(...arguments)) { this.deselect(); diff --git a/assets/javascripts/views/list/paginated_list.js b/assets/javascripts/views/list/paginated_list.js index f46e57c3..43553ef1 100644 --- a/assets/javascripts/views/list/paginated_list.js +++ b/assets/javascripts/views/list/paginated_list.js @@ -18,16 +18,13 @@ } constructor(data) { - let base; + super(); this.onClick = this.onClick.bind(this); + let base = this.constructor.events || (this.constructor.events = {}); this.data = data; - if ( - (base = this.constructor.events || (this.constructor.events = {})) - .click == null - ) { + if (base.click == null) { base.click = "onClick"; } - super(...arguments); } renderPaginated() { diff --git a/assets/javascripts/views/misc/notice.js b/assets/javascripts/views/misc/notice.js index 9601d473..d357018c 100644 --- a/assets/javascripts/views/misc/notice.js +++ b/assets/javascripts/views/misc/notice.js @@ -14,9 +14,9 @@ app.views.Notice = class Notice extends app.View { } constructor(type, ...rest) { + super(); this.type = type; [...this.args] = Array.from(rest); - super(...arguments); } init() { diff --git a/assets/javascripts/views/misc/notif.js b/assets/javascripts/views/misc/notif.js index 011600a7..4ed28223 100644 --- a/assets/javascripts/views/misc/notif.js +++ b/assets/javascripts/views/misc/notif.js @@ -19,7 +19,7 @@ app.views.Notif = class Notif extends app.View { } constructor(type, options) { - super(...arguments); + super(); this.type = type; this.options = $.extend({}, this.constructor.defaultOptions, options || {}); } diff --git a/assets/javascripts/views/pages/base.js b/assets/javascripts/views/pages/base.js index 21b6d481..ff1caa81 100644 --- a/assets/javascripts/views/pages/base.js +++ b/assets/javascripts/views/pages/base.js @@ -10,8 +10,7 @@ */ app.views.BasePage = class BasePage extends app.View { constructor(el, entry) { - super(...arguments); - this.el = el; + super(el); this.entry = entry; } diff --git a/assets/javascripts/views/pages/hidden.js b/assets/javascripts/views/pages/hidden.js index 552b7ee3..be7e928b 100644 --- a/assets/javascripts/views/pages/hidden.js +++ b/assets/javascripts/views/pages/hidden.js @@ -12,8 +12,7 @@ app.views.HiddenPage = class HiddenPage extends app.View { } constructor(el, entry) { - super(...arguments); - this.el = el; + super(el); this.entry = entry; } diff --git a/assets/javascripts/views/search/search_scope.js b/assets/javascripts/views/search/search_scope.js index 906178e6..fbcb8bd5 100644 --- a/assets/javascripts/views/search/search_scope.js +++ b/assets/javascripts/views/search/search_scope.js @@ -32,11 +32,6 @@ HASH_RGX = new RegExp(`^#${SEARCH_PARAM}=(.+?) .`); } - constructor(el) { - super(...arguments); - this.el = el; - } - init() { this.placeholder = this.input.getAttribute("placeholder"); diff --git a/assets/javascripts/views/sidebar/entry_list.js b/assets/javascripts/views/sidebar/entry_list.js index 82605f5c..854946b5 100644 --- a/assets/javascripts/views/sidebar/entry_list.js +++ b/assets/javascripts/views/sidebar/entry_list.js @@ -16,8 +16,8 @@ app.views.EntryList = class EntryList extends app.views.PaginatedList { } constructor(entries) { - this.entries = entries; super(...arguments); + this.entries = entries; } init() { diff --git a/assets/javascripts/views/sidebar/results.js b/assets/javascripts/views/sidebar/results.js index 9c541037..7ebd9e43 100644 --- a/assets/javascripts/views/sidebar/results.js +++ b/assets/javascripts/views/sidebar/results.js @@ -18,9 +18,11 @@ app.views.Results = class Results extends app.View { } constructor(sidebar, search) { - super(...arguments); + super(); this.sidebar = sidebar; this.search = search; + this.init0(); + this.refreshElements(); } 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.listSelect = new app.views.ListSelect(this.el))); diff --git a/assets/javascripts/views/sidebar/sidebar_hover.js b/assets/javascripts/views/sidebar/sidebar_hover.js index 48e3a6a5..57aa086e 100644 --- a/assets/javascripts/views/sidebar/sidebar_hover.js +++ b/assets/javascripts/views/sidebar/sidebar_hover.js @@ -26,8 +26,7 @@ app.views.SidebarHover = class SidebarHover extends app.View { } constructor(el) { - super(...arguments); - this.el = el; + super(el); if (!isPointerEventsSupported()) { delete this.constructor.events.mouseover; } diff --git a/assets/javascripts/views/sidebar/type_list.js b/assets/javascripts/views/sidebar/type_list.js index f6c4c2c1..8eba7404 100644 --- a/assets/javascripts/views/sidebar/type_list.js +++ b/assets/javascripts/views/sidebar/type_list.js @@ -21,7 +21,7 @@ app.views.TypeList = class TypeList extends app.View { } constructor(doc) { - super(...arguments); + super(); this.doc = doc; } diff --git a/assets/javascripts/views/view.js b/assets/javascripts/views/view.js index 11ad4777..75d04183 100644 --- a/assets/javascripts/views/view.js +++ b/assets/javascripts/views/view.js @@ -13,7 +13,10 @@ app.View = class View { $.extend(this.prototype, Events); } - constructor() { + constructor(el) { + if (el instanceof HTMLElement) { + this.el = el; + } this.setupElement(); if (this.el.className) { this.originalClassName = this.el.className;