Skip to content

Commit b9beca9

Browse files
Merge pull request #12992 from Snuffleupagus/scripting-compact-fallback-events
Use a more compact format for the fallback EventBus-listeners in `PDFViewerApplication_initializeJavaScript`
2 parents c79fd71 + 209fe60 commit b9beca9

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

web/app.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -1479,13 +1479,7 @@ const PDFViewerApplication = {
14791479
// It should be *extremely* rare for metadata to not have been resolved
14801480
// when this code runs, but ensure that we handle that case here.
14811481
await new Promise(resolve => {
1482-
this.eventBus._on(
1483-
"metadataloaded",
1484-
evt => {
1485-
resolve();
1486-
},
1487-
{ once: true }
1488-
);
1482+
this.eventBus._on("metadataloaded", resolve, { once: true });
14891483
});
14901484
if (pdfDocument !== this.pdfDocument) {
14911485
return; // The document was closed while the metadata resolved.
@@ -1498,13 +1492,7 @@ const PDFViewerApplication = {
14981492
// Hence we'll simply have to trust that the `contentLength` (as provided
14991493
// by the server), when it exists, is accurate enough here.
15001494
await new Promise(resolve => {
1501-
this.eventBus._on(
1502-
"documentloaded",
1503-
evt => {
1504-
resolve();
1505-
},
1506-
{ once: true }
1507-
);
1495+
this.eventBus._on("documentloaded", resolve, { once: true });
15081496
});
15091497
if (pdfDocument !== this.pdfDocument) {
15101498
return; // The document was closed while the downloadInfo resolved.

web/base_viewer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,8 @@ class BaseViewer {
740740
*/
741741
get _pageWidthScaleFactor() {
742742
if (
743-
this.spreadMode !== SpreadMode.NONE &&
744-
this.scrollMode !== ScrollMode.HORIZONTAL &&
743+
this._spreadMode !== SpreadMode.NONE &&
744+
this._scrollMode !== ScrollMode.HORIZONTAL &&
745745
!this.isInPresentationMode
746746
) {
747747
return 2;
@@ -1642,7 +1642,7 @@ class BaseViewer {
16421642
return true;
16431643
}
16441644

1645-
initializeScriptingEvents() {
1645+
async initializeScriptingEvents() {
16461646
if (!this.enableScripting || this._pageOpenPendingSet) {
16471647
return;
16481648
}

0 commit comments

Comments
 (0)