GeezerVison is showing github.com — Land enableDiscreteEventMicroTasks (#20954) · react/react@73e900b
File treeExpand file treeCollapse file tree Open diff view settings react-reconciler/src/__tests__
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { | 43 | 43 | } | 44 | 44 |
| 45 | 45 | // @gate experimental | 46 | | - // @gate enableDiscreteEventMicroTasks && enableNativeEventPriorityInference | | 46 | + // @gate enableNativeEventPriorityInference | 47 | 47 | it('ignores discrete events on a pending removed element', async () => { | 48 | 48 | const disableButtonRef = React.createRef(); | 49 | 49 | const submitButtonRef = React.createRef(); | @@ -95,7 +95,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { | 95 | 95 | }); | 96 | 96 |
| 97 | 97 | // @gate experimental | 98 | | - // @gate enableDiscreteEventMicroTasks && enableNativeEventPriorityInference | | 98 | + // @gate enableNativeEventPriorityInference | 99 | 99 | it('ignores discrete events on a pending removed event listener', async () => { | 100 | 100 | const disableButtonRef = React.createRef(); | 101 | 101 | const submitButtonRef = React.createRef(); | @@ -165,7 +165,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { | 165 | 165 | }); | 166 | 166 |
| 167 | 167 | // @gate experimental | 168 | | - // @gate enableDiscreteEventMicroTasks && enableNativeEventPriorityInference | | 168 | + // @gate enableNativeEventPriorityInference | 169 | 169 | it('uses the newest discrete events on a pending changed event listener', async () => { | 170 | 170 | const enableButtonRef = React.createRef(); | 171 | 171 | const submitButtonRef = React.createRef(); | @@ -229,7 +229,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { | 229 | 229 | }); | 230 | 230 |
| 231 | 231 | // @gate experimental | 232 | | - // @gate enableDiscreteEventMicroTasks && enableNativeEventPriorityInference | | 232 | + // @gate enableNativeEventPriorityInference | 233 | 233 | it('mouse over should be user-blocking but not discrete', async () => { | 234 | 234 | const root = ReactDOM.unstable_createRoot(container); | 235 | 235 |
| @@ -260,7 +260,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { | 260 | 260 | }); | 261 | 261 |
| 262 | 262 | // @gate experimental | 263 | | - // @gate enableDiscreteEventMicroTasks && enableNativeEventPriorityInference | | 263 | + // @gate enableNativeEventPriorityInference | 264 | 264 | it('mouse enter should be user-blocking but not discrete', async () => { | 265 | 265 | const root = ReactDOM.unstable_createRoot(container); | 266 | 266 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMHostConfig.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,6 @@ import { | 67 | 67 | enableCreateEventHandleAPI, | 68 | 68 | enableScopeAPI, | 69 | 69 | enableNewReconciler, | 70 | | - enableDiscreteEventMicroTasks, | 71 | 70 | } from 'shared/ReactFeatureFlags'; | 72 | 71 | import {HostComponent, HostText} from 'react-reconciler/src/ReactWorkTags'; | 73 | 72 | import {listenToAllSupportedEvents} from '../events/DOMPluginEventSystem'; | @@ -404,7 +403,7 @@ export const noTimeout = -1; | 404 | 403 | // ------------------- | 405 | 404 | // Microtasks | 406 | 405 | // ------------------- | 407 | | -export const supportsMicrotasks = enableDiscreteEventMicroTasks; | | 406 | +export const supportsMicrotasks = true; | 408 | 407 | export const scheduleMicrotask: any = | 409 | 408 | typeof queueMicrotask === 'function' | 410 | 409 | ? queueMicrotask | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/events/plugins/__tests__/ChangeEventPlugin-test.js +4-11Lines changed: 4 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -728,17 +728,10 @@ describe('ChangeEventPlugin', () => { | 728 | 728 | expect(Scheduler).toHaveYielded([]); | 729 | 729 | expect(input.value).toBe('initial'); | 730 | 730 |
| 731 | | - // Flush callbacks. | 732 | | - // Now the click update has flushed. | 733 | | - if (gate(flags => flags.enableDiscreteEventMicroTasks)) { | 734 | | - // Flush microtask queue. | 735 | | - await null; | 736 | | - expect(Scheduler).toHaveYielded(['render: ']); | 737 | | - expect(input.value).toBe(''); | 738 | | - } else { | 739 | | - expect(Scheduler).toFlushAndYield(['render: ']); | 740 | | - expect(input.value).toBe(''); | 741 | | - } | | 731 | + // Flush microtask queue. | | 732 | + await null; | | 733 | + expect(Scheduler).toHaveYielded(['render: ']); | | 734 | + expect(input.value).toBe(''); | 742 | 735 | }); | 743 | 736 |
| 744 | 737 | // @gate experimental | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/events/plugins/__tests__/SimpleEventPlugin-test.js +9-18Lines changed: 9 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -470,24 +470,15 @@ describe('SimpleEventPlugin', function() { | 470 | 470 | 'High-pri count: 7, Low-pri count: 0', | 471 | 471 | ]); | 472 | 472 |
| 473 | | - if (gate(flags => flags.enableDiscreteEventMicroTasks)) { | 474 | | - // Flush the microtask queue | 475 | | - await null; | 476 | | - | 477 | | - // At the end, both counters should equal the total number of clicks | 478 | | - expect(Scheduler).toHaveYielded([ | 479 | | - 'High-pri count: 8, Low-pri count: 0', | 480 | | - ]); | 481 | | - expect(Scheduler).toFlushAndYield([ | 482 | | - 'High-pri count: 8, Low-pri count: 8', | 483 | | - ]); | 484 | | - } else { | 485 | | - // At the end, both counters should equal the total number of clicks | 486 | | - expect(Scheduler).toFlushAndYield([ | 487 | | - 'High-pri count: 8, Low-pri count: 0', | 488 | | - 'High-pri count: 8, Low-pri count: 8', | 489 | | - ]); | 490 | | - } | | 473 | + // Flush the microtask queue | | 474 | + await null; | | 475 | + | | 476 | + // At the end, both counters should equal the total number of clicks | | 477 | + expect(Scheduler).toHaveYielded(['High-pri count: 8, Low-pri count: 0']); | | 478 | + expect(Scheduler).toFlushAndYield([ | | 479 | + 'High-pri count: 8, Low-pri count: 8', | | 480 | + ]); | | 481 | + | 491 | 482 | expect(button.textContent).toEqual('High-pri count: 8, Low-pri count: 8'); | 492 | 483 | }); | 493 | 484 | }); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-noop-renderer/src/createReactNoop.js +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,10 +27,7 @@ import { | 27 | 27 | LegacyRoot, | 28 | 28 | } from 'react-reconciler/src/ReactRootTags'; | 29 | 29 |
| 30 | | -import { | 31 | | - enableNativeEventPriorityInference, | 32 | | - enableDiscreteEventMicroTasks, | 33 | | -} from 'shared/ReactFeatureFlags'; | | 30 | +import {enableNativeEventPriorityInference} from 'shared/ReactFeatureFlags'; | 34 | 31 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 35 | 32 | import enqueueTask from 'shared/enqueueTask'; | 36 | 33 | const {IsSomeRendererActing} = ReactSharedInternals; | @@ -376,7 +373,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { | 376 | 373 | cancelTimeout: clearTimeout, | 377 | 374 | noTimeout: -1, | 378 | 375 |
| 379 | | - supportsMicrotasks: enableDiscreteEventMicroTasks, | | 376 | + supportsMicrotasks: true, | 380 | 377 | scheduleMicrotask: | 381 | 378 | typeof queueMicrotask === 'function' | 382 | 379 | ? queueMicrotask | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js -50Lines changed: 0 additions & 50 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3518,56 +3518,6 @@ describe('ReactSuspenseWithNoopRenderer', () => { | 3518 | 3518 | ); | 3519 | 3519 | }); | 3520 | 3520 |
| 3521 | | - // @gate enableCache | 3522 | | - // @gate !enableDiscreteEventMicroTasks | 3523 | | - it('regression: empty render at high priority causes update to be dropped', async () => { | 3524 | | - // Reproduces a bug where flushDiscreteUpdates starts a new (empty) render | 3525 | | - // pass which cancels a scheduled timeout and causes the fallback never to | 3526 | | - // be committed. | 3527 | | - function App({text, shouldSuspend}) { | 3528 | | - return ( | 3529 | | - <> | 3530 | | - <Text text={text} /> | 3531 | | - <Suspense fallback={<Text text="Loading..." />}> | 3532 | | - {shouldSuspend && <AsyncText text="B" />} | 3533 | | - </Suspense> | 3534 | | - </> | 3535 | | - ); | 3536 | | - } | 3537 | | - | 3538 | | - const root = ReactNoop.createRoot(); | 3539 | | - ReactNoop.discreteUpdates(() => { | 3540 | | - // High pri | 3541 | | - root.render(<App text="A" />); | 3542 | | - }); | 3543 | | - // Low pri | 3544 | | - root.render(<App text="A" shouldSuspend={true} />); | 3545 | | - | 3546 | | - expect(Scheduler).toFlushAndYield([ | 3547 | | - // Render the high pri update | 3548 | | - 'A', | 3549 | | - // Render the low pri update | 3550 | | - 'A', | 3551 | | - 'Suspend! [B]', | 3552 | | - 'Loading...', | 3553 | | - ]); | 3554 | | - expect(root).toMatchRenderedOutput(<span prop="A" />); | 3555 | | - | 3556 | | - // Triggers erstwhile bug where flushDiscreteUpdates caused an empty render | 3557 | | - // at a previously committed level | 3558 | | - ReactNoop.flushDiscreteUpdates(); | 3559 | | - | 3560 | | - // Commit the placeholder | 3561 | | - Scheduler.unstable_advanceTime(2000); | 3562 | | - await advanceTimers(2000); | 3563 | | - expect(root).toMatchRenderedOutput( | 3564 | | - <> | 3565 | | - <span prop="A" /> | 3566 | | - <span prop="Loading..." /> | 3567 | | - </>, | 3568 | | - ); | 3569 | | - }); | 3570 | | - | 3571 | 3521 | // @gate experimental | 3572 | 3522 | // @gate enableCache | 3573 | 3523 | it('regression: ping at high priority causes update to be dropped', async () => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/ReactFeatureFlags.js -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -150,8 +150,6 @@ export const enableRecursiveCommitTraversal = false; | 150 | 150 |
| 151 | 151 | export const disableSchedulerTimeoutInWorkLoop = false; | 152 | 152 |
| 153 | | -export const enableDiscreteEventMicroTasks = false; | 154 | | - | 155 | 153 | export const enableSyncMicroTasks = false; | 156 | 154 |
| 157 | 155 | export const enableNativeEventPriorityInference = false; | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-fb.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; | 57 | 57 |
| 58 | 58 | export const enableRecursiveCommitTraversal = false; | 59 | 59 | export const disableSchedulerTimeoutInWorkLoop = false; | 60 | | -export const enableDiscreteEventMicroTasks = false; | 61 | 60 | export const enableSyncMicroTasks = false; | 62 | 61 | export const enableNativeEventPriorityInference = false; | 63 | 62 | export const enableLazyContextPropagation = false; | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-oss.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,6 @@ export const enableUseRefAccessWarning = false; | 56 | 56 |
| 57 | 57 | export const enableRecursiveCommitTraversal = false; | 58 | 58 | export const disableSchedulerTimeoutInWorkLoop = false; | 59 | | -export const enableDiscreteEventMicroTasks = false; | 60 | 59 | export const enableSyncMicroTasks = false; | 61 | 60 | export const enableNativeEventPriorityInference = false; | 62 | 61 | export const enableLazyContextPropagation = false; | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.js -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,6 @@ export const enableUseRefAccessWarning = false; | 56 | 56 |
| 57 | 57 | export const enableRecursiveCommitTraversal = false; | 58 | 58 | export const disableSchedulerTimeoutInWorkLoop = false; | 59 | | -export const enableDiscreteEventMicroTasks = false; | 60 | 59 | export const enableSyncMicroTasks = false; | 61 | 60 | export const enableNativeEventPriorityInference = false; | 62 | 61 | export const enableLazyContextPropagation = false; | |
|