Критические изменения
Зд есь будут описаны критические изменения, а также будут добавлены предупреждения об устаревших функциях в JS коде, где это возможно, по крайней мере перед тем, как изменения будут сделаны в одной мажорной версии.
Типы критических изменений
В этом документе используется следующее соглашение для классификации критических изменений:
- Изменение API: API был изменен таким образом, что код, который не был обновлен, гарантировано бросит исключение.
- Изменение поведения: Поведение Electron было изменено, но не обязательно появление исключений.
- Изменено значение по-умолчанию: Код, работа которого зависит от старого значения по-умолчанию, может сломаться, не обязательно кидая исключение. Старое поведение можно восстановить, если явно указать значение.
- Устарело: API был помечен как устаревший. API продолжит функционировать, но будет появляться предупреждающее сообщение о том, что API будет удален в будущем релизе.
- Удалено: API или функция была удалена и больше не поддерживается Electron.
Запланированные критические изменения API (31.0)
Removed: WebSQL
support
Chromium has removed support for WebSQL upstream, transitioning it to Android only. See Chromium's intent to remove discussion for more information.
Behavior Changed: nativeImage.toDataURL
will preseve PNG colorspace
PNG decoder implementation has been changed to preserve colorspace data, the encoded data returned from this function now matches it.
See crbug.com/332584706 for more information.
Behavior Changed: window.flashFrame(bool)
will flash dock icon continuously on macOS
This brings the behavior to parity with Windows and Linux. Prior behavior: The first flashFrame(true)
bounces the dock icon only once (using the NSInformationalRequest level) and flashFrame(false)
does nothing. New behavior: Flash continuously until flashFrame(false)
is called. This uses the NSCriticalRequest level instead. To explicitly use NSInformationalRequest
to cause a single dock icon bounce, it is still possible to use dock.bounce('informational')
.
Запланированные критические изменения API (30.0)
Behavior Changed: cross-origin iframes now use Permission Policy to access features
Cross-origin iframes must now specify features available to a given iframe
via the allow
attribute in order to access them.
See documentation for more information.
Removed: The --disable-color-correct-rendering
switch
This switch was never formally documented but it's removal is being noted here regardless. Chromium itself now has better support for color spaces so this flag should not be needed.
Behavior Changed: BrowserView.setAutoResize
behavior on macOS
In Electron 30, BrowserView is now a wrapper around the new WebContentsView API.
Previously, the setAutoResize
function of the BrowserView
API was backed by autoresizing on macOS, and by a custom algorithm on Windows and Linux. For simple use cases such as making a BrowserView fill the entire window, the behavior of these two approaches was identical. However, in more advanced cases, BrowserViews would be autoresized differently on macOS than they would be on other platforms, as the custom resizing algorithm for Windows and Linux did not perfectly match the behavior of macOS's autoresizing API. The autoresizing behavior is now standardized across all platforms.
If your app uses BrowserView.setAutoResize
to do anything more complex than making a BrowserView fill the entire window, it's likely you already had custom logic in place to handle this difference in behavior on macOS. If so, that logic will no longer be needed in Electron 30 as autoresizing behavior is consistent.
Removed: params.inputFormType
property on context-menu
on WebContents
The inputFormType
property of the params object in the context-menu
event from WebContents
has been removed. Use the new formControlType
property instead.
Удален: process.getIOCounters()
Chromium has removed access to this information.
Запланированные критические изменения API (29.0)
Behavior Changed: ipcRenderer
can no longer be sent over the contextBridge
Attempting to send the entire ipcRenderer
module as an object over the contextBridge
will now result in an empty object on the receiving side of the bridge. This change was made to remove / mitigate a security footgun. You should not directly expose ipcRenderer or its methods over the bridge. Instead, provide a safe wrapper like below:
contextBridge.exposeInMainWorld('app', {
onEvent: (cb) => ipcRenderer.on('foo', (e, ...args) => cb(args))
})
Removed: renderer-process-crashed
event on app
The renderer-process-crashed
event on app
has been removed. Use the new render-process-gone
event instead.
// Removed
app.on('renderer-process-crashed', (event, webContents, killed) => { /* ... */ })
// Replace with
app.on('render-process-gone', (event, webContents, details) => { /* ... */ })
Removed: crashed
event on WebContents
and <webview>
The crashed
events on WebContents
and <webview>
have been removed. Use the new render-process-gone
event instead.
// Removed
win.webContents.on('crashed', (event, killed) => { /* ... */ })
webview.addEventListener('crashed', (event) => { /* ... */ })
// Replace with
win.webContents.on('render-process-gone', (event, details) => { /* ... */ })
webview.addEventListener('render-process-gone', (event) => { /* ... */ })
Removed: gpu-process-crashed
event on app
The gpu-process-crashed
event on app
has been removed. Use the new child-process-gone
event instead.
// Removed
app.on('gpu-process-crashed', (event, killed) => { /* ... */ })
// Replace with
app.on('child-process-gone', (event, details) => { /* ... */ })
Запланированные критические изменения API (28.0)
Behavior Changed: WebContents.backgroundThrottling
set to false affects all WebContents
in the host BrowserWindow
WebContents.backgroundThrottling
set to false will disable frames throttling in the BrowserWindow
for all WebContents
displayed by it.
Удален: BrowserWindow.setTrafficLightPosition(position)
BrowserWindow.setTrafficLightPosition(position)
has been removed, the BrowserWindow.setWindowButtonPosition(position)
API should be used instead which accepts null
instead of { x: 0, y: 0 }
to reset the position to system default.
// Removed in Electron 28
win.setTrafficLightPosition({ x: 10, y: 10 })
win.setTrafficLightPosition({ x: 0, y: 0 })
// Replace with
win.setWindowButtonPosition({ x: 10, y: 10 })
win.setWindowButtonPosition(null)
Удален: BrowserWindow.getTrafficLightPosition()
BrowserWindow.getTrafficLightPosition()
has been removed, the BrowserWindow.getWindowButtonPosition()
API should be used instead which returns null
instead of { x: 0, y: 0 }
when there is no custom position.
// Removed in Electron 28
const pos = win.getTrafficLightPosition()
if (pos.x === 0 && pos.y === 0) {
// No custom position.
}
// Replace with
const ret = win.getWindowButtonPosition()
if (ret === null) {
// No custom position.
}
Удален: ipcRenderer.sendTo()
The ipcRenderer.sendTo()
API has been removed. It should be replaced by setting up a MessageChannel
between the renderers.
The senderId
and senderIsMainFrame
properties of IpcRendererEvent
have been removed as well.
Удален: app.runningUnderRosettaTranslation
The app.runningUnderRosettaTranslation
property has been removed. Вместо него используйте app.runningUnderARM64Translation
.
// Removed
console.log(app.runningUnderRosettaTranslation)
// Replace with
console.log(app.runningUnderARM64Translation)
Deprecated: renderer-process-crashed
event on app
The renderer-process-crashed
event on app
has been deprecated. Use the new render-process-gone
event instead.
// Deprecated
app.on('renderer-process-crashed', (event, webContents, killed) => { /* ... */ })
// Replace with
app.on('render-process-gone', (event, webContents, details) => { /* ... */ })
Deprecated: params.inputFormType
property on context-menu
on WebContents
The inputFormType
property of the params object in the context-menu
event from WebContents
has been deprecated. Use the new formControlType
property instead.
Deprecated: crashed
event on WebContents
and <webview>
The crashed
events on WebContents
and <webview>
have been deprecated. Use the new render-process-gone
event instead.
// Deprecated
win.webContents.on('crashed', (event, killed) => { /* ... */ })
webview.addEventListener('crashed', (event) => { /* ... */ })
// Replace with
win.webContents.on('render-process-gone', (event, details) => { /* ... */ })
webview.addEventListener('render-process-gone', (event) => { /* ... */ })
Deprecated: gpu-process-crashed
event on app
The gpu-process-crashed
event on app
has been deprecated. Use the new child-process-gone
event instead.
// Deprecated
app.on('gpu-process-crashed', (event, killed) => { /* ... */ })
// Replace with
app.on('child-process-gone', (event, details) => { /* ... */ })