Skip to content

Commit

Permalink
Merge pull request #1448 from cornerstonejs/fix/resolve-prototype-on-…
Browse files Browse the repository at this point in the history
…deep-merge

Update deep merge to resolve target prototype
  • Loading branch information
igoroctaviano authored Nov 8, 2021
2 parents 4e77512 + 81571c6 commit 8e3886d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/util/deepmerge.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ const deepmerge = (target = {}, source = {}, optionsArgument) => {
: cloneIfNecessary(source, optionsArgument);
}

return mergeObject(target, source, optionsArgument);
const mergedObject = mergeObject(target, source, optionsArgument);

if (Object.getPrototypeOf(target) !== Object.prototype) {
Object.setPrototypeOf(mergedObject, Object.getPrototypeOf(target));
}

return mergedObject;
};

export default deepmerge;

0 comments on commit 8e3886d

Please sign in to comment.