mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Move, and modernize, Util.loadScript
from src/shared/util.js
to src/display/dom_utils.js
Not only is the `Util.loadScript` helper function unused on the Worker side, even trying to use it there would throw an Error (since `document` isn't defined/available in Workers). Hence this helper function is moved, and its code modernized slightly by having it return a Promise rather than needing a callback function. Finally, to reduced code duplication, the "new" loadScript function is exported and used in the viewer.
This commit is contained in:
parent
547f119be6
commit
07d610615c
5 changed files with 34 additions and 53 deletions
|
@ -21,8 +21,8 @@ import {
|
|||
UnexpectedResponseException, UnknownErrorException, unreachable, Util, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, PageViewport,
|
||||
RenderingCancelledException, StatTimer
|
||||
DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, loadScript,
|
||||
PageViewport, RenderingCancelledException, StatTimer
|
||||
} from './dom_utils';
|
||||
import { FontFaceObject, FontLoader } from './font_loader';
|
||||
import { apiCompatibilityParams } from './api_compatibility';
|
||||
|
@ -1356,7 +1356,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||
}
|
||||
} else {
|
||||
let loader = fakeWorkerFilesLoader || function(callback) {
|
||||
Util.loadScript(getWorkerSrc(), function() {
|
||||
loadScript(getWorkerSrc()).then(function() {
|
||||
callback(window.pdfjsWorker.WorkerMessageHandler);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue