Use more optional chaining in the web/-folder (PR 12961 follow-up)

I overlooked these cases previously, but there's no reason why optional chaining (and nullish coalescing) cannot be used here as well.
This commit is contained in:
Jonas Jenwald 2021-03-07 16:12:29 +01:00
parent bdde621366
commit bc13932ac1
2 changed files with 4 additions and 7 deletions

View file

@ -53,10 +53,7 @@ class PDFSidebarResizer {
* @type {number}
*/
get outerContainerWidth() {
if (!this._outerContainerWidth) {
this._outerContainerWidth = this.outerContainer.clientWidth;
}
return this._outerContainerWidth;
return (this._outerContainerWidth ||= this.outerContainer.clientWidth);
}
/**
@ -135,7 +132,7 @@ class PDFSidebarResizer {
this.eventBus._on("resize", evt => {
// When the *entire* viewer is resized, such that it becomes narrower,
// ensure that the sidebar doesn't end up being too wide.
if (!evt || evt.source !== window) {
if (evt?.source !== window) {
return;
}
// Always reset the cached width when the viewer is resized.