@@ -24,14 +24,17 @@ 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 , // getFiberCurrentPropsFromNode
35+ ,
36+ getInstanceFromNode ,
37+ ] = ReactDOM . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED . Events ;
3538
3639function Event ( suffix ) { }
3740
@@ -50,7 +53,7 @@ let hasWarnedAboutDeprecatedMockComponent = false;
5053 */
5154function simulateNativeEventOnNode ( topLevelType , node , fakeNativeEvent ) {
5255 fakeNativeEvent . target = node ;
53- ReactDOMEventListener . dispatchEvent ( topLevelType , fakeNativeEvent ) ;
56+ dispatchEvent ( topLevelType , fakeNativeEvent ) ;
5457}
5558
5659/**
@@ -399,16 +402,15 @@ function makeSimulator(eventType) {
399402 'a component instance. Pass the DOM node you wish to simulate the event on instead.' ,
400403 ) ;
401404
402- const dispatchConfig =
403- EventPluginRegistry . eventNameDispatchConfigs [ eventType ] ;
405+ const dispatchConfig = eventNameDispatchConfigs [ eventType ] ;
404406
405407 const fakeNativeEvent = new Event ( ) ;
406408 fakeNativeEvent . target = domNode ;
407409 fakeNativeEvent . type = eventType . toLowerCase ( ) ;
408410
409411 // We don't use SyntheticEvent.getPooled in order to not have to worry about
410412 // properly destroying any properties assigned from `eventData` upon release
411- const targetInst = ReactDOMComponentTree . getInstanceFromNode ( domNode ) ;
413+ const targetInst = getInstanceFromNode ( domNode ) ;
412414 const event = new SyntheticEvent (
413415 dispatchConfig ,
414416 targetInst ,
@@ -422,26 +424,26 @@ function makeSimulator(eventType) {
422424 Object . assign ( event , eventData ) ;
423425
424426 if ( dispatchConfig . phasedRegistrationNames ) {
425- EventPropagators . accumulateTwoPhaseDispatches ( event ) ;
427+ accumulateTwoPhaseDispatches ( event ) ;
426428 } else {
427- EventPropagators . accumulateDirectDispatches ( event ) ;
429+ accumulateDirectDispatches ( event ) ;
428430 }
429431
430432 ReactDOM . unstable_batchedUpdates ( function ( ) {
431433 // Normally extractEvent enqueues a state restore, but we'll just always
432434 // do that since we we're by-passing it here.
433- ReactControlledComponent . enqueueStateRestore ( domNode ) ;
434- EventPluginHub . runEventsInBatch ( event , true ) ;
435+ enqueueStateRestore ( domNode ) ;
436+ runEventsInBatch ( event , true ) ;
435437 } ) ;
436- ReactControlledComponent . restoreStateIfNeeded ( ) ;
438+ restoreStateIfNeeded ( ) ;
437439 } ;
438440}
439441
440442function buildSimulators ( ) {
441443 ReactTestUtils . Simulate = { } ;
442444
443445 let eventType ;
444- for ( eventType in EventPluginRegistry . eventNameDispatchConfigs ) {
446+ for ( eventType in eventNameDispatchConfigs ) {
445447 /**
446448 * @param {!Element|ReactDOMComponent } domComponentOrNode
447449 * @param {?object } eventData Fake event data to use in SyntheticEvent.
@@ -450,19 +452,6 @@ function buildSimulators() {
450452 }
451453}
452454
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-
466455buildSimulators ( ) ;
467456
468457/**
0 commit comments