docs: use optional chaining for app.dock (#46119)

docs: use optional chaining for app.dock
This commit is contained in:
Niklas Wenzel 2025-03-20 00:34:03 +01:00 committed by GitHub
parent d424c3aee7
commit bf1d377e08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 7 deletions

View file

@ -9,7 +9,7 @@ The following example shows how to bounce your icon on the dock.
```js ```js
const { app } = require('electron') const { app } = require('electron')
app.dock.bounce() app.dock?.bounce()
``` ```
### Instance Methods ### Instance Methods

View file

@ -24,9 +24,7 @@ const dockMenu = Menu.buildFromTemplate([
]) ])
app.whenReady().then(() => { app.whenReady().then(() => {
if (process.platform === 'darwin') { app.dock?.setMenu(dockMenu)
app.dock.setMenu(dockMenu)
}
}).then(createWindow) }).then(createWindow)
app.on('window-all-closed', () => { app.on('window-all-closed', () => {

View file

@ -50,9 +50,7 @@ const dockMenu = Menu.buildFromTemplate([
]) ])
app.whenReady().then(() => { app.whenReady().then(() => {
if (process.platform === 'darwin') { app.dock?.setMenu(dockMenu)
app.dock.setMenu(dockMenu)
}
}).then(createWindow) }).then(createWindow)
app.on('window-all-closed', () => { app.on('window-all-closed', () => {