Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

toReact mutates the faux element #7

Closed
mg opened this issue Sep 22, 2015 · 3 comments
Closed

toReact mutates the faux element #7

mg opened this issue Sep 22, 2015 · 3 comments
Assignees
Labels

Comments

@mg
Copy link

mg commented Sep 22, 2015

Hi,

when calling 'toReact()' it mutates the faux element (at least it seems to delete some functions on the style property) and therefore the faux element can not be reused between renderings and has to be recreated on every render.

Does this not stop us from using the enter-update-exit pattern in d3 since we are always starting with a new faux element?

cheers,
mg

@Olical
Copy link
Owner

Olical commented Sep 23, 2015

Ah, there may be a small bug there because I was performing a clone before mutating that object, but you're not supposed to use enter-edit-update with this, no. The idea is that you build and throw away elements in each call to render so as to minimise state. The point in the faux DOM is that it's mutable and lightweight to make this a possibility.

I will investigate the mutation issue, but you shouldn't need update or exit. I only use enter in my examples for convenience, you could just iterate over your data too.

There may be a nicer way to get D3 to generate (for example) a <p> tag for every value in an array without the use of .enter().

@Olical Olical self-assigned this Sep 23, 2015
@Olical Olical added the bug label Sep 23, 2015
@Olical
Copy link
Owner

Olical commented Sep 30, 2015

Ah, so there's two issues here. The first is that I need to also manually clone the style object, apparently the clone operation is not recursive!

The other issue is that I only delete those properties if you haven't defined a key! Damn. Sorry to anyone that's been bitten by this. I'm aware of it now though and will fix it soon. Other things on my radar are event and mouse integration.. Still on the fence about animations, not sure how they work in D3 yet, may be impossible to bridge (easily), we'll see.

@Olical Olical mentioned this issue Oct 3, 2015
@Olical
Copy link
Owner

Olical commented Oct 3, 2015

Fixed in v1.1.0 by #8

@Olical Olical closed this as completed Oct 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants