react-dom 16.4.2 → 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.2
1
+ /** @license React v16.5.0
2
2
  * react-dom-test-utils.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -19,16 +19,6 @@ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
19
19
 
20
20
  var _assign = ReactInternals.assign;
21
21
 
22
- /**
23
- * Copyright (c) 2013-present, Facebook, Inc.
24
- *
25
- * This source code is licensed under the MIT license found in the
26
- * LICENSE file in the root directory of this source tree.
27
- *
28
- */
29
-
30
-
31
-
32
22
  /**
33
23
  * Use invariant() to assert state which your program assumes to be true.
34
24
  *
@@ -40,10 +30,10 @@ var _assign = ReactInternals.assign;
40
30
  * will remain to ensure logic does not differ in production.
41
31
  */
42
32
 
43
- var validateFormat = function validateFormat(format) {};
33
+ var validateFormat = function () {};
44
34
 
45
35
  {
46
- validateFormat = function validateFormat(format) {
36
+ validateFormat = function (format) {
47
37
  if (format === undefined) {
48
38
  throw new Error('invariant requires an error message argument');
49
39
  }
@@ -54,7 +44,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
54
44
  validateFormat(format);
55
45
 
56
46
  if (!condition) {
57
- var error;
47
+ var error = void 0;
58
48
  if (format === undefined) {
59
49
  error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
60
50
  } else {
@@ -71,57 +61,8 @@ function invariant(condition, format, a, b, c, d, e, f) {
71
61
  }
72
62
  }
73
63
 
74
- var invariant_1 = invariant;
75
-
76
64
  // Relying on the `invariant()` implementation lets us
77
- // have preserve the format and params in the www builds.
78
-
79
- /**
80
- * Copyright (c) 2013-present, Facebook, Inc.
81
- *
82
- * This source code is licensed under the MIT license found in the
83
- * LICENSE file in the root directory of this source tree.
84
- *
85
- *
86
- */
87
-
88
- function makeEmptyFunction(arg) {
89
- return function () {
90
- return arg;
91
- };
92
- }
93
-
94
- /**
95
- * This function accepts and discards inputs; it has no side effects. This is
96
- * primarily useful idiomatically for overridable function endpoints which
97
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
98
- */
99
- var emptyFunction = function emptyFunction() {};
100
-
101
- emptyFunction.thatReturns = makeEmptyFunction;
102
- emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
103
- emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
104
- emptyFunction.thatReturnsNull = makeEmptyFunction(null);
105
- emptyFunction.thatReturnsThis = function () {
106
- return this;
107
- };
108
- emptyFunction.thatReturnsArgument = function (arg) {
109
- return arg;
110
- };
111
-
112
- var emptyFunction_1 = emptyFunction;
113
-
114
- /**
115
- * Copyright (c) 2014-present, Facebook, Inc.
116
- *
117
- * This source code is licensed under the MIT license found in the
118
- * LICENSE file in the root directory of this source tree.
119
- *
120
- */
121
-
122
-
123
-
124
-
65
+ // preserve the format and params in the www builds.
125
66
 
126
67
  /**
127
68
  * Similar to invariant but only logs a warning if the condition is not met.
@@ -130,49 +71,42 @@ var emptyFunction_1 = emptyFunction;
130
71
  * same logic and follow the same code paths.
131
72
  */
132
73
 
133
- var warning = emptyFunction_1;
74
+ var warningWithoutStack = function () {};
134
75
 
135
76
  {
136
- var printWarning = function printWarning(format) {
137
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
138
- args[_key - 1] = arguments[_key];
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];
139
80
  }
140
81
 
141
- var argIndex = 0;
142
- var message = 'Warning: ' + format.replace(/%s/g, function () {
143
- return args[argIndex++];
144
- });
82
+ if (format === undefined) {
83
+ throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
84
+ }
85
+ if (condition) {
86
+ return;
87
+ }
145
88
  if (typeof console !== 'undefined') {
146
- console.error(message);
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));
147
95
  }
148
96
  try {
149
97
  // --- Welcome to debugging React ---
150
98
  // This error was thrown as a convenience so that you can use this stack
151
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
+ });
152
104
  throw new Error(message);
153
105
  } catch (x) {}
154
106
  };
155
-
156
- warning = function warning(condition, format) {
157
- if (format === undefined) {
158
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
159
- }
160
-
161
- if (format.indexOf('Failed Composite propType: ') === 0) {
162
- return; // Ignore CompositeComponent proptype check.
163
- }
164
-
165
- if (!condition) {
166
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
167
- args[_key2 - 2] = arguments[_key2];
168
- }
169
-
170
- printWarning.apply(undefined, [format].concat(args));
171
- }
172
- };
173
107
  }
174
108
 
175
- var warning_1 = warning;
109
+ var warningWithoutStack$1 = warningWithoutStack;
176
110
 
177
111
  /**
178
112
  * `ReactInstanceMap` maintains a mapping from a public facing stateful
@@ -195,21 +129,20 @@ function get(key) {
195
129
  return key._reactInternalFiber;
196
130
  }
197
131
 
198
- var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
199
-
200
- var ReactCurrentOwner = ReactInternals$1.ReactCurrentOwner;
201
- var ReactDebugCurrentFrame = ReactInternals$1.ReactDebugCurrentFrame;
132
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
202
133
 
203
134
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
204
135
  // nor polyfill, then a plain number is used for performance.
205
136
 
206
- // Before we know whether it is functional or class
207
- var FunctionalComponent = 1;
137
+ var FunctionalComponent = 0;
138
+ var FunctionalComponentLazy = 1;
208
139
  var ClassComponent = 2;
209
- 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.
210
143
  // A subtree. Could be an entry point to a different renderer.
211
- var HostComponent = 5;
212
- var HostText = 6;
144
+ var HostComponent = 7;
145
+ var HostText = 8;
213
146
 
214
147
  // Don't change these two values. They're used by React Dev Tools.
215
148
  var NoEffect = /* */0;
@@ -226,8 +159,13 @@ var Placement = /* */2;
226
159
 
227
160
 
228
161
 
162
+ // Update & Callback & Ref & Snapshot
163
+
164
+
229
165
  // Union of all host effects
230
166
 
167
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
168
+
231
169
  var MOUNTING = 1;
232
170
  var MOUNTED = 2;
233
171
  var UNMOUNTED = 3;
@@ -266,7 +204,7 @@ function isFiberMountedImpl(fiber) {
266
204
 
267
205
 
268
206
  function assertIsMounted(fiber) {
269
- !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
207
+ !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
270
208
  }
271
209
 
272
210
  function findCurrentFiberUsingSlowPath(fiber) {
@@ -274,7 +212,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
274
212
  if (!alternate) {
275
213
  // If there is no alternate, then we only need to check if it is mounted.
276
214
  var state = isFiberMountedImpl(fiber);
277
- !(state !== UNMOUNTED) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
215
+ !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
278
216
  if (state === MOUNTING) {
279
217
  return null;
280
218
  }
@@ -313,7 +251,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
313
251
  }
314
252
  // We should never have an alternate for any mounting node. So the only
315
253
  // way this could possibly happen is if this was unmounted, if at all.
316
- invariant_1(false, 'Unable to find node on an unmounted component.');
254
+ invariant(false, 'Unable to find node on an unmounted component.');
317
255
  }
318
256
 
319
257
  if (a.return !== b.return) {
@@ -364,15 +302,15 @@ function findCurrentFiberUsingSlowPath(fiber) {
364
302
  }
365
303
  _child = _child.sibling;
366
304
  }
367
- !didFindChild ? invariant_1(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
305
+ !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
368
306
  }
369
307
  }
370
308
 
371
- !(a.alternate === b) ? invariant_1(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
309
+ !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
372
310
  }
373
311
  // If the root is not a host container, we're in a disconnected tree. I.e.
374
312
  // unmounted.
375
- !(a.tag === HostRoot) ? invariant_1(false, 'Unable to find node on an unmounted component.') : void 0;
313
+ !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
376
314
  if (a.stateNode.current === a) {
377
315
  // We've determined that A is the current branch.
378
316
  return fiber;
@@ -383,11 +321,8 @@ function findCurrentFiberUsingSlowPath(fiber) {
383
321
 
384
322
  /* eslint valid-typeof: 0 */
385
323
 
386
- var didWarnForAddedNewProperty = false;
387
324
  var EVENT_POOL_SIZE = 10;
388
325
 
389
- var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
390
-
391
326
  /**
392
327
  * @interface Event
393
328
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -396,7 +331,9 @@ var EventInterface = {
396
331
  type: null,
397
332
  target: null,
398
333
  // currentTarget is set when dispatching; no use in copying it here
399
- currentTarget: emptyFunction_1.thatReturnsNull,
334
+ currentTarget: function () {
335
+ return null;
336
+ },
400
337
  eventPhase: null,
401
338
  bubbles: null,
402
339
  cancelable: null,
@@ -407,6 +344,14 @@ var EventInterface = {
407
344
  isTrusted: null
408
345
  };
409
346
 
347
+ function functionThatReturnsTrue() {
348
+ return true;
349
+ }
350
+
351
+ function functionThatReturnsFalse() {
352
+ return false;
353
+ }
354
+
410
355
  /**
411
356
  * Synthetic events are dispatched by event plugins, typically in response to a
412
357
  * top-level event delegation handler.
@@ -431,6 +376,8 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
431
376
  delete this.nativeEvent;
432
377
  delete this.preventDefault;
433
378
  delete this.stopPropagation;
379
+ delete this.isDefaultPrevented;
380
+ delete this.isPropagationStopped;
434
381
  }
435
382
 
436
383
  this.dispatchConfig = dispatchConfig;
@@ -459,11 +406,11 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
459
406
 
460
407
  var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
461
408
  if (defaultPrevented) {
462
- this.isDefaultPrevented = emptyFunction_1.thatReturnsTrue;
409
+ this.isDefaultPrevented = functionThatReturnsTrue;
463
410
  } else {
464
- this.isDefaultPrevented = emptyFunction_1.thatReturnsFalse;
411
+ this.isDefaultPrevented = functionThatReturnsFalse;
465
412
  }
466
- this.isPropagationStopped = emptyFunction_1.thatReturnsFalse;
413
+ this.isPropagationStopped = functionThatReturnsFalse;
467
414
  return this;
468
415
  }
469
416
 
@@ -480,7 +427,7 @@ _assign(SyntheticEvent.prototype, {
480
427
  } else if (typeof event.returnValue !== 'unknown') {
481
428
  event.returnValue = false;
482
429
  }
483
- this.isDefaultPrevented = emptyFunction_1.thatReturnsTrue;
430
+ this.isDefaultPrevented = functionThatReturnsTrue;
484
431
  },
485
432
 
486
433
  stopPropagation: function () {
@@ -500,7 +447,7 @@ _assign(SyntheticEvent.prototype, {
500
447
  event.cancelBubble = true;
501
448
  }
502
449
 
503
- this.isPropagationStopped = emptyFunction_1.thatReturnsTrue;
450
+ this.isPropagationStopped = functionThatReturnsTrue;
504
451
  },
505
452
 
506
453
  /**
@@ -509,7 +456,7 @@ _assign(SyntheticEvent.prototype, {
509
456
  * won't be added back into the pool.
510
457
  */
511
458
  persist: function () {
512
- this.isPersistent = emptyFunction_1.thatReturnsTrue;
459
+ this.isPersistent = functionThatReturnsTrue;
513
460
  },
514
461
 
515
462
  /**
@@ -517,7 +464,7 @@ _assign(SyntheticEvent.prototype, {
517
464
  *
518
465
  * @return {boolean} True if this should not be released, false otherwise.
519
466
  */
520
- isPersistent: emptyFunction_1.thatReturnsFalse,
467
+ isPersistent: functionThatReturnsFalse,
521
468
 
522
469
  /**
523
470
  * `PooledClass` looks for `destructor` on each instance it releases.
@@ -529,13 +476,19 @@ _assign(SyntheticEvent.prototype, {
529
476
  Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
530
477
  }
531
478
  }
532
- for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
533
- this[shouldBeReleasedProperties[i]] = null;
534
- }
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;
535
486
  {
536
487
  Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
537
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction_1));
538
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction_1));
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 () {}));
539
492
  }
540
493
  }
541
494
  });
@@ -566,38 +519,6 @@ SyntheticEvent.extend = function (Interface) {
566
519
  return Class;
567
520
  };
568
521
 
569
- /** Proxying after everything set on SyntheticEvent
570
- * to resolve Proxy issue on some WebKit browsers
571
- * in which some Event properties are set to undefined (GH#10010)
572
- */
573
- {
574
- var isProxySupported = typeof Proxy === 'function' &&
575
- // https://github.com/facebook/react/issues/12011
576
- !Object.isSealed(new Proxy({}, {}));
577
-
578
- if (isProxySupported) {
579
- /*eslint-disable no-func-assign */
580
- SyntheticEvent = new Proxy(SyntheticEvent, {
581
- construct: function (target, args) {
582
- return this.apply(target, Object.create(target.prototype), args);
583
- },
584
- apply: function (constructor, that, args) {
585
- return new Proxy(constructor.apply(that, args), {
586
- set: function (target, prop, value) {
587
- if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
588
- !(didWarnForAddedNewProperty || target.isPersistent()) ? warning_1(false, "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.') : void 0;
589
- didWarnForAddedNewProperty = true;
590
- }
591
- target[prop] = value;
592
- return true;
593
- }
594
- });
595
- }
596
- });
597
- /*eslint-enable no-func-assign */
598
- }
599
- }
600
-
601
522
  addEventPoolingTo(SyntheticEvent);
602
523
 
603
524
  /**
@@ -630,7 +551,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
630
551
 
631
552
  function warn(action, result) {
632
553
  var warningCondition = false;
633
- !warningCondition ? warning_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;
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;
634
555
  }
635
556
  }
636
557
 
@@ -646,7 +567,7 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
646
567
 
647
568
  function releasePooledEvent(event) {
648
569
  var EventConstructor = this;
649
- !(event instanceof EventConstructor) ? invariant_1(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;
650
571
  event.destructor();
651
572
  if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
652
573
  EventConstructor.eventPool.push(event);
@@ -659,49 +580,74 @@ function addEventPoolingTo(EventConstructor) {
659
580
  EventConstructor.release = releasePooledEvent;
660
581
  }
661
582
 
662
- var SyntheticEvent$1 = SyntheticEvent;
663
-
664
- // Do not uses the below two methods directly!
665
- // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
666
- // (It is the only module that is allowed to access these methods.)
667
-
668
- function unsafeCastStringToDOMTopLevelType(topLevelType) {
669
- return topLevelType;
670
- }
671
-
672
583
  /**
673
- * Copyright (c) 2013-present, Facebook, Inc.
674
- *
675
- * This source code is licensed under the MIT license found in the
676
- * LICENSE file in the root directory of this source tree.
584
+ * Forked from fbjs/warning:
585
+ * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
677
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.
678
595
  */
679
596
 
597
+ var lowPriorityWarning = function () {};
680
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
+ }
681
604
 
682
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
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
+ };
683
619
 
684
- /**
685
- * Simple, lightweight module assisting with the detection and context of
686
- * Worker. Helps avoid circular dependencies and allows code to reason about
687
- * whether or not they are in a Worker, even if they never include the main
688
- * `ReactWorker` dependency.
689
- */
690
- var ExecutionEnvironment = {
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
+ }
691
628
 
692
- canUseDOM: canUseDOM,
629
+ printWarning.apply(undefined, [format].concat(args));
630
+ }
631
+ };
632
+ }
693
633
 
694
- canUseWorkers: typeof Worker !== 'undefined',
634
+ var lowPriorityWarning$1 = lowPriorityWarning;
695
635
 
696
- canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
636
+ /**
637
+ * HTML nodeType values that represent the type of the node
638
+ */
697
639
 
698
- canUseViewport: canUseDOM && !!window.screen,
640
+ var ELEMENT_NODE = 1;
699
641
 
700
- isInWorker: !canUseDOM // For now, this is true - might change in the future.
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.)
701
645
 
702
- };
646
+ function unsafeCastStringToDOMTopLevelType(topLevelType) {
647
+ return topLevelType;
648
+ }
703
649
 
704
- var ExecutionEnvironment_1 = ExecutionEnvironment;
650
+ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
705
651
 
706
652
  /**
707
653
  * Generate a mapping of standard vendor prefixes using the defined style property and event name.
@@ -716,8 +662,6 @@ function makePrefixMap(styleProp, eventName) {
716
662
  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
717
663
  prefixes['Webkit' + styleProp] = 'webkit' + eventName;
718
664
  prefixes['Moz' + styleProp] = 'moz' + eventName;
719
- prefixes['ms' + styleProp] = 'MS' + eventName;
720
- prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
721
665
 
722
666
  return prefixes;
723
667
  }
@@ -745,7 +689,7 @@ var style = {};
745
689
  /**
746
690
  * Bootstrap if a DOM exists.
747
691
  */
748
- if (ExecutionEnvironment_1.canUseDOM) {
692
+ if (canUseDOM) {
749
693
  style = document.createElement('div').style;
750
694
 
751
695
  // On some platforms, in particular some releases of Android 4.x,
@@ -813,6 +757,7 @@ var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
813
757
  var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
814
758
  var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
815
759
  var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
760
+
816
761
  var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
817
762
  var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
818
763
  var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
@@ -882,17 +827,26 @@ var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
882
827
  // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
883
828
 
884
829
  var findDOMNode = ReactDOM.findDOMNode;
885
- var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
886
- var EventPluginHub = _ReactDOM$__SECRET_IN.EventPluginHub;
887
- var EventPluginRegistry = _ReactDOM$__SECRET_IN.EventPluginRegistry;
888
- var EventPropagators = _ReactDOM$__SECRET_IN.EventPropagators;
889
- var ReactControlledComponent = _ReactDOM$__SECRET_IN.ReactControlledComponent;
890
- var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree;
891
- 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];
892
844
 
893
845
 
894
846
  function Event(suffix) {}
895
847
 
848
+ var hasWarnedAboutDeprecatedMockComponent = false;
849
+
896
850
  /**
897
851
  * @class ReactTestUtils
898
852
  */
@@ -906,7 +860,7 @@ function Event(suffix) {}
906
860
  */
907
861
  function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
908
862
  fakeNativeEvent.target = node;
909
- ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent);
863
+ dispatchEvent(topLevelType, fakeNativeEvent);
910
864
  }
911
865
 
912
866
  /**
@@ -931,7 +885,7 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
931
885
  var node = currentParent;
932
886
  var ret = [];
933
887
  while (true) {
934
- 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) {
935
889
  var publicInst = node.stateNode;
936
890
  if (test(publicInst)) {
937
891
  ret.push(publicInst);
@@ -956,6 +910,29 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
956
910
  }
957
911
  }
958
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
+
959
936
  /**
960
937
  * Utilities for making it easy to test React components.
961
938
  *
@@ -985,7 +962,7 @@ var ReactTestUtils = {
985
962
  },
986
963
 
987
964
  isDOMComponent: function (inst) {
988
- return !!(inst && inst.nodeType === 1 && inst.tagName);
965
+ return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
989
966
  },
990
967
 
991
968
  isDOMComponentElement: function (inst) {
@@ -1011,10 +988,10 @@ var ReactTestUtils = {
1011
988
  },
1012
989
 
1013
990
  findAllInRenderedTree: function (inst, test) {
991
+ validateClassInstance(inst, 'findAllInRenderedTree');
1014
992
  if (!inst) {
1015
993
  return [];
1016
994
  }
1017
- !ReactTestUtils.isCompositeComponent(inst) ? invariant_1(false, 'findAllInRenderedTree(...): instance must be a composite component') : void 0;
1018
995
  var internalInstance = get(inst);
1019
996
  return findAllInRenderedFiberTreeInternal(internalInstance, test);
1020
997
  },
@@ -1025,6 +1002,7 @@ var ReactTestUtils = {
1025
1002
  * @return {array} an array of all the matches.
1026
1003
  */
1027
1004
  scryRenderedDOMComponentsWithClass: function (root, classNames) {
1005
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
1028
1006
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1029
1007
  if (ReactTestUtils.isDOMComponent(inst)) {
1030
1008
  var className = inst.className;
@@ -1035,7 +1013,7 @@ var ReactTestUtils = {
1035
1013
  var classList = className.split(/\s+/);
1036
1014
 
1037
1015
  if (!Array.isArray(classNames)) {
1038
- !(classNames !== undefined) ? invariant_1(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
1016
+ !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
1039
1017
  classNames = classNames.split(/\s+/);
1040
1018
  }
1041
1019
  return classNames.every(function (name) {
@@ -1053,6 +1031,7 @@ var ReactTestUtils = {
1053
1031
  * @return {!ReactDOMComponent} The one match.
1054
1032
  */
1055
1033
  findRenderedDOMComponentWithClass: function (root, className) {
1034
+ validateClassInstance(root, 'findRenderedDOMComponentWithClass');
1056
1035
  var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
1057
1036
  if (all.length !== 1) {
1058
1037
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
@@ -1066,6 +1045,7 @@ var ReactTestUtils = {
1066
1045
  * @return {array} an array of all the matches.
1067
1046
  */
1068
1047
  scryRenderedDOMComponentsWithTag: function (root, tagName) {
1048
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
1069
1049
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1070
1050
  return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
1071
1051
  });
@@ -1078,6 +1058,7 @@ var ReactTestUtils = {
1078
1058
  * @return {!ReactDOMComponent} The one match.
1079
1059
  */
1080
1060
  findRenderedDOMComponentWithTag: function (root, tagName) {
1061
+ validateClassInstance(root, 'findRenderedDOMComponentWithTag');
1081
1062
  var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
1082
1063
  if (all.length !== 1) {
1083
1064
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
@@ -1090,6 +1071,7 @@ var ReactTestUtils = {
1090
1071
  * @return {array} an array of all the matches.
1091
1072
  */
1092
1073
  scryRenderedComponentsWithType: function (root, componentType) {
1074
+ validateClassInstance(root, 'scryRenderedComponentsWithType');
1093
1075
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1094
1076
  return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
1095
1077
  });
@@ -1102,6 +1084,7 @@ var ReactTestUtils = {
1102
1084
  * @return {!ReactComponent} The one match.
1103
1085
  */
1104
1086
  findRenderedComponentWithType: function (root, componentType) {
1087
+ validateClassInstance(root, 'findRenderedComponentWithType');
1105
1088
  var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
1106
1089
  if (all.length !== 1) {
1107
1090
  throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
@@ -1123,6 +1106,11 @@ var ReactTestUtils = {
1123
1106
  * @return {object} the ReactTestUtils object (for chaining)
1124
1107
  */
1125
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
+
1126
1114
  mockTagName = mockTagName || module.mockTagName || 'div';
1127
1115
 
1128
1116
  module.prototype.render.mockImplementation(function () {
@@ -1152,10 +1140,10 @@ var ReactTestUtils = {
1152
1140
  */
1153
1141
  function makeSimulator(eventType) {
1154
1142
  return function (domNode, eventData) {
1155
- !!React.isValidElement(domNode) ? invariant_1(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;
1156
- !!ReactTestUtils.isCompositeComponent(domNode) ? invariant_1(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;
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;
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;
1157
1145
 
1158
- var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType];
1146
+ var dispatchConfig = eventNameDispatchConfigs[eventType];
1159
1147
 
1160
1148
  var fakeNativeEvent = new Event();
1161
1149
  fakeNativeEvent.target = domNode;
@@ -1163,8 +1151,8 @@ function makeSimulator(eventType) {
1163
1151
 
1164
1152
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
1165
1153
  // properly destroying any properties assigned from `eventData` upon release
1166
- var targetInst = ReactDOMComponentTree.getInstanceFromNode(domNode);
1167
- var event = new SyntheticEvent$1(dispatchConfig, targetInst, fakeNativeEvent, domNode);
1154
+ var targetInst = getInstanceFromNode(domNode);
1155
+ var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode);
1168
1156
 
1169
1157
  // Since we aren't using pooling, always persist the event. This will make
1170
1158
  // sure it's marked and won't warn when setting additional properties.
@@ -1172,18 +1160,18 @@ function makeSimulator(eventType) {
1172
1160
  _assign(event, eventData);
1173
1161
 
1174
1162
  if (dispatchConfig.phasedRegistrationNames) {
1175
- EventPropagators.accumulateTwoPhaseDispatches(event);
1163
+ accumulateTwoPhaseDispatches(event);
1176
1164
  } else {
1177
- EventPropagators.accumulateDirectDispatches(event);
1165
+ accumulateDirectDispatches(event);
1178
1166
  }
1179
1167
 
1180
1168
  ReactDOM.unstable_batchedUpdates(function () {
1181
1169
  // Normally extractEvent enqueues a state restore, but we'll just always
1182
1170
  // do that since we we're by-passing it here.
1183
- ReactControlledComponent.enqueueStateRestore(domNode);
1184
- EventPluginHub.runEventsInBatch(event, true);
1171
+ enqueueStateRestore(domNode);
1172
+ runEventsInBatch(event, true);
1185
1173
  });
1186
- ReactControlledComponent.restoreStateIfNeeded();
1174
+ restoreStateIfNeeded();
1187
1175
  };
1188
1176
  }
1189
1177
 
@@ -1191,7 +1179,7 @@ function buildSimulators() {
1191
1179
  ReactTestUtils.Simulate = {};
1192
1180
 
1193
1181
  var eventType = void 0;
1194
- for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
1182
+ for (eventType in eventNameDispatchConfigs) {
1195
1183
  /**
1196
1184
  * @param {!Element|ReactDOMComponent} domComponentOrNode
1197
1185
  * @param {?object} eventData Fake event data to use in SyntheticEvent.
@@ -1200,18 +1188,6 @@ function buildSimulators() {
1200
1188
  }
1201
1189
  }
1202
1190
 
1203
- // Rebuild ReactTestUtils.Simulate whenever event plugins are injected
1204
- var oldInjectEventPluginOrder = EventPluginHub.injection.injectEventPluginOrder;
1205
- EventPluginHub.injection.injectEventPluginOrder = function () {
1206
- oldInjectEventPluginOrder.apply(this, arguments);
1207
- buildSimulators();
1208
- };
1209
- var oldInjectEventPlugins = EventPluginHub.injection.injectEventPluginsByName;
1210
- EventPluginHub.injection.injectEventPluginsByName = function () {
1211
- oldInjectEventPlugins.apply(this, arguments);
1212
- buildSimulators();
1213
- };
1214
-
1215
1191
  buildSimulators();
1216
1192
 
1217
1193
  /**
@@ -1264,7 +1240,7 @@ var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$
1264
1240
 
1265
1241
  // TODO: decide on the top-level export form.
1266
1242
  // This is hacky but makes it work with both Rollup and Jest.
1267
- var testUtils = ReactTestUtils$3.default ? ReactTestUtils$3.default : ReactTestUtils$3;
1243
+ var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
1268
1244
 
1269
1245
  return testUtils;
1270
1246