mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Introduce more optional chaining in the src/core/
folder
After PR 12563 we're now free to use optional chaining in the worker-thread as well. (This patch also fixes one previously "missed" case in the `web/` folder.) For the MOZCENTRAL build-target this patch reduces the total bundle-size by `1.6` kilobytes.
This commit is contained in:
parent
c20c1b3362
commit
1b4a7c5965
27 changed files with 90 additions and 137 deletions
|
@ -1421,7 +1421,7 @@ class PDFDocument {
|
|||
const { catalog, linearization, xref } = this;
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
assert(
|
||||
linearization && linearization.pageFirst === pageIndex,
|
||||
linearization?.pageFirst === pageIndex,
|
||||
"_getLinearizationPage - invalid pageIndex argument."
|
||||
);
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ class PDFDocument {
|
|||
let promise;
|
||||
if (xfaFactory) {
|
||||
promise = Promise.resolve([Dict.empty, null]);
|
||||
} else if (linearization && linearization.pageFirst === pageIndex) {
|
||||
} else if (linearization?.pageFirst === pageIndex) {
|
||||
promise = this._getLinearizationPage(pageIndex);
|
||||
} else {
|
||||
promise = catalog.getPageDict(pageIndex);
|
||||
|
@ -1630,7 +1630,7 @@ class PDFDocument {
|
|||
this._localIdFactory,
|
||||
/* collectFields */ true
|
||||
)
|
||||
.then(annotation => annotation && annotation.getFieldObject())
|
||||
.then(annotation => annotation?.getFieldObject())
|
||||
.catch(function (reason) {
|
||||
warn(`_collectFieldObjects: "${reason}".`);
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue