2019-05-21 07:15:57 +00:00
# Breaking Changes
2018-05-29 09:15:30 +00:00
2020-01-28 22:19:18 +00:00
Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least [one major version ](tutorial/electron-versioning.md#semver ) before the change is made.
2018-05-29 09:15:30 +00:00
2020-03-26 17:57:55 +00:00
### Types of Breaking Changes
2018-05-29 09:15:30 +00:00
2020-03-26 17:57:55 +00:00
This document uses the following convention to categorize breaking changes:
2020-11-23 17:15:27 +00:00
* **API Changed:** An API was changed in such a way that code that has not been updated is guaranteed to throw an exception.
* **Behavior Changed:** The behavior of Electron has changed, but not in such a way that an exception will necessarily be thrown.
* **Default Changed:** Code depending on the old default may break, not necessarily throwing an exception. The old behavior can be restored by explicitly specifying the value.
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
2018-05-29 09:15:30 +00:00
2021-01-26 22:23:35 +00:00
## Planned Breaking API Changes (14.0)
2021-04-21 20:59:11 +00:00
### Removed: `app.allowRendererProcessReuse`
The `app.allowRendererProcessReuse` property will be removed as part of our plan to
more closely align with Chromium's process model for security, performance and maintainability.
For more detailed information see [#18397 ](https://github.com/electron/electron/issues/18397 ).
### Removed: Browser Window Affinity
The `affinity` option when constructing a new `BrowserWindow` will be removed
as part of our plan to more closely align with Chromium's process model for security,
performance and maintainability.
For more detailed information see [#18397 ](https://github.com/electron/electron/issues/18397 ).
2021-04-07 17:32:32 +00:00
### API Changed: `window.open()`
2021-02-05 19:20:58 +00:00
The optional parameter `frameName` will no longer set the title of the window. This now follows the specification described by the [native documentation ](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#parameters ) under the corresponding parameter `windowName` .
2021-06-14 19:02:23 +00:00
If you were using this parameter to set the title of a window, you can instead use [win.setTitle(title) ](api/browser-window.md#winsettitletitle ).
2021-02-05 19:20:58 +00:00
2021-01-26 22:23:35 +00:00
### Removed: `worldSafeExecuteJavaScript`
In Electron 14, `worldSafeExecuteJavaScript` will be removed. There is no alternative, please
ensure your code works with this property enabled. It has been enabled by default since Electron
12.
You will be affected by this change if you use either `webFrame.executeJavaScript` or `webFrame.executeJavaScriptInIsolatedWorld` . You will need to ensure that values returned by either of those methods are supported by the [Context Bridge API ](api/context-bridge.md#parameter--error--return-type-support ) as these methods use the same value passing semantics.
2021-04-13 19:36:38 +00:00
### Default Changed: `nativeWindowOpen` defaults to `true`
Prior to Electron 14, `window.open` was by default shimmed to use
`BrowserWindowProxy` . This meant that `window.open('about:blank')` did not work
to open synchronously scriptable child windows, among other incompatibilities.
`nativeWindowOpen` is no longer experimental, and is now the default.
See the documentation for [window.open in Electron ](api/window-open.md )
for more details.
2021-04-21 17:55:17 +00:00
### Removed: BrowserWindowConstructorOptions inheriting from parent windows
Prior to Electron 14, windows opened with `window.open` would inherit
BrowserWindow constructor options such as `transparent` and `resizable` from
their parent window. Beginning with Electron 14, this behavior is removed, and
windows will not inherit any BrowserWindow constructor options from their
parents.
Instead, explicitly set options for the new window with `setWindowOpenHandler` :
```js
webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
// ...
}
}
})
```
2021-04-19 22:46:54 +00:00
### Removed: `additionalFeatures`
The deprecated `additionalFeatures` property in the `new-window` and
`did-create-window` events of WebContents has been removed. Since `new-window`
uses positional arguments, the argument is still present, but will always be
the empty array `[]` . (Though note, the `new-window` event itself is
deprecated, and is replaced by `setWindowOpenHandler` .) Bare keys in window
features will now present as keys with the value `true` in the options object.
```js
// Removed in Electron 14
// Triggered by window.open('...', '', 'my-key')
webContents.on('did-create-window', (window, details) => {
if (details.additionalFeatures.includes('my-key')) {
// ...
}
})
// Replace with
webContents.on('did-create-window', (window, details) => {
if (details.options['my-key']) {
// ...
}
})
```
2020-09-03 19:44:16 +00:00
## Planned Breaking API Changes (13.0)
2020-12-07 23:44:56 +00:00
### API Changed: `session.setPermissionCheckHandler(handler)`
The `handler` methods first parameter was previously always a `webContents` , it can now sometimes be `null` . You should use the `requestingOrigin` , `embeddingOrigin` and `securityOrigin` properties to respond to the permission check correctly. As the `webContents` can be `null` it can no longer be relied on.
```js
// Old code
session.setPermissionCheckHandler((webContents, permission) => {
if (webContents.getURL().startsWith('https://google.com/') & & permission === 'notification') {
return true
}
return false
})
// Replace with
session.setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
if (new URL(requestingOrigin).hostname === 'google.com' & & permission === 'notification') {
return true
}
return false
})
```
2020-09-03 19:44:16 +00:00
### Removed: `shell.moveItemToTrash()`
The deprecated synchronous `shell.moveItemToTrash()` API has been removed. Use
the asynchronous `shell.trashItem()` instead.
```js
// Removed in Electron 13
shell.moveItemToTrash(path)
// Replace with
shell.trashItem(path).then(/* ... */)
```
2020-11-30 22:40:56 +00:00
### Removed: `BrowserWindow` extension APIs
The deprecated extension APIs have been removed:
2020-12-08 07:08:19 +00:00
2020-11-30 22:40:56 +00:00
* `BrowserWindow.addExtension(path)`
* `BrowserWindow.addDevToolsExtension(path)`
* `BrowserWindow.removeExtension(name)`
* `BrowserWindow.removeDevToolsExtension(name)`
* `BrowserWindow.getExtensions()`
* `BrowserWindow.getDevToolsExtensions()`
Use the session APIs instead:
2020-12-08 07:08:19 +00:00
2020-11-30 22:40:56 +00:00
* `ses.loadExtension(path)`
* `ses.removeExtension(extension_id)`
* `ses.getAllExtensions()`
```js
// Removed in Electron 13
BrowserWindow.addExtension(path)
BrowserWindow.addDevToolsExtension(path)
// Replace with
session.defaultSession.loadExtension(path)
```
```js
// Removed in Electron 13
BrowserWindow.removeExtension(name)
BrowserWindow.removeDevToolsExtension(name)
// Replace with
session.defaultSession.removeExtension(extension_id)
```
```js
// Removed in Electron 13
BrowserWindow.getExtensions()
BrowserWindow.getDevToolsExtensions()
// Replace with
session.defaultSession.getAllExtensions()
```
2020-12-15 23:34:24 +00:00
### Removed: methods in `systemPreferences`
The following `systemPreferences` methods have been deprecated:
2021-01-14 08:31:26 +00:00
2020-12-15 23:34:24 +00:00
* `systemPreferences.isDarkMode()`
* `systemPreferences.isInvertedColorScheme()`
* `systemPreferences.isHighContrastColorScheme()`
Use the following `nativeTheme` properties instead:
2021-01-14 08:31:26 +00:00
2020-12-15 23:34:24 +00:00
* `nativeTheme.shouldUseDarkColors`
* `nativeTheme.shouldUseInvertedColorScheme`
* `nativeTheme.shouldUseHighContrastColors`
```js
// Removed in Electron 13
systemPreferences.isDarkMode()
// Replace with
nativeTheme.shouldUseDarkColors
// Removed in Electron 13
systemPreferences.isInvertedColorScheme()
// Replace with
nativeTheme.shouldUseInvertedColorScheme
// Removed in Electron 13
systemPreferences.isHighContrastColorScheme()
// Replace with
nativeTheme.shouldUseHighContrastColors
```
2021-04-08 14:52:14 +00:00
### Deprecated: WebContents `new-window` event
The `new-window` event of WebContents has been deprecated. It is replaced by [`webContents.setWindowOpenHandler()` ](api/web-contents.md#contentssetwindowopenhandlerhandler ).
```js
// Deprecated in Electron 13
webContents.on('new-window', (event) => {
event.preventDefault()
})
// Replace with
webContents.setWindowOpenHandler((details) => {
return { action: 'deny' }
})
```
2020-05-07 20:31:26 +00:00
## Planned Breaking API Changes (12.0)
2020-10-16 01:30:41 +00:00
### Removed: Pepper Flash support
Chromium has removed support for Flash, and so we must follow suit. See
Chromium's [Flash Roadmap ](https://www.chromium.org/flash-roadmap ) for more
details.
2021-01-26 22:23:35 +00:00
### Default Changed: `worldSafeExecuteJavaScript` defaults to `true`
In Electron 12, `worldSafeExecuteJavaScript` will be enabled by default. To restore
the previous behavior, `worldSafeExecuteJavaScript: false` must be specified in WebPreferences.
Please note that setting this option to `false` is **insecure** .
This option will be removed in Electron 14 so please migrate your code to support the default
value.
2020-06-25 17:55:17 +00:00
### Default Changed: `contextIsolation` defaults to `true`
In Electron 12, `contextIsolation` will be enabled by default. To restore
the previous behavior, `contextIsolation: false` must be specified in WebPreferences.
2021-06-14 19:02:23 +00:00
We [recommend having contextIsolation enabled ](tutorial/security.md#3-enable-context-isolation-for-remote-content ) for the security of your application.
2020-06-25 17:55:17 +00:00
2021-03-12 07:42:15 +00:00
Another implication is that `require()` cannot be used in the renderer process unless
`nodeIntegration` is `true` and `contextIsolation` is `false` .
2020-06-25 17:55:17 +00:00
For more details see: https://github.com/electron/electron/issues/23506
2020-11-26 19:07:40 +00:00
### Removed: `crashReporter.getCrashesDirectory()`
The `crashReporter.getCrashesDirectory` method has been removed. Usage
should be replaced by `app.getPath('crashDumps')` .
```js
// Removed in Electron 12
crashReporter.getCrashesDirectory()
// Replace with
app.getPath('crashDumps')
```
2020-05-07 20:31:26 +00:00
### Removed: `crashReporter` methods in the renderer process
The following `crashReporter` methods are no longer available in the renderer
process:
2020-11-23 17:15:27 +00:00
* `crashReporter.start`
* `crashReporter.getLastCrashReport`
* `crashReporter.getUploadedReports`
* `crashReporter.getUploadToServer`
* `crashReporter.setUploadToServer`
* `crashReporter.getCrashesDirectory`
2020-05-07 20:31:26 +00:00
They should be called only from the main process.
See [#23265 ](https://github.com/electron/electron/pull/23265 ) for more details.
2020-05-19 20:47:21 +00:00
### Default Changed: `crashReporter.start({ compress: true })`
The default value of the `compress` option to `crashReporter.start` has changed
from `false` to `true` . This means that crash dumps will be uploaded to the
crash ingestion server with the `Content-Encoding: gzip` header, and the body
will be compressed.
If your crash ingestion server does not support compressed payloads, you can
turn off compression by specifying `{ compress: false }` in the crash reporter
options.
2020-09-10 16:17:17 +00:00
### Deprecated: `remote` module
The `remote` module is deprecated in Electron 12, and will be removed in
Electron 14. It is replaced by the
[`@electron/remote` ](https://github.com/electron/remote ) module.
```js
// Deprecated in Electron 12:
const { BrowserWindow } = require('electron').remote
```
```js
// Replace with:
const { BrowserWindow } = require('@electron/remote')
// In the main process:
require('@electron/remote/main').initialize()
```
2020-09-03 19:44:16 +00:00
### Deprecated: `shell.moveItemToTrash()`
The synchronous `shell.moveItemToTrash()` has been replaced by the new,
asynchronous `shell.trashItem()` .
```js
// Deprecated in Electron 12
shell.moveItemToTrash(path)
// Replace with
shell.trashItem(path).then(/* ... */)
```
2020-05-07 20:31:26 +00:00
## Planned Breaking API Changes (11.0)
2020-11-17 16:35:23 +00:00
### Removed: `BrowserView.{destroy, fromId, fromWebContents, getAllViews}` and `id` property of `BrowserView`
2020-11-19 04:58:47 +00:00
2020-11-17 16:35:23 +00:00
The experimental APIs `BrowserView.{destroy, fromId, fromWebContents, getAllViews}`
have now been removed. Additionally, the `id` property of `BrowserView`
has also been removed.
For more detailed information, see [#23578 ](https://github.com/electron/electron/pull/23578 ).
2020-05-19 19:39:51 +00:00
2020-02-10 18:49:09 +00:00
## Planned Breaking API Changes (10.0)
2020-05-07 20:31:26 +00:00
### Deprecated: `companyName` argument to `crashReporter.start()`
The `companyName` argument to `crashReporter.start()` , which was previously
required, is now optional, and further, is deprecated. To get the same
behavior in a non-deprecated way, you can pass a `companyName` value in
`globalExtra` .
```js
// Deprecated in Electron 10
crashReporter.start({ companyName: 'Umbrella Corporation' })
// Replace with
crashReporter.start({ globalExtra: { _companyName: 'Umbrella Corporation' } })
```
### Deprecated: `crashReporter.getCrashesDirectory()`
The `crashReporter.getCrashesDirectory` method has been deprecated. Usage
should be replaced by `app.getPath('crashDumps')` .
```js
// Deprecated in Electron 10
crashReporter.getCrashesDirectory()
// Replace with
app.getPath('crashDumps')
```
### Deprecated: `crashReporter` methods in the renderer process
Calling the following `crashReporter` methods from the renderer process is
deprecated:
2020-11-23 17:15:27 +00:00
* `crashReporter.start`
* `crashReporter.getLastCrashReport`
* `crashReporter.getUploadedReports`
* `crashReporter.getUploadToServer`
* `crashReporter.setUploadToServer`
* `crashReporter.getCrashesDirectory`
2020-05-07 20:31:26 +00:00
The only non-deprecated methods remaining in the `crashReporter` module in the
renderer are `addExtraParameter` , `removeExtraParameter` and `getParameters` .
All above methods remain non-deprecated when called from the main process.
See [#23265 ](https://github.com/electron/electron/pull/23265 ) for more details.
2020-05-19 20:47:21 +00:00
### Deprecated: `crashReporter.start({ compress: false })`
Setting `{ compress: false }` in `crashReporter.start` is deprecated. Nearly
all crash ingestion servers support gzip compression. This option will be
removed in a future version of Electron.
2020-03-26 17:57:55 +00:00
### Default Changed: `enableRemoteModule` defaults to `false`
2020-02-10 18:49:09 +00:00
In Electron 9, using the remote module without explicitly enabling it via the
`enableRemoteModule` WebPreferences option began emitting a warning. In
Electron 10, the remote module is now disabled by default. To use the remote
module, `enableRemoteModule: true` must be specified in WebPreferences:
```js
const w = new BrowserWindow({
webPreferences: {
enableRemoteModule: true
}
})
```
We [recommend moving away from the remote
module](https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31).
2020-10-14 17:17:07 +00:00
### `protocol.unregisterProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.uninterceptProtocol`
The APIs are now synchronous and the optional callback is no longer needed.
```javascript
// Deprecated
protocol.unregisterProtocol(scheme, () => { /* ... */ })
// Replace with
protocol.unregisterProtocol(scheme)
```
### `protocol.registerFileProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.registerBufferProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.registerStringProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.registerHttpProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.registerStreamProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.interceptFileProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.interceptStringProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.interceptBufferProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.interceptHttpProtocol`
2020-11-19 04:58:47 +00:00
2020-10-14 17:17:07 +00:00
### `protocol.interceptStreamProtocol`
The APIs are now synchronous and the optional callback is no longer needed.
```javascript
// Deprecated
protocol.registerFileProtocol(scheme, handler, () => { /* ... */ })
// Replace with
protocol.registerFileProtocol(scheme, handler)
```
The registered or intercepted protocol does not have effect on current page
until navigation happens.
### `protocol.isProtocolHandled`
This API is deprecated and users should use `protocol.isProtocolRegistered`
and `protocol.isProtocolIntercepted` instead.
```javascript
// Deprecated
protocol.isProtocolHandled(scheme).then(() => { /* ... */ })
// Replace with
const isRegistered = protocol.isProtocolRegistered(scheme)
const isIntercepted = protocol.isProtocolIntercepted(scheme)
```
2019-11-08 20:46:35 +00:00
## Planned Breaking API Changes (9.0)
2020-03-26 17:57:55 +00:00
### Default Changed: Loading non-context-aware native modules in the renderer process is disabled by default
2020-02-25 02:11:06 +00:00
As of Electron 9 we do not allow loading of non-context-aware native modules in
the renderer process. This is to improve security, performance and maintainability
of Electron as a project.
If this impacts you, you can temporarily set `app.allowRendererProcessReuse` to `false`
to revert to the old behavior. This flag will only be an option until Electron 11 so
you should plan to update your native modules to be context aware.
For more detailed information see [#18397 ](https://github.com/electron/electron/issues/18397 ).
2020-12-02 00:27:19 +00:00
### Deprecated: `BrowserWindow` extension APIs
The following extension APIs have been deprecated:
2020-12-08 07:08:19 +00:00
2020-12-02 00:27:19 +00:00
* `BrowserWindow.addExtension(path)`
* `BrowserWindow.addDevToolsExtension(path)`
* `BrowserWindow.removeExtension(name)`
* `BrowserWindow.removeDevToolsExtension(name)`
* `BrowserWindow.getExtensions()`
* `BrowserWindow.getDevToolsExtensions()`
Use the session APIs instead:
2020-12-08 07:08:19 +00:00
2020-12-02 00:27:19 +00:00
* `ses.loadExtension(path)`
* `ses.removeExtension(extension_id)`
* `ses.getAllExtensions()`
```js
// Deprecated in Electron 9
BrowserWindow.addExtension(path)
BrowserWindow.addDevToolsExtension(path)
// Replace with
session.defaultSession.loadExtension(path)
```
```js
// Deprecated in Electron 9
BrowserWindow.removeExtension(name)
BrowserWindow.removeDevToolsExtension(name)
// Replace with
session.defaultSession.removeExtension(extension_id)
```
```js
// Deprecated in Electron 9
BrowserWindow.getExtensions()
BrowserWindow.getDevToolsExtensions()
// Replace with
session.defaultSession.getAllExtensions()
```
2020-03-26 17:57:55 +00:00
### Removed: `<webview>.getWebContents()`
2019-11-08 20:46:35 +00:00
This API, which was deprecated in Electron 8.0, is now removed.
```js
// Removed in Electron 9.0
webview.getWebContents()
// Replace with
const { remote } = require('electron')
remote.webContents.fromId(webview.getWebContentsId())
```
2020-03-26 17:57:55 +00:00
### Removed: `webFrame.setLayoutZoomLevelLimits()`
2019-12-06 21:14:25 +00:00
Chromium has removed support for changing the layout zoom level limits, and it
is beyond Electron's capacity to maintain it. The function was deprecated in
Electron 8.x, and has been removed in Electron 9.x. The layout zoom level limits
are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined
[here ](https://chromium.googlesource.com/chromium/src/+/938b37a6d2886bf8335fc7db792f1eb46c65b2ae/third_party/blink/common/page/page_zoom.cc#11 ).
2020-03-26 17:57:55 +00:00
### Behavior Changed: Sending non-JS objects over IPC now throws an exception
2019-12-18 06:24:50 +00:00
In Electron 8.0, IPC was changed to use the Structured Clone Algorithm,
bringing significant performance improvements. To help ease the transition, the
old IPC serialization algorithm was kept and used for some objects that aren't
serializable with Structured Clone. In particular, DOM objects (e.g. `Element` ,
`Location` and `DOMMatrix` ), Node.js objects backed by C++ classes (e.g.
`process.env` , some members of `Stream` ), and Electron objects backed by C++
classes (e.g. `WebContents` , `BrowserWindow` and `WebFrame` ) are not
serializable with Structured Clone. Whenever the old algorithm was invoked, a
deprecation warning was printed.
In Electron 9.0, the old serialization algorithm has been removed, and sending
such non-serializable objects will now throw an "object could not be cloned"
error.
2020-03-26 17:57:55 +00:00
### API Changed: `shell.openItem` is now `shell.openPath`
2020-03-04 07:17:27 +00:00
The `shell.openItem` API has been replaced with an asynchronous `shell.openPath` API.
You can see the original API proposal and reasoning [here ](https://github.com/electron/governance/blob/master/wg-api/spec-documents/shell-openitem.md ).
2019-10-09 17:59:08 +00:00
## Planned Breaking API Changes (8.0)
2020-03-26 17:57:55 +00:00
### Behavior Changed: Values sent over IPC are now serialized with Structured Clone Algorithm
2019-10-09 17:59:08 +00:00
The algorithm used to serialize objects sent over IPC (through
`ipcRenderer.send` , `ipcRenderer.sendSync` , `WebContents.send` and related
methods) has been switched from a custom algorithm to V8's built-in [Structured
Clone Algorithm][SCA], the same algorithm used to serialize messages for
`postMessage` . This brings about a 2x performance improvement for large
messages, but also brings some breaking changes in behavior.
2020-11-23 17:15:27 +00:00
* Sending Functions, Promises, WeakMaps, WeakSets, or objects containing any
2019-10-09 17:59:08 +00:00
such values, over IPC will now throw an exception, instead of silently
converting the functions to `undefined` .
2020-11-05 22:12:43 +00:00
2019-10-09 17:59:08 +00:00
```js
// Previously:
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
// => results in { value: 3 } arriving in the main process
// From Electron 8:
ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
// => throws Error("() => {} could not be cloned.")
```
2020-11-05 22:12:43 +00:00
2020-11-23 17:15:27 +00:00
* `NaN` , `Infinity` and `-Infinity` will now be correctly serialized, instead
2019-10-09 17:59:08 +00:00
of being converted to `null` .
2020-11-23 17:15:27 +00:00
* Objects containing cyclic references will now be correctly serialized,
2019-10-09 17:59:08 +00:00
instead of being converted to `null` .
2020-11-23 17:15:27 +00:00
* `Set` , `Map` , `Error` and `RegExp` values will be correctly serialized,
2019-10-09 17:59:08 +00:00
instead of being converted to `{}` .
2020-11-23 17:15:27 +00:00
* `BigInt` values will be correctly serialized, instead of being converted to
2019-10-09 17:59:08 +00:00
`null` .
2020-11-23 17:15:27 +00:00
* Sparse arrays will be serialized as such, instead of being converted to dense
2019-10-09 17:59:08 +00:00
arrays with `null` s.
2020-11-23 17:15:27 +00:00
* `Date` objects will be transferred as `Date` objects, instead of being
2019-10-09 17:59:08 +00:00
converted to their ISO string representation.
2020-11-23 17:15:27 +00:00
* Typed Arrays (such as `Uint8Array` , `Uint16Array` , `Uint32Array` and so on)
2019-10-09 17:59:08 +00:00
will be transferred as such, instead of being converted to Node.js `Buffer` .
2020-11-23 17:15:27 +00:00
* Node.js `Buffer` objects will be transferred as `Uint8Array` s. You can
2019-10-09 17:59:08 +00:00
convert a `Uint8Array` back to a Node.js `Buffer` by wrapping the underlying
`ArrayBuffer` :
2020-11-05 22:12:43 +00:00
2019-10-09 17:59:08 +00:00
```js
Buffer.from(value.buffer, value.byteOffset, value.byteLength)
```
Sending any objects that aren't native JS types, such as DOM objects (e.g.
`Element` , `Location` , `DOMMatrix` ), Node.js objects (e.g. `process.env` ,
`Stream` ), or Electron objects (e.g. `WebContents` , `BrowserWindow` ,
`WebFrame` ) is deprecated. In Electron 8, these objects will be serialized as
before with a DeprecationWarning message, but starting in Electron 9, sending
these kinds of objects will throw a 'could not be cloned' error.
[SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
2020-03-26 17:57:55 +00:00
### Deprecated: `<webview>.getWebContents()`
2019-11-07 17:43:19 +00:00
This API is implemented using the `remote` module, which has both performance
and security implications. Therefore its usage should be explicit.
```js
// Deprecated
webview.getWebContents()
// Replace with
const { remote } = require('electron')
remote.webContents.fromId(webview.getWebContentsId())
```
However, it is recommended to avoid using the `remote` module altogether.
```js
// main
const { ipcMain, webContents } = require('electron')
2020-01-13 01:29:46 +00:00
const getGuestForWebContents = (webContentsId, contents) => {
2019-11-07 17:43:19 +00:00
const guest = webContents.fromId(webContentsId)
if (!guest) {
throw new Error(`Invalid webContentsId: ${webContentsId}`)
}
if (guest.hostWebContents !== contents) {
2020-07-09 17:18:49 +00:00
throw new Error('Access denied to webContents')
2019-11-07 17:43:19 +00:00
}
return guest
}
ipcMain.handle('openDevTools', (event, webContentsId) => {
const guest = getGuestForWebContents(webContentsId, event.sender)
guest.openDevTools()
})
// renderer
const { ipcRenderer } = require('electron')
ipcRenderer.invoke('openDevTools', webview.getWebContentsId())
```
2020-03-26 17:57:55 +00:00
### Deprecated: `webFrame.setLayoutZoomLevelLimits()`
2019-12-02 21:27:03 +00:00
Chromium has removed support for changing the layout zoom level limits, and it
is beyond Electron's capacity to maintain it. The function will emit a warning
in Electron 8.x, and cease to exist in Electron 9.x. The layout zoom level
limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined
[here ](https://chromium.googlesource.com/chromium/src/+/938b37a6d2886bf8335fc7db792f1eb46c65b2ae/third_party/blink/common/page/page_zoom.cc#11 ).
2020-12-11 00:42:23 +00:00
### Deprecated events in `systemPreferences`
The following `systemPreferences` events have been deprecated:
2021-01-14 08:31:26 +00:00
2020-12-11 00:42:23 +00:00
* `inverted-color-scheme-changed`
* `high-contrast-color-scheme-changed`
Use the new `updated` event on the `nativeTheme` module instead.
```js
// Deprecated
systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ })
systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ })
// Replace with
nativeTheme.on('updated', () => { /* ... */ })
```
### Deprecated: methods in `systemPreferences`
The following `systemPreferences` methods have been deprecated:
2021-01-14 08:31:26 +00:00
2020-12-11 00:42:23 +00:00
* `systemPreferences.isDarkMode()`
* `systemPreferences.isInvertedColorScheme()`
* `systemPreferences.isHighContrastColorScheme()`
Use the following `nativeTheme` properties instead:
2021-01-14 08:31:26 +00:00
2020-12-11 00:42:23 +00:00
* `nativeTheme.shouldUseDarkColors`
* `nativeTheme.shouldUseInvertedColorScheme`
* `nativeTheme.shouldUseHighContrastColors`
```js
// Deprecated
systemPreferences.isDarkMode()
// Replace with
nativeTheme.shouldUseDarkColors
// Deprecated
systemPreferences.isInvertedColorScheme()
// Replace with
nativeTheme.shouldUseInvertedColorScheme
// Deprecated
systemPreferences.isHighContrastColorScheme()
// Replace with
nativeTheme.shouldUseHighContrastColors
```
2019-05-09 14:58:02 +00:00
## Planned Breaking API Changes (7.0)
2020-03-26 17:57:55 +00:00
### Deprecated: Atom.io Node Headers URL
2019-05-21 07:17:08 +00:00
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
command line flag when building native Node modules. Both will be supported for
2019-06-21 21:19:21 +00:00
the foreseeable future but it is recommended that you switch.
2019-05-21 07:17:08 +00:00
Deprecated: https://atom.io/download/electron
Replace with: https://electronjs.org/headers
2020-03-26 17:57:55 +00:00
### API Changed: `session.clearAuthCache()` no longer accepts options
2019-05-09 14:58:02 +00:00
The `session.clearAuthCache` API no longer accepts options for what to clear, and instead unconditionally clears the whole cache.
```js
// Deprecated
session.clearAuthCache({ type: 'password' })
// Replace with
session.clearAuthCache()
```
2020-03-26 17:57:55 +00:00
### API Changed: `powerMonitor.querySystemIdleState` is now `powerMonitor.getSystemIdleState`
2019-05-09 18:48:10 +00:00
```js
// Removed in Electron 7.0
powerMonitor.querySystemIdleState(threshold, callback)
// Replace with synchronous API
2020-03-26 17:57:55 +00:00
const idleState = powerMonitor.getSystemIdleState(threshold)
2019-05-09 18:48:10 +00:00
```
2020-07-15 16:31:54 +00:00
### API Changed: `powerMonitor.querySystemIdleTime` is now `powerMonitor.getSystemIdleTime`
2019-05-09 18:48:10 +00:00
```js
// Removed in Electron 7.0
powerMonitor.querySystemIdleTime(callback)
// Replace with synchronous API
2020-03-26 17:57:55 +00:00
const idleTime = powerMonitor.getSystemIdleTime()
2019-05-09 18:48:10 +00:00
```
2020-03-26 17:57:55 +00:00
### API Changed: `webFrame.setIsolatedWorldInfo` replaces separate methods
2019-05-09 18:48:10 +00:00
```js
2019-11-13 19:11:25 +00:00
// Removed in Electron 7.0
2019-05-09 18:48:10 +00:00
webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
webFrame.setIsolatedWorldHumanReadableName(worldId, name)
webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
// Replace with
webFrame.setIsolatedWorldInfo(
worldId,
{
securityOrigin: 'some_origin',
name: 'human_readable_name',
csp: 'content_security_policy'
})
```
2020-03-26 17:57:55 +00:00
### Removed: `marked` property on `getBlinkMemoryInfo`
2019-07-03 01:22:09 +00:00
This property was removed in Chromium 77, and as such is no longer available.
2020-03-26 17:57:55 +00:00
### Behavior Changed: `webkitdirectory` attribute for `<input type="file"/>` now lists directory contents
2019-11-13 19:11:25 +00:00
The `webkitdirectory` property on HTML file inputs allows them to select folders.
Previous versions of Electron had an incorrect implementation where the `event.target.files`
of the input returned a `FileList` that returned one `File` corresponding to the selected folder.
As of Electron 7, that `FileList` is now list of all files contained within
the folder, similarly to Chrome, Firefox, and Edge
([link to MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)).
As an illustration, take a folder with this structure:
2020-11-05 22:12:43 +00:00
2019-11-13 19:11:25 +00:00
```console
folder
├── file1
├── file2
└── file3
```
In Electron < =6, this would return a `FileList` with a `File` object for:
2020-11-05 22:12:43 +00:00
2019-11-13 19:11:25 +00:00
```console
path/to/folder
```
In Electron 7, this now returns a `FileList` with a `File` object for:
2020-11-05 22:12:43 +00:00
2019-11-13 19:11:25 +00:00
```console
/path/to/folder/file3
/path/to/folder/file2
/path/to/folder/file1
```
Note that `webkitdirectory` no longer exposes the path to the selected folder.
If you require the path to the selected folder rather than the folder contents,
2021-06-14 19:02:23 +00:00
see the `dialog.showOpenDialog` API ([link](api/dialog.md#dialogshowopendialogbrowserwindow-options)).
2020-03-26 17:57:55 +00:00
2021-02-03 06:57:33 +00:00
### API Changed: Callback-based versions of promisified APIs
Electron 5 and Electron 6 introduced Promise-based versions of existing
asynchronous APIs and deprecated their older, callback-based counterparts.
In Electron 7, all deprecated callback-based APIs are now removed.
These functions now only return Promises:
* `app.getFileIcon()` [#15742 ](https://github.com/electron/electron/pull/15742 )
* `app.dock.show()` [#16904 ](https://github.com/electron/electron/pull/16904 )
* `contentTracing.getCategories()` [#16583 ](https://github.com/electron/electron/pull/16583 )
* `contentTracing.getTraceBufferUsage()` [#16600 ](https://github.com/electron/electron/pull/16600 )
* `contentTracing.startRecording()` [#16584 ](https://github.com/electron/electron/pull/16584 )
* `contentTracing.stopRecording()` [#16584 ](https://github.com/electron/electron/pull/16584 )
* `contents.executeJavaScript()` [#17312 ](https://github.com/electron/electron/pull/17312 )
* `cookies.flushStore()` [#16464 ](https://github.com/electron/electron/pull/16464 )
* `cookies.get()` [#16464 ](https://github.com/electron/electron/pull/16464 )
* `cookies.remove()` [#16464 ](https://github.com/electron/electron/pull/16464 )
* `cookies.set()` [#16464 ](https://github.com/electron/electron/pull/16464 )
* `debugger.sendCommand()` [#16861 ](https://github.com/electron/electron/pull/16861 )
* `dialog.showCertificateTrustDialog()` [#17181 ](https://github.com/electron/electron/pull/17181 )
* `inAppPurchase.getProducts()` [#17355 ](https://github.com/electron/electron/pull/17355 )
* `inAppPurchase.purchaseProduct()` [#17355 ](https://github.com/electron/electron/pull/17355 )
* `netLog.stopLogging()` [#16862 ](https://github.com/electron/electron/pull/16862 )
* `session.clearAuthCache()` [#17259 ](https://github.com/electron/electron/pull/17259 )
* `session.clearCache()` [#17185 ](https://github.com/electron/electron/pull/17185 )
* `session.clearHostResolverCache()` [#17229 ](https://github.com/electron/electron/pull/17229 )
* `session.clearStorageData()` [#17249 ](https://github.com/electron/electron/pull/17249 )
* `session.getBlobData()` [#17303 ](https://github.com/electron/electron/pull/17303 )
* `session.getCacheSize()` [#17185 ](https://github.com/electron/electron/pull/17185 )
* `session.resolveProxy()` [#17222 ](https://github.com/electron/electron/pull/17222 )
* `session.setProxy()` [#17222 ](https://github.com/electron/electron/pull/17222 )
* `shell.openExternal()` [#16176 ](https://github.com/electron/electron/pull/16176 )
* `webContents.loadFile()` [#15855 ](https://github.com/electron/electron/pull/15855 )
* `webContents.loadURL()` [#15855 ](https://github.com/electron/electron/pull/15855 )
* `webContents.hasServiceWorker()` [#16535 ](https://github.com/electron/electron/pull/16535 )
* `webContents.printToPDF()` [#16795 ](https://github.com/electron/electron/pull/16795 )
* `webContents.savePage()` [#16742 ](https://github.com/electron/electron/pull/16742 )
* `webFrame.executeJavaScript()` [#17312 ](https://github.com/electron/electron/pull/17312 )
* `webFrame.executeJavaScriptInIsolatedWorld()` [#17312 ](https://github.com/electron/electron/pull/17312 )
* `webviewTag.executeJavaScript()` [#17312 ](https://github.com/electron/electron/pull/17312 )
* `win.capturePage()` [#15743 ](https://github.com/electron/electron/pull/15743 )
These functions now have two forms, synchronous and Promise-based asynchronous:
* `dialog.showMessageBox()` /`dialog.showMessageBoxSync()` [#17298 ](https://github.com/electron/electron/pull/17298 )
* `dialog.showOpenDialog()` /`dialog.showOpenDialogSync()` [#16973 ](https://github.com/electron/electron/pull/16973 )
* `dialog.showSaveDialog()` /`dialog.showSaveDialogSync()` [#17054 ](https://github.com/electron/electron/pull/17054 )
2019-04-25 22:14:19 +00:00
## Planned Breaking API Changes (6.0)
2018-12-17 22:01:00 +00:00
2020-03-26 17:57:55 +00:00
### API Changed: `win.setMenu(null)` is now `win.removeMenu()`
2019-01-31 18:58:23 +00:00
```js
// Deprecated
win.setMenu(null)
// Replace with
win.removeMenu()
```
2020-03-26 17:57:55 +00:00
### API Changed: `electron.screen` in the renderer process should be accessed via `remote`
2018-12-17 22:01:00 +00:00
```js
// Deprecated
require('electron').screen
// Replace with
require('electron').remote.screen
```
2020-03-26 17:57:55 +00:00
### API Changed: `require()`ing node builtins in sandboxed renderers no longer implicitly loads the `remote` version
2018-12-17 22:01:00 +00:00
```js
// Deprecated
require('child_process')
// Replace with
require('electron').remote.require('child_process')
// Deprecated
require('fs')
// Replace with
require('electron').remote.require('fs')
// Deprecated
require('os')
// Replace with
require('electron').remote.require('os')
// Deprecated
require('path')
// Replace with
require('electron').remote.require('path')
```
2020-03-26 17:57:55 +00:00
### Deprecated: `powerMonitor.querySystemIdleState` replaced with `powerMonitor.getSystemIdleState`
2019-02-27 20:54:01 +00:00
```js
// Deprecated
powerMonitor.querySystemIdleState(threshold, callback)
// Replace with synchronous API
2020-03-26 17:57:55 +00:00
const idleState = powerMonitor.getSystemIdleState(threshold)
2019-02-27 20:54:01 +00:00
```
2020-03-26 17:57:55 +00:00
### Deprecated: `powerMonitor.querySystemIdleTime` replaced with `powerMonitor.getSystemIdleTime`
2019-02-27 20:54:01 +00:00
```js
// Deprecated
powerMonitor.querySystemIdleTime(callback)
// Replace with synchronous API
2020-03-26 17:57:55 +00:00
const idleTime = powerMonitor.getSystemIdleTime()
2019-02-27 20:54:01 +00:00
```
2020-03-26 17:57:55 +00:00
### Deprecated: `app.enableMixedSandbox()` is no longer needed
2019-04-24 04:07:40 +00:00
```js
// Deprecated
app.enableMixedSandbox()
```
Mixed-sandbox mode is now enabled by default.
2020-03-26 17:57:55 +00:00
### Deprecated: `Tray.setHighlightMode`
2019-07-11 15:11:46 +00:00
Under macOS Catalina our former Tray implementation breaks.
Apple's native substitute doesn't support changing the highlighting behavior.
```js
// Deprecated
tray.setHighlightMode(mode)
// API will be removed in v7.0 without replacement.
```
2019-04-25 22:14:19 +00:00
## Planned Breaking API Changes (5.0)
2018-10-10 05:36:18 +00:00
2020-03-26 17:57:55 +00:00
### Default Changed: `nodeIntegration` and `webviewTag` default to false, `contextIsolation` defaults to true
2018-10-10 05:36:18 +00:00
The following `webPreferences` option default values are deprecated in favor of the new defaults listed below.
| Property | Deprecated Default | New Default |
|----------|--------------------|-------------|
| `contextIsolation` | `false` | `true` |
| `nodeIntegration` | `true` | `false` |
| `webviewTag` | `nodeIntegration` if set else `true` | `false` |
2019-04-26 20:30:45 +00:00
E.g. Re-enabling the webviewTag
```js
const w = new BrowserWindow({
webPreferences: {
webviewTag: true
}
})
```
2020-03-26 17:57:55 +00:00
### Behavior Changed: `nodeIntegration` in child windows opened via `nativeWindowOpen`
2018-10-25 06:31:07 +00:00
2020-03-26 17:57:55 +00:00
Child windows opened with the `nativeWindowOpen` option will always have Node.js integration disabled, unless `nodeIntegrationInSubFrames` is `true` .
2018-05-29 09:15:30 +00:00
2020-03-26 17:57:55 +00:00
### API Changed: Registering privileged schemes must now be done before app ready
2019-01-29 07:11:01 +00:00
2020-03-26 17:57:55 +00:00
Renderer process APIs `webFrame.registerURLSchemeAsPrivileged` and `webFrame.registerURLSchemeAsBypassingCSP` as well as browser process API `protocol.registerStandardSchemes` have been removed.
2019-01-29 07:11:01 +00:00
A new API, `protocol.registerSchemesAsPrivileged` has been added and should be used for registering custom schemes with the required privileges. Custom schemes are required to be registered before app ready.
2020-03-26 17:57:55 +00:00
### Deprecated: `webFrame.setIsolatedWorld*` replaced with `webFrame.setIsolatedWorldInfo`
2019-02-13 18:05:28 +00:00
```js
// Deprecated
webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
webFrame.setIsolatedWorldHumanReadableName(worldId, name)
webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
// Replace with
webFrame.setIsolatedWorldInfo(
worldId,
{
securityOrigin: 'some_origin',
name: 'human_readable_name',
csp: 'content_security_policy'
})
```
2020-03-26 17:57:55 +00:00
### API Changed: `webFrame.setSpellCheckProvider` now takes an asynchronous callback
2020-11-05 22:12:43 +00:00
2019-06-03 18:56:46 +00:00
The `spellCheck` callback is now asynchronous, and `autoCorrectWord` parameter has been removed.
2020-11-05 22:12:43 +00:00
2019-06-03 18:56:46 +00:00
```js
// Deprecated
webFrame.setSpellCheckProvider('en-US', true, {
spellCheck: (text) => {
return !spellchecker.isMisspelled(text)
}
})
// Replace with
webFrame.setSpellCheckProvider('en-US', {
spellCheck: (words, callback) => {
callback(words.filter(text => spellchecker.isMisspelled(text)))
}
})
```
2021-02-03 06:57:33 +00:00
### API Changed: `webContents.getZoomLevel` and `webContents.getZoomFactor` are now synchronous
`webContents.getZoomLevel` and `webContents.getZoomFactor` no longer take callback parameters,
instead directly returning their number values.
```js
// Deprecated
webContents.getZoomLevel((level) => {
console.log(level)
})
// Replace with
const level = webContents.getZoomLevel()
console.log(level)
```
```js
// Deprecated
webContents.getZoomFactor((factor) => {
console.log(factor)
})
// Replace with
const factor = webContents.getZoomFactor()
console.log(factor)
```
2019-04-25 22:14:19 +00:00
## Planned Breaking API Changes (4.0)
2018-05-29 09:17:26 +00:00
2019-01-31 18:58:23 +00:00
The following list includes the breaking API changes made in Electron 4.0.
2018-05-29 09:17:26 +00:00
2019-04-25 22:14:19 +00:00
### `app.makeSingleInstance`
2018-05-29 09:17:26 +00:00
```js
// Deprecated
2018-12-05 12:14:52 +00:00
app.makeSingleInstance((argv, cwd) => {
/* ... */
2018-05-29 09:17:26 +00:00
})
// Replace with
app.requestSingleInstanceLock()
2018-12-05 12:14:52 +00:00
app.on('second-instance', (event, argv, cwd) => {
/* ... */
2018-05-29 09:17:26 +00:00
})
```
2019-04-25 22:14:19 +00:00
### `app.releaseSingleInstance`
2018-05-29 09:17:26 +00:00
```js
// Deprecated
app.releaseSingleInstance()
// Replace with
app.releaseSingleInstanceLock()
```
2019-04-25 22:14:19 +00:00
### `app.getGPUInfo`
2018-10-08 04:06:50 +00:00
```js
app.getGPUInfo('complete')
// Now behaves the same with `basic` on macOS
app.getGPUInfo('basic')
```
2019-04-25 22:14:19 +00:00
### `win_delay_load_hook`
2018-11-20 00:13:50 +00:00
When building native modules for windows, the `win_delay_load_hook` variable in
the module's `binding.gyp` must be true (which is the default). If this hook is
not present, then the native module will fail to load on Windows, with an error
message like `Cannot find module` . See the [native module
guide](/docs/tutorial/using-native-node-modules.md) for more.
2019-04-25 22:14:19 +00:00
## Breaking API Changes (3.0)
2016-09-07 18:41:54 +00:00
2018-06-27 06:47:01 +00:00
The following list includes the breaking API changes in Electron 3.0.
2016-09-07 18:41:54 +00:00
2019-04-25 22:14:19 +00:00
### `app`
2017-05-18 03:01:06 +00:00
```js
// Deprecated
app.getAppMemoryInfo()
// Replace with
app.getAppMetrics()
2018-06-27 06:47:01 +00:00
// Deprecated
const metrics = app.getAppMetrics()
2018-09-13 16:10:51 +00:00
const { memory } = metrics[0] // Deprecated property
2017-05-18 03:01:06 +00:00
```
2019-04-25 22:14:19 +00:00
### `BrowserWindow`
2016-09-08 16:09:49 +00:00
```js
// Deprecated
2020-07-09 17:18:49 +00:00
const optionsA = { webPreferences: { blinkFeatures: '' } }
const windowA = new BrowserWindow(optionsA)
2016-09-08 16:09:49 +00:00
// Replace with
2020-07-09 17:18:49 +00:00
const optionsB = { webPreferences: { enableBlinkFeatures: '' } }
const windowB = new BrowserWindow(optionsB)
2018-05-21 01:52:04 +00:00
// Deprecated
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play_pause') {
// do something
}
})
// Replace with
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play-pause') {
// do something
}
})
2016-09-08 16:09:49 +00:00
```
2019-04-25 22:14:19 +00:00
### `clipboard`
2016-09-08 16:09:49 +00:00
2016-09-07 18:41:54 +00:00
```js
// Deprecated
clipboard.readRtf()
// Replace with
clipboard.readRTF()
// Deprecated
clipboard.writeRtf()
// Replace with
clipboard.writeRTF()
// Deprecated
clipboard.readHtml()
// Replace with
clipboard.readHTML()
// Deprecated
clipboard.writeHtml()
// Replace with
clipboard.writeHTML()
2016-09-08 16:09:49 +00:00
```
2019-04-25 22:14:19 +00:00
### `crashReporter`
2016-11-28 23:06:03 +00:00
```js
// Deprecated
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
autoSubmit: true
})
// Replace with
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
uploadToServer: true
})
```
2019-04-25 22:14:19 +00:00
### `nativeImage`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
2016-12-14 18:12:37 +00:00
// Deprecated
nativeImage.createFromBuffer(buffer, 1.0)
// Replace with
nativeImage.createFromBuffer(buffer, {
scaleFactor: 1.0
})
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
2019-04-25 22:14:19 +00:00
### `process`
2018-06-27 06:47:01 +00:00
```js
// Deprecated
const info = process.getProcessMemoryInfo()
```
2019-04-25 22:14:19 +00:00
### `screen`
2016-09-16 22:57:07 +00:00
```js
// Deprecated
2018-03-07 07:06:33 +00:00
screen.getMenuBarHeight()
2016-09-16 22:57:07 +00:00
// Replace with
2018-03-07 07:06:33 +00:00
screen.getPrimaryDisplay().workArea
2016-09-16 22:57:07 +00:00
```
2019-04-25 22:14:19 +00:00
### `session`
2017-02-07 23:44:56 +00:00
```js
// Deprecated
2018-12-05 12:14:52 +00:00
ses.setCertificateVerifyProc((hostname, certificate, callback) => {
2017-02-07 23:44:56 +00:00
callback(true)
})
// Replace with
2018-12-05 12:14:52 +00:00
ses.setCertificateVerifyProc((request, callback) => {
2017-02-07 23:44:56 +00:00
callback(0)
})
```
2019-04-25 22:14:19 +00:00
### `Tray`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
2016-09-07 18:41:54 +00:00
// Deprecated
tray.setHighlightMode(true)
// Replace with
tray.setHighlightMode('on')
// Deprecated
tray.setHighlightMode(false)
// Replace with
tray.setHighlightMode('off')
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
2019-04-25 22:14:19 +00:00
### `webContents`
2016-09-08 16:09:49 +00:00
```js
2016-09-07 18:41:54 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ detach: true })
2016-09-07 18:41:54 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ mode: 'detach' })
2018-08-23 01:45:43 +00:00
// Removed
webContents.setSize(options)
// There is no replacement for this API
2016-09-07 18:41:54 +00:00
```
2016-11-04 21:30:14 +00:00
2019-04-25 22:14:19 +00:00
### `webFrame`
2016-11-22 16:11:14 +00:00
```js
2016-11-14 18:33:30 +00:00
// Deprecated
webFrame.registerURLSchemeAsSecure('app')
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
2016-11-14 18:33:30 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webFrame.registerURLSchemeAsPrivileged('app', { secure: true })
2016-11-14 18:33:30 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
2016-11-22 16:11:14 +00:00
```
2019-04-25 22:14:19 +00:00
### `<webview>`
2018-08-23 01:45:43 +00:00
```js
// Removed
webview.setAttribute('disableguestresize', '')
// There is no replacement for this API
// Removed
webview.setAttribute('guestinstance', instanceId)
// There is no replacement for this API
2018-08-29 06:59:23 +00:00
// Keyboard listeners no longer work on webview tag
webview.onkeydown = () => { /* handler */ }
webview.onkeyup = () => { /* handler */ }
2018-08-23 01:45:43 +00:00
```
2019-04-25 22:14:19 +00:00
### Node Headers URL
2016-11-04 21:30:14 +00:00
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
command line flag when building native Node modules.
Deprecated: https://atom.io/download/atom-shell
Replace with: https://atom.io/download/electron
2017-06-15 19:46:25 +00:00
2019-04-25 22:14:19 +00:00
## Breaking API Changes (2.0)
2018-05-29 09:23:28 +00:00
2018-05-29 09:42:20 +00:00
The following list includes the breaking API changes made in Electron 2.0.
2019-04-25 22:14:19 +00:00
### `BrowserWindow`
2018-05-29 09:23:28 +00:00
```js
// Deprecated
2020-07-09 17:18:49 +00:00
const optionsA = { titleBarStyle: 'hidden-inset' }
const windowA = new BrowserWindow(optionsA)
2018-05-29 09:23:28 +00:00
// Replace with
2020-07-09 17:18:49 +00:00
const optionsB = { titleBarStyle: 'hiddenInset' }
const windowB = new BrowserWindow(optionsB)
2018-05-29 09:23:28 +00:00
```
2019-04-25 22:14:19 +00:00
### `menu`
2018-05-29 09:23:28 +00:00
```js
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
menu.popup(browserWindow, 100, 200, 2)
2018-05-29 09:37:42 +00:00
// Replaced with
2018-09-13 16:10:51 +00:00
menu.popup(browserWindow, { x: 100, y: 200, positioningItem: 2 })
2018-05-29 09:23:28 +00:00
```
2019-04-25 22:14:19 +00:00
### `nativeImage`
2018-05-29 09:23:28 +00:00
```js
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
nativeImage.toPng()
2018-05-29 09:37:42 +00:00
// Replaced with
2018-05-29 09:23:28 +00:00
nativeImage.toPNG()
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
nativeImage.toJpeg()
2018-05-29 09:37:42 +00:00
// Replaced with
2018-05-29 09:23:28 +00:00
nativeImage.toJPEG()
```
2019-04-25 22:14:19 +00:00
### `process`
2018-05-29 09:23:28 +00:00
* `process.versions.electron` and `process.version.chrome` will be made
read-only properties for consistency with the other `process.versions`
properties set by Node.
2019-04-25 22:14:19 +00:00
### `webContents`
2018-05-29 09:23:28 +00:00
```js
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
webContents.setZoomLevelLimits(1, 2)
2018-05-29 09:37:42 +00:00
// Replaced with
2018-05-29 09:23:28 +00:00
webContents.setVisualZoomLevelLimits(1, 2)
```
2019-04-25 22:14:19 +00:00
### `webFrame`
2018-05-29 09:23:28 +00:00
```js
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
webFrame.setZoomLevelLimits(1, 2)
2018-05-29 09:37:42 +00:00
// Replaced with
2018-05-29 09:23:28 +00:00
webFrame.setVisualZoomLevelLimits(1, 2)
```
2019-04-25 22:14:19 +00:00
### `<webview>`
2018-05-29 09:23:28 +00:00
```js
2018-05-29 09:37:42 +00:00
// Removed
2018-05-29 09:23:28 +00:00
webview.setZoomLevelLimits(1, 2)
2018-05-29 09:37:42 +00:00
// Replaced with
2018-05-29 09:23:28 +00:00
webview.setVisualZoomLevelLimits(1, 2)
```
2019-04-25 22:14:19 +00:00
### Duplicate ARM Assets
2018-05-29 09:23:28 +00:00
2018-05-29 09:37:42 +00:00
Each Electron release includes two identical ARM builds with slightly different
filenames, like `electron-v1.7.3-linux-arm.zip` and
`electron-v1.7.3-linux-armv7l.zip` . The asset with the `v7l` prefix was added
to clarify to users which ARM version it supports, and to disambiguate it from
2018-05-29 09:23:28 +00:00
future armv6l and arm64 assets that may be produced.
2018-05-29 09:37:42 +00:00
The file _without the prefix_ is still being published to avoid breaking any
2019-06-21 21:19:21 +00:00
setups that may be consuming it. Starting at 2.0, the unprefixed file will
2018-05-29 09:23:28 +00:00
no longer be published.
For details, see
[6986 ](https://github.com/electron/electron/pull/6986 )
2018-05-29 09:37:42 +00:00
and
2018-05-29 09:23:28 +00:00
[7189 ](https://github.com/electron/electron/pull/7189 ).