From fe875bbd99980b175fc366a2bfd4395be9cbad72 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 20 Feb 2024 10:13:57 -0500 Subject: Constructor simplification (#713) * Update AudioDownloader * Update Translator * Update ClipboardMonitor * Update ClipboardReader * Update PanelElement * Update QueryParser * Update DisplayGenerator * Update DisplayHistory * Update DOMDataBinder * Remove unnecessary cast * Update Popup types * One declaration per line * Remove optionals from Frontend constructor * Fix Translator constructor --- ext/js/dom/dom-data-binder.js | 13 +++++++++---- ext/js/dom/panel-element.js | 5 +++-- ext/js/dom/selector-observer.js | 9 ++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'ext/js/dom') diff --git a/ext/js/dom/dom-data-binder.js b/ext/js/dom/dom-data-binder.js index d33f1a2b..14b3b2cd 100644 --- a/ext/js/dom/dom-data-binder.js +++ b/ext/js/dom/dom-data-binder.js @@ -25,9 +25,14 @@ import {SelectorObserver} from './selector-observer.js'; */ export class DOMDataBinder { /** - * @param {import('dom-data-binder').ConstructorDetails} details + * @param {string} selector + * @param {import('dom-data-binder').CreateElementMetadataCallback} createElementMetadata + * @param {import('dom-data-binder').CompareElementMetadataCallback} compareElementMetadata + * @param {import('dom-data-binder').GetValuesCallback} getValues + * @param {import('dom-data-binder').SetValuesCallback} setValues + * @param {import('dom-data-binder').OnErrorCallback|null} [onError] */ - constructor({selector, createElementMetadata, compareElementMetadata, getValues, setValues, onError = null}) { + constructor(selector, createElementMetadata, compareElementMetadata, getValues, setValues, onError = null) { /** @type {string} */ this._selector = selector; /** @type {import('dom-data-binder').CreateElementMetadataCallback} */ @@ -45,14 +50,14 @@ export class DOMDataBinder { /** @type {TaskAccumulator, import('dom-data-binder').AssignTaskValue>} */ this._assignTasks = new TaskAccumulator(this._onBulkAssign.bind(this)); /** @type {SelectorObserver>} */ - this._selectorObserver = /** @type {SelectorObserver>} */ (new SelectorObserver({ + this._selectorObserver = new SelectorObserver({ selector, ignoreSelector: null, onAdded: this._createObserver.bind(this), onRemoved: this._removeObserver.bind(this), onChildrenUpdated: this._onObserverChildrenUpdated.bind(this), isStale: this._isObserverStale.bind(this) - })); + }); } /** diff --git a/ext/js/dom/panel-element.js b/ext/js/dom/panel-element.js index 0f2801e6..97b05599 100644 --- a/ext/js/dom/panel-element.js +++ b/ext/js/dom/panel-element.js @@ -23,9 +23,10 @@ import {EventDispatcher} from '../core/event-dispatcher.js'; */ export class PanelElement extends EventDispatcher { /** - * @param {import('panel-element').ConstructorDetails} details + * @param {HTMLElement} node + * @param {number} closingAnimationDuration */ - constructor({node, closingAnimationDuration}) { + constructor(node, closingAnimationDuration) { super(); /** @type {HTMLElement} */ this._node = node; diff --git a/ext/js/dom/selector-observer.js b/ext/js/dom/selector-observer.js index 86607130..032805e8 100644 --- a/ext/js/dom/selector-observer.js +++ b/ext/js/dom/selector-observer.js @@ -25,7 +25,14 @@ export class SelectorObserver { * Creates a new instance. * @param {import('selector-observer').ConstructorDetails} details The configuration for the object. */ - constructor({selector, ignoreSelector = null, onAdded = null, onRemoved = null, onChildrenUpdated = null, isStale = null}) { + constructor({ + selector, + ignoreSelector = null, + onAdded = null, + onRemoved = null, + onChildrenUpdated = null, + isStale = null + }) { /** @type {string} */ this._selector = selector; /** @type {?string} */ -- cgit v1.2.3