@@ -24,14 +24,22 @@ import {ELEMENT_NODE} from '../shared/HTMLNodeType';
24
24
import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes' ;
25
25
26
26
const { 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 ;
35
43
36
44
function Event ( suffix ) { }
37
45
@@ -50,7 +58,7 @@ let hasWarnedAboutDeprecatedMockComponent = false;
50
58
*/
51
59
function simulateNativeEventOnNode ( topLevelType , node , fakeNativeEvent ) {
52
60
fakeNativeEvent . target = node ;
53
- ReactDOMEventListener . dispatchEvent ( topLevelType , fakeNativeEvent ) ;
61
+ dispatchEvent ( topLevelType , fakeNativeEvent ) ;
54
62
}
55
63
56
64
/**
@@ -399,16 +407,15 @@ function makeSimulator(eventType) {
399
407
'a component instance. Pass the DOM node you wish to simulate the event on instead.' ,
400
408
) ;
401
409
402
- const dispatchConfig =
403
- EventPluginRegistry . eventNameDispatchConfigs [ eventType ] ;
410
+ const dispatchConfig = eventNameDispatchConfigs [ eventType ] ;
404
411
405
412
const fakeNativeEvent = new Event ( ) ;
406
413
fakeNativeEvent . target = domNode ;
407
414
fakeNativeEvent . type = eventType . toLowerCase ( ) ;
408
415
409
416
// We don't use SyntheticEvent.getPooled in order to not have to worry about
410
417
// properly destroying any properties assigned from `eventData` upon release
411
- const targetInst = ReactDOMComponentTree . getInstanceFromNode ( domNode ) ;
418
+ const targetInst = getInstanceFromNode ( domNode ) ;
412
419
const event = new SyntheticEvent (
413
420
dispatchConfig ,
414
421
targetInst ,
@@ -422,26 +429,26 @@ function makeSimulator(eventType) {
422
429
Object . assign ( event , eventData ) ;
423
430
424
431
if ( dispatchConfig . phasedRegistrationNames ) {
425
- EventPropagators . accumulateTwoPhaseDispatches ( event ) ;
432
+ accumulateTwoPhaseDispatches ( event ) ;
426
433
} else {
427
- EventPropagators . accumulateDirectDispatches ( event ) ;
434
+ accumulateDirectDispatches ( event ) ;
428
435
}
429
436
430
437
ReactDOM . unstable_batchedUpdates ( function ( ) {
431
438
// Normally extractEvent enqueues a state restore, but we'll just always
432
439
// 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 ) ;
435
442
} ) ;
436
- ReactControlledComponent . restoreStateIfNeeded ( ) ;
443
+ restoreStateIfNeeded ( ) ;
437
444
} ;
438
445
}
439
446
440
447
function buildSimulators ( ) {
441
448
ReactTestUtils . Simulate = { } ;
442
449
443
450
let eventType ;
444
- for ( eventType in EventPluginRegistry . eventNameDispatchConfigs ) {
451
+ for ( eventType in eventNameDispatchConfigs ) {
445
452
/**
446
453
* @param {!Element|ReactDOMComponent } domComponentOrNode
447
454
* @param {?object } eventData Fake event data to use in SyntheticEvent.
@@ -450,19 +457,6 @@ function buildSimulators() {
450
457
}
451
458
}
452
459
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
-
466
460
buildSimulators ( ) ;
467
461
468
462
/**
0 commit comments