Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-minor] Only support browsers/environments that have *basic* support for Promise natively #12331

Merged
merged 1 commit into from
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feel free to stop by our [Matrix room](https://chat.mozilla.org/#/room/#pdfjs:mo
### Online demo

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

Expand Down
3 changes: 1 addition & 2 deletions external/dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This is a pre-built version of the PDF.js source code. It is automatically
generated by the build scripts.

For usage with older browsers/environments, without support for modern features
such as e.g. `async`/`await`, `Promise`, and `ReadableStream`,
please refer to the `es5` folder.
such as e.g. `async`/`await`, and `ReadableStream`, please see the `es5` folder.

See https://github.com/mozilla/pdf.js for learning and contributing.
6 changes: 4 additions & 2 deletions src/shared/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,16 @@ if (
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() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
// The current image decoders are synchronous, hence `Promise` shouldn't
// need to be polyfilled for the IMAGE_DECODERS build target.
return;
}
if (globalThis.Promise && globalThis.Promise.allSettled) {
if (globalThis.Promise.allSettled) {
return;
}
globalThis.Promise = require("core-js/es/promise/index.js");
Expand Down