@@ -61,25 +61,16 @@ import {
6161 shouldRemoveAttribute ,
6262} from '../shared/DOMProperty' ;
6363import assertValidProps from '../shared/assertValidProps' ;
64- import {
65- DOCUMENT_NODE ,
66- ELEMENT_NODE ,
67- COMMENT_NODE ,
68- DOCUMENT_FRAGMENT_NODE ,
69- } from '../shared/HTMLNodeType' ;
64+ import { DOCUMENT_NODE } from '../shared/HTMLNodeType' ;
7065import isCustomComponent from '../shared/isCustomComponent' ;
7166import possibleStandardNames from '../shared/possibleStandardNames' ;
7267import { validateProperties as validateARIAProperties } from '../shared/ReactDOMInvalidARIAHook' ;
7368import { validateProperties as validateInputProperties } from '../shared/ReactDOMNullInputValuePropHook' ;
7469import { validateProperties as validateUnknownProperties } from '../shared/ReactDOMUnknownPropertyHook' ;
7570import { REACT_OPAQUE_ID_TYPE } from 'shared/ReactSymbols' ;
7671
72+ import { enableTrustedTypesIntegration } from 'shared/ReactFeatureFlags' ;
7773import {
78- enableTrustedTypesIntegration ,
79- enableEagerRootListeners ,
80- } from 'shared/ReactFeatureFlags' ;
81- import {
82- listenToReactEvent ,
8374 mediaEventTypes ,
8475 listenToNonDelegatedEvent ,
8576} from '../events/DOMPluginEventSystem' ;
@@ -253,39 +244,6 @@ if (__DEV__) {
253244 } ;
254245}
255246
256- export function ensureListeningTo (
257- rootContainerInstance : Element | Node ,
258- reactPropEvent : string ,
259- targetElement : Element | null ,
260- ) : void {
261- if ( ! enableEagerRootListeners ) {
262- // If we have a comment node, then use the parent node,
263- // which should be an element.
264- const rootContainerElement =
265- rootContainerInstance . nodeType === COMMENT_NODE
266- ? rootContainerInstance . parentNode
267- : rootContainerInstance ;
268- if ( __DEV__ ) {
269- if (
270- rootContainerElement == null ||
271- ( rootContainerElement . nodeType !== ELEMENT_NODE &&
272- // This is to support rendering into a ShadowRoot:
273- rootContainerElement . nodeType !== DOCUMENT_FRAGMENT_NODE )
274- ) {
275- console . error (
276- 'ensureListeningTo(): received a container that was not an element node. ' +
277- 'This is likely a bug in React. Please file an issue.' ,
278- ) ;
279- }
280- }
281- listenToReactEvent (
282- reactPropEvent ,
283- ( ( rootContainerElement : any ) : Element ) ,
284- targetElement ,
285- ) ;
286- }
287- }
288-
289247function getOwnerDocumentFromRootContainer (
290248 rootContainerElement : Element | Document ,
291249) : Document {
@@ -364,9 +322,7 @@ function setInitialDOMProperties(
364322 if ( __DEV__ && typeof nextProp !== 'function' ) {
365323 warnForInvalidEventListener ( propKey , nextProp ) ;
366324 }
367- if ( ! enableEagerRootListeners ) {
368- ensureListeningTo ( rootContainerElement , propKey , domElement ) ;
369- } else if ( propKey === 'onScroll' ) {
325+ if ( propKey === 'onScroll' ) {
370326 listenToNonDelegatedEvent ( 'scroll' , domElement ) ;
371327 }
372328 }
@@ -577,11 +533,6 @@ export function setInitialProperties(
577533 // We listen to this event in case to ensure emulated bubble
578534 // listeners still fire for the invalid event.
579535 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
580- if ( ! enableEagerRootListeners ) {
581- // For controlled components we always need to ensure we're listening
582- // to onChange. Even if there is no listener.
583- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
584- }
585536 break ;
586537 case 'option' :
587538 ReactDOMOptionValidateProps ( domElement , rawProps ) ;
@@ -593,23 +544,13 @@ export function setInitialProperties(
593544 // We listen to this event in case to ensure emulated bubble
594545 // listeners still fire for the invalid event.
595546 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
596- if ( ! enableEagerRootListeners ) {
597- // For controlled components we always need to ensure we're listening
598- // to onChange. Even if there is no listener.
599- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
600- }
601547 break ;
602548 case 'textarea' :
603549 ReactDOMTextareaInitWrapperState ( domElement , rawProps ) ;
604550 props = ReactDOMTextareaGetHostProps ( domElement , rawProps ) ;
605551 // We listen to this event in case to ensure emulated bubble
606552 // listeners still fire for the invalid event.
607553 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
608- if ( ! enableEagerRootListeners ) {
609- // For controlled components we always need to ensure we're listening
610- // to onChange. Even if there is no listener.
611- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
612- }
613554 break ;
614555 default :
615556 props = rawProps ;
@@ -827,9 +768,7 @@ export function diffProperties(
827768 if ( __DEV__ && typeof nextProp !== 'function' ) {
828769 warnForInvalidEventListener ( propKey , nextProp ) ;
829770 }
830- if ( ! enableEagerRootListeners ) {
831- ensureListeningTo ( rootContainerElement , propKey , domElement ) ;
832- } else if ( propKey === 'onScroll' ) {
771+ if ( propKey === 'onScroll' ) {
833772 listenToNonDelegatedEvent ( 'scroll' , domElement ) ;
834773 }
835774 }
@@ -983,11 +922,6 @@ export function diffHydratedProperties(
983922 // We listen to this event in case to ensure emulated bubble
984923 // listeners still fire for the invalid event.
985924 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
986- if ( ! enableEagerRootListeners ) {
987- // For controlled components we always need to ensure we're listening
988- // to onChange. Even if there is no listener.
989- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
990- }
991925 break ;
992926 case 'option' :
993927 ReactDOMOptionValidateProps ( domElement , rawProps ) ;
@@ -997,22 +931,12 @@ export function diffHydratedProperties(
997931 // We listen to this event in case to ensure emulated bubble
998932 // listeners still fire for the invalid event.
999933 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
1000- if ( ! enableEagerRootListeners ) {
1001- // For controlled components we always need to ensure we're listening
1002- // to onChange. Even if there is no listener.
1003- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
1004- }
1005934 break ;
1006935 case 'textarea' :
1007936 ReactDOMTextareaInitWrapperState ( domElement , rawProps ) ;
1008937 // We listen to this event in case to ensure emulated bubble
1009938 // listeners still fire for the invalid event.
1010939 listenToNonDelegatedEvent ( 'invalid' , domElement ) ;
1011- if ( ! enableEagerRootListeners ) {
1012- // For controlled components we always need to ensure we're listening
1013- // to onChange. Even if there is no listener.
1014- ensureListeningTo ( rootContainerElement , 'onChange' , domElement ) ;
1015- }
1016940 break ;
1017941 }
1018942
@@ -1079,9 +1003,7 @@ export function diffHydratedProperties(
10791003 if ( __DEV__ && typeof nextProp !== 'function' ) {
10801004 warnForInvalidEventListener ( propKey , nextProp ) ;
10811005 }
1082- if ( ! enableEagerRootListeners ) {
1083- ensureListeningTo ( rootContainerElement , propKey , domElement ) ;
1084- } else if ( propKey === 'onScroll' ) {
1006+ if ( propKey === 'onScroll' ) {
10851007 listenToNonDelegatedEvent ( 'scroll' , domElement ) ;
10861008 }
10871009 }
0 commit comments