Skip to content

Commit

Permalink
fix add profile conditions (#416)
Browse files Browse the repository at this point in the history
* fix add profile conditions

* remove legacy code, re-add safe query selector

* remove unnecessary typecast
  • Loading branch information
Casheeew authored Dec 22, 2023
1 parent 11d2b93 commit 8d2aaf2
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions ext/js/pages/settings/profile-conditions-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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');
Expand Down Expand Up @@ -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);
}

/** */
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8d2aaf2

Please sign in to comment.