Fixed incorrect merging algorithm; did not deep-clone when merging into empty object
Showing
1 changed file
with
5 additions
and
5 deletions
... | @@ -533,14 +533,14 @@ exports.isWebPage = isWebPage; | ... | @@ -533,14 +533,14 @@ 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 { | 536 | if (add[p].constructor === Object) { |
537 | 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 | } |
546 | return origin; | 546 | return origin; | ... | ... |
-
Please register or sign in to post a comment