From 123c84052b381ccbfcae4d8faf39ddcdcc3e43d4 Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Wed, 2 Aug 2023 09:12:25 -0700 Subject: [PATCH] Temporarily roll back buggy optimizations of enabling/disabling widget instances See #986 --- src/js/widget.js | 9 --------- src/js/widgets-controller.js | 39 ++---------------------------------- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/src/js/widget.js b/src/js/widget.js index 09dc16d4..8542f318 100644 --- a/src/js/widget.js +++ b/src/js/widget.js @@ -15,13 +15,6 @@ class Widget { static globalInit(form, rootElement) { this.form = form; this.rootElement = rootElement; - - if (form.features.relevant) { - this.implementsDisable = - this.prototype.disable !== Widget.prototype.disable; - this.implementsEnable = - this.prototype.enable !== Widget.prototype.enable; - } } static globalReset() { @@ -29,8 +22,6 @@ class Widget { delete this.form; delete this.rootElement; - delete this.implementsDisable; - delete this.implementsEnable; return { form, rootElement }; } diff --git a/src/js/widgets-controller.js b/src/js/widgets-controller.js index cb413f83..8874ef2b 100644 --- a/src/js/widgets-controller.js +++ b/src/js/widgets-controller.js @@ -14,12 +14,6 @@ import events from './event'; /** @type {WidgetClass[]} */ let widgets = _widgets.filter((widget) => widget.selector); -/** @type {Set} */ -let widgetsImplementingDisable = new Set(); - -/** @type {Set} */ -let widgetsImplementingEnable = new Set(); - let options; /** @type {import('./form').Form} */ @@ -37,21 +31,6 @@ const initForm = (formElement) => { widget.selector && formElement.querySelector(widget.selector) != null ); - - widgetsImplementingDisable = new Set(); - widgetsImplementingEnable = new Set(); - - widgets.forEach((Widget) => { - const { implementsDisable, implementsEnable } = Widget; - - if (implementsDisable) { - widgetsImplementingDisable.add(Widget); - } - - if (implementsEnable) { - widgetsImplementingEnable.add(Widget); - } - }); }; /** @@ -94,13 +73,7 @@ function init($group, opts = {}) { * @param {HTMLElement} group - HTML element */ function enable(group) { - if (group.closest('.widgets-disabled') == null) { - return; - } - - group.classList.remove('widgets-disbled'); - - widgetsImplementingEnable.forEach((Widget) => { + widgets.forEach((Widget) => { const els = _getElements(group, Widget.selector).filter((el) => el.nodeName.toLowerCase() === 'select' ? !el.hasAttribute('readonly') @@ -119,13 +92,7 @@ function enable(group) { * @param {HTMLElement} group - The element inside which all widgets need to be disabled. */ function disable(group) { - if (group.closest('.widgets-disabled') != null) { - return; - } - - group.classList.add('widgets-disbled'); - - widgetsImplementingDisable.forEach((Widget) => { + widgets.forEach((Widget) => { const els = _getElements(group, Widget.selector); new Collection(els).disable(Widget); @@ -202,8 +169,6 @@ const reset = () => { }); widgets = [..._widgets]; - widgetsImplementingDisable = new Set(); - widgetsImplementingEnable = new Set(); }; /** @type {Map>} */