-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[WIP] Replace top-level event types with numbers #11894
Conversation
@@ -465,42 +496,40 @@ export function setInitialProperties( | |||
switch (tag) { | |||
case 'iframe': | |||
case 'object': | |||
trapBubbledEvent('topLoad', 'load', domElement); | |||
trapBubbledEvent(TOP_LOAD, 'load', domElement); |
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.
We can remove all of these event name strings like 'load'
if we have trapBubbledEvent
/trapCaptureEvent
call getRawEventName
directly. Assuming we never call it with a mismatched top-level type and event. I don't think we do.
After rebasing this work on top of the latest
|
Superseded by #12629 |
This is a rough proof of concept.
Not sure if it's worth it, but it removes about 0.5K post min+gzip.
The idea is to use number constants since
top*
strings don't have special meanings anyway. I'm using ESM exports because GCC can inline those numbers.A few observations:
on*
as the "base" name and thus ensure it stays interned (and only the rareon*Capture
would be uninterned). Not sure where we compare to it so don't know if it makes a difference.mediaEvents
list inReactDOMFiberComponent
can be an array. There's no need to duplicate raw event names there since they already exist inBrowserEventConstants
.BrowserEventConstants
we could use "Reacty" names fromSimpleEventPlugin
with leadingon
sliced out. Not sure if there's any perf difference in passing an uninterned string toaddEventListener
. There's also a caveat that we don't want to listen to someSimpleEventPlugin
events at top level. But we could still share a list between them if this is beneficial.Still broken: