@@ -24,14 +24,22 @@ 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+ // Keep in sync with ReactDOMUnstableNativeDependencies.js
28+ // and ReactDOM.js:
29+ const [
30+ getInstanceFromNode ,
31+ /* eslint-disable no-unused-vars */
32+ getNodeFromInstance ,
33+ getFiberCurrentPropsFromNode ,
34+ /* eslint-enable no-unused-vars */
35+ eventNameDispatchConfigs ,
36+ accumulateTwoPhaseDispatches ,
37+ accumulateDirectDispatches ,
38+ enqueueStateRestore ,
39+ restoreStateIfNeeded ,
40+ dispatchEvent ,
41+ runEventsInBatch ,
42+ ] = ReactDOM . __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED . Events ;
3543
3644function Event ( suffix ) { }
3745
@@ -50,7 +58,7 @@ let hasWarnedAboutDeprecatedMockComponent = false;
5058 */
5159function simulateNativeEventOnNode ( topLevelType , node , fakeNativeEvent ) {
5260 fakeNativeEvent . target = node ;
53- ReactDOMEventListener . dispatchEvent ( topLevelType , fakeNativeEvent ) ;
61+ dispatchEvent ( topLevelType , fakeNativeEvent ) ;
5462}
5563
5664/**
@@ -399,16 +407,15 @@ function makeSimulator(eventType) {
399407 'a component instance. Pass the DOM node you wish to simulate the event on instead.' ,
400408 ) ;
401409
402- const dispatchConfig =
403- EventPluginRegistry . eventNameDispatchConfigs [ eventType ] ;
410+ const dispatchConfig = eventNameDispatchConfigs [ eventType ] ;
404411
405412 const fakeNativeEvent = new Event ( ) ;
406413 fakeNativeEvent . target = domNode ;
407414 fakeNativeEvent . type = eventType . toLowerCase ( ) ;
408415
409416 // We don't use SyntheticEvent.getPooled in order to not have to worry about
410417 // properly destroying any properties assigned from `eventData` upon release
411- const targetInst = ReactDOMComponentTree . getInstanceFromNode ( domNode ) ;
418+ const targetInst = getInstanceFromNode ( domNode ) ;
412419 const event = new SyntheticEvent (
413420 dispatchConfig ,
414421 targetInst ,
@@ -422,26 +429,26 @@ function makeSimulator(eventType) {
422429 Object . assign ( event , eventData ) ;
423430
424431 if ( dispatchConfig . phasedRegistrationNames ) {
425- EventPropagators . accumulateTwoPhaseDispatches ( event ) ;
432+ accumulateTwoPhaseDispatches ( event ) ;
426433 } else {
427- EventPropagators . accumulateDirectDispatches ( event ) ;
434+ accumulateDirectDispatches ( event ) ;
428435 }
429436
430437 ReactDOM . unstable_batchedUpdates ( function ( ) {
431438 // Normally extractEvent enqueues a state restore, but we'll just always
432439 // do that since we we're by-passing it here.
433- ReactControlledComponent . enqueueStateRestore ( domNode ) ;
434- EventPluginHub . runEventsInBatch ( event , true ) ;
440+ enqueueStateRestore ( domNode ) ;
441+ runEventsInBatch ( event , true ) ;
435442 } ) ;
436- ReactControlledComponent . restoreStateIfNeeded ( ) ;
443+ restoreStateIfNeeded ( ) ;
437444 } ;
438445}
439446
440447function buildSimulators ( ) {
441448 ReactTestUtils . Simulate = { } ;
442449
443450 let eventType ;
444- for ( eventType in EventPluginRegistry . eventNameDispatchConfigs ) {
451+ for ( eventType in eventNameDispatchConfigs ) {
445452 /**
446453 * @param {!Element|ReactDOMComponent } domComponentOrNode
447454 * @param {?object } eventData Fake event data to use in SyntheticEvent.
@@ -450,19 +457,6 @@ function buildSimulators() {
450457 }
451458}
452459
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-
466460buildSimulators ( ) ;
467461
468462/**
0 commit comments