react-dom 16.4.0-alpha.7926752 → 16.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0-alpha.7926752
1
+ /** @license React v16.5.0
2
2
  * react-dom-test-utils.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -18,18 +18,96 @@ if (process.env.NODE_ENV !== "production") {
18
18
  var _assign = require('object-assign');
19
19
  var React = require('react');
20
20
  var ReactDOM = require('react-dom');
21
- var invariant = require('fbjs/lib/invariant');
22
- var warning = require('fbjs/lib/warning');
23
- var emptyFunction = require('fbjs/lib/emptyFunction');
24
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
25
21
 
26
22
  /**
27
- * WARNING: DO NOT manually require this module.
28
- * This is a replacement for `invariant(...)` used by the error code system
29
- * and will _only_ be required by the corresponding babel pass.
30
- * It always throws.
23
+ * Use invariant() to assert state which your program assumes to be true.
24
+ *
25
+ * Provide sprintf-style format (only %s is supported) and arguments
26
+ * to provide information about what broke and what you were
27
+ * expecting.
28
+ *
29
+ * The invariant message will be stripped in production, but the invariant
30
+ * will remain to ensure logic does not differ in production.
31
31
  */
32
32
 
33
+ var validateFormat = function () {};
34
+
35
+ {
36
+ validateFormat = function (format) {
37
+ if (format === undefined) {
38
+ throw new Error('invariant requires an error message argument');
39
+ }
40
+ };
41
+ }
42
+
43
+ function invariant(condition, format, a, b, c, d, e, f) {
44
+ validateFormat(format);
45
+
46
+ if (!condition) {
47
+ var error = void 0;
48
+ if (format === undefined) {
49
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
50
+ } else {
51
+ var args = [a, b, c, d, e, f];
52
+ var argIndex = 0;
53
+ error = new Error(format.replace(/%s/g, function () {
54
+ return args[argIndex++];
55
+ }));
56
+ error.name = 'Invariant Violation';
57
+ }
58
+
59
+ error.framesToPop = 1; // we don't care about invariant's own frame
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ // Relying on the `invariant()` implementation lets us
65
+ // preserve the format and params in the www builds.
66
+
67
+ /**
68
+ * Similar to invariant but only logs a warning if the condition is not met.
69
+ * This can be used to log issues in development environments in critical
70
+ * paths. Removing the logging code for production environments will keep the
71
+ * same logic and follow the same code paths.
72
+ */
73
+
74
+ var warningWithoutStack = function () {};
75
+
76
+ {
77
+ warningWithoutStack = function (condition, format) {
78
+ for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
79
+ args[_key - 2] = arguments[_key];
80
+ }
81
+
82
+ if (format === undefined) {
83
+ throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
84
+ }
85
+ if (condition) {
86
+ return;
87
+ }
88
+ if (typeof console !== 'undefined') {
89
+ var _console;
90
+
91
+ var stringArgs = args.map(function (item) {
92
+ return '' + item;
93
+ });
94
+ (_console = console).error.apply(_console, ['Warning: ' + format].concat(stringArgs));
95
+ }
96
+ try {
97
+ // --- Welcome to debugging React ---
98
+ // This error was thrown as a convenience so that you can use this stack
99
+ // to find the callsite that caused this warning to fire.
100
+ var argIndex = 0;
101
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
102
+ return args[argIndex++];
103
+ });
104
+ throw new Error(message);
105
+ } catch (x) {}
106
+ };
107
+ }
108
+
109
+ var warningWithoutStack$1 = warningWithoutStack;
110
+
33
111
  /**
34
112
  * `ReactInstanceMap` maintains a mapping from a public facing stateful
35
113
  * instance (key) and the internal representation (value). This allows public
@@ -51,21 +129,20 @@ function get(key) {
51
129
  return key._reactInternalFiber;
52
130
  }
53
131
 
54
- var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
55
-
56
- var ReactCurrentOwner = ReactInternals.ReactCurrentOwner;
57
- var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
132
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
58
133
 
59
134
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
60
135
  // nor polyfill, then a plain number is used for performance.
61
136
 
62
- // Before we know whether it is functional or class
63
- var FunctionalComponent = 1;
137
+ var FunctionalComponent = 0;
138
+ var FunctionalComponentLazy = 1;
64
139
  var ClassComponent = 2;
65
- var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
140
+ var ClassComponentLazy = 3;
141
+ // Before we know whether it is functional or class
142
+ var HostRoot = 5; // Root of a host tree. Could be nested inside another node.
66
143
  // A subtree. Could be an entry point to a different renderer.
67
- var HostComponent = 5;
68
- var HostText = 6;
144
+ var HostComponent = 7;
145
+ var HostText = 8;
69
146
 
70
147
  // Don't change these two values. They're used by React Dev Tools.
71
148
  var NoEffect = /* */0;
@@ -82,21 +159,12 @@ var Placement = /* */2;
82
159
 
83
160
 
84
161
 
85
- // Union of all host effects
86
-
87
-
88
- // This indicates we exited the fiber without completing it.
89
-
90
-
91
- // Bits greater than Incomplete are used to identify fibers that threw. These
92
- // are like algebraic effects. These bits are mutually exclusive.
93
-
94
-
95
-
162
+ // Update & Callback & Ref & Snapshot
96
163
 
97
164
 
165
+ // Union of all host effects
98
166
 
99
- // Union of all algebraic effects
167
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
100
168
 
101
169
  var MOUNTING = 1;
102
170
  var MOUNTED = 2;
@@ -110,15 +178,15 @@ function isFiberMountedImpl(fiber) {
110
178
  if ((node.effectTag & Placement) !== NoEffect) {
111
179
  return MOUNTING;
112
180
  }
113
- while (node['return']) {
114
- node = node['return'];
181
+ while (node.return) {
182
+ node = node.return;
115
183
  if ((node.effectTag & Placement) !== NoEffect) {
116
184
  return MOUNTING;
117
185
  }
118
186
  }
119
187
  } else {
120
- while (node['return']) {
121
- node = node['return'];
188
+ while (node.return) {
189
+ node = node.return;
122
190
  }
123
191
  }
124
192
  if (node.tag === HostRoot) {
@@ -156,7 +224,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
156
224
  var a = fiber;
157
225
  var b = alternate;
158
226
  while (true) {
159
- var parentA = a['return'];
227
+ var parentA = a.return;
160
228
  var parentB = parentA ? parentA.alternate : null;
161
229
  if (!parentA || !parentB) {
162
230
  // We're at the root.
@@ -186,7 +254,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
186
254
  invariant(false, 'Unable to find node on an unmounted component.');
187
255
  }
188
256
 
189
- if (a['return'] !== b['return']) {
257
+ if (a.return !== b.return) {
190
258
  // The return pointer of A and the return pointer of B point to different
191
259
  // fibers. We assume that return pointers never criss-cross, so A must
192
260
  // belong to the child set of A.return, and B must belong to the child
@@ -253,11 +321,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
253
321
 
254
322
  /* eslint valid-typeof: 0 */
255
323
 
256
- var didWarnForAddedNewProperty = false;
257
324
  var EVENT_POOL_SIZE = 10;
258
325
 
259
- var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
260
-
261
326
  /**
262
327
  * @interface Event
263
328
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -266,7 +331,9 @@ var EventInterface = {
266
331
  type: null,
267
332
  target: null,
268
333
  // currentTarget is set when dispatching; no use in copying it here
269
- currentTarget: emptyFunction.thatReturnsNull,
334
+ currentTarget: function () {
335
+ return null;
336
+ },
270
337
  eventPhase: null,
271
338
  bubbles: null,
272
339
  cancelable: null,
@@ -277,6 +344,14 @@ var EventInterface = {
277
344
  isTrusted: null
278
345
  };
279
346
 
347
+ function functionThatReturnsTrue() {
348
+ return true;
349
+ }
350
+
351
+ function functionThatReturnsFalse() {
352
+ return false;
353
+ }
354
+
280
355
  /**
281
356
  * Synthetic events are dispatched by event plugins, typically in response to a
282
357
  * top-level event delegation handler.
@@ -301,6 +376,8 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
301
376
  delete this.nativeEvent;
302
377
  delete this.preventDefault;
303
378
  delete this.stopPropagation;
379
+ delete this.isDefaultPrevented;
380
+ delete this.isPropagationStopped;
304
381
  }
305
382
 
306
383
  this.dispatchConfig = dispatchConfig;
@@ -329,11 +406,11 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
329
406
 
330
407
  var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
331
408
  if (defaultPrevented) {
332
- this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
409
+ this.isDefaultPrevented = functionThatReturnsTrue;
333
410
  } else {
334
- this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
411
+ this.isDefaultPrevented = functionThatReturnsFalse;
335
412
  }
336
- this.isPropagationStopped = emptyFunction.thatReturnsFalse;
413
+ this.isPropagationStopped = functionThatReturnsFalse;
337
414
  return this;
338
415
  }
339
416
 
@@ -350,7 +427,7 @@ _assign(SyntheticEvent.prototype, {
350
427
  } else if (typeof event.returnValue !== 'unknown') {
351
428
  event.returnValue = false;
352
429
  }
353
- this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
430
+ this.isDefaultPrevented = functionThatReturnsTrue;
354
431
  },
355
432
 
356
433
  stopPropagation: function () {
@@ -370,7 +447,7 @@ _assign(SyntheticEvent.prototype, {
370
447
  event.cancelBubble = true;
371
448
  }
372
449
 
373
- this.isPropagationStopped = emptyFunction.thatReturnsTrue;
450
+ this.isPropagationStopped = functionThatReturnsTrue;
374
451
  },
375
452
 
376
453
  /**
@@ -379,7 +456,7 @@ _assign(SyntheticEvent.prototype, {
379
456
  * won't be added back into the pool.
380
457
  */
381
458
  persist: function () {
382
- this.isPersistent = emptyFunction.thatReturnsTrue;
459
+ this.isPersistent = functionThatReturnsTrue;
383
460
  },
384
461
 
385
462
  /**
@@ -387,7 +464,7 @@ _assign(SyntheticEvent.prototype, {
387
464
  *
388
465
  * @return {boolean} True if this should not be released, false otherwise.
389
466
  */
390
- isPersistent: emptyFunction.thatReturnsFalse,
467
+ isPersistent: functionThatReturnsFalse,
391
468
 
392
469
  /**
393
470
  * `PooledClass` looks for `destructor` on each instance it releases.
@@ -399,13 +476,19 @@ _assign(SyntheticEvent.prototype, {
399
476
  Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
400
477
  }
401
478
  }
402
- for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
403
- this[shouldBeReleasedProperties[i]] = null;
404
- }
479
+ this.dispatchConfig = null;
480
+ this._targetInst = null;
481
+ this.nativeEvent = null;
482
+ this.isDefaultPrevented = functionThatReturnsFalse;
483
+ this.isPropagationStopped = functionThatReturnsFalse;
484
+ this._dispatchListeners = null;
485
+ this._dispatchInstances = null;
405
486
  {
406
487
  Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
407
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction));
408
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction));
488
+ Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
489
+ Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
490
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
491
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
409
492
  }
410
493
  }
411
494
  });
@@ -436,38 +519,6 @@ SyntheticEvent.extend = function (Interface) {
436
519
  return Class;
437
520
  };
438
521
 
439
- /** Proxying after everything set on SyntheticEvent
440
- * to resolve Proxy issue on some WebKit browsers
441
- * in which some Event properties are set to undefined (GH#10010)
442
- */
443
- {
444
- var isProxySupported = typeof Proxy === 'function' &&
445
- // https://github.com/facebook/react/issues/12011
446
- !Object.isSealed(new Proxy({}, {}));
447
-
448
- if (isProxySupported) {
449
- /*eslint-disable no-func-assign */
450
- SyntheticEvent = new Proxy(SyntheticEvent, {
451
- construct: function (target, args) {
452
- return this.apply(target, Object.create(target.prototype), args);
453
- },
454
- apply: function (constructor, that, args) {
455
- return new Proxy(constructor.apply(that, args), {
456
- set: function (target, prop, value) {
457
- if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
458
- warning(didWarnForAddedNewProperty || target.isPersistent(), "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.');
459
- didWarnForAddedNewProperty = true;
460
- }
461
- target[prop] = value;
462
- return true;
463
- }
464
- });
465
- }
466
- });
467
- /*eslint-enable no-func-assign */
468
- }
469
- }
470
-
471
522
  addEventPoolingTo(SyntheticEvent);
472
523
 
473
524
  /**
@@ -500,7 +551,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
500
551
 
501
552
  function warn(action, result) {
502
553
  var warningCondition = false;
503
- warning(warningCondition, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result);
554
+ !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
504
555
  }
505
556
  }
506
557
 
@@ -516,7 +567,7 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
516
567
 
517
568
  function releasePooledEvent(event) {
518
569
  var EventConstructor = this;
519
- !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
570
+ !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
520
571
  event.destructor();
521
572
  if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
522
573
  EventConstructor.eventPool.push(event);
@@ -529,7 +580,74 @@ function addEventPoolingTo(EventConstructor) {
529
580
  EventConstructor.release = releasePooledEvent;
530
581
  }
531
582
 
532
- var SyntheticEvent$1 = SyntheticEvent;
583
+ /**
584
+ * Forked from fbjs/warning:
585
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
586
+ *
587
+ * Only change is we use console.warn instead of console.error,
588
+ * and do nothing when 'console' is not supported.
589
+ * This really simplifies the code.
590
+ * ---
591
+ * Similar to invariant but only logs a warning if the condition is not met.
592
+ * This can be used to log issues in development environments in critical
593
+ * paths. Removing the logging code for production environments will keep the
594
+ * same logic and follow the same code paths.
595
+ */
596
+
597
+ var lowPriorityWarning = function () {};
598
+
599
+ {
600
+ var printWarning = function (format) {
601
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
602
+ args[_key - 1] = arguments[_key];
603
+ }
604
+
605
+ var argIndex = 0;
606
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
607
+ return args[argIndex++];
608
+ });
609
+ if (typeof console !== 'undefined') {
610
+ console.warn(message);
611
+ }
612
+ try {
613
+ // --- Welcome to debugging React ---
614
+ // This error was thrown as a convenience so that you can use this stack
615
+ // to find the callsite that caused this warning to fire.
616
+ throw new Error(message);
617
+ } catch (x) {}
618
+ };
619
+
620
+ lowPriorityWarning = function (condition, format) {
621
+ if (format === undefined) {
622
+ throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
623
+ }
624
+ if (!condition) {
625
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
626
+ args[_key2 - 2] = arguments[_key2];
627
+ }
628
+
629
+ printWarning.apply(undefined, [format].concat(args));
630
+ }
631
+ };
632
+ }
633
+
634
+ var lowPriorityWarning$1 = lowPriorityWarning;
635
+
636
+ /**
637
+ * HTML nodeType values that represent the type of the node
638
+ */
639
+
640
+ var ELEMENT_NODE = 1;
641
+
642
+ // Do not uses the below two methods directly!
643
+ // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
644
+ // (It is the only module that is allowed to access these methods.)
645
+
646
+ function unsafeCastStringToDOMTopLevelType(topLevelType) {
647
+ return topLevelType;
648
+ }
649
+
650
+ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
533
651
 
534
652
  /**
535
653
  * Generate a mapping of standard vendor prefixes using the defined style property and event name.
@@ -544,8 +662,6 @@ function makePrefixMap(styleProp, eventName) {
544
662
  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
545
663
  prefixes['Webkit' + styleProp] = 'webkit' + eventName;
546
664
  prefixes['Moz' + styleProp] = 'moz' + eventName;
547
- prefixes['ms' + styleProp] = 'MS' + eventName;
548
- prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
549
665
 
550
666
  return prefixes;
551
667
  }
@@ -573,7 +689,7 @@ var style = {};
573
689
  /**
574
690
  * Bootstrap if a DOM exists.
575
691
  */
576
- if (ExecutionEnvironment.canUseDOM) {
692
+ if (canUseDOM) {
577
693
  style = document.createElement('div').style;
578
694
 
579
695
  // On some platforms, in particular some releases of Android 4.x,
@@ -617,108 +733,147 @@ function getVendorPrefixedEventName(eventName) {
617
733
  }
618
734
 
619
735
  /**
620
- * Types of raw signals from the browser caught at the top level.
621
- *
622
- * For events like 'submit' or audio/video events which don't consistently
623
- * bubble (which we trap at a lower node than `document`), binding
624
- * at `document` would cause duplicate events so we don't include them here.
736
+ * To identify top level events in ReactDOM, we use constants defined by this
737
+ * module. This is the only module that uses the unsafe* methods to express
738
+ * that the constants actually correspond to the browser event names. This lets
739
+ * us save some bundle size by avoiding a top level type -> event name map.
740
+ * The rest of ReactDOM code should import top level types from this file.
625
741
  */
626
- var topLevelTypes = {
627
- topAnimationEnd: getVendorPrefixedEventName('animationend'),
628
- topAnimationIteration: getVendorPrefixedEventName('animationiteration'),
629
- topAnimationStart: getVendorPrefixedEventName('animationstart'),
630
- topBlur: 'blur',
631
- topCancel: 'cancel',
632
- topChange: 'change',
633
- topClick: 'click',
634
- topClose: 'close',
635
- topCompositionEnd: 'compositionend',
636
- topCompositionStart: 'compositionstart',
637
- topCompositionUpdate: 'compositionupdate',
638
- topContextMenu: 'contextmenu',
639
- topCopy: 'copy',
640
- topCut: 'cut',
641
- topDoubleClick: 'dblclick',
642
- topDrag: 'drag',
643
- topDragEnd: 'dragend',
644
- topDragEnter: 'dragenter',
645
- topDragExit: 'dragexit',
646
- topDragLeave: 'dragleave',
647
- topDragOver: 'dragover',
648
- topDragStart: 'dragstart',
649
- topDrop: 'drop',
650
- topFocus: 'focus',
651
- topInput: 'input',
652
- topKeyDown: 'keydown',
653
- topKeyPress: 'keypress',
654
- topKeyUp: 'keyup',
655
- topLoad: 'load',
656
- topLoadStart: 'loadstart',
657
- topMouseDown: 'mousedown',
658
- topMouseMove: 'mousemove',
659
- topMouseOut: 'mouseout',
660
- topMouseOver: 'mouseover',
661
- topMouseUp: 'mouseup',
662
- topPaste: 'paste',
663
- topScroll: 'scroll',
664
- topSelectionChange: 'selectionchange',
665
- topTextInput: 'textInput',
666
- topToggle: 'toggle',
667
- topTouchCancel: 'touchcancel',
668
- topTouchEnd: 'touchend',
669
- topTouchMove: 'touchmove',
670
- topTouchStart: 'touchstart',
671
- topTransitionEnd: getVendorPrefixedEventName('transitionend'),
672
- topWheel: 'wheel'
673
- };
674
-
675
- // There are so many media events, it makes sense to just
676
- // maintain a list of them. Note these aren't technically
677
- // "top-level" since they don't bubble. We should come up
678
- // with a better naming convention if we come to refactoring
679
- // the event system.
680
- var mediaEventTypes = {
681
- topAbort: 'abort',
682
- topCanPlay: 'canplay',
683
- topCanPlayThrough: 'canplaythrough',
684
- topDurationChange: 'durationchange',
685
- topEmptied: 'emptied',
686
- topEncrypted: 'encrypted',
687
- topEnded: 'ended',
688
- topError: 'error',
689
- topLoadedData: 'loadeddata',
690
- topLoadedMetadata: 'loadedmetadata',
691
- topLoadStart: 'loadstart',
692
- topPause: 'pause',
693
- topPlay: 'play',
694
- topPlaying: 'playing',
695
- topProgress: 'progress',
696
- topRateChange: 'ratechange',
697
- topSeeked: 'seeked',
698
- topSeeking: 'seeking',
699
- topStalled: 'stalled',
700
- topSuspend: 'suspend',
701
- topTimeUpdate: 'timeupdate',
702
- topVolumeChange: 'volumechange',
703
- topWaiting: 'waiting'
704
- };
742
+ var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
743
+ var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
744
+ var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
745
+ var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
746
+ var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
747
+ var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
748
+ var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
749
+ var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
750
+ var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
751
+ var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
752
+ var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
753
+ var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
754
+ var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
755
+ var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
756
+ var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
757
+ var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
758
+ var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
759
+ var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
760
+
761
+ var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
762
+ var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
763
+ var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
764
+ var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
765
+ var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
766
+ var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
767
+ var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
768
+ var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
769
+ var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
770
+ var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
771
+ var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
772
+ var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
773
+ var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
774
+ var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
775
+
776
+ var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
777
+
778
+ var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
779
+ var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
780
+ var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
781
+ var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
782
+ var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
783
+ var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
784
+ var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
785
+
786
+ var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
787
+ var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
788
+ var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
789
+ var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
790
+ var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
791
+ var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
792
+ var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
793
+ var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
794
+ var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+ var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
804
+ var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
805
+
806
+ var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
807
+ var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
808
+ var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
809
+ var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
810
+ var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
811
+
812
+ var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
813
+ var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
814
+ var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
815
+ var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
816
+ var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
817
+ var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
818
+ var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
819
+ var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
820
+ var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
821
+ var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
822
+ var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
823
+ var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
824
+
825
+ // List of events that need to be individually attached to media elements.
826
+ // Note that events in this list will *not* be listened to at the top level
827
+ // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
705
828
 
706
829
  var findDOMNode = ReactDOM.findDOMNode;
707
- var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
708
- var EventPluginHub = _ReactDOM$__SECRET_IN.EventPluginHub;
709
- var EventPluginRegistry = _ReactDOM$__SECRET_IN.EventPluginRegistry;
710
- var EventPropagators = _ReactDOM$__SECRET_IN.EventPropagators;
711
- var ReactControlledComponent = _ReactDOM$__SECRET_IN.ReactControlledComponent;
712
- var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree;
713
- var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener;
830
+ // Keep in sync with ReactDOMUnstableNativeDependencies.js
831
+ // and ReactDOM.js:
832
+
833
+ var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
834
+ var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
835
+ var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
836
+ var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
837
+ var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[3];
838
+ var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[4];
839
+ var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[5];
840
+ var enqueueStateRestore = _ReactDOM$__SECRET_IN[6];
841
+ var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[7];
842
+ var dispatchEvent = _ReactDOM$__SECRET_IN[8];
843
+ var runEventsInBatch = _ReactDOM$__SECRET_IN[9];
714
844
 
715
845
 
716
846
  function Event(suffix) {}
717
847
 
848
+ var hasWarnedAboutDeprecatedMockComponent = false;
849
+
718
850
  /**
719
851
  * @class ReactTestUtils
720
852
  */
721
853
 
854
+ /**
855
+ * Simulates a top level event being dispatched from a raw event that occurred
856
+ * on an `Element` node.
857
+ * @param {number} topLevelType A number from `TopLevelEventTypes`
858
+ * @param {!Element} node The dom to simulate an event occurring on.
859
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
860
+ */
861
+ function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
862
+ fakeNativeEvent.target = node;
863
+ dispatchEvent(topLevelType, fakeNativeEvent);
864
+ }
865
+
866
+ /**
867
+ * Simulates a top level event being dispatched from a raw event that occurred
868
+ * on the `ReactDOMComponent` `comp`.
869
+ * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
870
+ * @param {!ReactDOMComponent} comp
871
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
872
+ */
873
+ function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
874
+ simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
875
+ }
876
+
722
877
  function findAllInRenderedFiberTreeInternal(fiber, test) {
723
878
  if (!fiber) {
724
879
  return [];
@@ -730,14 +885,14 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
730
885
  var node = currentParent;
731
886
  var ret = [];
732
887
  while (true) {
733
- if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionalComponent) {
888
+ if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === ClassComponentLazy || node.tag === FunctionalComponent || node.tag === FunctionalComponentLazy) {
734
889
  var publicInst = node.stateNode;
735
890
  if (test(publicInst)) {
736
891
  ret.push(publicInst);
737
892
  }
738
893
  }
739
894
  if (node.child) {
740
- node.child['return'] = node;
895
+ node.child.return = node;
741
896
  node = node.child;
742
897
  continue;
743
898
  }
@@ -745,16 +900,39 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
745
900
  return ret;
746
901
  }
747
902
  while (!node.sibling) {
748
- if (!node['return'] || node['return'] === currentParent) {
903
+ if (!node.return || node.return === currentParent) {
749
904
  return ret;
750
905
  }
751
- node = node['return'];
906
+ node = node.return;
752
907
  }
753
- node.sibling['return'] = node['return'];
908
+ node.sibling.return = node.return;
754
909
  node = node.sibling;
755
910
  }
756
911
  }
757
912
 
913
+ function validateClassInstance(inst, methodName) {
914
+ if (!inst) {
915
+ // This is probably too relaxed but it's existing behavior.
916
+ return;
917
+ }
918
+ if (get(inst)) {
919
+ // This is a public instance indeed.
920
+ return;
921
+ }
922
+ var received = void 0;
923
+ var stringified = '' + inst;
924
+ if (Array.isArray(inst)) {
925
+ received = 'an array';
926
+ } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
927
+ received = 'a DOM node';
928
+ } else if (stringified === '[object Object]') {
929
+ received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
930
+ } else {
931
+ received = stringified;
932
+ }
933
+ invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
934
+ }
935
+
758
936
  /**
759
937
  * Utilities for making it easy to test React components.
760
938
  *
@@ -784,7 +962,7 @@ var ReactTestUtils = {
784
962
  },
785
963
 
786
964
  isDOMComponent: function (inst) {
787
- return !!(inst && inst.nodeType === 1 && inst.tagName);
965
+ return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
788
966
  },
789
967
 
790
968
  isDOMComponentElement: function (inst) {
@@ -810,10 +988,10 @@ var ReactTestUtils = {
810
988
  },
811
989
 
812
990
  findAllInRenderedTree: function (inst, test) {
991
+ validateClassInstance(inst, 'findAllInRenderedTree');
813
992
  if (!inst) {
814
993
  return [];
815
994
  }
816
- !ReactTestUtils.isCompositeComponent(inst) ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : void 0;
817
995
  var internalInstance = get(inst);
818
996
  return findAllInRenderedFiberTreeInternal(internalInstance, test);
819
997
  },
@@ -824,6 +1002,7 @@ var ReactTestUtils = {
824
1002
  * @return {array} an array of all the matches.
825
1003
  */
826
1004
  scryRenderedDOMComponentsWithClass: function (root, classNames) {
1005
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
827
1006
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
828
1007
  if (ReactTestUtils.isDOMComponent(inst)) {
829
1008
  var className = inst.className;
@@ -852,6 +1031,7 @@ var ReactTestUtils = {
852
1031
  * @return {!ReactDOMComponent} The one match.
853
1032
  */
854
1033
  findRenderedDOMComponentWithClass: function (root, className) {
1034
+ validateClassInstance(root, 'findRenderedDOMComponentWithClass');
855
1035
  var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
856
1036
  if (all.length !== 1) {
857
1037
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
@@ -865,6 +1045,7 @@ var ReactTestUtils = {
865
1045
  * @return {array} an array of all the matches.
866
1046
  */
867
1047
  scryRenderedDOMComponentsWithTag: function (root, tagName) {
1048
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
868
1049
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
869
1050
  return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
870
1051
  });
@@ -877,6 +1058,7 @@ var ReactTestUtils = {
877
1058
  * @return {!ReactDOMComponent} The one match.
878
1059
  */
879
1060
  findRenderedDOMComponentWithTag: function (root, tagName) {
1061
+ validateClassInstance(root, 'findRenderedDOMComponentWithTag');
880
1062
  var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
881
1063
  if (all.length !== 1) {
882
1064
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
@@ -889,6 +1071,7 @@ var ReactTestUtils = {
889
1071
  * @return {array} an array of all the matches.
890
1072
  */
891
1073
  scryRenderedComponentsWithType: function (root, componentType) {
1074
+ validateClassInstance(root, 'scryRenderedComponentsWithType');
892
1075
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
893
1076
  return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
894
1077
  });
@@ -901,6 +1084,7 @@ var ReactTestUtils = {
901
1084
  * @return {!ReactComponent} The one match.
902
1085
  */
903
1086
  findRenderedComponentWithType: function (root, componentType) {
1087
+ validateClassInstance(root, 'findRenderedComponentWithType');
904
1088
  var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
905
1089
  if (all.length !== 1) {
906
1090
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
@@ -922,6 +1106,11 @@ var ReactTestUtils = {
922
1106
  * @return {object} the ReactTestUtils object (for chaining)
923
1107
  */
924
1108
  mockComponent: function (module, mockTagName) {
1109
+ if (!hasWarnedAboutDeprecatedMockComponent) {
1110
+ hasWarnedAboutDeprecatedMockComponent = true;
1111
+ lowPriorityWarning$1(false, 'ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://fb.me/test-utils-mock-component for more information.');
1112
+ }
1113
+
925
1114
  mockTagName = mockTagName || module.mockTagName || 'div';
926
1115
 
927
1116
  module.prototype.render.mockImplementation(function () {
@@ -931,29 +1120,6 @@ var ReactTestUtils = {
931
1120
  return this;
932
1121
  },
933
1122
 
934
- /**
935
- * Simulates a top level event being dispatched from a raw event that occurred
936
- * on an `Element` node.
937
- * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`
938
- * @param {!Element} node The dom to simulate an event occurring on.
939
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
940
- */
941
- simulateNativeEventOnNode: function (topLevelType, node, fakeNativeEvent) {
942
- fakeNativeEvent.target = node;
943
- ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
944
- },
945
-
946
- /**
947
- * Simulates a top level event being dispatched from a raw event that occurred
948
- * on the `ReactDOMComponent` `comp`.
949
- * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
950
- * @param {!ReactDOMComponent} comp
951
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
952
- */
953
- simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
954
- ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
955
- },
956
-
957
1123
  nativeTouchData: function (x, y) {
958
1124
  return {
959
1125
  touches: [{ pageX: x, pageY: y }]
@@ -977,7 +1143,7 @@ function makeSimulator(eventType) {
977
1143
  !!React.isValidElement(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a React element. Pass the DOM node you wish to simulate the event on instead. Note that TestUtils.Simulate will not work if you are using shallow rendering.') : void 0;
978
1144
  !!ReactTestUtils.isCompositeComponent(domNode) ? invariant(false, 'TestUtils.Simulate expected a DOM node as the first argument but received a component instance. Pass the DOM node you wish to simulate the event on instead.') : void 0;
979
1145
 
980
- var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType];
1146
+ var dispatchConfig = eventNameDispatchConfigs[eventType];
981
1147
 
982
1148
  var fakeNativeEvent = new Event();
983
1149
  fakeNativeEvent.target = domNode;
@@ -985,8 +1151,8 @@ function makeSimulator(eventType) {
985
1151
 
986
1152
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
987
1153
  // properly destroying any properties assigned from `eventData` upon release
988
- var targetInst = ReactDOMComponentTree.getInstanceFromNode(domNode);
989
- var event = new SyntheticEvent$1(dispatchConfig, targetInst, fakeNativeEvent, domNode);
1154
+ var targetInst = getInstanceFromNode(domNode);
1155
+ var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
990
1156
 
991
1157
  // Since we aren't using pooling, always persist the event. This will make
992
1158
  // sure it's marked and won't warn when setting additional properties.
@@ -994,18 +1160,18 @@ function makeSimulator(eventType) {
994
1160
  _assign(event, eventData);
995
1161
 
996
1162
  if (dispatchConfig.phasedRegistrationNames) {
997
- EventPropagators.accumulateTwoPhaseDispatches(event);
1163
+ accumulateTwoPhaseDispatches(event);
998
1164
  } else {
999
- EventPropagators.accumulateDirectDispatches(event);
1165
+ accumulateDirectDispatches(event);
1000
1166
  }
1001
1167
 
1002
1168
  ReactDOM.unstable_batchedUpdates(function () {
1003
1169
  // Normally extractEvent enqueues a state restore, but we'll just always
1004
1170
  // do that since we we're by-passing it here.
1005
- ReactControlledComponent.enqueueStateRestore(domNode);
1006
- EventPluginHub.runEventsInBatch(event, true);
1171
+ enqueueStateRestore(domNode);
1172
+ runEventsInBatch(event, true);
1007
1173
  });
1008
- ReactControlledComponent.restoreStateIfNeeded();
1174
+ restoreStateIfNeeded();
1009
1175
  };
1010
1176
  }
1011
1177
 
@@ -1013,7 +1179,7 @@ function buildSimulators() {
1013
1179
  ReactTestUtils.Simulate = {};
1014
1180
 
1015
1181
  var eventType = void 0;
1016
- for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
1182
+ for (eventType in eventNameDispatchConfigs) {
1017
1183
  /**
1018
1184
  * @param {!Element|ReactDOMComponent} domComponentOrNode
1019
1185
  * @param {?object} eventData Fake event data to use in SyntheticEvent.
@@ -1022,18 +1188,6 @@ function buildSimulators() {
1022
1188
  }
1023
1189
  }
1024
1190
 
1025
- // Rebuild ReactTestUtils.Simulate whenever event plugins are injected
1026
- var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
1027
- EventPluginHub.injection.injectEventPluginOrder = function () {
1028
- oldInjectEventPluginOrder.apply(this, arguments);
1029
- buildSimulators();
1030
- };
1031
- var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
1032
- EventPluginHub.injection.injectEventPluginsByName = function () {
1033
- oldInjectEventPlugins.apply(this, arguments);
1034
- buildSimulators();
1035
- };
1036
-
1037
1191
  buildSimulators();
1038
1192
 
1039
1193
  /**
@@ -1052,29 +1206,28 @@ buildSimulators();
1052
1206
  * to dispatch synthetic events.
1053
1207
  */
1054
1208
 
1055
- function makeNativeSimulator(eventType) {
1209
+ function makeNativeSimulator(eventType, topLevelType) {
1056
1210
  return function (domComponentOrNode, nativeEventData) {
1057
1211
  var fakeNativeEvent = new Event(eventType);
1058
1212
  _assign(fakeNativeEvent, nativeEventData);
1059
1213
  if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
1060
- ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
1214
+ simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
1061
1215
  } else if (domComponentOrNode.tagName) {
1062
1216
  // Will allow on actual dom nodes.
1063
- ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
1217
+ simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
1064
1218
  }
1065
1219
  };
1066
1220
  }
1067
1221
 
1068
- var eventKeys = [].concat(Object.keys(topLevelTypes), Object.keys(mediaEventTypes));
1222
+ [[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
1223
+ var topLevelType = _ref[0],
1224
+ eventType = _ref[1];
1069
1225
 
1070
- eventKeys.forEach(function (eventType) {
1071
- // Event type is stored as 'topClick' - we transform that to 'click'
1072
- var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
1073
1226
  /**
1074
1227
  * @param {!Element|ReactDOMComponent} domComponentOrNode
1075
1228
  * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
1076
1229
  */
1077
- ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
1230
+ ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
1078
1231
  });
1079
1232
 
1080
1233
 
@@ -1087,7 +1240,7 @@ var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$
1087
1240
 
1088
1241
  // TODO: decide on the top-level export form.
1089
1242
  // This is hacky but makes it work with both Rollup and Jest.
1090
- var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3;
1243
+ var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
1091
1244
 
1092
1245
  module.exports = testUtils;
1093
1246
  })();