Skip to content

Commit

Permalink
Merge pull request #13063 from Snuffleupagus/more-web-optional-chaining
Browse files Browse the repository at this point in the history
Use more optional chaining in the web/-folder (PR 12961 follow-up)
  • Loading branch information
timvandermeij authored Mar 7, 2021
2 parents 34c9e88 + bc13932 commit 5e3af62
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class PDFDocumentProperties {
}
return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
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(),
});
}
Expand Down
4 changes: 2 additions & 2 deletions web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -797,7 +797,7 @@ class PDFFindController {
state,
previous,
matchesCount: this._requestMatchesCount(),
rawQuery: this._state ? this._state.query : null,
rawQuery: this._state?.query ?? null,
});
}
}
Expand Down
7 changes: 2 additions & 5 deletions web/pdf_sidebar_resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5e3af62

Please sign in to comment.