-
Notifications
You must be signed in to change notification settings - Fork 50.4k
[WIP] Remove event whitelist #11992
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] Remove event whitelist #11992
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,15 @@ let reactTopListenersCounter = 0; | |
| */ | ||
| const topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); | ||
|
|
||
| function getEventsFromRegistraionName(registrationName) { | ||
| if (!(registrationName in registrationNameDependencies)) { | ||
| registrationNameDependencies[registrationName] = [ | ||
| `top${registrationName.slice(2)}`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Purely for discussion but... It's really a bummer we need top level event name constants period. There's nothing special about them. We could probably just use the event name that comes from the DOM. If we dropped top level event name constants, we could avoid binding all events, eliminating overhead for local listeners: Maybe that's too aggressive. 🤷♂️
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I was thinking the same thing. There doesn't seem to be much value to them they are just the event name with 'top' appended.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends on how it affects bundle size. If we keep them and do something like #11894 then the event plugins can just use the numeric constants for dependencies/switching on events, which would probably compress better. |
||
| ]; | ||
| } | ||
| return registrationNameDependencies[registrationName]; | ||
| } | ||
|
|
||
| function getListeningForDocument(mountAt) { | ||
| // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` | ||
| // directly. | ||
|
|
@@ -115,7 +124,7 @@ function getListeningForDocument(mountAt) { | |
| export function listenTo(registrationName, contentDocumentHandle) { | ||
| const mountAt = contentDocumentHandle; | ||
| const isListening = getListeningForDocument(mountAt); | ||
| const dependencies = registrationNameDependencies[registrationName]; | ||
| const dependencies = getEventsFromRegistraionName(registrationName); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| for (let i = 0; i < dependencies.length; i++) { | ||
| const dependency = dependencies[i]; | ||
|
|
||
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.
It might be worth extracting this into a function like
isEventNameso it minifies better.