Fixed incorrect merging algorithm; did not deep-clone when merging into empty object
Showing
1 changed file
with
3 additions
and
3 deletions
... | @@ -533,13 +533,13 @@ exports.isWebPage = isWebPage; | ... | @@ -533,13 +533,13 @@ exports.isWebPage = isWebPage; |
533 | function mergeObjects(origin, add) { | 533 | function mergeObjects(origin, add) { |
534 | "use strict"; | 534 | "use strict"; |
535 | for (var p in add) { | 535 | for (var p in add) { |
536 | try { | ||
537 | if (add[p].constructor === Object) { | 536 | if (add[p].constructor === Object) { |
537 | if (origin.hasOwnProperty(p) && origin[p].constructor === Object) { | ||
538 | origin[p] = mergeObjects(origin[p], add[p]); | 538 | origin[p] = mergeObjects(origin[p], add[p]); |
539 | } else { | 539 | } else { |
540 | origin[p] = add[p]; | 540 | origin[p] = clone(add[p]); |
541 | } | 541 | } |
542 | } catch(e) { | 542 | } else { |
543 | origin[p] = add[p]; | 543 | origin[p] = add[p]; |
544 | } | 544 | } |
545 | } | 545 | } | ... | ... |
-
Please register or sign in to post a comment