[react-dom] Refactor event priority handling to its own module#17678
[react-dom] Refactor event priority handling to its own module#17678trueadm merged 1 commit intofacebook:masterfrom
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 bf1ed10:
|
Details of bundled changes.Comparing: dbc46ac...bf1ed10 react-dom
ReactDOM: size: 0.0%, gzip: -0.0% Size changes (experimental) |
Details of bundled changes.Comparing: dbc46ac...bf1ed10 react-dom
ReactDOM: size: -0.4%, gzip: -0.6% Size changes (stable) |
2f6b4be to
5ef8236
Compare
7059476 to
5c4998d
Compare
|
I did some benchmarking on FF and Safari and it looks like using multiple Sets is not as optimal as Chrome's V8. I've changed my approach to use Maps and moved things around so we don't do multiple lookups – this is now consistently faster in Chrome and Safari, neutral in Firefox. I also did some neat code golfing to save us more code size compared to master! |
c292316 to
e12b4bf
Compare
necolas
left a comment
There was a problem hiding this comment.
Can we avoid creating the cyclic dependency?
| priority: EventPriority, | ||
| ): void { | ||
| // As the event types are in pairs of two, we need to iterate | ||
| // through in twos. |
f6634dc to
0df550e
Compare
Fix lint Revise comment Revise strategy Did some code golfing Added comment about iteration Remove cyclic dependency Fix typo Extend comment Fix typo
0df550e to
bf1ed10
Compare
The team have mentioned a bunch of times that it felt wrong that DOM Event Priority handling was all coupled with the SimpleEventPlugin, especially as might want to extend on the priorities with newer features and refactors in the future.
This PR breaks out the priority logic into a dedicated module and makes uses of Maps for faster lookups (I benchmarked before and after and Maps were consistently faster than object property lookups in Chrome and Safari, neutral in Firefox). We should also get a slight code size saving by some of the code golfing that I did whilst refactoring the code.