Skip to content

Commit 4b73e0e

Browse files
Fixed a bug in the the Options code
1 parent cf45f89 commit 4b73e0e

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

lib/options.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ function merge(src, dest) {
9494
var topKeys = Object.keys(src);
9595
for (var i = 0; i < topKeys.length; i++) {
9696
var topKey = topKeys[i];
97-
var child = src[topKey];
98-
var childKeys = Object.keys(child);
99-
for (var j = 0; j < childKeys.length; j++) {
100-
var childKey = childKeys[j];
101-
var childValue = child[childKey];
102-
if (childValue !== undefined) {
103-
dest[topKey][childKey] = childValue;
97+
var srcChild = src[topKey];
98+
if (dest[topKey] === undefined) {
99+
dest[topKey] = srcChild;
100+
}
101+
else {
102+
var childKeys = Object.keys(srcChild);
103+
for (var j = 0; j < childKeys.length; j++) {
104+
var childKey = childKeys[j];
105+
var srcChildValue = srcChild[childKey];
106+
if (srcChildValue !== undefined) {
107+
dest[topKey][childKey] = srcChildValue;
108+
}
104109
}
105110
}
106111
}

0 commit comments

Comments
 (0)