aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/extension-keyboard-shortcuts-controller.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/settings/extension-keyboard-shortcuts-controller.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/settings/extension-keyboard-shortcuts-controller.js')
-rw-r--r--ext/js/pages/settings/extension-keyboard-shortcuts-controller.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
index d36d965a..e92d9e93 100644
--- a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
+++ b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js
@@ -17,6 +17,7 @@
*/
import {EventListenerCollection, isObject} from '../../core.js';
+import {querySelectorNotNull} from '../../dom/query-selector.js';
import {HotkeyUtil} from '../../input/hotkey-util.js';
import {yomitan} from '../../yomitan.js';
import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js';
@@ -28,12 +29,12 @@ export class ExtensionKeyboardShortcutController {
constructor(settingsController) {
/** @type {import('./settings-controller.js').SettingsController} */
this._settingsController = settingsController;
- /** @type {?HTMLButtonElement} */
- this._resetButton = null;
- /** @type {?HTMLButtonElement} */
- this._clearButton = null;
- /** @type {?HTMLElement} */
- this._listContainer = null;
+ /** @type {HTMLButtonElement} */
+ this._resetButton = querySelectorNotNull(document, '#extension-hotkey-list-reset-all');
+ /** @type {HTMLButtonElement} */
+ this._clearButton = querySelectorNotNull(document, '#extension-hotkey-list-clear-all');
+ /** @type {HTMLElement} */
+ this._listContainer = querySelectorNotNull(document, '#extension-hotkey-list');
/** @type {HotkeyUtil} */
this._hotkeyUtil = new HotkeyUtil();
/** @type {?import('environment').OperatingSystem} */
@@ -49,10 +50,6 @@ export class ExtensionKeyboardShortcutController {
/** */
async prepare() {
- this._resetButton = /** @type {HTMLButtonElement} */ (document.querySelector('#extension-hotkey-list-reset-all'));
- this._clearButton = /** @type {HTMLButtonElement} */ (document.querySelector('#extension-hotkey-list-clear-all'));
- this._listContainer = /** @type {HTMLElement} */ (document.querySelector('#extension-hotkey-list'));
-
const canResetCommands = this.canResetCommands();
const canModifyCommands = this.canModifyCommands();
this._resetButton.hidden = !canResetCommands;
@@ -277,11 +274,14 @@ class ExtensionKeyboardShortcutHotkeyEntry {
/** */
prepare() {
- const label = /** @type {HTMLElement} */ (this._node.querySelector('.settings-item-label'));
+ /** @type {HTMLElement} */
+ const label = querySelectorNotNull(this._node, '.settings-item-label');
label.textContent = this._description || this._name;
- const button = /** @type {HTMLButtonElement} */ (this._node.querySelector('.extension-hotkey-list-item-button'));
- const input = /** @type {HTMLInputElement} */ (this._node.querySelector('input'));
+ /** @type {HTMLButtonElement} */
+ const button = querySelectorNotNull(this._node, '.extension-hotkey-list-item-button');
+ /** @type {HTMLInputElement} */
+ const input = querySelectorNotNull(this._node, 'input');
this._input = input;