-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Modern Event System: make on*Capture events use capture phase #19221
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d8e5480:
|
Details of bundled changes.Comparing: 4eb9b1d...d8e5480 react-dom
ReactDOM: size: 0.0%, gzip: 🔺+0.1% Size changes (stable) |
Details of bundled changes.Comparing: 4eb9b1d...d8e5480 react-dom
ReactDOM: size: 0.0%, gzip: 🔺+0.1% Size changes (experimental) |
15ac292
to
c1fac38
Compare
ef10361
to
52b692b
Compare
9768ac4
to
814b227
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to add a lot of Map access in hot paths. Is there any way at all to avoid that?
@gaearon What Map access were you referencing specifically? I was also of the understanding that the difference was tiny, especially when the inline cache is utilized. I remember this being a perf issue a few years back with V8, but Sets and Maps are really fast now. |
6dbd8ce
to
f888b6c
Compare
Note: this PR is rebased on #19244.
This PR alters the modern event system so that events that are of the format
on*Capture
(capture events) are actually put into the browser's native capture event phase when React creates the event listener. This is a deparature of the previous logic, which "virtualized" the capture and bubble phases within the native bubble event listener.This is an important change to the modern event system, as the modern event system delegates to React roots (or portals) rather than the
document
. This means events that are setup to be capture listener, i.e.onClickCapture
now correctly behave has expected. This also fixes some long-standing issues with how React and the browser differ in regards to how events are handled in co-ordination with native event listeners.Lastly, we still (for now) enforce
blur
andfocus
to be capture phase listeners (so they emulate two phase propagation in the native capture phase, as we did before). We also emulate two phase propagation in the native bubble phase, as we did before, for theChangeEventPlugin
,BeforeInputEventPlugin
andSelectEventPlugin
event plugins.