Skip to content

Commit 1f0e34a

Browse files
committed
Fix rjsf-team#1233 : Exclude File object from isObject detection
1 parent 9104a71 commit 1f0e34a

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ export function getUiOptions(uiSchema) {
229229
}
230230

231231
export function isObject(thing) {
232+
if (thing instanceof File) {
233+
return false;
234+
}
232235
return typeof thing === "object" && thing !== null && !Array.isArray(thing);
233236
}
234237

test/setup-jsdom.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (!global.hasOwnProperty("window")) {
66
global.document = jsdom.jsdom("<!doctype html><html><body></body></html>");
77
global.window = document.defaultView;
88
global.navigator = global.window.navigator;
9+
global.File = global.window.File;
910
}
1011

1112
// atob

test/utils_test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,17 @@ describe("utils", () => {
517517
expect(mergeObjects(obj1, obj2)).eql(expected);
518518
});
519519

520+
it("shouldn't recursively merge File object", () => {
521+
const file = new File(["test"], "test.txt");
522+
const obj1 = {
523+
a: {},
524+
};
525+
const obj2 = {
526+
a: file,
527+
};
528+
expect(mergeObjects(obj1, obj2).a).instanceOf(File);
529+
});
530+
520531
describe("concatArrays option", () => {
521532
it("should not concat arrays by default", () => {
522533
const obj1 = { a: [1] };

0 commit comments

Comments
 (0)