fix: used local files array instead of mutating outside event
This commit is contained in:
parent
70dac18fa3
commit
06736cbcdf
@ -153,18 +153,18 @@ class InputWaiter {
|
|||||||
paste(event, view) {
|
paste(event, view) {
|
||||||
const clipboardData = event.clipboardData;
|
const clipboardData = event.clipboardData;
|
||||||
const items = clipboardData.items;
|
const items = clipboardData.items;
|
||||||
event.target.files = [];
|
const files = [];
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const item = items[i];
|
const item = items[i];
|
||||||
if (item.kind === "file") {
|
if (item.kind === "file") {
|
||||||
const file = item.getAsFile();
|
const file = item.getAsFile();
|
||||||
event.target.files.push(file);
|
files.push(file);
|
||||||
|
|
||||||
event.preventDefault(); // Prevent the default paste behavior
|
event.preventDefault(); // Prevent the default paste behavior
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.afterPaste(event);
|
self.afterPaste(files);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -926,11 +926,11 @@ class InputWaiter {
|
|||||||
* Handler that fires just after input paste events.
|
* Handler that fires just after input paste events.
|
||||||
* Checks whether the EOL separator or character encoding should be updated.
|
* Checks whether the EOL separator or character encoding should be updated.
|
||||||
*
|
*
|
||||||
* @param {event} e
|
* @param {File[]} files - An array of any files that were included in the paste event
|
||||||
*/
|
*/
|
||||||
afterPaste(e) {
|
afterPaste(files) {
|
||||||
if (e.target.files.length > 0) {
|
if (files.length > 0) {
|
||||||
this.loadUIFiles(e.target.files);
|
this.loadUIFiles(files);
|
||||||
}
|
}
|
||||||
// If EOL has been fixed, skip this.
|
// If EOL has been fixed, skip this.
|
||||||
if (this.eolState > 1) return;
|
if (this.eolState > 1) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user