Skip to content

Move beforeblur phase to prepareForCommit #18609

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

Merged
merged 2 commits into from
Apr 14, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 14, 2020

This is a follow up to #18564. Specifically, this moves the beforeblur logic in ReactDOMHostConfig, so that it occurs during prepareForCommit – avoiding the issues with conflicting with a partially mutated tree. To do this logic we pass through a helper function to prepareForCommit called isInstanceInsideHiddenOrRemovedTree. This helps us determine if the "active element" is within a sub-tree that is either hidden or removed.

Furthermore, the effeciency of this approach should be a nice improvement, as it means we have to do far less logic than before – along with a slight code size improvement.

I also applied the detachFiber changes from #18564 and included the regression test from that PR too.

@trueadm trueadm requested review from sebmarkbage and gaearon April 14, 2020 17:45
@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels Apr 14, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 14, 2020

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 9301d38:

Sandbox Source
heuristic-dew-rvt4w Configuration

@sizebot
Copy link

sizebot commented Apr 14, 2020

Details of bundled changes.

Comparing: b928fc0...9301d38

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js 0.0% 0.0% 119.7 KB 119.72 KB 37.54 KB 37.55 KB NODE_PROD
ReactDOMTesting-profiling.js -0.0% -0.1% 405.58 KB 405.39 KB 73.6 KB 73.51 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.9 KB 4.9 KB 1.64 KB 1.64 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 123.58 KB 123.6 KB 38.67 KB 38.68 KB NODE_PROFILING
react-dom-test-utils.production.min.js 0.0% 0.0% 13.22 KB 13.22 KB 4.89 KB 4.89 KB UMD_PROD
react-dom-server.node.development.js 0.0% -0.0% 147.14 KB 147.14 KB 38.93 KB 38.93 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 23.23 KB 23.23 KB 8.65 KB 8.65 KB NODE_PROD
ReactDOMForked-dev.js -0.0% -0.1% 1015.41 KB 1014.93 KB 225.54 KB 225.42 KB FB_WWW_DEV
ReactDOMForked-prod.js -0.0% -0.1% 425.18 KB 424.99 KB 76.69 KB 76.6 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.16 KB 5.16 KB 1.69 KB 1.69 KB NODE_DEV
react-dom.development.js 0.0% 0.0% 907.82 KB 907.96 KB 199.36 KB 199.41 KB UMD_DEV
ReactDOMForked-profiling.js -0.0% -0.1% 436.14 KB 435.95 KB 78.58 KB 78.5 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 155.09 KB 155.09 KB 39.45 KB 39.44 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.3% 1.16 KB 1.16 KB 658 B 660 B NODE_PROD
react-dom.production.min.js 0.0% 0.0% 119.58 KB 119.6 KB 38.26 KB 38.26 KB UMD_PROD
react-dom-server.browser.production.min.js 0.0% -0.0% 22.92 KB 22.92 KB 8.51 KB 8.51 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 123.32 KB 123.33 KB 39.51 KB 39.52 KB UMD_PROFILING
ReactDOMTesting-dev.js -0.0% -0.1% 959.46 KB 958.98 KB 213.67 KB 213.55 KB FB_WWW_DEV
react-dom.development.js 0.0% 0.0% 864.21 KB 864.35 KB 196.91 KB 196.96 KB NODE_DEV
ReactDOMTesting-prod.js -0.0% -0.1% 405.58 KB 405.39 KB 73.6 KB 73.51 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% -0.0% 145.92 KB 145.92 KB 38.68 KB 38.68 KB NODE_DEV
ReactDOM-dev.js -0.0% -0.0% 1015.39 KB 1014.92 KB 225.38 KB 225.27 KB FB_WWW_DEV
ReactDOM-prod.js -0.0% -0.1% 424.6 KB 424.4 KB 76.6 KB 76.51 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 69.97 KB 69.97 KB 19.6 KB 19.6 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.42 KB 4.42 KB 1.54 KB 1.54 KB NODE_DEV
ReactDOM-profiling.js -0.0% -0.1% 435.56 KB 435.37 KB 78.5 KB 78.43 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% 0.0% 13.09 KB 13.09 KB 4.8 KB 4.8 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 56.1 KB 56.1 KB 13.84 KB 13.84 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.98 KB 9.98 KB 3.36 KB 3.36 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 53.2 KB 53.2 KB 13.64 KB 13.64 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 9.73 KB 9.73 KB 3.25 KB 3.25 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js 0.0% 0.0% 579.07 KB 579.14 KB 122.61 KB 122.63 KB NODE_DEV
react-reconciler-reflection.development.js +4.6% +4.2% 16.22 KB 16.97 KB 4.91 KB 5.12 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 77.16 KB 77.18 KB 22.89 KB 22.89 KB NODE_PROD
react-reconciler-reflection.production.min.js 🔺+9.3% 🔺+7.6% 2.57 KB 2.8 KB 1.08 KB 1.17 KB NODE_PROD

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 9301d38

@sizebot
Copy link

sizebot commented Apr 14, 2020

Details of bundled changes.

Comparing: b928fc0...9301d38

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js 0.0% 0.0% 162.2 KB 162.2 KB 41.21 KB 41.21 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 128.53 KB 128.54 KB 40.19 KB 40.2 KB NODE_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.91 KB 4.91 KB 1.64 KB 1.64 KB UMD_DEV
ReactDOM-dev.js -0.0% -0.0% 990.13 KB 989.65 KB 220.13 KB 220.02 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.2 KB 1.2 KB 705 B 706 B UMD_PROD
ReactDOM-prod.js -0.0% -0.1% 413.18 KB 412.99 KB 74.96 KB 74.86 KB FB_WWW_PROD
ReactDOM-profiling.js -0.0% -0.1% 424.08 KB 423.89 KB 76.81 KB 76.73 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 4.43 KB 4.43 KB 1.55 KB 1.55 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 13.23 KB 13.23 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js -0.1% -0.1% 932.91 KB 932.44 KB 208.04 KB 207.9 KB FB_WWW_DEV
ReactDOMTesting-prod.js -0.0% -0.1% 393.76 KB 393.57 KB 71.81 KB 71.72 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% 0.0% 69.98 KB 69.98 KB 19.61 KB 19.61 KB NODE_DEV
ReactDOMTesting-profiling.js -0.0% -0.1% 393.76 KB 393.57 KB 71.81 KB 71.72 KB FB_WWW_PROFILING
react-dom-server.node.development.js 0.0% 0.0% 153.9 KB 153.9 KB 40.69 KB 40.69 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 13.1 KB 13.1 KB 4.81 KB 4.81 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 23.69 KB 23.69 KB 8.72 KB 8.72 KB NODE_PROD
react-dom.development.js 0.0% 0.0% 941.5 KB 941.65 KB 205.81 KB 205.87 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 56.11 KB 56.11 KB 13.85 KB 13.85 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 124.33 KB 124.35 KB 39.71 KB 39.72 KB UMD_PROD
ReactDOMForked-dev.js -0.0% -0.0% 990.15 KB 989.67 KB 220.28 KB 220.17 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10 KB 10 KB 3.36 KB 3.36 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 161.46 KB 161.46 KB 40.99 KB 40.99 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% 0.0% 128.18 KB 128.2 KB 40.93 KB 40.94 KB UMD_PROFILING
ReactDOMForked-prod.js -0.0% -0.1% 413.75 KB 413.56 KB 75.04 KB 74.94 KB FB_WWW_PROD
ReactDOMServer-prod.js 0.0% 0.0% 52.57 KB 52.57 KB 12.68 KB 12.68 KB FB_WWW_PROD
react-dom.development.js 0.0% 0.0% 896.46 KB 896.59 KB 203.32 KB 203.37 KB NODE_DEV
ReactDOMForked-profiling.js -0.0% -0.1% 424.65 KB 424.46 KB 76.91 KB 76.83 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 53.21 KB 53.21 KB 13.65 KB 13.65 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 5.18 KB 5.18 KB 1.7 KB 1.7 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 124.53 KB 124.54 KB 38.95 KB 38.96 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.1% 1.17 KB 1.17 KB 667 B 668 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-reflection.development.js +4.6% +4.2% 16.23 KB 16.98 KB 4.92 KB 5.12 KB NODE_DEV
react-reconciler-reflection.production.min.js 🔺+9.2% 🔺+7.5% 2.58 KB 2.82 KB 1.09 KB 1.17 KB NODE_PROD
react-reconciler.development.js 0.0% 0.0% 604.57 KB 604.63 KB 127.94 KB 127.96 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 80.81 KB 80.82 KB 23.93 KB 23.93 KB NODE_PROD

Size changes (experimental)

Generated by 🚫 dangerJS against 9301d38

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a ton of context on this but the change seems okay.

fiber.memoizedState = null;
fiber.pendingProps = null;
fiber.return = null;
fiber.sibling = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice change 👍

@@ -95,6 +94,10 @@ import {
import {getListenerMapForElement} from '../events/DOMEventListenerMap';
import {TOP_BEFORE_BLUR, TOP_AFTER_BLUR} from '../events/DOMTopLevelEventTypes';

// TODO: This is an exposed internal, we should move this around
// so this isn't the case.
import {isFiberInsideHiddenOrRemovedTree} from 'react-reconciler/src/ReactFiberTreeReflection';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @acdlite in case this affects your fork. I don't think it will.

@trueadm trueadm merged commit bf55ea7 into facebook:master Apr 14, 2020
@trueadm trueadm deleted the before-blur-move branch April 14, 2020 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants