mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Use more optional chaining in the code-base
This patch updates a bunch of older code, that makes conditional function calls, to use optional chaining rather than `if`-blocks. These mostly mechanical changes reduce the size of the `gulp mozcentral` build by a little over 1 kB.
This commit is contained in:
parent
9578152ae4
commit
38ee28b1d3
15 changed files with 51 additions and 119 deletions
|
@ -637,12 +637,9 @@ class BaseViewer {
|
|||
this._cancelRendering();
|
||||
this._resetView();
|
||||
|
||||
if (this.findController) {
|
||||
this.findController.setDocument(null);
|
||||
}
|
||||
if (this._scriptingManager) {
|
||||
this._scriptingManager.setDocument(null);
|
||||
}
|
||||
this.findController?.setDocument(null);
|
||||
this._scriptingManager?.setDocument(null);
|
||||
|
||||
if (this.#annotationEditorUIManager) {
|
||||
this.#annotationEditorUIManager.destroy();
|
||||
this.#annotationEditorUIManager = null;
|
||||
|
@ -807,12 +804,8 @@ class BaseViewer {
|
|||
// starts to create the correct size canvas. Wait until one page is
|
||||
// rendered so we don't tie up too many resources early on.
|
||||
this.#onePageRenderedOrForceFetch().then(async () => {
|
||||
if (this.findController) {
|
||||
this.findController.setDocument(pdfDocument); // Enable searching.
|
||||
}
|
||||
if (this._scriptingManager) {
|
||||
this._scriptingManager.setDocument(pdfDocument); // Enable scripting.
|
||||
}
|
||||
this.findController?.setDocument(pdfDocument); // Enable searching.
|
||||
this._scriptingManager?.setDocument(pdfDocument); // Enable scripting.
|
||||
|
||||
if (this.#annotationEditorUIManager) {
|
||||
// Ensure that the Editor buttons, in the toolbar, are updated.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue