Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix options shared state between instances of new Datamap() #298

Merged
merged 1 commit into from
May 9, 2016

Conversation

magic890
Copy link
Contributor

@magic890 magic890 commented May 9, 2016

The problem with the old line of code:

if (obj[prop] == null) obj[prop] = source[prop];

was that obj[prop] is a pointer to source[prop], this cause a shared state of memory between different instances of new Datamap().

Now it's fixed using a deep copy implemented in pure JavaScript (no additional dependencies! 馃帀).

I've also tried jQuery.extend({}, ...) and _.cloneDeep but they had problems evaluating Datamap.prototype.draw on line var pathAndProjection = options.setProjection.apply(self, [options.element, options] );

This will close #296

@markmarkoh markmarkoh merged commit 672e2d1 into markmarkoh:master May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new Datamap() keeps a shared state of memory between invocations
2 participants