Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix in util.merge to properly match property names. #529

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants

When merging objects, util.merge uses seen/lastseen to avoid entering into an infinite loop while copying recursive objects. The seen array, then, contain the name of all properties already copied in the current level or above.

However, current code in util.merge does not push attribute names to the array but attribute values. This change fixes the problem.

I have the same problem on using socket.io-client with Dojo. This change solves the problem. Thank you!

@gabmontes gabmontes commented on the diff Mar 21, 2013

lib/util.js
@@ -225,7 +225,7 @@
if (additional.hasOwnProperty(prop) && util.indexOf(seen, prop) < 0) {
@gabmontes

gabmontes Mar 21, 2013

Name of the property prop is searched into the seen array.

@gabmontes gabmontes commented on the diff Mar 21, 2013

lib/util.js
@@ -225,7 +225,7 @@
if (additional.hasOwnProperty(prop) && util.indexOf(seen, prop) < 0) {
if (typeof target[prop] !== 'object' || !depth) {
target[prop] = additional[prop];
- seen.push(additional[prop]);
@gabmontes

gabmontes Mar 21, 2013

Value of property prop is being pushed into seen.

@gabmontes gabmontes pushed a commit to gabmontes/socket.io-client that referenced this pull request Jul 2, 2014

Gabriel Montes Release 0.9.16-patch1
Built from original 0.9.16 and patched with pull requests #516, #529
and #531.
0a41587

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment