@@ -53,6 +53,7 @@ import {
53
53
enableLegacyFBSupport ,
54
54
enableCreateEventHandleAPI ,
55
55
enableScopeAPI ,
56
+ enablePassiveEventIntervention ,
56
57
} from 'shared/ReactFeatureFlags' ;
57
58
import {
58
59
invokeGuardedCallbackAndCatchFirstError ,
@@ -342,6 +343,21 @@ export function listenToNativeEvent(
342
343
if ( domEventName === 'selectionchange' ) {
343
344
target = ( rootContainerElement : any ) . ownerDocument ;
344
345
}
346
+ if ( enablePassiveEventIntervention && isPassiveListener === undefined ) {
347
+ // Browsers introduced an intervention, making these events
348
+ // passive by default on document. React doesn't bind them
349
+ // to document anymore, but changing this now would undo
350
+ // the performance wins from the change. So we emulate
351
+ // the existing behavior manually on the roots now.
352
+ // https://github.com/facebook/react/issues/19651
353
+ if (
354
+ domEventName === 'touchstart' ||
355
+ domEventName === 'touchmove' ||
356
+ domEventName === 'wheel'
357
+ ) {
358
+ isPassiveListener = true ;
359
+ }
360
+ }
345
361
// If the event can be delegated (or is capture phase), we can
346
362
// register it to the root container. Otherwise, we should
347
363
// register the event to the target element and mark it as
@@ -506,7 +522,7 @@ function addTrappedEventListener(
506
522
} ;
507
523
}
508
524
if ( isCapturePhaseListener ) {
509
- if ( enableCreateEventHandleAPI && isPassiveListener !== undefined ) {
525
+ if ( isPassiveListener !== undefined ) {
510
526
unsubscribeListener = addEventCaptureListenerWithPassiveFlag (
511
527
targetContainer ,
512
528
domEventName ,
@@ -521,7 +537,7 @@ function addTrappedEventListener(
521
537
) ;
522
538
}
523
539
} else {
524
- if ( enableCreateEventHandleAPI && isPassiveListener !== undefined ) {
540
+ if ( isPassiveListener !== undefined ) {
525
541
unsubscribeListener = addEventBubbleListenerWithPassiveFlag (
526
542
targetContainer ,
527
543
domEventName ,
0 commit comments