Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions test/setup-jsdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if (!global.hasOwnProperty("window")) {
global.document = jsdom.jsdom("<!doctype html><html><body></body></html>");
global.window = document.defaultView;
global.navigator = global.window.navigator;
global.File = global.window.File;
}

// atob
Expand Down
11 changes: 11 additions & 0 deletions test/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,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] };
Expand Down