diff --git a/lib/merge.js b/lib/merge.js index 132d12500c..0913323747 100644 --- a/lib/merge.js +++ b/lib/merge.js @@ -3,8 +3,8 @@ // Merge two objects, including their prototypes function mergePrototypes(to, from) { const prototypes = [...getPrototypes(to), ...getPrototypes(from)]; - const newPrototype = prototypes.reduce(reducePrototype, {}); - return Object.assign(Object.setPrototypeOf(to, newPrototype), to, from); + const prototype = prototypes.reduce(shallowMerge, {}); + return Object.assign(Object.setPrototypeOf(to, prototype), from); } function getPrototypes(object, prototypes = []) { @@ -16,8 +16,8 @@ function getPrototypes(object, prototypes = []) { return prototypes; } -function reducePrototype(prototype, constructor) { - return Object.defineProperties(prototype, Object.getOwnPropertyDescriptors(constructor)); +function shallowMerge(toObject, fromObject) { + return Object.defineProperties(toObject, Object.getOwnPropertyDescriptors(fromObject)); } module.exports = mergePrototypes;