Remove redundant compatibility checks, for modern generic
builds, in src/core/worker.js
With the recent additions of optional chaining and nullish coalescing to the PDF.js code-base, a couple of the checks in `src/core/worker.js` are now redundant; please see this compatibility information: - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#browser_compatibility - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator#browser_compatibility In practice, for the non-translated/non-polyfilled PDF.js builds, browsers without support for optional chaining and nullish coalescing will simply throw immediately upon loading of the code. Hence both the `globalThis` and `Promise.allSettled` checks are now unnecessary, given this compatibility information: - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled#browser_compatibility *Please note:* The `ReadableStream` check is however still necessary, since Node.js doesn't support that.
This commit is contained in:
parent
a10dc1cb6e
commit
b4eb55250e
@ -139,19 +139,15 @@ class WorkerMessageHandler {
|
|||||||
|
|
||||||
// Ensure that (primarily) Node.js users won't accidentally attempt to use
|
// Ensure that (primarily) Node.js users won't accidentally attempt to use
|
||||||
// a non-translated/non-polyfilled build of the library, since that would
|
// a non-translated/non-polyfilled build of the library, since that would
|
||||||
// quickly fail anyway because of missing functionality (such as e.g.
|
// quickly fail anyway because of missing functionality.
|
||||||
// `ReadableStream` and `Promise.allSettled`).
|
|
||||||
if (
|
if (
|
||||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("SKIP_BABEL")) &&
|
(typeof PDFJSDev === "undefined" || PDFJSDev.test("SKIP_BABEL")) &&
|
||||||
(typeof globalThis === "undefined" ||
|
typeof ReadableStream === "undefined"
|
||||||
typeof ReadableStream === "undefined" ||
|
|
||||||
typeof Promise.allSettled === "undefined")
|
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"The browser/environment lacks native support for critical " +
|
"The browser/environment lacks native support for critical " +
|
||||||
"functionality used by the PDF.js library (e.g. `globalThis`, " +
|
"functionality used by the PDF.js library (e.g. `ReadableStream`); " +
|
||||||
"`ReadableStream`, and/or `Promise.allSettled`); " +
|
"please use an `es5`-build instead."
|
||||||
"please use an ES5-compatible build instead."
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user