aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCashew <52880648+Scrub1492@users.noreply.github.com>2023-12-22 23:02:31 +0900
committerGitHub <noreply@github.com>2023-12-22 14:02:31 +0000
commit8d2aaf2757f69bdf85281319813ff57db276f71a (patch)
tree4c9c7fcf588586b67b64a48f941deac34c337e0e
parent11d2b933be3f775fe1723a4a60452635b0aa6cfd (diff)
fix add profile conditions (#416)
* fix add profile conditions * remove legacy code, re-add safe query selector * remove unnecessary typecast
-rw-r--r--ext/js/pages/settings/profile-conditions-ui.js20
1 files changed, 4 insertions, 16 deletions
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);
}