Use a more compact format for the fallback EventBus-listeners in PDFViewerApplication_initializeJavaScript

Given that these event listeners should essentially never be needed, but are included simply to avoid breakage in edge-cases, it can't hurt to make this code slightly less verbose.
This commit is contained in:
Jonas Jenwald 2021-02-14 12:37:37 +01:00
parent 48f4580991
commit 209fe60472

View File

@ -1479,13 +1479,7 @@ const PDFViewerApplication = {
// It should be *extremely* rare for metadata to not have been resolved
// when this code runs, but ensure that we handle that case here.
await new Promise(resolve => {
this.eventBus._on(
"metadataloaded",
evt => {
resolve();
},
{ once: true }
);
this.eventBus._on("metadataloaded", resolve, { once: true });
});
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the metadata resolved.
@ -1498,13 +1492,7 @@ const PDFViewerApplication = {
// Hence we'll simply have to trust that the `contentLength` (as provided
// by the server), when it exists, is accurate enough here.
await new Promise(resolve => {
this.eventBus._on(
"documentloaded",
evt => {
resolve();
},
{ once: true }
);
this.eventBus._on("documentloaded", resolve, { once: true });
});
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the downloadInfo resolved.