Skip to content

Commit

Permalink
fix(FEC-10324): class instances merged like simple object (#500)
Browse files Browse the repository at this point in the history
Issue: config with instance object merged like object.
Solution: check if it's an instance of class and merge it.
  • Loading branch information
Yuvalke committed Nov 24, 2020
1 parent 6f5ded1 commit f06aa5e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const _Object = {
return item && typeof item === 'object' && !Array.isArray(item);
},

isClassInstance: function (item: any) {
return item && item.constructor && item.constructor.name && item.constructor.name !== 'Object';
},

/**
* @param {any} target - The target object.
* @param {any} sources - The objects to merge.
Expand All @@ -90,7 +94,7 @@ const _Object = {
const source = sources.shift();
if (this.isObject(target) && this.isObject(source)) {
for (const key in source) {
if (this.isObject(source[key])) {
if (this.isObject(source[key]) && !this.isClassInstance(source[key])) {
if (!target[key]) Object.assign(target, {[key]: {}});
this.mergeDeep(target[key], source[key]);
} else {
Expand Down

0 comments on commit f06aa5e

Please sign in to comment.