Skip to content
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

Flare: Fix listener upgrade bug #18270

Merged
merged 1 commit into from
Mar 10, 2020
Merged

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 10, 2020

This fixes a bug that was found internally when attempting to upgrade to an active event listener. We weren't properly removing the passive event listener. Also wired up logic for fb event listeners so we correctly remove those too.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 10, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 10, 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 db1f226:

Sandbox Source
modest-wing-z8xyw Configuration

@sizebot
Copy link

sizebot commented Mar 10, 2020

Details of bundled changes.

Comparing: 2953425...db1f226

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 124.38 KB 124.39 KB 38.8 KB 38.8 KB NODE_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 58.91 KB 58.91 KB 14.71 KB 14.71 KB UMD_DEV
ReactDOM-dev.js 0.0% 0.0% 911.07 KB 911.44 KB 203.62 KB 203.68 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.27 KB 10.27 KB 3.5 KB 3.5 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 137.64 KB 137.64 KB 35.16 KB 35.17 KB FB_WWW_DEV
ReactDOMTesting-dev.js 0.0% 0.0% 875.16 KB 875.57 KB 195.95 KB 196.02 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 369.92 KB 370.03 KB 67.69 KB 67.71 KB FB_WWW_PROD
ReactDOMTesting-profiling.js 0.0% 0.0% 369.92 KB 370.03 KB 67.69 KB 67.71 KB FB_WWW_PROFILING
react-dom-server.node.development.js 0.0% -0.0% 131.08 KB 131.08 KB 34.84 KB 34.83 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.81 KB 10.81 KB 4.1 KB 4.1 KB NODE_PROD
react-dom.development.js 0.0% 0.0% 916.32 KB 916.47 KB 200.5 KB 200.56 KB UMD_DEV
react-dom-server.browser.development.js 0.0% -0.0% 136.87 KB 136.87 KB 34.99 KB 34.99 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 120.26 KB 120.27 KB 38.41 KB 38.41 KB UMD_PROD
react-dom-server.browser.production.min.js 0.0% -0.0% 20.51 KB 20.51 KB 7.51 KB 7.51 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 124.08 KB 124.09 KB 39.62 KB 39.63 KB UMD_PROFILING
react-dom.development.js 0.0% 0.0% 872.21 KB 872.36 KB 198.06 KB 198.11 KB NODE_DEV
react-dom-server.browser.development.js 0.0% -0.0% 129.87 KB 129.87 KB 34.58 KB 34.58 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 120.41 KB 120.42 KB 37.61 KB 37.61 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% -0.0% 20.43 KB 20.43 KB 7.46 KB 7.46 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 375.84 KB 375.92 KB 68.41 KB 68.43 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 387.53 KB 387.61 KB 70.57 KB 70.58 KB FB_WWW_PROFILING
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 3.69 KB 3.69 KB 1.34 KB 1.34 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10 KB 10 KB 3.38 KB 3.38 KB NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.2% 1.16 KB 1.16 KB 664 B 663 B NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.35 KB 3.35 KB 1.27 KB 1.27 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.19 KB 1.19 KB 700 B 699 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.2% 2.95 KB 2.95 KB 1.18 KB 1.18 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1 KB 1 KB 612 B 610 B NODE_PROD

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against db1f226

@sizebot
Copy link

sizebot commented Mar 10, 2020

Details of bundled changes.

Comparing: 2953425...db1f226

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js 0.0% 0.0% 414.21 KB 414.3 KB 75.34 KB 75.36 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 135.28 KB 135.28 KB 34.79 KB 34.78 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% -0.2% 1.15 KB 1.15 KB 655 B 654 B NODE_PROD
react-dom-server.browser.production.min.js 0.0% -0.0% 20.05 KB 20.05 KB 7.42 KB 7.42 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 55.86 KB 55.86 KB 14.46 KB 14.46 KB NODE_DEV
react-dom.development.js 0.0% 0.0% 885.85 KB 886 KB 195.26 KB 195.32 KB UMD_DEV
react-dom.production.min.js 0.0% -0.1% 116.06 KB 116.07 KB 37.19 KB 37.17 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 119.77 KB 119.78 KB 38.41 KB 38.43 KB UMD_PROFILING
react-dom.development.js 0.0% 0.0% 843.02 KB 843.17 KB 192.82 KB 192.88 KB NODE_DEV
react-dom-server.node.development.js 0.0% -0.0% 129.57 KB 129.57 KB 34.61 KB 34.61 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 116.14 KB 116.15 KB 36.51 KB 36.52 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% -0.0% 20.38 KB 20.38 KB 7.53 KB 7.53 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 120 KB 120.01 KB 37.64 KB 37.64 KB NODE_PROFILING
ReactDOM-dev.js 0.0% 0.0% 957 KB 957.36 KB 213.59 KB 213.67 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 402.44 KB 402.53 KB 73.08 KB 73.11 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 3.68 KB 3.68 KB 1.33 KB 1.33 KB NODE_DEV
ReactDOMTesting-dev.js 0.0% 0.0% 901.81 KB 902.21 KB 201.53 KB 201.61 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 383.47 KB 383.59 KB 69.85 KB 69.88 KB FB_WWW_PROD
react-dom-server.browser.development.js 0.0% -0.0% 128.35 KB 128.35 KB 34.36 KB 34.36 KB NODE_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 383.47 KB 383.59 KB 69.85 KB 69.88 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 0.0% -0.0% 19.97 KB 19.97 KB 7.38 KB 7.38 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.34 KB 3.34 KB 1.26 KB 1.26 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.94 KB 10.94 KB 4.16 KB 4.16 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1.17 KB 1.17 KB 692 B 690 B UMD_PROD
ReactDOMServer-dev.js 0.0% -0.0% 138.5 KB 138.5 KB 35.3 KB 35.3 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% -0.0% 49.55 KB 49.55 KB 13.51 KB 13.51 KB NODE_DEV
ReactDOMServer-prod.js 0.0% -0.0% 47.49 KB 47.49 KB 11.05 KB 11.05 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.2% 2.94 KB 2.94 KB 1.17 KB 1.17 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 58.9 KB 58.9 KB 14.7 KB 14.7 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.3% 1013 B 1013 B 604 B 602 B NODE_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.26 KB 10.26 KB 3.49 KB 3.49 KB UMD_PROD

ReactDOM: size: 0.0%, gzip: -0.0%

Size changes (stable)

Generated by 🚫 dangerJS against db1f226

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

stamping to unblock, but maybe you should get another pair of eyes on this.

Flare: fix bug with event upgrading

Fix

Fix
@trueadm trueadm force-pushed the fix-listener-upgrade branch from 51fcc95 to db1f226 Compare March 10, 2020 17:18
@trueadm trueadm merged commit a3bf668 into facebook:master Mar 10, 2020
@trueadm trueadm deleted the fix-listener-upgrade branch March 10, 2020 17:59
topLevelType: string,
listener: any => void,
) {
if (listener.remove != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not great because we're shipping this code even if it's not an FB listener. Like if Function.prototype.remove is added on the page. It also confuses the compiler. We should be sure which path we're using and consistently call that - statically

passive: true,
});
} else {
document.removeEventListener(topLevelType, listener, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't going through the forked indirection which isn't the right layering. This whole function should all be moved to EventListener.js. That way it can be properly forked and you can statically choose which function to call.

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