summaryrefslogtreecommitdiff
path: root/ext/js/pages/settings/popup-preview-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages/settings/popup-preview-controller.js')
-rw-r--r--ext/js/pages/settings/popup-preview-controller.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/ext/js/pages/settings/popup-preview-controller.js b/ext/js/pages/settings/popup-preview-controller.js
index 7239ca17..d8bc9850 100644
--- a/ext/js/pages/settings/popup-preview-controller.js
+++ b/ext/js/pages/settings/popup-preview-controller.js
@@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {querySelectorNotNull} from '../../dom/query-selector.js';
+
export class PopupPreviewController {
/**
* @param {import('./settings-controller.js').SettingsController} settingsController
@@ -25,25 +27,20 @@ export class PopupPreviewController {
this._settingsController = settingsController;
/** @type {string} */
this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');
- /** @type {?HTMLIFrameElement} */
- this._frame = null;
- /** @type {?HTMLTextAreaElement} */
- this._customCss = null;
- /** @type {?HTMLTextAreaElement} */
- this._customOuterCss = null;
- /** @type {?HTMLElement} */
- this._previewFrameContainer = null;
+ /** @type {HTMLIFrameElement} */
+ this._frame = querySelectorNotNull(document, '#popup-preview-frame');
+ /** @type {HTMLTextAreaElement} */
+ this._customCss = querySelectorNotNull(document, '#custom-popup-css');
+ /** @type {HTMLTextAreaElement} */
+ this._customOuterCss = querySelectorNotNull(document, '#custom-popup-outer-css');
+ /** @type {HTMLElement} */
+ this._previewFrameContainer = querySelectorNotNull(document, '.preview-frame-container');
}
/** */
async prepare() {
if (new URLSearchParams(location.search).get('popup-preview') === 'false') { return; }
- this._frame = /** @type {HTMLIFrameElement} */ (document.querySelector('#popup-preview-frame'));
- this._customCss = /** @type {HTMLTextAreaElement} */ (document.querySelector('#custom-popup-css'));
- this._customOuterCss = /** @type {HTMLTextAreaElement} */ (document.querySelector('#custom-popup-outer-css'));
- this._previewFrameContainer = /** @type {HTMLElement} */ (document.querySelector('.preview-frame-container'));
-
this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false);
this._customCss.addEventListener('settingChanged', this._onCustomCssChange.bind(this), false);
this._customOuterCss.addEventListener('input', this._onCustomOuterCssChange.bind(this), false);