From 8d2aaf2757f69bdf85281319813ff57db276f71a Mon Sep 17 00:00:00 2001 From: Cashew <52880648+Scrub1492@users.noreply.github.com> Date: Fri, 22 Dec 2023 23:02:31 +0900 Subject: fix add profile conditions (#416) * fix add profile conditions * remove legacy code, re-add safe query selector * remove unnecessary typecast --- ext/js/pages/settings/profile-conditions-ui.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'ext/js/pages/settings') diff --git a/ext/js/pages/settings/profile-conditions-ui.js b/ext/js/pages/settings/profile-conditions-ui.js index 8e5da3d8..29e7460f 100644 --- a/ext/js/pages/settings/profile-conditions-ui.js +++ b/ext/js/pages/settings/profile-conditions-ui.js @@ -600,9 +600,7 @@ class ProfileConditionGroupUI { const child = new ProfileConditionUI(this, index); child.prepare(condition); this._children.push(child); - if (this._conditionContainer !== null) { - this._conditionContainer.appendChild(child.node); - } + this._conditionContainer.appendChild(child.node); return child; } } @@ -624,8 +622,6 @@ class ProfileConditionUI { /** @type {HTMLSelectElement} */ this._operatorInput = querySelectorNotNull(this._node, '.profile-condition-operator'); /** @type {HTMLButtonElement} */ - this._removeButton = querySelectorNotNull(this._node, '.profile-condition-remove'); - /** @type {HTMLButtonElement} */ this._mouseButton = querySelectorNotNull(this._node, '.mouse-button'); /** @type {HTMLElement} */ this._mouseButtonContainer = querySelectorNotNull(this._node, '.mouse-button-container'); @@ -684,11 +680,8 @@ class ProfileConditionUI { this._eventListeners.addEventListener(this._typeInput, 'change', this._onTypeChange.bind(this), false); this._eventListeners.addEventListener(this._operatorInput, 'change', this._onOperatorChange.bind(this), false); - if (this._removeButton !== null) { this._eventListeners.addEventListener(this._removeButton, 'click', this._onRemoveButtonClick.bind(this), false); } - if (this._menuButton !== null) { - this._eventListeners.addEventListener(this._menuButton, 'menuOpen', this._onMenuOpen.bind(this), false); - this._eventListeners.addEventListener(this._menuButton, 'menuClose', this._onMenuClose.bind(this), false); - } + this._eventListeners.addEventListener(this._menuButton, 'menuOpen', this._onMenuOpen.bind(this), false); + this._eventListeners.addEventListener(this._menuButton, 'menuClose', this._onMenuClose.bind(this), false); } /** */ @@ -766,18 +759,13 @@ class ProfileConditionUI { } } - /** */ - _onRemoveButtonClick() { - this._removeSelf(); - } - /** * @param {import('popup-menu').MenuOpenEvent} e */ _onMenuOpen(e) { const bodyNode = e.detail.menu.bodyNode; /** @type {HTMLElement} */ - const deleteGroup = querySelectorNotNull(bodyNode, '.popup-menu-item[data-menu-action="deleteGroup"]'); + const deleteGroup = /** @type {HTMLElement} */ (bodyNode.querySelector('.popup-menu-item[data-menu-action="deleteGroup"]')); if (deleteGroup !== null) { deleteGroup.hidden = (this._parent.childCount <= 1); } -- cgit v1.2.3