aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/popup-preview-frame.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages/settings/popup-preview-frame.js')
-rw-r--r--ext/js/pages/settings/popup-preview-frame.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js
index 60d264fa..e5cc6580 100644
--- a/ext/js/pages/settings/popup-preview-frame.js
+++ b/ext/js/pages/settings/popup-preview-frame.js
@@ -18,6 +18,7 @@
import * as wanakana from '../../../lib/wanakana.js';
import {Frontend} from '../../app/frontend.js';
+import {querySelectorNotNull} from '../../dom/query-selector.js';
import {TextSourceRange} from '../../dom/text-source-range.js';
import {yomitan} from '../../yomitan.js';
@@ -49,10 +50,10 @@ export class PopupPreviewFrame {
this._textSource = null;
/** @type {?import('settings').OptionsContext} */
this._optionsContext = null;
- /** @type {?HTMLElement} */
- this._exampleText = null;
- /** @type {?HTMLInputElement} */
- this._exampleTextInput = null;
+ /** @type {HTMLElement} */
+ this._exampleText = querySelectorNotNull(document, '#example-text');
+ /** @type {HTMLInputElement} */
+ this._exampleTextInput = querySelectorNotNull(document, '#example-text-input');
/** @type {string} */
this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');
@@ -67,9 +68,6 @@ export class PopupPreviewFrame {
/** */
async prepare() {
- this._exampleText = /** @type {HTMLElement} */ (document.querySelector('#example-text'));
- this._exampleTextInput = /** @type {HTMLInputElement} */ (document.querySelector('#example-text-input'));
-
if (this._exampleTextInput !== null && typeof wanakana !== 'undefined') {
wanakana.bind(this._exampleTextInput);
}
@@ -77,7 +75,8 @@ export class PopupPreviewFrame {
window.addEventListener('message', this._onMessage.bind(this), false);
// Setup events
- const darkThemeCheckbox = /** @type {HTMLInputElement} */ (document.querySelector('#theme-dark-checkbox'));
+ /** @type {HTMLInputElement} */
+ const darkThemeCheckbox = querySelectorNotNull(document, '#theme-dark-checkbox');
darkThemeCheckbox.addEventListener('change', this._onThemeDarkCheckboxChanged.bind(this), false);
this._exampleText.addEventListener('click', this._onExampleTextClick.bind(this), false);
this._exampleTextInput.addEventListener('blur', this._onExampleTextInputBlur.bind(this), false);