@@ -53,6 +53,7 @@ import {
5353 enableLegacyFBSupport ,
5454 enableCreateEventHandleAPI ,
5555 enableScopeAPI ,
56+ enablePassiveEventIntervention ,
5657} from 'shared/ReactFeatureFlags' ;
5758import {
5859 invokeGuardedCallbackAndCatchFirstError ,
@@ -342,6 +343,21 @@ export function listenToNativeEvent(
342343 if ( domEventName === 'selectionchange' ) {
343344 target = ( rootContainerElement : any ) . ownerDocument ;
344345 }
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+ }
345361 // If the event can be delegated (or is capture phase), we can
346362 // register it to the root container. Otherwise, we should
347363 // register the event to the target element and mark it as
@@ -506,7 +522,7 @@ function addTrappedEventListener(
506522 } ;
507523 }
508524 if ( isCapturePhaseListener ) {
509- if ( enableCreateEventHandleAPI && isPassiveListener !== undefined ) {
525+ if ( isPassiveListener !== undefined ) {
510526 unsubscribeListener = addEventCaptureListenerWithPassiveFlag (
511527 targetContainer ,
512528 domEventName ,
@@ -521,7 +537,7 @@ function addTrappedEventListener(
521537 ) ;
522538 }
523539 } else {
524- if ( enableCreateEventHandleAPI && isPassiveListener !== undefined ) {
540+ if ( isPassiveListener !== undefined ) {
525541 unsubscribeListener = addEventBubbleListenerWithPassiveFlag (
526542 targetContainer ,
527543 domEventName ,
0 commit comments