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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with selection.data/selection.datum of d3-selection #442

Closed
shamansir opened this issue Feb 18, 2017 · 2 comments
Closed

Problems with selection.data/selection.datum of d3-selection #442

shamansir opened this issue Feb 18, 2017 · 2 comments

Comments

@shamansir
Copy link
Owner

I treated selection.datum the wrong way, I though that it just sets/gets the __data__ property and that's it. But by d3 philosophy is actually overwrites __data__ for a child when it is appended, see:

https://github.com/d3/d3-selection/blob/e3b5455107/src/selection/append.js#L5
https://github.com/d3/d3-selection/blob/e3b5455107/src/selection/select.js#L9

Also see the issue and the comment: d3/d3-selection#106 (comment)

It affects the way I build HTML: for example, I create an HTML/SVG element corresponding to the Patch, set some data to it, and then at some point I create an HTML/SVG element corresponding to the Node, set another data to it, and append it to the parent Patch element. It turned out, at this point of appending, d3 literally overwrites the __data__ property of a child with a data from a parent (see code above).

At some point, I'll try to follow d3 philosophy (#441), but for now I will add my own __rpd_data__ property and some function to access it easily and to replace it with something right in the future.

@shamansir
Copy link
Owner Author

shamansir commented Feb 18, 2017

Required for #440 / #405

shamansir added a commit that referenced this issue Feb 18, 2017
shamansir added a commit that referenced this issue Feb 18, 2017
shamansir added a commit that referenced this issue Feb 18, 2017
@shamansir
Copy link
Owner Author

Fixed with #440

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

No branches or pull requests

1 participant