Use more optional chaining in the code-base

This patch updates a bunch of older code, that makes conditional function calls, to use optional chaining rather than `if`-blocks.

These mostly mechanical changes reduce the size of the `gulp mozcentral` build by a little over 1 kB.
This commit is contained in:
Jonas Jenwald 2022-09-05 15:36:04 +02:00
parent 9578152ae4
commit 38ee28b1d3
15 changed files with 51 additions and 119 deletions

View file

@ -380,9 +380,7 @@ class AnnotationElement {
const commonActions = this._commonActions;
for (const name of Object.keys(jsEvent.detail)) {
const action = actions[name] || commonActions[name];
if (action) {
action(jsEvent);
}
action?.(jsEvent);
}
}
@ -752,9 +750,7 @@ class LinkAnnotationElement extends AnnotationElement {
}
link.onclick = () => {
if (otherClickAction) {
otherClickAction();
}
otherClickAction?.();
const {
fields: resetFormFields,