Fix Array.from syntax in nonmultiple file upload (#2357)

- Fix Array.from syntax in nonmultiple file upload as Array.from(<non-array or string>) returns an empty array which is the case when a file is selected from an input element (when multiple attribute isn't  supported) which can be found in Array.from(element.files[0]) -> results in an empty array.
This commit is contained in:
Omar Ahmed Hassan 2024-11-29 14:22:52 +02:00 committed by GitHub
parent a5ba6c403a
commit 99d481d69f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,7 +86,7 @@ function setupFileInput(chooser) {
if (element instanceof HTMLInputElement && element.hasAttribute("multiple")) { if (element instanceof HTMLInputElement && element.hasAttribute("multiple")) {
allFiles = isDragAndDrop ? allFiles : [... allFiles, ... element.files]; allFiles = isDragAndDrop ? allFiles : [... allFiles, ... element.files];
} else { } else {
allFiles = Array.from(isDragAndDrop ? allFiles : element.files[0]); allFiles = Array.from(isDragAndDrop ? allFiles : [element.files[0]]);
} }
if (!isDragAndDrop) { if (!isDragAndDrop) {