diff --git a/src/utils.js b/src/utils.js index 36376e436a..ce13634b5d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -229,6 +229,9 @@ export function getUiOptions(uiSchema) { } export function isObject(thing) { + if (thing instanceof File) { + return false; + } return typeof thing === "object" && thing !== null && !Array.isArray(thing); } diff --git a/test/setup-jsdom.js b/test/setup-jsdom.js index 3cbf2cd127..d9f1115da4 100644 --- a/test/setup-jsdom.js +++ b/test/setup-jsdom.js @@ -6,6 +6,7 @@ if (!global.hasOwnProperty("window")) { global.document = jsdom.jsdom(""); global.window = document.defaultView; global.navigator = global.window.navigator; + global.File = global.window.File; } // atob diff --git a/test/utils_test.js b/test/utils_test.js index bb61973f22..2f1ecc3696 100644 --- a/test/utils_test.js +++ b/test/utils_test.js @@ -549,6 +549,17 @@ describe("utils", () => { expect(mergeObjects(obj1, obj2)).eql(expected); }); + it("should recursively merge File objects", () => { + const file = new File(["test"], "test.txt"); + const obj1 = { + a: {}, + }; + const obj2 = { + a: file, + }; + expect(mergeObjects(obj1, obj2).a).instanceOf(File); + }); + describe("concatArrays option", () => { it("should not concat arrays by default", () => { const obj1 = { a: [1] };