@@ -61,25 +61,16 @@ import { |
61 | 61 | shouldRemoveAttribute, |
62 | 62 | } from '../shared/DOMProperty'; |
63 | 63 | import 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'; |
70 | 65 | import isCustomComponent from '../shared/isCustomComponent'; |
71 | 66 | import possibleStandardNames from '../shared/possibleStandardNames'; |
72 | 67 | import {validateProperties as validateARIAProperties} from '../shared/ReactDOMInvalidARIAHook'; |
73 | 68 | import {validateProperties as validateInputProperties} from '../shared/ReactDOMNullInputValuePropHook'; |
74 | 69 | import {validateProperties as validateUnknownProperties} from '../shared/ReactDOMUnknownPropertyHook'; |
75 | 70 | import {REACT_OPAQUE_ID_TYPE} from 'shared/ReactSymbols'; |
76 | 71 |
|
| 72 | +import {enableTrustedTypesIntegration} from 'shared/ReactFeatureFlags'; |
77 | 73 | import { |
78 | | - enableTrustedTypesIntegration, |
79 | | - enableEagerRootListeners, |
80 | | -} from 'shared/ReactFeatureFlags'; |
81 | | -import { |
82 | | - listenToReactEvent, |
83 | 74 | mediaEventTypes, |
84 | 75 | listenToNonDelegatedEvent, |
85 | 76 | } from '../events/DOMPluginEventSystem'; |
@@ -253,39 +244,6 @@ if (__DEV__) { |
253 | 244 | }; |
254 | 245 | } |
255 | 246 |
|
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 | | - |
289 | 247 | function getOwnerDocumentFromRootContainer( |
290 | 248 | rootContainerElement: Element | Document, |
291 | 249 | ): Document { |
@@ -364,9 +322,7 @@ function setInitialDOMProperties( |
364 | 322 | if (__DEV__ && typeof nextProp !== 'function') { |
365 | 323 | warnForInvalidEventListener(propKey, nextProp); |
366 | 324 | } |
367 | | - if (!enableEagerRootListeners) { |
368 | | - ensureListeningTo(rootContainerElement, propKey, domElement); |
369 | | - } else if (propKey === 'onScroll') { |
| 325 | + if (propKey === 'onScroll') { |
370 | 326 | listenToNonDelegatedEvent('scroll', domElement); |
371 | 327 | } |
372 | 328 | } |
@@ -577,11 +533,6 @@ export function setInitialProperties( |
577 | 533 | // We listen to this event in case to ensure emulated bubble |
578 | 534 | // listeners still fire for the invalid event. |
579 | 535 | 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 | | - } |
585 | 536 | break; |
586 | 537 | case 'option': |
587 | 538 | ReactDOMOptionValidateProps(domElement, rawProps); |
@@ -593,23 +544,13 @@ export function setInitialProperties( |
593 | 544 | // We listen to this event in case to ensure emulated bubble |
594 | 545 | // listeners still fire for the invalid event. |
595 | 546 | 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 | | - } |
601 | 547 | break; |
602 | 548 | case 'textarea': |
603 | 549 | ReactDOMTextareaInitWrapperState(domElement, rawProps); |
604 | 550 | props = ReactDOMTextareaGetHostProps(domElement, rawProps); |
605 | 551 | // We listen to this event in case to ensure emulated bubble |
606 | 552 | // listeners still fire for the invalid event. |
607 | 553 | 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 | | - } |
613 | 554 | break; |
614 | 555 | default: |
615 | 556 | props = rawProps; |
@@ -827,9 +768,7 @@ export function diffProperties( |
827 | 768 | if (__DEV__ && typeof nextProp !== 'function') { |
828 | 769 | warnForInvalidEventListener(propKey, nextProp); |
829 | 770 | } |
830 | | - if (!enableEagerRootListeners) { |
831 | | - ensureListeningTo(rootContainerElement, propKey, domElement); |
832 | | - } else if (propKey === 'onScroll') { |
| 771 | + if (propKey === 'onScroll') { |
833 | 772 | listenToNonDelegatedEvent('scroll', domElement); |
834 | 773 | } |
835 | 774 | } |
@@ -983,11 +922,6 @@ export function diffHydratedProperties( |
983 | 922 | // We listen to this event in case to ensure emulated bubble |
984 | 923 | // listeners still fire for the invalid event. |
985 | 924 | 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 | | - } |
991 | 925 | break; |
992 | 926 | case 'option': |
993 | 927 | ReactDOMOptionValidateProps(domElement, rawProps); |
@@ -997,22 +931,12 @@ export function diffHydratedProperties( |
997 | 931 | // We listen to this event in case to ensure emulated bubble |
998 | 932 | // listeners still fire for the invalid event. |
999 | 933 | 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 | | - } |
1005 | 934 | break; |
1006 | 935 | case 'textarea': |
1007 | 936 | ReactDOMTextareaInitWrapperState(domElement, rawProps); |
1008 | 937 | // We listen to this event in case to ensure emulated bubble |
1009 | 938 | // listeners still fire for the invalid event. |
1010 | 939 | 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 | | - } |
1016 | 940 | break; |
1017 | 941 | } |
1018 | 942 |
|
@@ -1079,9 +1003,7 @@ export function diffHydratedProperties( |
1079 | 1003 | if (__DEV__ && typeof nextProp !== 'function') { |
1080 | 1004 | warnForInvalidEventListener(propKey, nextProp); |
1081 | 1005 | } |
1082 | | - if (!enableEagerRootListeners) { |
1083 | | - ensureListeningTo(rootContainerElement, propKey, domElement); |
1084 | | - } else if (propKey === 'onScroll') { |
| 1006 | + if (propKey === 'onScroll') { |
1085 | 1007 | listenToNonDelegatedEvent('scroll', domElement); |
1086 | 1008 | } |
1087 | 1009 | } |
|