@@ -31,7 +31,6 @@ const [
31
31
getNodeFromInstance ,
32
32
getFiberCurrentPropsFromNode ,
33
33
/* eslint-enable no-unused-vars */
34
- eventNameDispatchConfigs ,
35
34
enqueueStateRestore ,
36
35
restoreStateIfNeeded ,
37
36
/* eslint-disable no-unused-vars */
@@ -549,6 +548,13 @@ function accumulateTwoPhaseDispatchesSingle(event) {
549
548
550
549
const Simulate = { } ;
551
550
551
+ const directDispatchEventTypes = new Set ( [
552
+ 'mouseEnter' ,
553
+ 'mouseLeave' ,
554
+ 'pointerEnter' ,
555
+ 'pointerLeave' ,
556
+ ] ) ;
557
+
552
558
/**
553
559
* Exports:
554
560
*
@@ -571,7 +577,19 @@ function makeSimulator(eventType) {
571
577
'a component instance. Pass the DOM node you wish to simulate the event on instead.' ,
572
578
) ;
573
579
574
- const dispatchConfig = eventNameDispatchConfigs [ eventType ] ;
580
+ // Reconstruct more or less what the original event system produced.
581
+ // We could remove this indirection here but we also don't plan to invest in Simulate anyway.
582
+ const dispatchConfig = { } ;
583
+ if ( directDispatchEventTypes . has ( eventType ) ) {
584
+ dispatchConfig . registrationName =
585
+ 'on' + eventType [ 0 ] . toUpperCase ( ) + eventType . slice ( 1 ) ;
586
+ } else {
587
+ dispatchConfig . phasedRegistrationNames = {
588
+ bubbled : 'on' + eventType [ 0 ] . toUpperCase ( ) + eventType . slice ( 1 ) ,
589
+ captured :
590
+ 'on' + eventType [ 0 ] . toUpperCase ( ) + eventType . slice ( 1 ) + 'Capture' ,
591
+ } ;
592
+ }
575
593
576
594
const fakeNativeEvent = new Event ( ) ;
577
595
fakeNativeEvent . target = domNode ;
@@ -607,17 +625,98 @@ function makeSimulator(eventType) {
607
625
} ;
608
626
}
609
627
628
+ // A one-time snapshot with no plans to update. We'll probably want to deprecate Simulate API.
629
+ const simulatedEventTypes = [
630
+ 'blur' ,
631
+ 'cancel' ,
632
+ 'click' ,
633
+ 'close' ,
634
+ 'contextMenu' ,
635
+ 'copy' ,
636
+ 'cut' ,
637
+ 'auxClick' ,
638
+ 'doubleClick' ,
639
+ 'dragEnd' ,
640
+ 'dragStart' ,
641
+ 'drop' ,
642
+ 'focus' ,
643
+ 'input' ,
644
+ 'invalid' ,
645
+ 'keyDown' ,
646
+ 'keyPress' ,
647
+ 'keyUp' ,
648
+ 'mouseDown' ,
649
+ 'mouseUp' ,
650
+ 'paste' ,
651
+ 'pause' ,
652
+ 'play' ,
653
+ 'pointerCancel' ,
654
+ 'pointerDown' ,
655
+ 'pointerUp' ,
656
+ 'rateChange' ,
657
+ 'reset' ,
658
+ 'seeked' ,
659
+ 'submit' ,
660
+ 'touchCancel' ,
661
+ 'touchEnd' ,
662
+ 'touchStart' ,
663
+ 'volumeChange' ,
664
+ 'drag' ,
665
+ 'dragEnter' ,
666
+ 'dragExit' ,
667
+ 'dragLeave' ,
668
+ 'dragOver' ,
669
+ 'mouseMove' ,
670
+ 'mouseOut' ,
671
+ 'mouseOver' ,
672
+ 'pointerMove' ,
673
+ 'pointerOut' ,
674
+ 'pointerOver' ,
675
+ 'scroll' ,
676
+ 'toggle' ,
677
+ 'touchMove' ,
678
+ 'wheel' ,
679
+ 'abort' ,
680
+ 'animationEnd' ,
681
+ 'animationIteration' ,
682
+ 'animationStart' ,
683
+ 'canPlay' ,
684
+ 'canPlayThrough' ,
685
+ 'durationChange' ,
686
+ 'emptied' ,
687
+ 'encrypted' ,
688
+ 'ended' ,
689
+ 'error' ,
690
+ 'gotPointerCapture' ,
691
+ 'load' ,
692
+ 'loadedData' ,
693
+ 'loadedMetadata' ,
694
+ 'loadStart' ,
695
+ 'lostPointerCapture' ,
696
+ 'playing' ,
697
+ 'progress' ,
698
+ 'seeking' ,
699
+ 'stalled' ,
700
+ 'suspend' ,
701
+ 'timeUpdate' ,
702
+ 'transitionEnd' ,
703
+ 'waiting' ,
704
+ 'mouseEnter' ,
705
+ 'mouseLeave' ,
706
+ 'pointerEnter' ,
707
+ 'pointerLeave' ,
708
+ 'change' ,
709
+ 'select' ,
710
+ 'beforeInput' ,
711
+ 'compositionEnd' ,
712
+ 'compositionStart' ,
713
+ 'compositionUpdate' ,
714
+ ] ;
610
715
function buildSimulators ( ) {
611
- let eventType ;
612
- for ( eventType in eventNameDispatchConfigs ) {
613
- /**
614
- * @param {!Element|ReactDOMComponent } domComponentOrNode
615
- * @param {?object } eventData Fake event data to use in SyntheticEvent.
616
- */
716
+ simulatedEventTypes . forEach ( eventType => {
617
717
Simulate [ eventType ] = makeSimulator ( eventType ) ;
618
- }
718
+ } ) ;
619
719
}
620
-
621
720
buildSimulators ( ) ;
622
721
623
722
export {
0 commit comments