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:
parent
bdde621366
commit
bc13932ac1
@ -771,7 +771,7 @@ class PDFFindController {
|
||||
total = this._matchesCountTotal;
|
||||
if (matchIdx !== -1) {
|
||||
for (let i = 0; i < pageIdx; i++) {
|
||||
current += (this._pageMatches[i] && this._pageMatches[i].length) || 0;
|
||||
current += this._pageMatches[i]?.length || 0;
|
||||
}
|
||||
current += matchIdx + 1;
|
||||
}
|
||||
@ -797,7 +797,7 @@ class PDFFindController {
|
||||
state,
|
||||
previous,
|
||||
matchesCount: this._requestMatchesCount(),
|
||||
rawQuery: this._state ? this._state.query : null,
|
||||
rawQuery: this._state?.query ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user