Merge pull request #12331 from Snuffleupagus/Promise-polyfill

[api-minor] Only support browsers/environments that have *basic* support for `Promise` natively
This commit is contained in:
Tim van der Meij 2020-09-06 14:19:55 +02:00 committed by GitHub
commit 50958c46f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -24,7 +24,7 @@ Feel free to stop by our [Matrix room](https://chat.mozilla.org/#/room/#pdfjs:mo
### Online demo ### Online demo
Please note that the "Modern browsers" version assumes native support for Please note that the "Modern browsers" version assumes native support for
features such as e.g. `async`/`await`, `Promise`, and `ReadableStream`. features such as e.g. `async`/`await`, and `ReadableStream`.
+ Modern browsers: https://mozilla.github.io/pdf.js/web/viewer.html + Modern browsers: https://mozilla.github.io/pdf.js/web/viewer.html

View File

@ -8,7 +8,6 @@ This is a pre-built version of the PDF.js source code. It is automatically
generated by the build scripts. generated by the build scripts.
For usage with older browsers/environments, without support for modern features For usage with older browsers/environments, without support for modern features
such as e.g. `async`/`await`, `Promise`, and `ReadableStream`, such as e.g. `async`/`await`, and `ReadableStream`, please see the `es5` folder.
please refer to the `es5` folder.
See https://github.com/mozilla/pdf.js for learning and contributing. See https://github.com/mozilla/pdf.js for learning and contributing.

View File

@ -242,14 +242,16 @@ if (
require("core-js/es/typed-array/slice"); require("core-js/es/typed-array/slice");
})(); })();
// Support: IE, Safari<11, Chrome<63 // Provides support for *recent* additions to the Promise specification,
// however basic Promise support is assumed to be available natively.
// Support: Firefox<71, Safari<13, Chrome<76
(function checkPromise() { (function checkPromise() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
// The current image decoders are synchronous, hence `Promise` shouldn't // The current image decoders are synchronous, hence `Promise` shouldn't
// need to be polyfilled for the IMAGE_DECODERS build target. // need to be polyfilled for the IMAGE_DECODERS build target.
return; return;
} }
if (globalThis.Promise && globalThis.Promise.allSettled) { if (globalThis.Promise.allSettled) {
return; return;
} }
globalThis.Promise = require("core-js/es/promise/index.js"); globalThis.Promise = require("core-js/es/promise/index.js");