diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2023-12-16 19:55:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-17 00:55:02 +0000 |
commit | 95ad1ae1ef4a53802c12eab4c9b1545af0333aa1 (patch) | |
tree | c08016ccb3265a5931baf413cd9d78fcbf600ae9 /ext/js/pages/settings/settings-display-controller.js | |
parent | 77d27113d347b4724302f1c72de1f238e04aeead (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/settings-display-controller.js')
-rw-r--r-- | ext/js/pages/settings/settings-display-controller.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js index 16e6cfae..e575a1cb 100644 --- a/ext/js/pages/settings/settings-display-controller.js +++ b/ext/js/pages/settings/settings-display-controller.js @@ -18,6 +18,7 @@ import {DocumentUtil} from '../../dom/document-util.js'; import {PopupMenu} from '../../dom/popup-menu.js'; +import {querySelectorNotNull} from '../../dom/query-selector.js'; import {SelectorObserver} from '../../dom/selector-observer.js'; export class SettingsDisplayController { @@ -30,10 +31,10 @@ export class SettingsDisplayController { this._settingsController = settingsController; /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; - /** @type {?HTMLElement} */ - this._contentNode = null; - /** @type {?HTMLElement} */ - this._menuContainer = null; + /** @type {HTMLElement} */ + this._contentNode = querySelectorNotNull(document, '.content'); + /** @type {HTMLElement} */ + this._menuContainer = querySelectorNotNull(document, '#popup-menus'); /** @type {(event: MouseEvent) => void} */ this._onMoreToggleClickBind = this._onMoreToggleClick.bind(this); /** @type {(event: MouseEvent) => void} */ @@ -42,9 +43,6 @@ export class SettingsDisplayController { /** */ prepare() { - this._contentNode = /** @type {HTMLElement} */ (document.querySelector('.content')); - this._menuContainer = /** @type {HTMLElement} */ (document.querySelector('#popup-menus')); - const onFabButtonClick = this._onFabButtonClick.bind(this); for (const fabButton of /** @type {NodeListOf<HTMLElement>} */ (document.querySelectorAll('.fab-button'))) { fabButton.addEventListener('click', onFabButtonClick, false); @@ -156,7 +154,8 @@ export class SettingsDisplayController { const container = this._getMoreContainer(node); if (container === null) { return; } - const more = /** @type {?HTMLElement} */ (container.querySelector('.more')); + /** @type {?HTMLElement} */ + const more = container.querySelector('.more'); if (more === null) { return; } const moreVisible = more.hidden; |