Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove File.path #42053

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ These individual tutorials expand on topics discussed in the guide above.

### Custom DOM Elements:

* [`File` Object](api/file-object.md)
* [`<webview>` Tag](api/webview-tag.md)
* [`window.open` Function](api/window-open.md)

Expand Down
36 changes: 0 additions & 36 deletions docs/api/file-object.md

This file was deleted.

32 changes: 32 additions & 0 deletions docs/breaking-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@ This document uses the following convention to categorize breaking changes:
* **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.

## Planned Breaking API Changes (32.0)

### Removed: `File.path`

The nonstandard `path` property of the Web `File` object was added in an early version of Electron as a convenience method for working with native files when doing everything in the renderer was more common. However, it represents a deviation from the standard and poses a minor security risk as well, so beginning in Electron 32.0 it has been removed in favor of the [`webUtils.getPathForFile`](api/web-utils.md#webutilsgetpathforfilefile) method.

```js
// Before (renderer)

const file = document.querySelector('input[type=file]')
alert(`Uploaded file path was: ${file.path}`)
```

```js
// After (renderer)

const file = document.querySelector('input[type=file]')
electron.showFilePath(file)

// (preload)
const { contextBridge, webUtils } = require('electron')

contextBridge.exposeInMainWorld('electron', {
showFilePath (file) {
// It's best not to expose the full file path to the web content if
// possible.
const path = webUtils.getPathForFile(file)
alert(`Uploaded file path was: ${path}`)
}
})
```

## Planned Breaking API Changes (31.0)

### Behavior Changed: `nativeImage.toDataURL` will preseve PNG colorspace
Expand Down
1 change: 0 additions & 1 deletion filenames.auto.gni
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ auto_filenames = {
"docs/api/download-item.md",
"docs/api/environment-variables.md",
"docs/api/extensions.md",
"docs/api/file-object.md",
"docs/api/global-shortcut.md",
"docs/api/in-app-purchase.md",
"docs/api/incoming-message.md",
Expand Down
1 change: 0 additions & 1 deletion patches/chromium/.patches
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build_gn.patch
accelerator.patch
blink_file_path.patch
blink_local_frame.patch
can_create_window.patch
disable_hidden.patch
Expand Down
34 changes: 0 additions & 34 deletions patches/chromium/blink_file_path.patch

This file was deleted.

26 changes: 0 additions & 26 deletions spec/ts-smoke/electron/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,6 @@ function getUserMediaError (error: Error) {
console.log('getUserMediaError', error);
}

// File object
// https://github.com/electron/electron/blob/main/docs/api/file-object.md

/*
<div id="holder">
Drag your file here
</div>
*/

const holder = document.getElementById('holder');

holder.ondragover = function () {
return false;
};

holder.ondragleave = holder.ondragend = function () {
return false;
};

holder.ondrop = function (e) {
e.preventDefault();
const file = e.dataTransfer.files[0];
console.log('File you dragged here is', file.path);
return false;
};

// nativeImage
// https://github.com/electron/electron/blob/main/docs/api/native-image.md

Expand Down