mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-minor] Only support browsers/environments that have *basic* support for Promise
natively
Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility and https://caniuse.com/#feat=promises, all even remotely modern browsers already support *basic* `Promise` functionality natively. The only reason for keeping the `Promise` polyfill (at all) is to be able to support recent additions to the specification, such as e.g. `finally` and `allSettled`. Note that this patch will, on its own, remove support for IE 11/Edge (non-Chromium based) in both the general PDF.js library and the default viewer.
This commit is contained in:
parent
4caa14b4dc
commit
449c7763d5
3 changed files with 6 additions and 5 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue