mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Convert files in the src/display/
-folder to use optional chaining where possible
By using optional chaining, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining, it's possible to reduce unnecessary code-repetition in many cases. Note that these changes also reduce the size of the *built* `pdf.js` file, when `SKIP_BABEL == true` is set, and for the `MOZCENTRAL` build-target that result in a `0.1%` filesize reduction from a simple and mostly mechanical code change.
This commit is contained in:
parent
e3851a6765
commit
1dad255784
8 changed files with 19 additions and 41 deletions
|
@ -121,9 +121,7 @@ class BaseFontLoader {
|
|||
}
|
||||
|
||||
get isFontLoadingAPISupported() {
|
||||
const supported =
|
||||
typeof this._document !== "undefined" && !!this._document.fonts;
|
||||
return shadow(this, "isFontLoadingAPISupported", supported);
|
||||
return shadow(this, "isFontLoadingAPISupported", !!this._document?.fonts);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line getter-return
|
||||
|
@ -173,7 +171,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
const m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(
|
||||
navigator.userAgent
|
||||
);
|
||||
if (m && m[1] >= 14) {
|
||||
if (m?.[1] >= 14) {
|
||||
supported = true;
|
||||
}
|
||||
// TODO - other browsers...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue