aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/action-popup-main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-16 19:55:02 -0500
committerGitHub <noreply@github.com>2023-12-17 00:55:02 +0000
commit95ad1ae1ef4a53802c12eab4c9b1545af0333aa1 (patch)
treec08016ccb3265a5931baf413cd9d78fcbf600ae9 /ext/js/pages/action-popup-main.js
parent77d27113d347b4724302f1c72de1f238e04aeead (diff)
Safer query selector (#364)
* Add querySelectorNotNull helper function * Use querySelectorNotNull * Updates * Update settings * Remove unused * Update * Update function calls * More updates * Update types * Remove obsolete code
Diffstat (limited to 'ext/js/pages/action-popup-main.js')
-rw-r--r--ext/js/pages/action-popup-main.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js
index 94b9b356..f8dd865f 100644
--- a/ext/js/pages/action-popup-main.js
+++ b/ext/js/pages/action-popup-main.js
@@ -17,6 +17,7 @@
*/
import {PermissionsUtil} from '../data/permissions-util.js';
+import {querySelectorNotNull} from '../dom/query-selector.js';
import {HotkeyHelpController} from '../input/hotkey-help-controller.js';
import {yomitan} from '../yomitan.js';
@@ -57,7 +58,9 @@ export class DisplayController {
this._setupOptions(primaryProfile);
}
- /** @type {HTMLElement} */ (document.querySelector('.action-select-profile')).hidden = (profiles.length <= 1);
+ /** @type {HTMLElement} */
+ const profileSelect = querySelectorNotNull(document, '.action-select-profile');
+ profileSelect.hidden = (profiles.length <= 1);
this._updateProfileSelect(profiles, profileCurrent);
@@ -207,8 +210,10 @@ export class DisplayController {
* @param {number} profileCurrent
*/
_updateProfileSelect(profiles, profileCurrent) {
- const select = /** @type {HTMLSelectElement} */ (document.querySelector('#profile-select'));
- const optionGroup = /** @type {HTMLElement} */ (document.querySelector('#profile-select-option-group'));
+ /** @type {HTMLSelectElement} */
+ const select = querySelectorNotNull(document, '#profile-select');
+ /** @type {HTMLElement} */
+ const optionGroup = querySelectorNotNull(document, '#profile-select-option-group');
const fragment = document.createDocumentFragment();
for (let i = 0, ii = profiles.length; i < ii; ++i) {
const {name} = profiles[i];