Merge pull request #13063 from Snuffleupagus/more-web-optional-chaining

Use more optional chaining in the web/-folder (PR 12961 follow-up)
This commit is contained in:
Tim van der Meij 2021-03-07 19:00:57 +01:00 committed by GitHub
commit 5e3af62d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -262,7 +262,7 @@ class PDFDocumentProperties {
} }
return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, { return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(), size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
size_kb: (+kb.toPrecision(3)).toLocaleString(), size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString(), size_b: fileSize.toLocaleString(),
}); });
} }

View File

@ -771,7 +771,7 @@ class PDFFindController {
total = this._matchesCountTotal; total = this._matchesCountTotal;
if (matchIdx !== -1) { if (matchIdx !== -1) {
for (let i = 0; i < pageIdx; i++) { 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; current += matchIdx + 1;
} }
@ -797,7 +797,7 @@ class PDFFindController {
state, state,
previous, previous,
matchesCount: this._requestMatchesCount(), matchesCount: this._requestMatchesCount(),
rawQuery: this._state ? this._state.query : null, rawQuery: this._state?.query ?? null,
}); });
} }
} }

View File

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