From b1c46aa103c4598ef0178115680e2e7e8d720d35 Mon Sep 17 00:00:00 2001 From: Angelo Date: Wed, 9 Sep 2026 20:18:14 +0700 Subject: [PATCH 1/2] fix(upload/transformFiles): remove unnecessary validation --- packages/upload/src/helpers.ts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/packages/upload/src/helpers.ts b/packages/upload/src/helpers.ts index 8f6533791..9ccd584cb 100644 --- a/packages/upload/src/helpers.ts +++ b/packages/upload/src/helpers.ts @@ -14,29 +14,20 @@ export function createInputComponent({ multiple = false, accept = "" }: FileUplo } export function transformFiles(files: FileList | null): UploadFile[] { - const parsedFiles: UploadFile[] = []; - - if (!files) return parsedFiles; - - for (const index in files) { - const fileIndex = +index; - if (isNaN(+fileIndex)) { - continue; - } - - const file = files[fileIndex]; - if (!file) { - continue; - } - - const parsedFile: UploadFile = { + if (!files) return []; + + const parsed: UploadFile[] = [] + for (const idx in files) { + // SAFETY: w3c File API defines FileList item access to be valid from index 0 to `files.length - 1` + // https://w3c.github.io/FileAPI/#filelist-methods-params: "Supported property indices are the numbers in the range zero to one less than the number of File objects represented by the FileList object." + const file = files[Number(idx)]! + parsed.push({ source: URL.createObjectURL(file), name: file.name, size: file.size, file, - }; - parsedFiles.push(parsedFile); + }); } - return parsedFiles; + return parsed; } From 04c31eefa5fd4be4b63c49df020bc861502c1238 Mon Sep 17 00:00:00 2001 From: Angelo Date: Thu, 10 Sep 2026 22:25:23 +0700 Subject: [PATCH 2/2] chore: changeset for changelog --- .changeset/fine-kids-grin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fine-kids-grin.md diff --git a/.changeset/fine-kids-grin.md b/.changeset/fine-kids-grin.md new file mode 100644 index 000000000..427408b63 --- /dev/null +++ b/.changeset/fine-kids-grin.md @@ -0,0 +1,5 @@ +--- +"@solid-primitives/upload": patch +--- + +`helper`: rework `transformFiles` internal function to remove unneeded checks