react-dom 16.8.5 → 16.9.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.
Files changed (34) hide show
  1. package/build-info.json +5 -5
  2. package/cjs/react-dom-server.browser.development.js +473 -136
  3. package/cjs/react-dom-server.browser.production.min.js +45 -42
  4. package/cjs/react-dom-server.node.development.js +456 -131
  5. package/cjs/react-dom-server.node.production.min.js +46 -44
  6. package/cjs/react-dom-test-utils.development.js +328 -82
  7. package/cjs/react-dom-test-utils.production.min.js +26 -23
  8. package/cjs/react-dom-unstable-fizz.browser.development.js +9 -1
  9. package/cjs/react-dom-unstable-fizz.browser.production.min.js +1 -1
  10. package/cjs/react-dom-unstable-fizz.node.development.js +9 -1
  11. package/cjs/react-dom-unstable-fizz.node.production.min.js +1 -1
  12. package/cjs/react-dom-unstable-native-dependencies.development.js +67 -44
  13. package/cjs/react-dom-unstable-native-dependencies.production.min.js +20 -21
  14. package/cjs/react-dom.development.js +15465 -11493
  15. package/cjs/react-dom.production.min.js +266 -257
  16. package/cjs/react-dom.profiling.min.js +272 -263
  17. package/package.json +2 -2
  18. package/umd/react-dom-server.browser.development.js +473 -136
  19. package/umd/react-dom-server.browser.production.min.js +38 -37
  20. package/umd/react-dom-test-utils.development.js +349 -82
  21. package/umd/react-dom-test-utils.production.min.js +23 -22
  22. package/umd/react-dom-unstable-fizz.browser.development.js +9 -1
  23. package/umd/react-dom-unstable-fizz.browser.production.min.js +1 -1
  24. package/umd/react-dom-unstable-native-dependencies.development.js +67 -44
  25. package/umd/react-dom-unstable-native-dependencies.production.min.js +21 -22
  26. package/umd/react-dom.development.js +12006 -8031
  27. package/umd/react-dom.production.min.js +220 -209
  28. package/umd/react-dom.profiling.min.js +227 -214
  29. package/cjs/react-dom-unstable-fire.development.js +0 -21252
  30. package/cjs/react-dom-unstable-fire.production.min.js +0 -269
  31. package/cjs/react-dom-unstable-fire.profiling.min.js +0 -278
  32. package/umd/react-dom-unstable-fire.development.js +0 -21387
  33. package/umd/react-dom-unstable-fire.production.min.js +0 -220
  34. package/umd/react-dom-unstable-fire.profiling.min.js +0 -225
@@ -1,4 +1,4 @@
1
- /** @license React v16.8.5
1
+ /** @license React v16.9.0
2
2
  * react-dom-test-utils.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -18,6 +18,20 @@ 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 Scheduler = require('scheduler');
22
+
23
+ // Do not require this module directly! Use normal `invariant` calls with
24
+ // template literal strings. The messages will be converted to ReactError during
25
+ // build, and in production they will be minified.
26
+
27
+ // Do not require this module directly! Use normal `invariant` calls with
28
+ // template literal strings. The messages will be converted to ReactError during
29
+ // build, and in production they will be minified.
30
+
31
+ function ReactError(error) {
32
+ error.name = 'Invariant Violation';
33
+ return error;
34
+ }
21
35
 
22
36
  /**
23
37
  * Use invariant() to assert state which your program assumes to be true.
@@ -30,40 +44,6 @@ var ReactDOM = require('react-dom');
30
44
  * will remain to ensure logic does not differ in production.
31
45
  */
32
46
 
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
47
  /**
68
48
  * Similar to invariant but only logs a warning if the condition is not met.
69
49
  * This can be used to log issues in development environments in critical
@@ -145,10 +125,24 @@ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
145
125
  current: null
146
126
  };
147
127
  }
128
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
129
+ ReactSharedInternals.ReactCurrentBatchConfig = {
130
+ suspense: null
131
+ };
132
+ }
148
133
 
149
134
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
150
135
  // nor polyfill, then a plain number is used for performance.
151
136
 
137
+
138
+
139
+
140
+
141
+
142
+
143
+ // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
144
+ // (unstable) APIs that have been removed. Can we remove the symbols?
145
+
152
146
  var FunctionComponent = 0;
153
147
  var ClassComponent = 1;
154
148
  // Before we know whether it is function or class
@@ -218,7 +212,13 @@ function isFiberMountedImpl(fiber) {
218
212
 
219
213
 
220
214
  function assertIsMounted(fiber) {
221
- !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
215
+ (function () {
216
+ if (!(isFiberMountedImpl(fiber) === MOUNTED)) {
217
+ {
218
+ throw ReactError(Error('Unable to find node on an unmounted component.'));
219
+ }
220
+ }
221
+ })();
222
222
  }
223
223
 
224
224
  function findCurrentFiberUsingSlowPath(fiber) {
@@ -226,7 +226,13 @@ function findCurrentFiberUsingSlowPath(fiber) {
226
226
  if (!alternate) {
227
227
  // If there is no alternate, then we only need to check if it is mounted.
228
228
  var state = isFiberMountedImpl(fiber);
229
- !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
229
+ (function () {
230
+ if (!(state !== UNMOUNTED)) {
231
+ {
232
+ throw ReactError(Error('Unable to find node on an unmounted component.'));
233
+ }
234
+ }
235
+ })();
230
236
  if (state === MOUNTING) {
231
237
  return null;
232
238
  }
@@ -239,11 +245,24 @@ function findCurrentFiberUsingSlowPath(fiber) {
239
245
  var b = alternate;
240
246
  while (true) {
241
247
  var parentA = a.return;
242
- var parentB = parentA ? parentA.alternate : null;
243
- if (!parentA || !parentB) {
248
+ if (parentA === null) {
244
249
  // We're at the root.
245
250
  break;
246
251
  }
252
+ var parentB = parentA.alternate;
253
+ if (parentB === null) {
254
+ // There is no alternate. This is an unusual case. Currently, it only
255
+ // happens when a Suspense component is hidden. An extra fragment fiber
256
+ // is inserted in between the Suspense fiber and its children. Skip
257
+ // over this extra fragment fiber and proceed to the next parent.
258
+ var nextParent = parentA.return;
259
+ if (nextParent !== null) {
260
+ a = b = nextParent;
261
+ continue;
262
+ }
263
+ // If there's no parent, we're at the root.
264
+ break;
265
+ }
247
266
 
248
267
  // If both copies of the parent fiber point to the same child, we can
249
268
  // assume that the child is current. This happens when we bailout on low
@@ -265,7 +284,13 @@ function findCurrentFiberUsingSlowPath(fiber) {
265
284
  }
266
285
  // We should never have an alternate for any mounting node. So the only
267
286
  // way this could possibly happen is if this was unmounted, if at all.
268
- invariant(false, 'Unable to find node on an unmounted component.');
287
+ (function () {
288
+ {
289
+ {
290
+ throw ReactError(Error('Unable to find node on an unmounted component.'));
291
+ }
292
+ }
293
+ })();
269
294
  }
270
295
 
271
296
  if (a.return !== b.return) {
@@ -316,15 +341,33 @@ function findCurrentFiberUsingSlowPath(fiber) {
316
341
  }
317
342
  _child = _child.sibling;
318
343
  }
319
- !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;
344
+ (function () {
345
+ if (!didFindChild) {
346
+ {
347
+ throw ReactError(Error('Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.'));
348
+ }
349
+ }
350
+ })();
320
351
  }
321
352
  }
322
353
 
323
- !(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;
354
+ (function () {
355
+ if (!(a.alternate === b)) {
356
+ {
357
+ throw ReactError(Error('Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.'));
358
+ }
359
+ }
360
+ })();
324
361
  }
325
362
  // If the root is not a host container, we're in a disconnected tree. I.e.
326
363
  // unmounted.
327
- !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
364
+ (function () {
365
+ if (!(a.tag === HostRoot)) {
366
+ {
367
+ throw ReactError(Error('Unable to find node on an unmounted component.'));
368
+ }
369
+ }
370
+ })();
328
371
  if (a.stateNode.current === a) {
329
372
  // We've determined that A is the current branch.
330
373
  return fiber;
@@ -581,7 +624,13 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
581
624
 
582
625
  function releasePooledEvent(event) {
583
626
  var EventConstructor = this;
584
- !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
627
+ (function () {
628
+ if (!(event instanceof EventConstructor)) {
629
+ {
630
+ throw ReactError(Error('Trying to release an event instance into a pool of a different type.'));
631
+ }
632
+ }
633
+ })();
585
634
  event.destructor();
586
635
  if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
587
636
  EventConstructor.eventPool.push(event);
@@ -653,7 +702,7 @@ var lowPriorityWarning$1 = lowPriorityWarning;
653
702
 
654
703
  var ELEMENT_NODE = 1;
655
704
 
656
- // Do not uses the below two methods directly!
705
+ // Do not use the below two methods directly!
657
706
  // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
658
707
  // (It is the only module that is allowed to access these methods.)
659
708
 
@@ -661,7 +710,7 @@ function unsafeCastStringToDOMTopLevelType(topLevelType) {
661
710
  return topLevelType;
662
711
  }
663
712
 
664
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
713
+ var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
665
714
 
666
715
  /**
667
716
  * Generate a mapping of standard vendor prefixes using the defined style property and event name.
@@ -840,10 +889,199 @@ var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
840
889
  // Note that events in this list will *not* be listened to at the top level
841
890
  // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
842
891
 
843
- // for .act's return value
892
+ var PLUGIN_EVENT_SYSTEM = 1;
893
+
894
+ var didWarnAboutMessageChannel = false;
895
+ var enqueueTask = void 0;
896
+ try {
897
+ // read require off the module object to get around the bundlers.
898
+ // we don't want them to detect a require and bundle a Node polyfill.
899
+ var requireString = ('require' + Math.random()).slice(0, 7);
900
+ var nodeRequire = module && module[requireString];
901
+ // assuming we're in node, let's try to get node's
902
+ // version of setImmediate, bypassing fake timers if any.
903
+ enqueueTask = nodeRequire('timers').setImmediate;
904
+ } catch (_err) {
905
+ // we're in a browser
906
+ // we can't use regular timers because they may still be faked
907
+ // so we try MessageChannel+postMessage instead
908
+ enqueueTask = function (callback) {
909
+ {
910
+ if (didWarnAboutMessageChannel === false) {
911
+ didWarnAboutMessageChannel = true;
912
+ !(typeof MessageChannel !== 'undefined') ? warningWithoutStack$1(false, 'This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.') : void 0;
913
+ }
914
+ }
915
+ var channel = new MessageChannel();
916
+ channel.port1.onmessage = callback;
917
+ channel.port2.postMessage(undefined);
918
+ };
919
+ }
920
+
921
+ var enqueueTask$1 = enqueueTask;
922
+
923
+ // Keep in sync with ReactDOMUnstableNativeDependencies.js
924
+ // ReactDOM.js, and ReactTestUtils.js:
925
+ var _ReactDOM$__SECRET_IN$1 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
926
+ var getInstanceFromNode$1 = _ReactDOM$__SECRET_IN$1[0];
927
+ var getNodeFromInstance$1 = _ReactDOM$__SECRET_IN$1[1];
928
+ var getFiberCurrentPropsFromNode$1 = _ReactDOM$__SECRET_IN$1[2];
929
+ var injectEventPluginsByName$1 = _ReactDOM$__SECRET_IN$1[3];
930
+ var eventNameDispatchConfigs$1 = _ReactDOM$__SECRET_IN$1[4];
931
+ var accumulateTwoPhaseDispatches$1 = _ReactDOM$__SECRET_IN$1[5];
932
+ var accumulateDirectDispatches$1 = _ReactDOM$__SECRET_IN$1[6];
933
+ var enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[7];
934
+ var restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[8];
935
+ var dispatchEvent$1 = _ReactDOM$__SECRET_IN$1[9];
936
+ var runEventsInBatch$1 = _ReactDOM$__SECRET_IN$1[10];
937
+ var flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[11];
938
+ var IsThisRendererActing$1 = _ReactDOM$__SECRET_IN$1[12];
939
+
940
+
941
+ var batchedUpdates = ReactDOM.unstable_batchedUpdates;
942
+
943
+ var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
944
+
945
+ // this implementation should be exactly the same in
946
+ // ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js
947
+
948
+ var isSchedulerMocked = typeof Scheduler.unstable_flushAllWithoutAsserting === 'function';
949
+ var flushWork = Scheduler.unstable_flushAllWithoutAsserting || function () {
950
+ var didFlushWork = false;
951
+ while (flushPassiveEffects$1()) {
952
+ didFlushWork = true;
953
+ }
954
+
955
+ return didFlushWork;
956
+ };
957
+
958
+ function flushWorkAndMicroTasks(onDone) {
959
+ try {
960
+ flushWork();
961
+ enqueueTask$1(function () {
962
+ if (flushWork()) {
963
+ flushWorkAndMicroTasks(onDone);
964
+ } else {
965
+ onDone();
966
+ }
967
+ });
968
+ } catch (err) {
969
+ onDone(err);
970
+ }
971
+ }
972
+
973
+ // we track the 'depth' of the act() calls with this counter,
974
+ // so we can tell if any async act() calls try to run in parallel.
975
+
976
+ var actingUpdatesScopeDepth = 0;
977
+ function act(callback) {
978
+ var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
979
+ var previousIsSomeRendererActing = void 0;
980
+ var previousIsThisRendererActing = void 0;
981
+ actingUpdatesScopeDepth++;
982
+
983
+ previousIsSomeRendererActing = IsSomeRendererActing.current;
984
+ previousIsThisRendererActing = IsThisRendererActing$1.current;
985
+ IsSomeRendererActing.current = true;
986
+ IsThisRendererActing$1.current = true;
987
+
988
+ function onDone() {
989
+ actingUpdatesScopeDepth--;
990
+ IsSomeRendererActing.current = previousIsSomeRendererActing;
991
+ IsThisRendererActing$1.current = previousIsThisRendererActing;
992
+ {
993
+ if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
994
+ // if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
995
+ warningWithoutStack$1(false, 'You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
996
+ }
997
+ }
998
+ }
999
+
1000
+ var result = void 0;
1001
+ try {
1002
+ result = batchedUpdates(callback);
1003
+ } catch (error) {
1004
+ // on sync errors, we still want to 'cleanup' and decrement actingUpdatesScopeDepth
1005
+ onDone();
1006
+ throw error;
1007
+ }
1008
+
1009
+ if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
1010
+ // setup a boolean that gets set to true only
1011
+ // once this act() call is await-ed
1012
+ var called = false;
1013
+ {
1014
+ if (typeof Promise !== 'undefined') {
1015
+ //eslint-disable-next-line no-undef
1016
+ Promise.resolve().then(function () {}).then(function () {
1017
+ if (called === false) {
1018
+ warningWithoutStack$1(false, 'You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, interleaving multiple act ' + 'calls and mixing their scopes. You should - await act(async () => ...);');
1019
+ }
1020
+ });
1021
+ }
1022
+ }
1023
+
1024
+ // in the async case, the returned thenable runs the callback, flushes
1025
+ // effects and microtasks in a loop until flushPassiveEffects() === false,
1026
+ // and cleans up
1027
+ return {
1028
+ then: function (resolve, reject) {
1029
+ called = true;
1030
+ result.then(function () {
1031
+ if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
1032
+ onDone();
1033
+ resolve();
1034
+ return;
1035
+ }
1036
+ // we're about to exit the act() scope,
1037
+ // now's the time to flush tasks/effects
1038
+ flushWorkAndMicroTasks(function (err) {
1039
+ onDone();
1040
+ if (err) {
1041
+ reject(err);
1042
+ } else {
1043
+ resolve();
1044
+ }
1045
+ });
1046
+ }, function (err) {
1047
+ onDone();
1048
+ reject(err);
1049
+ });
1050
+ }
1051
+ };
1052
+ } else {
1053
+ {
1054
+ !(result === undefined) ? warningWithoutStack$1(false, 'The callback passed to act(...) function ' + 'must return undefined, or a Promise. You returned %s', result) : void 0;
1055
+ }
1056
+
1057
+ // flush effects until none remain, and cleanup
1058
+ try {
1059
+ if (actingUpdatesScopeDepth === 1 && (isSchedulerMocked === false || previousIsSomeRendererActing === false)) {
1060
+ // we're about to exit the act() scope,
1061
+ // now's the time to flush effects
1062
+ flushWork();
1063
+ }
1064
+ onDone();
1065
+ } catch (err) {
1066
+ onDone();
1067
+ throw err;
1068
+ }
1069
+
1070
+ // in the sync case, the returned thenable only warns *if* await-ed
1071
+ return {
1072
+ then: function (resolve) {
1073
+ {
1074
+ warningWithoutStack$1(false, 'Do not await the result of calling act(...) with sync logic, it is not a Promise.');
1075
+ }
1076
+ resolve();
1077
+ }
1078
+ };
1079
+ }
1080
+ }
1081
+
844
1082
  var findDOMNode = ReactDOM.findDOMNode;
845
1083
  // Keep in sync with ReactDOMUnstableNativeDependencies.js
846
- // and ReactDOM.js:
1084
+ // ReactDOM.js, and ReactTestUtilsAct.js:
847
1085
 
848
1086
  var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
849
1087
  var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
@@ -857,6 +1095,8 @@ var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
857
1095
  var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
858
1096
  var dispatchEvent = _ReactDOM$__SECRET_IN[9];
859
1097
  var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
1098
+ var flushPassiveEffects = _ReactDOM$__SECRET_IN[11];
1099
+ var IsThisRendererActing = _ReactDOM$__SECRET_IN[12];
860
1100
 
861
1101
 
862
1102
  function Event(suffix) {}
@@ -876,7 +1116,7 @@ var hasWarnedAboutDeprecatedMockComponent = false;
876
1116
  */
877
1117
  function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
878
1118
  fakeNativeEvent.target = node;
879
- dispatchEvent(topLevelType, fakeNativeEvent);
1119
+ dispatchEvent(topLevelType, PLUGIN_EVENT_SYSTEM, fakeNativeEvent);
880
1120
  }
881
1121
 
882
1122
  /**
@@ -946,12 +1186,21 @@ function validateClassInstance(inst, methodName) {
946
1186
  } else {
947
1187
  received = stringified;
948
1188
  }
949
- invariant(false, '%s(...): the first argument must be a React class instance. Instead received: %s.', methodName, received);
1189
+ (function () {
1190
+ {
1191
+ {
1192
+ throw ReactError(Error(methodName + '(...): the first argument must be a React class instance. Instead received: ' + received + '.'));
1193
+ }
1194
+ }
1195
+ })();
950
1196
  }
951
1197
 
952
- // a stub element, lazily initialized, used by act() when flushing effects
1198
+ // a plain dom element, lazily initialized, used by act() when flushing effects
953
1199
  var actContainerElement = null;
954
1200
 
1201
+ // a warning for when you try to use TestUtils.act in a non-browser environment
1202
+ var didWarnAboutActInNodejs = false;
1203
+
955
1204
  /**
956
1205
  * Utilities for making it easy to test React components.
957
1206
  *
@@ -1032,7 +1281,13 @@ var ReactTestUtils = {
1032
1281
  var classList = className.split(/\s+/);
1033
1282
 
1034
1283
  if (!Array.isArray(classNames)) {
1035
- !(classNames !== undefined) ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : void 0;
1284
+ (function () {
1285
+ if (!(classNames !== undefined)) {
1286
+ {
1287
+ throw ReactError(Error('TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.'));
1288
+ }
1289
+ }
1290
+ })();
1036
1291
  classNames = classNames.split(/\s+/);
1037
1292
  }
1038
1293
  return classNames.every(function (name) {
@@ -1150,38 +1405,17 @@ var ReactTestUtils = {
1150
1405
 
1151
1406
  act: function (callback) {
1152
1407
  if (actContainerElement === null) {
1153
- // warn if we can't actually create the stub element
1154
1408
  {
1155
- !(typeof document !== 'undefined' && document !== null && typeof document.createElement === 'function') ? warningWithoutStack$1(false, 'It looks like you called TestUtils.act(...) in a non-browser environment. ' + "If you're using TestRenderer for your tests, you should call " + 'TestRenderer.act(...) instead of TestUtils.act(...).') : void 0;
1156
- }
1157
- // then make it
1158
- actContainerElement = document.createElement('div');
1159
- }
1160
-
1161
- var result = ReactDOM.unstable_batchedUpdates(callback);
1162
- // note: keep these warning messages in sync with
1163
- // createReactNoop.js and ReactTestRenderer.js
1164
- {
1165
- if (result !== undefined) {
1166
- var addendum = void 0;
1167
- if (result !== null && typeof result.then === 'function') {
1168
- addendum = '\n\nIt looks like you wrote ReactTestUtils.act(async () => ...), ' + 'or returned a Promise from the callback passed to it. ' + 'Putting asynchronous logic inside ReactTestUtils.act(...) is not supported.\n';
1169
- } else {
1170
- addendum = ' You returned: ' + result;
1409
+ // warn if we're trying to use this in something like node (without jsdom)
1410
+ if (didWarnAboutActInNodejs === false) {
1411
+ didWarnAboutActInNodejs = true;
1412
+ !(typeof document !== 'undefined' && document !== null) ? warningWithoutStack$1(false, 'It looks like you called ReactTestUtils.act(...) in a non-browser environment. ' + "If you're using TestRenderer for your tests, you should call " + 'ReactTestRenderer.act(...) instead of ReactTestUtils.act(...).') : void 0;
1171
1413
  }
1172
- warningWithoutStack$1(false, 'The callback passed to ReactTestUtils.act(...) function must not return anything.%s', addendum);
1173
1414
  }
1415
+ // now make the stub element
1416
+ actContainerElement = document.createElement('div');
1174
1417
  }
1175
- ReactDOM.render(React.createElement('div', null), actContainerElement);
1176
- // we want the user to not expect a return,
1177
- // but we want to warn if they use it like they can await on it.
1178
- return {
1179
- then: function () {
1180
- {
1181
- warningWithoutStack$1(false, 'Do not await the result of calling ReactTestUtils.act(...), it is not a Promise.');
1182
- }
1183
- }
1184
- };
1418
+ return act(callback);
1185
1419
  }
1186
1420
  };
1187
1421
 
@@ -1195,8 +1429,20 @@ var ReactTestUtils = {
1195
1429
  */
1196
1430
  function makeSimulator(eventType) {
1197
1431
  return function (domNode, eventData) {
1198
- !!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;
1199
- !!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;
1432
+ (function () {
1433
+ if (!!React.isValidElement(domNode)) {
1434
+ {
1435
+ throw ReactError(Error('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.'));
1436
+ }
1437
+ }
1438
+ })();
1439
+ (function () {
1440
+ if (!!ReactTestUtils.isCompositeComponent(domNode)) {
1441
+ {
1442
+ throw ReactError(Error('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.'));
1443
+ }
1444
+ }
1445
+ })();
1200
1446
 
1201
1447
  var dispatchConfig = eventNameDispatchConfigs[eventType];
1202
1448