@@ -24,14 +24,18 @@ import {ELEMENT_NODE} from '../shared/HTMLNodeType';
2424import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes' ;
2525
2626const { findDOMNode} = ReactDOM ;
27- const {
28- EventPluginHub,
29- EventPluginRegistry,
30- EventPropagators,
31- ReactControlledComponent,
32- ReactDOMComponentTree,
33- ReactDOMEventListener,
34- } = ReactDOM . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ;
27+ const [
28+ eventNameDispatchConfigs ,
29+ accumulateTwoPhaseDispatches ,
30+ accumulateDirectDispatches ,
31+ enqueueStateRestore ,
32+ restoreStateIfNeeded ,
33+ dispatchEvent ,
34+ runEventsInBatch ,
35+ // eslint-disable-next-line no-unused-vars
36+ getFiberCurrentPropsFromNode ,
37+ getInstanceFromNode ,
38+ ] = ReactDOM . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED . Events ;
3539
3640function Event ( suffix ) { }
3741
@@ -50,7 +54,7 @@ let hasWarnedAboutDeprecatedMockComponent = false;
5054 */
5155function simulateNativeEventOnNode ( topLevelType , node , fakeNativeEvent ) {
5256 fakeNativeEvent . target = node ;
53- ReactDOMEventListener . dispatchEvent ( topLevelType , fakeNativeEvent ) ;
57+ dispatchEvent ( topLevelType , fakeNativeEvent ) ;
5458}
5559
5660/**
@@ -399,16 +403,15 @@ function makeSimulator(eventType) {
399403 'a component instance. Pass the DOM node you wish to simulate the event on instead.' ,
400404 ) ;
401405
402- const dispatchConfig =
403- EventPluginRegistry . eventNameDispatchConfigs [ eventType ] ;
406+ const dispatchConfig = eventNameDispatchConfigs [ eventType ] ;
404407
405408 const fakeNativeEvent = new Event ( ) ;
406409 fakeNativeEvent . target = domNode ;
407410 fakeNativeEvent . type = eventType . toLowerCase ( ) ;
408411
409412 // We don't use SyntheticEvent.getPooled in order to not have to worry about
410413 // properly destroying any properties assigned from `eventData` upon release
411- const targetInst = ReactDOMComponentTree . getInstanceFromNode ( domNode ) ;
414+ const targetInst = getInstanceFromNode ( domNode ) ;
412415 const event = new SyntheticEvent (
413416 dispatchConfig ,
414417 targetInst ,
@@ -422,26 +425,26 @@ function makeSimulator(eventType) {
422425 Object . assign ( event , eventData ) ;
423426
424427 if ( dispatchConfig . phasedRegistrationNames ) {
425- EventPropagators . accumulateTwoPhaseDispatches ( event ) ;
428+ accumulateTwoPhaseDispatches ( event ) ;
426429 } else {
427- EventPropagators . accumulateDirectDispatches ( event ) ;
430+ accumulateDirectDispatches ( event ) ;
428431 }
429432
430433 ReactDOM . unstable_batchedUpdates ( function ( ) {
431434 // Normally extractEvent enqueues a state restore, but we'll just always
432435 // do that since we we're by-passing it here.
433- ReactControlledComponent . enqueueStateRestore ( domNode ) ;
434- EventPluginHub . runEventsInBatch ( event , true ) ;
436+ enqueueStateRestore ( domNode ) ;
437+ runEventsInBatch ( event , true ) ;
435438 } ) ;
436- ReactControlledComponent . restoreStateIfNeeded ( ) ;
439+ restoreStateIfNeeded ( ) ;
437440 } ;
438441}
439442
440443function buildSimulators ( ) {
441444 ReactTestUtils . Simulate = { } ;
442445
443446 let eventType ;
444- for ( eventType in EventPluginRegistry . eventNameDispatchConfigs ) {
447+ for ( eventType in eventNameDispatchConfigs ) {
445448 /**
446449 * @param {!Element|ReactDOMComponent } domComponentOrNode
447450 * @param {?object } eventData Fake event data to use in SyntheticEvent.
@@ -450,19 +453,6 @@ function buildSimulators() {
450453 }
451454}
452455
453- // Rebuild ReactTestUtils.Simulate whenever event plugins are injected
454- const oldInjectEventPluginOrder =
455- EventPluginHub . injection . injectEventPluginOrder ;
456- EventPluginHub . injection . injectEventPluginOrder = function ( ) {
457- oldInjectEventPluginOrder . apply ( this , arguments ) ;
458- buildSimulators ( ) ;
459- } ;
460- const oldInjectEventPlugins = EventPluginHub . injection . injectEventPluginsByName ;
461- EventPluginHub . injection . injectEventPluginsByName = function ( ) {
462- oldInjectEventPlugins . apply ( this , arguments ) ;
463- buildSimulators ( ) ;
464- } ;
465-
466456buildSimulators ( ) ;
467457
468458/**
0 commit comments