Skip to content

Commit

Permalink
Use optional chain expressions where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Cirras committed Nov 10, 2023
1 parent 0fe1b45 commit 099a804
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/components/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Accordion extends Focusable {

get focusElement() {
const items = this.items;
if (items && items.length) {
if (items?.length) {
let index = 0;
while (index < items.length && items[index].disabled) {
index += 1;
Expand All @@ -42,7 +42,7 @@ export class Accordion extends Focusable {

startListeningToKeyboard() {
const items = this.items;
if (items && items.length) {
if (items?.length) {
this.addEventListener("keydown", this.handleKeyDown);
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/core/components/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ export class Application extends LitElement {
}

modalOpen(modal) {
return !!(modal && modal.open);
return !!modal?.open;
}

emitHasOpenPromptChanged() {
Expand Down Expand Up @@ -1100,16 +1100,14 @@ export class Application extends LitElement {

async needGFXDirectoryPermission() {
return (
this.settingsState &&
this.settingsState.gfxDirectory &&
this.settingsState?.gfxDirectory &&
(await this.settingsState.gfxDirectory.queryPermission()) !== "granted"
);
}

async needAssetsDirectoryPermission() {
return (
this.settingsState &&
this.settingsState.customAssetsDirectory &&
this.settingsState?.customAssetsDirectory &&
(await this.settingsState.customAssetsDirectory.queryPermission()) !==
"granted"
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class Menu extends SpectrumElement {
return (
this === element ||
this.menuItems.includes(element) ||
(this.submenu && this.submenu.menu.isDescendant(element))
this.submenu?.menu.isDescendant(element)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/electron/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ function newWindow() {
state = WindowState.read(getWindowStateFilePath());
}

if (state && state.isVisibleOnAnyDisplay()) {
if (state?.isVisibleOnAnyDisplay()) {
options.x = state.x;
options.y = state.y;
options.width = state.width;
Expand Down
2 changes: 1 addition & 1 deletion webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = (env) => {
CANVAS_RENDERER: JSON.stringify(true),
WEBGL_RENDERER: JSON.stringify(true),
FORCE_CONNECTED_MODE_URL: JSON.stringify(
(env && env.FORCE_CONNECTED_MODE_URL) || ""
env?.FORCE_CONNECTED_MODE_URL || ""
),
NPM_VERSION: JSON.stringify(getVersion()),
RELEASE_NOTES_URL: JSON.stringify(getReleaseNotesUrl()),
Expand Down

0 comments on commit 099a804

Please sign in to comment.