mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-07 23:55:49 +02:00
Use more optional chaining in the src/ and web/ folders
There's a few spots where we check if something is either undefined or if its length is zero, which can be simplified by instead using optional chaining.
This commit is contained in:
parent
8bdd159699
commit
b7b3a4c454
@ -2688,7 +2688,7 @@ class PDFEditor {
|
|||||||
*/
|
*/
|
||||||
#makePageLabelsTree() {
|
#makePageLabelsTree() {
|
||||||
const { pageLabels } = this;
|
const { pageLabels } = this;
|
||||||
if (!pageLabels || pageLabels.length === 0) {
|
if (!pageLabels?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { rootDict } = this;
|
const { rootDict } = this;
|
||||||
@ -2776,7 +2776,7 @@ class PDFEditor {
|
|||||||
|
|
||||||
#makeStructTree() {
|
#makeStructTree() {
|
||||||
const { structTreeKids } = this;
|
const { structTreeKids } = this;
|
||||||
if (!structTreeKids || structTreeKids.length === 0) {
|
if (!structTreeKids?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { rootDict } = this;
|
const { rootDict } = this;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class InkDrawOutliner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isEmpty() {
|
isEmpty() {
|
||||||
return !this.#lines || this.#lines.length === 0;
|
return !this.#lines?.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
isCancellable() {
|
isCancellable() {
|
||||||
|
|||||||
@ -800,7 +800,7 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
} = data;
|
} = data;
|
||||||
// textContent is supposed to be an array of strings containing each line
|
// textContent is supposed to be an array of strings containing each line
|
||||||
// of text. However, it can be null or empty.
|
// of text. However, it can be null or empty.
|
||||||
if (!textContent || textContent.length === 0) {
|
if (!textContent?.length) {
|
||||||
// Empty annotation.
|
// Empty annotation.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -846,7 +846,7 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
fileInput.addEventListener("change", function (evt) {
|
fileInput.addEventListener("change", function (evt) {
|
||||||
const { files } = evt.target;
|
const { files } = evt.target;
|
||||||
if (!files || files.length === 0) {
|
if (!files?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eventBus.dispatch("fileinputchange", {
|
eventBus.dispatch("fileinputchange", {
|
||||||
|
|||||||
@ -237,7 +237,7 @@ class DrawOpDetailView {
|
|||||||
header.textContent = name;
|
header.textContent = name;
|
||||||
argsContainer.append(header);
|
argsContainer.append(header);
|
||||||
|
|
||||||
if (!args || args.length === 0) {
|
if (!args?.length) {
|
||||||
const none = document.createElement("div");
|
const none = document.createElement("div");
|
||||||
none.className = "detail-empty";
|
none.className = "detail-empty";
|
||||||
none.textContent = "(no arguments)";
|
none.textContent = "(no arguments)";
|
||||||
|
|||||||
@ -138,7 +138,7 @@ class TextAccessibilityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const children = this.#textChildren;
|
const children = this.#textChildren;
|
||||||
if (!children || children.length === 0) {
|
if (!children?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ class TextAccessibilityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const children = this.#textChildren;
|
const children = this.#textChildren;
|
||||||
if (!children || children.length === 0) {
|
if (!children?.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user