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

Rendered markup roots should be added to ReactMount node cache #2365

Closed
syranide opened this issue Oct 16, 2014 · 8 comments
Closed

Rendered markup roots should be added to ReactMount node cache #2365

syranide opened this issue Oct 16, 2014 · 8 comments

Comments

@syranide
Copy link
Contributor

ReactMount caches all children for each parent it visits, this avoids worst-case exponential cost. However, use of ReactDOMIDOperations for updates forces ReactMount to populate the cache with the previous children.

If a newly rendered node needs to be found, then "the children of the parent" of "the newly rendered root" has to be re-traversed as it does not exist in the node cache. Since it's guaranteed that all the siblings of newly rendered roots are cached and that we have a reference to the node, it's trivial to manually add it to the node cache which should avoid "double-traversals" entirely.

@claudiopro
Copy link
Contributor

@syranide what would be a good test case to exercise this logic?

@sophiebits
Copy link
Collaborator

I am not sure I understand what you meant originally, but I think #4983 fixes this. In any event, this is not really a "good first bug".

@syranide
Copy link
Contributor Author

syranide commented Oct 2, 2015

@spicyj Scanning #4983 quickly it seems like it does yes, anyway the basic issue is/was:

<div>
  <u />
  <b key={random} ref={} />
</div>

Every time it re-renders and the DOM node for b is looked up, it would re-cache all the nodes of div because b could not be found in nodecache.

@sophiebits
Copy link
Collaborator

Oh, I see. I think this is slightly separate then. I'll probably get to fixing this soon though.

@syranide
Copy link
Contributor Author

syranide commented Oct 2, 2015

@spicyj FYI, IIRC this is not currently a very big issue as childIndex is used in some places to reach the actual node inside the parent node instead (rather than the actual node directly), but it probably will be when React gets around to dropping the wrapping spans and thus childIndex I would assume.

@claudiopro
Copy link
Contributor

@spicyj I concur it's a tad beyond the beginner level 😅

@syranide
Copy link
Contributor Author

@spicyj I'm thinking this is no longer relevant for the new renderer? Or is it still perhaps?

@sophiebits
Copy link
Collaborator

Yeah I got rid of all this! It should be a lot easier to reason about now.

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

3 participants