Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Temporarily roll back buggy optimizations of enabling/disabling widget instances #990

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/js/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@ 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() {
const { form, rootElement } = this;

delete this.form;
delete this.rootElement;
delete this.implementsDisable;
delete this.implementsEnable;

return { form, rootElement };
}
Expand Down
39 changes: 2 additions & 37 deletions src/js/widgets-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import events from './event';
/** @type {WidgetClass[]} */
let widgets = _widgets.filter((widget) => widget.selector);

/** @type {Set<WidgetClass>} */
let widgetsImplementingDisable = new Set();

/** @type {Set<WidgetClass>} */
let widgetsImplementingEnable = new Set();

let options;

/** @type {import('./form').Form} */
Expand All @@ -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);
}
});
};

/**
Expand Down Expand Up @@ -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')
Expand All @@ -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);
Expand Down Expand Up @@ -202,8 +169,6 @@ const reset = () => {
});

widgets = [..._widgets];
widgetsImplementingDisable = new Set();
widgetsImplementingEnable = new Set();
};

/** @type {Map<typeof Widget, Set<HTMLElement>>} */
Expand Down