Skip to content

Commit

Permalink
fix: deep_merge should stop recursing at class instances (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnysprinkles authored Jun 17, 2021
1 parent aedec24 commit b145096
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/kit/src/core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ export function validate_config(config) {
*/
function merge_into(a, b, conflicts = [], path = []) {
/**
* Checks for "plain old Javascript object", typically made as an object
* literal. Excludes Arrays and built-in types like Buffer.
* @param {any} x
*/
const is_object = (x) => typeof x === 'object' && !Array.isArray(x);
const is_plain_object = (x) => typeof x === 'object' && x.constructor === Object;

for (const prop in b) {
if (is_object(b[prop])) {
if (!is_object(a[prop])) {
if (is_plain_object(b[prop])) {
if (!is_plain_object(a[prop])) {
if (a[prop] !== undefined) {
conflicts.push([...path, prop].join('.'));
}
Expand Down

0 comments on commit b145096

Please sign in to comment.