Open
Description
I'm working on a new virtualization engine for the MUI X Data Grid and other components. I was hoping to be able to do some work outside of react for performance reasons, and to tie React in with portals, but the base cost of adding portals is too high for that use-case due to the event listeners that are added on new roots.
React version: 19
Steps To Reproduce
- Create a portal inside the app's main root
Link to code example: https://stackblitz.com/edit/mui-virtual-exploration
The current behavior
React attaches event listeners to new portal roots even when the root node is contained by the main app root node. It creates a lot of overhead for cases where multiple portals are attached at once.

The expected behavior
No added listeners if the root is contained in the main root.