-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
ReactMount.nodeCache is repopulated with purged nodes that are focused at unmount #2988
Comments
I'll go ahead and put good first bug on this one, it may be a bit tricky to find the root cause but it should be quite easy to narrow down and the fix should be rather simple too I think. So perhaps not the easiest bug if you're entirely new. |
Hi syranide, I'd like to take a look but the link is not working, can you check it please? |
@javpaw I can have it fixed in an hour or so, but really, just change |
Fixed. |
After a bunch of experimentation related to the fix in #3144, I was able to trace this issue to It looks like when an ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
topLevelTypes.topBlur,
'blur',
mountAt
); Which leads us to https://github.com/facebook/react/blob/master/src/renderers/dom/client/ReactEventListener.js#L145-L155 trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
var element = handle;
if (!element) {
return null;
}
return EventListener.capture(
element,
handlerBaseName,
ReactEventListener.dispatchEvent.bind(null, topLevelType)
);
}, and finally to https://github.com/facebook/react/blob/master/src/shared/vendor/stubs/EventListener.js#L74-L79 target.addEventListener(eventType, callback, true);
return {
remove: function() {
target.removeEventListener(eventType, callback, true);
}
}; So a I'm not sure where best to handle this, given that I'm fairly new to React's source and it's sort of massive. Are there any conventions in use or places that I should look? |
@pletcher You're right that those aren't removed, but they're added only once per document at the top level so that shouldn't really be a problem. |
Right right, but it seems like there's a handler getting attched that's firing the |
@spicyj I think we intentionally fire events on removed nodes. I'm pretty sure there was a unit test for that, ensuring that we fire an event on nodes even if they are removed as part of an event handler as the event bubbles up. |
Spec says |
Yeah, goes back to #1105. |
Looks like nodeCache was killed in 4ba0e95. Is this still an issue? |
Nope, thank you. |
If you unmount a currently focused node,
nodeCache
is repopulated after being purged and unless that specific ID is revisited later, it will remain there forever.This is mostly likely due to the focus/selection restoration phase after reconciliation.Repro: http://dev.cetrez.com/jsx/nodecache.html (nodeCache is output into the console)
The text was updated successfully, but these errors were encountered: