react-dom 16.12.0 → 16.13.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 (42) hide show
  1. package/build-info.json +4 -4
  2. package/cjs/react-dom-server.browser.development.js +331 -594
  3. package/cjs/react-dom-server.browser.production.min.js +37 -37
  4. package/cjs/react-dom-server.node.development.js +330 -593
  5. package/cjs/react-dom-server.node.production.min.js +38 -38
  6. package/cjs/react-dom-test-utils.development.js +171 -328
  7. package/cjs/react-dom-test-utils.production.min.js +17 -17
  8. package/cjs/react-dom-unstable-fizz.browser.development.js +3 -21
  9. package/cjs/react-dom-unstable-fizz.browser.production.min.js +2 -2
  10. package/cjs/react-dom-unstable-fizz.node.development.js +2 -18
  11. package/cjs/react-dom-unstable-fizz.node.production.min.js +3 -3
  12. package/cjs/react-dom-unstable-native-dependencies.development.js +190 -305
  13. package/cjs/react-dom-unstable-native-dependencies.production.min.js +23 -27
  14. package/cjs/react-dom.development.js +11227 -13976
  15. package/cjs/react-dom.production.min.js +280 -278
  16. package/cjs/react-dom.profiling.min.js +287 -284
  17. package/package.json +3 -8
  18. package/umd/react-dom-server.browser.development.js +3320 -3594
  19. package/umd/react-dom-server.browser.production.min.js +35 -35
  20. package/umd/react-dom-test-utils.development.js +1200 -1357
  21. package/umd/react-dom-test-utils.production.min.js +23 -23
  22. package/umd/react-dom-unstable-fizz.browser.development.js +105 -123
  23. package/umd/react-dom-unstable-fizz.browser.production.min.js +3 -3
  24. package/umd/react-dom-unstable-native-dependencies.development.js +1333 -1449
  25. package/umd/react-dom-unstable-native-dependencies.production.min.js +21 -22
  26. package/umd/react-dom.development.js +19953 -22713
  27. package/umd/react-dom.production.min.js +229 -232
  28. package/umd/react-dom.profiling.min.js +236 -239
  29. package/cjs/react-dom-unstable-flight-client.development.js +0 -357
  30. package/cjs/react-dom-unstable-flight-client.production.min.js +0 -16
  31. package/cjs/react-dom-unstable-flight-server.browser.development.js +0 -392
  32. package/cjs/react-dom-unstable-flight-server.browser.production.min.js +0 -16
  33. package/cjs/react-dom-unstable-flight-server.node.development.js +0 -415
  34. package/cjs/react-dom-unstable-flight-server.node.production.min.js +0 -16
  35. package/umd/react-dom-unstable-flight-client.development.js +0 -357
  36. package/umd/react-dom-unstable-flight-client.production.min.js +0 -14
  37. package/umd/react-dom-unstable-flight-server.browser.development.js +0 -390
  38. package/umd/react-dom-unstable-flight-server.browser.production.min.js +0 -14
  39. package/unstable-flight-client.js +0 -7
  40. package/unstable-flight-server.browser.js +0 -7
  41. package/unstable-flight-server.js +0 -3
  42. package/unstable-flight-server.node.js +0 -7
@@ -1,4 +1,4 @@
1
- /** @license React v16.12.0
1
+ /** @license React v16.13.0
2
2
  * react-dom-test-utils.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -10,1647 +10,1490 @@
10
10
  'use strict';
11
11
 
12
12
  (function (global, factory) {
13
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('react-dom')) :
14
- typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
15
- (global.ReactTestUtils = factory(global.React,global.ReactDOM));
16
- }(this, (function (React,ReactDOM) { 'use strict';
13
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('react-dom')) :
14
+ typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
15
+ (global = global || self, global.ReactTestUtils = factory(global.React, global.ReactDOM));
16
+ }(this, (function (React, ReactDOM) { 'use strict';
17
17
 
18
- var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
19
- var _assign = ReactInternals.assign;
18
+ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
19
+ var _assign = ReactInternals.assign;
20
20
 
21
- // Do not require this module directly! Use normal `invariant` calls with
22
- // template literal strings. The messages will be replaced with error codes
23
- // during build.
21
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
22
+ // Current owner and dispatcher used to share the same ref,
23
+ // but PR #14548 split them out to better support the react-debug-tools package.
24
24
 
25
- /**
26
- * Use invariant() to assert state which your program assumes to be true.
27
- *
28
- * Provide sprintf-style format (only %s is supported) and arguments
29
- * to provide information about what broke and what you were
30
- * expecting.
31
- *
32
- * The invariant message will be stripped in production, but the invariant
33
- * will remain to ensure logic does not differ in production.
34
- */
35
-
36
- /**
37
- * Similar to invariant but only logs a warning if the condition is not met.
38
- * This can be used to log issues in development environments in critical
39
- * paths. Removing the logging code for production environments will keep the
40
- * same logic and follow the same code paths.
41
- */
42
- var warningWithoutStack = function () {};
25
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
26
+ ReactSharedInternals.ReactCurrentDispatcher = {
27
+ current: null
28
+ };
29
+ }
43
30
 
44
- {
45
- warningWithoutStack = function (condition, format) {
46
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
47
- args[_key - 2] = arguments[_key];
48
- }
31
+ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
32
+ ReactSharedInternals.ReactCurrentBatchConfig = {
33
+ suspense: null
34
+ };
35
+ }
49
36
 
50
- if (format === undefined) {
51
- throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
52
- }
37
+ // by calls to these methods by a Babel plugin.
38
+ //
39
+ // In PROD (or in packages without access to React internals),
40
+ // they are left as they are instead.
53
41
 
54
- if (args.length > 8) {
55
- // Check before the condition to catch violations early.
56
- throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
57
- }
42
+ function warn(format) {
43
+ {
44
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
45
+ args[_key - 1] = arguments[_key];
46
+ }
58
47
 
59
- if (condition) {
60
- return;
48
+ printWarning('warn', format, args);
61
49
  }
50
+ }
51
+ function error(format) {
52
+ {
53
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
54
+ args[_key2 - 1] = arguments[_key2];
55
+ }
62
56
 
63
- if (typeof console !== 'undefined') {
64
- var argsWithFormat = args.map(function (item) {
65
- return '' + item;
66
- });
67
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
68
- // breaks IE9: https://github.com/facebook/react/issues/13610
69
-
70
- Function.prototype.apply.call(console.error, console, argsWithFormat);
57
+ printWarning('error', format, args);
71
58
  }
59
+ }
72
60
 
73
- try {
74
- // --- Welcome to debugging React ---
75
- // This error was thrown as a convenience so that you can use this stack
76
- // to find the callsite that caused this warning to fire.
77
- var argIndex = 0;
78
- var message = 'Warning: ' + format.replace(/%s/g, function () {
79
- return args[argIndex++];
80
- });
81
- throw new Error(message);
82
- } catch (x) {}
83
- };
84
- }
85
-
86
- var warningWithoutStack$1 = warningWithoutStack;
87
-
88
- /**
89
- * `ReactInstanceMap` maintains a mapping from a public facing stateful
90
- * instance (key) and the internal representation (value). This allows public
91
- * methods to accept the user facing instance as an argument and map them back
92
- * to internal methods.
93
- *
94
- * Note that this module is currently shared and assumed to be stateless.
95
- * If this becomes an actual Map, that will break.
96
- */
97
-
98
- /**
99
- * This API should be called `delete` but we'd have to make sure to always
100
- * transform these to strings for IE support. When this transform is fully
101
- * supported we can rename it.
102
- */
103
-
104
- function get(key) {
105
- return key._reactInternalFiber;
106
- }
107
-
108
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
109
- // Current owner and dispatcher used to share the same ref,
110
- // but PR #14548 split them out to better support the react-debug-tools package.
111
-
112
- if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
113
- ReactSharedInternals.ReactCurrentDispatcher = {
114
- current: null
115
- };
116
- }
117
-
118
- if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
119
- ReactSharedInternals.ReactCurrentBatchConfig = {
120
- suspense: null
121
- };
122
- }
123
-
124
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
125
- // nor polyfill, then a plain number is used for performance.
61
+ function printWarning(level, format, args) {
62
+ // When changing this logic, you might want to also
63
+ // update consoleWithStackDev.www.js as well.
64
+ {
65
+ var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
126
66
 
67
+ if (!hasExistingStack) {
68
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
69
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
127
70
 
71
+ if (stack !== '') {
72
+ format += '%s';
73
+ args = args.concat([stack]);
74
+ }
75
+ }
128
76
 
77
+ var argsWithFormat = args.map(function (item) {
78
+ return '' + item;
79
+ }); // Careful: RN currently depends on this prefix
129
80
 
81
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
82
+ // breaks IE9: https://github.com/facebook/react/issues/13610
83
+ // eslint-disable-next-line react-internal/no-production-logging
130
84
 
85
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
131
86
 
132
- // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
133
- // (unstable) APIs that have been removed. Can we remove the symbols?
87
+ try {
88
+ // --- Welcome to debugging React ---
89
+ // This error was thrown as a convenience so that you can use this stack
90
+ // to find the callsite that caused this warning to fire.
91
+ var argIndex = 0;
92
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
93
+ return args[argIndex++];
94
+ });
95
+ throw new Error(message);
96
+ } catch (x) {}
97
+ }
98
+ }
134
99
 
135
- {
136
-
137
- }
100
+ /**
101
+ * `ReactInstanceMap` maintains a mapping from a public facing stateful
102
+ * instance (key) and the internal representation (value). This allows public
103
+ * methods to accept the user facing instance as an argument and map them back
104
+ * to internal methods.
105
+ *
106
+ * Note that this module is currently shared and assumed to be stateless.
107
+ * If this becomes an actual Map, that will break.
108
+ */
109
+ function get(key) {
110
+ return key._reactInternalFiber;
111
+ }
138
112
 
139
- var FunctionComponent = 0;
140
- var ClassComponent = 1;
141
- // Before we know whether it is function or class
113
+ var FunctionComponent = 0;
114
+ var ClassComponent = 1;
142
115
 
143
- var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
116
+ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
144
117
 
145
- // A subtree. Could be an entry point to a different renderer.
118
+ var HostComponent = 5;
119
+ var HostText = 6;
146
120
 
147
- var HostComponent = 5;
148
- var HostText = 6;
121
+ // Don't change these two values. They're used by React Dev Tools.
122
+ var NoEffect =
123
+ /* */
124
+ 0;
149
125
 
150
- // Don't change these two values. They're used by React Dev Tools.
151
- var NoEffect =
152
- /* */
153
- 0;
154
- // You can change the rest (and add more).
126
+ var Placement =
127
+ /* */
128
+ 2;
129
+ var Hydrating =
130
+ /* */
131
+ 1024;
155
132
 
156
- var Placement =
157
- /* */
158
- 2;
133
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
134
+ function getNearestMountedFiber(fiber) {
135
+ var node = fiber;
136
+ var nearestMounted = fiber;
159
137
 
138
+ if (!fiber.alternate) {
139
+ // If there is no alternate, this might be a new tree that isn't inserted
140
+ // yet. If it is, then it will have a pending insertion effect on it.
141
+ var nextNode = node;
160
142
 
143
+ do {
144
+ node = nextNode;
161
145
 
146
+ if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
147
+ // This is an insertion or in-progress hydration. The nearest possible
148
+ // mounted fiber is the parent but we need to continue to figure out
149
+ // if that one is still mounted.
150
+ nearestMounted = node.return;
151
+ }
162
152
 
153
+ nextNode = node.return;
154
+ } while (nextNode);
155
+ } else {
156
+ while (node.return) {
157
+ node = node.return;
158
+ }
159
+ }
163
160
 
161
+ if (node.tag === HostRoot) {
162
+ // TODO: Check if this was a nested HostRoot when used with
163
+ // renderContainerIntoSubtree.
164
+ return nearestMounted;
165
+ } // If we didn't hit the root, that means that we're in an disconnected tree
166
+ // that has been unmounted.
164
167
 
165
168
 
169
+ return null;
170
+ }
166
171
 
172
+ function assertIsMounted(fiber) {
173
+ if (!(getNearestMountedFiber(fiber) === fiber)) {
174
+ {
175
+ throw Error( "Unable to find node on an unmounted component." );
176
+ }
177
+ }
178
+ }
167
179
 
168
- var Hydrating =
169
- /* */
170
- 1024;
171
- // Passive & Update & Callback & Ref & Snapshot
180
+ function findCurrentFiberUsingSlowPath(fiber) {
181
+ var alternate = fiber.alternate;
172
182
 
173
- // Union of all host effects
183
+ if (!alternate) {
184
+ // If there is no alternate, then we only need to check if it is mounted.
185
+ var nearestMounted = getNearestMountedFiber(fiber);
174
186
 
175
- // Helps identify side effects in render-phase lifecycle hooks and setState
176
- // reducers by double invoking them in Strict Mode.
187
+ if (!(nearestMounted !== null)) {
188
+ {
189
+ throw Error( "Unable to find node on an unmounted component." );
190
+ }
191
+ }
177
192
 
178
- // To preserve the "Pause on caught exceptions" behavior of the debugger, we
179
- // replay the begin phase of a failed component inside invokeGuardedCallback.
193
+ if (nearestMounted !== fiber) {
194
+ return null;
195
+ }
180
196
 
181
- // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
197
+ return fiber;
198
+ } // If we have two possible branches, we'll walk backwards up to the root
199
+ // to see what path the root points to. On the way we may hit one of the
200
+ // special cases and we'll deal with them.
182
201
 
183
- // Gather advanced timing metrics for Profiler subtrees.
184
202
 
185
- // Trace which interactions trigger each commit.
203
+ var a = fiber;
204
+ var b = alternate;
186
205
 
187
- // SSR experiments
206
+ while (true) {
207
+ var parentA = a.return;
188
208
 
209
+ if (parentA === null) {
210
+ // We're at the root.
211
+ break;
212
+ }
189
213
 
190
- // Only used in www builds.
214
+ var parentB = parentA.alternate;
191
215
 
192
- // Only used in www builds.
216
+ if (parentB === null) {
217
+ // There is no alternate. This is an unusual case. Currently, it only
218
+ // happens when a Suspense component is hidden. An extra fragment fiber
219
+ // is inserted in between the Suspense fiber and its children. Skip
220
+ // over this extra fragment fiber and proceed to the next parent.
221
+ var nextParent = parentA.return;
193
222
 
194
- // Disable javascript: URL strings in href for XSS protection.
223
+ if (nextParent !== null) {
224
+ a = b = nextParent;
225
+ continue;
226
+ } // If there's no parent, we're at the root.
195
227
 
196
- // React Fire: prevent the value and checked attributes from syncing
197
- // with their related DOM properties
198
228
 
199
- // These APIs will no longer be "unstable" in the upcoming 16.7 release,
200
- // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
229
+ break;
230
+ } // If both copies of the parent fiber point to the same child, we can
231
+ // assume that the child is current. This happens when we bailout on low
232
+ // priority: the bailed out fiber's child reuses the current child.
201
233
 
202
234
 
203
- // Experimental React Flare event system and event components support.
235
+ if (parentA.child === parentB.child) {
236
+ var child = parentA.child;
204
237
 
205
- // Experimental Host Component support.
238
+ while (child) {
239
+ if (child === a) {
240
+ // We've determined that A is the current branch.
241
+ assertIsMounted(parentA);
242
+ return fiber;
243
+ }
206
244
 
207
- // Experimental Scope support.
245
+ if (child === b) {
246
+ // We've determined that B is the current branch.
247
+ assertIsMounted(parentA);
248
+ return alternate;
249
+ }
208
250
 
209
- // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
251
+ child = child.sibling;
252
+ } // We should never have an alternate for any mounting node. So the only
253
+ // way this could possibly happen is if this was unmounted, if at all.
210
254
 
211
- // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
212
- // Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
213
255
 
214
- // For tests, we flush suspense fallbacks in an act scope;
215
- // *except* in some of our own tests, where we test incremental loading states.
256
+ {
257
+ {
258
+ throw Error( "Unable to find node on an unmounted component." );
259
+ }
260
+ }
261
+ }
216
262
 
217
- // Add a callback property to suspense to notify which promises are currently
218
- // in the update queue. This allows reporting and tracing of what is causing
219
- // the user to see a loading state.
220
- // Also allows hydration callbacks to fire when a dehydrated boundary gets
221
- // hydrated or deleted.
263
+ if (a.return !== b.return) {
264
+ // The return pointer of A and the return pointer of B point to different
265
+ // fibers. We assume that return pointers never criss-cross, so A must
266
+ // belong to the child set of A.return, and B must belong to the child
267
+ // set of B.return.
268
+ a = parentA;
269
+ b = parentB;
270
+ } else {
271
+ // The return pointers point to the same fiber. We'll have to use the
272
+ // default, slow path: scan the child sets of each parent alternate to see
273
+ // which child belongs to which set.
274
+ //
275
+ // Search parent A's child set
276
+ var didFindChild = false;
277
+ var _child = parentA.child;
222
278
 
223
- // Part of the simplification of React.createElement so we can eventually move
224
- // from React.createElement to React.jsx
225
- // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
279
+ while (_child) {
280
+ if (_child === a) {
281
+ didFindChild = true;
282
+ a = parentA;
283
+ b = parentB;
284
+ break;
285
+ }
226
286
 
287
+ if (_child === b) {
288
+ didFindChild = true;
289
+ b = parentA;
290
+ a = parentB;
291
+ break;
292
+ }
227
293
 
294
+ _child = _child.sibling;
295
+ }
228
296
 
297
+ if (!didFindChild) {
298
+ // Search parent B's child set
299
+ _child = parentB.child;
300
+
301
+ while (_child) {
302
+ if (_child === a) {
303
+ didFindChild = true;
304
+ a = parentB;
305
+ b = parentA;
306
+ break;
307
+ }
229
308
 
309
+ if (_child === b) {
310
+ didFindChild = true;
311
+ b = parentB;
312
+ a = parentA;
313
+ break;
314
+ }
230
315
 
231
- // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
316
+ _child = _child.sibling;
317
+ }
232
318
 
233
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
234
- function getNearestMountedFiber(fiber) {
235
- var node = fiber;
236
- var nearestMounted = fiber;
319
+ if (!didFindChild) {
320
+ {
321
+ throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." );
322
+ }
323
+ }
324
+ }
325
+ }
237
326
 
238
- if (!fiber.alternate) {
239
- // If there is no alternate, this might be a new tree that isn't inserted
240
- // yet. If it is, then it will have a pending insertion effect on it.
241
- var nextNode = node;
327
+ if (!(a.alternate === b)) {
328
+ {
329
+ throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." );
330
+ }
331
+ }
332
+ } // If the root is not a host container, we're in a disconnected tree. I.e.
333
+ // unmounted.
242
334
 
243
- do {
244
- node = nextNode;
245
335
 
246
- if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
247
- // This is an insertion or in-progress hydration. The nearest possible
248
- // mounted fiber is the parent but we need to continue to figure out
249
- // if that one is still mounted.
250
- nearestMounted = node.return;
336
+ if (!(a.tag === HostRoot)) {
337
+ {
338
+ throw Error( "Unable to find node on an unmounted component." );
251
339
  }
252
-
253
- nextNode = node.return;
254
- } while (nextNode);
255
- } else {
256
- while (node.return) {
257
- node = node.return;
258
340
  }
259
- }
260
-
261
- if (node.tag === HostRoot) {
262
- // TODO: Check if this was a nested HostRoot when used with
263
- // renderContainerIntoSubtree.
264
- return nearestMounted;
265
- } // If we didn't hit the root, that means that we're in an disconnected tree
266
- // that has been unmounted.
267
-
268
-
269
- return null;
270
- }
271
-
272
341
 
342
+ if (a.stateNode.current === a) {
343
+ // We've determined that A is the current branch.
344
+ return fiber;
345
+ } // Otherwise B has to be current branch.
273
346
 
274
347
 
275
-
276
- function assertIsMounted(fiber) {
277
- if (!(getNearestMountedFiber(fiber) === fiber)) {
278
- {
279
- throw Error("Unable to find node on an unmounted component.");
280
- }
348
+ return alternate;
281
349
  }
282
- }
283
-
284
- function findCurrentFiberUsingSlowPath(fiber) {
285
- var alternate = fiber.alternate;
286
350
 
287
- if (!alternate) {
288
- // If there is no alternate, then we only need to check if it is mounted.
289
- var nearestMounted = getNearestMountedFiber(fiber);
290
-
291
- if (!(nearestMounted !== null)) {
292
- {
293
- throw Error("Unable to find node on an unmounted component.");
294
- }
295
- }
351
+ var EVENT_POOL_SIZE = 10;
352
+ /**
353
+ * @interface Event
354
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
355
+ */
296
356
 
297
- if (nearestMounted !== fiber) {
357
+ var EventInterface = {
358
+ type: null,
359
+ target: null,
360
+ // currentTarget is set when dispatching; no use in copying it here
361
+ currentTarget: function () {
298
362
  return null;
299
- }
300
-
301
- return fiber;
302
- } // If we have two possible branches, we'll walk backwards up to the root
303
- // to see what path the root points to. On the way we may hit one of the
304
- // special cases and we'll deal with them.
363
+ },
364
+ eventPhase: null,
365
+ bubbles: null,
366
+ cancelable: null,
367
+ timeStamp: function (event) {
368
+ return event.timeStamp || Date.now();
369
+ },
370
+ defaultPrevented: null,
371
+ isTrusted: null
372
+ };
305
373
 
374
+ function functionThatReturnsTrue() {
375
+ return true;
376
+ }
306
377
 
307
- var a = fiber;
308
- var b = alternate;
378
+ function functionThatReturnsFalse() {
379
+ return false;
380
+ }
381
+ /**
382
+ * Synthetic events are dispatched by event plugins, typically in response to a
383
+ * top-level event delegation handler.
384
+ *
385
+ * These systems should generally use pooling to reduce the frequency of garbage
386
+ * collection. The system should check `isPersistent` to determine whether the
387
+ * event should be released into the pool after being dispatched. Users that
388
+ * need a persisted event should invoke `persist`.
389
+ *
390
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
391
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
392
+ * DOM interface; custom application-specific events can also subclass this.
393
+ *
394
+ * @param {object} dispatchConfig Configuration used to dispatch this event.
395
+ * @param {*} targetInst Marker identifying the event target.
396
+ * @param {object} nativeEvent Native browser event.
397
+ * @param {DOMEventTarget} nativeEventTarget Target node.
398
+ */
309
399
 
310
- while (true) {
311
- var parentA = a.return;
312
400
 
313
- if (parentA === null) {
314
- // We're at the root.
315
- break;
401
+ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
402
+ {
403
+ // these have a getter/setter for warnings
404
+ delete this.nativeEvent;
405
+ delete this.preventDefault;
406
+ delete this.stopPropagation;
407
+ delete this.isDefaultPrevented;
408
+ delete this.isPropagationStopped;
316
409
  }
317
410
 
318
- var parentB = parentA.alternate;
319
-
320
- if (parentB === null) {
321
- // There is no alternate. This is an unusual case. Currently, it only
322
- // happens when a Suspense component is hidden. An extra fragment fiber
323
- // is inserted in between the Suspense fiber and its children. Skip
324
- // over this extra fragment fiber and proceed to the next parent.
325
- var nextParent = parentA.return;
411
+ this.dispatchConfig = dispatchConfig;
412
+ this._targetInst = targetInst;
413
+ this.nativeEvent = nativeEvent;
414
+ var Interface = this.constructor.Interface;
326
415
 
327
- if (nextParent !== null) {
328
- a = b = nextParent;
416
+ for (var propName in Interface) {
417
+ if (!Interface.hasOwnProperty(propName)) {
329
418
  continue;
330
- } // If there's no parent, we're at the root.
419
+ }
331
420
 
421
+ {
422
+ delete this[propName]; // this has a getter/setter for warnings
423
+ }
332
424
 
333
- break;
334
- } // If both copies of the parent fiber point to the same child, we can
335
- // assume that the child is current. This happens when we bailout on low
336
- // priority: the bailed out fiber's child reuses the current child.
425
+ var normalize = Interface[propName];
337
426
 
427
+ if (normalize) {
428
+ this[propName] = normalize(nativeEvent);
429
+ } else {
430
+ if (propName === 'target') {
431
+ this.target = nativeEventTarget;
432
+ } else {
433
+ this[propName] = nativeEvent[propName];
434
+ }
435
+ }
436
+ }
338
437
 
339
- if (parentA.child === parentB.child) {
340
- var child = parentA.child;
438
+ var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
341
439
 
342
- while (child) {
343
- if (child === a) {
344
- // We've determined that A is the current branch.
345
- assertIsMounted(parentA);
346
- return fiber;
347
- }
440
+ if (defaultPrevented) {
441
+ this.isDefaultPrevented = functionThatReturnsTrue;
442
+ } else {
443
+ this.isDefaultPrevented = functionThatReturnsFalse;
444
+ }
348
445
 
349
- if (child === b) {
350
- // We've determined that B is the current branch.
351
- assertIsMounted(parentA);
352
- return alternate;
353
- }
446
+ this.isPropagationStopped = functionThatReturnsFalse;
447
+ return this;
448
+ }
354
449
 
355
- child = child.sibling;
356
- } // We should never have an alternate for any mounting node. So the only
357
- // way this could possibly happen is if this was unmounted, if at all.
450
+ _assign(SyntheticEvent.prototype, {
451
+ preventDefault: function () {
452
+ this.defaultPrevented = true;
453
+ var event = this.nativeEvent;
358
454
 
455
+ if (!event) {
456
+ return;
457
+ }
359
458
 
360
- {
361
- {
362
- throw Error("Unable to find node on an unmounted component.");
363
- }
459
+ if (event.preventDefault) {
460
+ event.preventDefault();
461
+ } else if (typeof event.returnValue !== 'unknown') {
462
+ event.returnValue = false;
364
463
  }
365
- }
366
464
 
367
- if (a.return !== b.return) {
368
- // The return pointer of A and the return pointer of B point to different
369
- // fibers. We assume that return pointers never criss-cross, so A must
370
- // belong to the child set of A.return, and B must belong to the child
371
- // set of B.return.
372
- a = parentA;
373
- b = parentB;
374
- } else {
375
- // The return pointers point to the same fiber. We'll have to use the
376
- // default, slow path: scan the child sets of each parent alternate to see
377
- // which child belongs to which set.
378
- //
379
- // Search parent A's child set
380
- var didFindChild = false;
381
- var _child = parentA.child;
382
-
383
- while (_child) {
384
- if (_child === a) {
385
- didFindChild = true;
386
- a = parentA;
387
- b = parentB;
388
- break;
389
- }
465
+ this.isDefaultPrevented = functionThatReturnsTrue;
466
+ },
467
+ stopPropagation: function () {
468
+ var event = this.nativeEvent;
390
469
 
391
- if (_child === b) {
392
- didFindChild = true;
393
- b = parentA;
394
- a = parentB;
395
- break;
396
- }
470
+ if (!event) {
471
+ return;
472
+ }
397
473
 
398
- _child = _child.sibling;
474
+ if (event.stopPropagation) {
475
+ event.stopPropagation();
476
+ } else if (typeof event.cancelBubble !== 'unknown') {
477
+ // The ChangeEventPlugin registers a "propertychange" event for
478
+ // IE. This event does not support bubbling or cancelling, and
479
+ // any references to cancelBubble throw "Member not found". A
480
+ // typeof check of "unknown" circumvents this issue (and is also
481
+ // IE specific).
482
+ event.cancelBubble = true;
399
483
  }
400
484
 
401
- if (!didFindChild) {
402
- // Search parent B's child set
403
- _child = parentB.child;
485
+ this.isPropagationStopped = functionThatReturnsTrue;
486
+ },
404
487
 
405
- while (_child) {
406
- if (_child === a) {
407
- didFindChild = true;
408
- a = parentB;
409
- b = parentA;
410
- break;
411
- }
488
+ /**
489
+ * We release all dispatched `SyntheticEvent`s after each event loop, adding
490
+ * them back into the pool. This allows a way to hold onto a reference that
491
+ * won't be added back into the pool.
492
+ */
493
+ persist: function () {
494
+ this.isPersistent = functionThatReturnsTrue;
495
+ },
412
496
 
413
- if (_child === b) {
414
- didFindChild = true;
415
- b = parentB;
416
- a = parentA;
417
- break;
418
- }
497
+ /**
498
+ * Checks if this event should be released back into the pool.
499
+ *
500
+ * @return {boolean} True if this should not be released, false otherwise.
501
+ */
502
+ isPersistent: functionThatReturnsFalse,
419
503
 
420
- _child = _child.sibling;
421
- }
504
+ /**
505
+ * `PooledClass` looks for `destructor` on each instance it releases.
506
+ */
507
+ destructor: function () {
508
+ var Interface = this.constructor.Interface;
422
509
 
423
- if (!didFindChild) {
424
- {
425
- throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
426
- }
510
+ for (var propName in Interface) {
511
+ {
512
+ Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
427
513
  }
428
514
  }
429
- }
430
515
 
431
- if (!(a.alternate === b)) {
516
+ this.dispatchConfig = null;
517
+ this._targetInst = null;
518
+ this.nativeEvent = null;
519
+ this.isDefaultPrevented = functionThatReturnsFalse;
520
+ this.isPropagationStopped = functionThatReturnsFalse;
521
+ this._dispatchListeners = null;
522
+ this._dispatchInstances = null;
523
+
432
524
  {
433
- throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
525
+ Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
526
+ Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
527
+ Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
528
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
529
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
434
530
  }
435
531
  }
436
- } // If the root is not a host container, we're in a disconnected tree. I.e.
437
- // unmounted.
532
+ });
438
533
 
534
+ SyntheticEvent.Interface = EventInterface;
535
+ /**
536
+ * Helper to reduce boilerplate when creating subclasses.
537
+ */
439
538
 
440
- if (!(a.tag === HostRoot)) {
441
- {
442
- throw Error("Unable to find node on an unmounted component.");
443
- }
444
- }
445
-
446
- if (a.stateNode.current === a) {
447
- // We've determined that A is the current branch.
448
- return fiber;
449
- } // Otherwise B has to be current branch.
539
+ SyntheticEvent.extend = function (Interface) {
540
+ var Super = this;
450
541
 
542
+ var E = function () {};
451
543
 
452
- return alternate;
453
- }
544
+ E.prototype = Super.prototype;
545
+ var prototype = new E();
454
546
 
455
- /* eslint valid-typeof: 0 */
456
- var EVENT_POOL_SIZE = 10;
457
- /**
458
- * @interface Event
459
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
460
- */
547
+ function Class() {
548
+ return Super.apply(this, arguments);
549
+ }
461
550
 
462
- var EventInterface = {
463
- type: null,
464
- target: null,
465
- // currentTarget is set when dispatching; no use in copying it here
466
- currentTarget: function () {
467
- return null;
468
- },
469
- eventPhase: null,
470
- bubbles: null,
471
- cancelable: null,
472
- timeStamp: function (event) {
473
- return event.timeStamp || Date.now();
474
- },
475
- defaultPrevented: null,
476
- isTrusted: null
477
- };
478
-
479
- function functionThatReturnsTrue() {
480
- return true;
481
- }
482
-
483
- function functionThatReturnsFalse() {
484
- return false;
485
- }
486
- /**
487
- * Synthetic events are dispatched by event plugins, typically in response to a
488
- * top-level event delegation handler.
489
- *
490
- * These systems should generally use pooling to reduce the frequency of garbage
491
- * collection. The system should check `isPersistent` to determine whether the
492
- * event should be released into the pool after being dispatched. Users that
493
- * need a persisted event should invoke `persist`.
494
- *
495
- * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
496
- * normalizing browser quirks. Subclasses do not necessarily have to implement a
497
- * DOM interface; custom application-specific events can also subclass this.
498
- *
499
- * @param {object} dispatchConfig Configuration used to dispatch this event.
500
- * @param {*} targetInst Marker identifying the event target.
501
- * @param {object} nativeEvent Native browser event.
502
- * @param {DOMEventTarget} nativeEventTarget Target node.
503
- */
551
+ _assign(prototype, Class.prototype);
504
552
 
553
+ Class.prototype = prototype;
554
+ Class.prototype.constructor = Class;
555
+ Class.Interface = _assign({}, Super.Interface, Interface);
556
+ Class.extend = Super.extend;
557
+ addEventPoolingTo(Class);
558
+ return Class;
559
+ };
505
560
 
506
- function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
507
- {
508
- // these have a getter/setter for warnings
509
- delete this.nativeEvent;
510
- delete this.preventDefault;
511
- delete this.stopPropagation;
512
- delete this.isDefaultPrevented;
513
- delete this.isPropagationStopped;
514
- }
561
+ addEventPoolingTo(SyntheticEvent);
562
+ /**
563
+ * Helper to nullify syntheticEvent instance properties when destructing
564
+ *
565
+ * @param {String} propName
566
+ * @param {?object} getVal
567
+ * @return {object} defineProperty object
568
+ */
515
569
 
516
- this.dispatchConfig = dispatchConfig;
517
- this._targetInst = targetInst;
518
- this.nativeEvent = nativeEvent;
519
- var Interface = this.constructor.Interface;
570
+ function getPooledWarningPropertyDefinition(propName, getVal) {
571
+ var isFunction = typeof getVal === 'function';
572
+ return {
573
+ configurable: true,
574
+ set: set,
575
+ get: get
576
+ };
520
577
 
521
- for (var propName in Interface) {
522
- if (!Interface.hasOwnProperty(propName)) {
523
- continue;
578
+ function set(val) {
579
+ var action = isFunction ? 'setting the method' : 'setting the property';
580
+ warn(action, 'This is effectively a no-op');
581
+ return val;
524
582
  }
525
583
 
526
- {
527
- delete this[propName]; // this has a getter/setter for warnings
584
+ function get() {
585
+ var action = isFunction ? 'accessing the method' : 'accessing the property';
586
+ var result = isFunction ? 'This is a no-op function' : 'This is set to null';
587
+ warn(action, result);
588
+ return getVal;
528
589
  }
529
590
 
530
- var normalize = Interface[propName];
531
-
532
- if (normalize) {
533
- this[propName] = normalize(nativeEvent);
534
- } else {
535
- if (propName === 'target') {
536
- this.target = nativeEventTarget;
537
- } else {
538
- this[propName] = nativeEvent[propName];
591
+ function warn(action, result) {
592
+ {
593
+ error("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);
539
594
  }
540
595
  }
541
596
  }
542
597
 
543
- var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
544
-
545
- if (defaultPrevented) {
546
- this.isDefaultPrevented = functionThatReturnsTrue;
547
- } else {
548
- this.isDefaultPrevented = functionThatReturnsFalse;
549
- }
550
-
551
- this.isPropagationStopped = functionThatReturnsFalse;
552
- return this;
553
- }
598
+ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
599
+ var EventConstructor = this;
554
600
 
555
- _assign(SyntheticEvent.prototype, {
556
- preventDefault: function () {
557
- this.defaultPrevented = true;
558
- var event = this.nativeEvent;
559
-
560
- if (!event) {
561
- return;
601
+ if (EventConstructor.eventPool.length) {
602
+ var instance = EventConstructor.eventPool.pop();
603
+ EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
604
+ return instance;
562
605
  }
563
606
 
564
- if (event.preventDefault) {
565
- event.preventDefault();
566
- } else if (typeof event.returnValue !== 'unknown') {
567
- event.returnValue = false;
568
- }
607
+ return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
608
+ }
569
609
 
570
- this.isDefaultPrevented = functionThatReturnsTrue;
571
- },
572
- stopPropagation: function () {
573
- var event = this.nativeEvent;
610
+ function releasePooledEvent(event) {
611
+ var EventConstructor = this;
574
612
 
575
- if (!event) {
576
- return;
613
+ if (!(event instanceof EventConstructor)) {
614
+ {
615
+ throw Error( "Trying to release an event instance into a pool of a different type." );
616
+ }
577
617
  }
578
618
 
579
- if (event.stopPropagation) {
580
- event.stopPropagation();
581
- } else if (typeof event.cancelBubble !== 'unknown') {
582
- // The ChangeEventPlugin registers a "propertychange" event for
583
- // IE. This event does not support bubbling or cancelling, and
584
- // any references to cancelBubble throw "Member not found". A
585
- // typeof check of "unknown" circumvents this issue (and is also
586
- // IE specific).
587
- event.cancelBubble = true;
619
+ event.destructor();
620
+
621
+ if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
622
+ EventConstructor.eventPool.push(event);
588
623
  }
624
+ }
589
625
 
590
- this.isPropagationStopped = functionThatReturnsTrue;
591
- },
626
+ function addEventPoolingTo(EventConstructor) {
627
+ EventConstructor.eventPool = [];
628
+ EventConstructor.getPooled = getPooledEvent;
629
+ EventConstructor.release = releasePooledEvent;
630
+ }
592
631
 
593
632
  /**
594
- * We release all dispatched `SyntheticEvent`s after each event loop, adding
595
- * them back into the pool. This allows a way to hold onto a reference that
596
- * won't be added back into the pool.
633
+ * HTML nodeType values that represent the type of the node
597
634
  */
598
- persist: function () {
599
- this.isPersistent = functionThatReturnsTrue;
600
- },
635
+ var ELEMENT_NODE = 1;
636
+
637
+ // Do not use the below two methods directly!
638
+ // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
639
+ // (It is the only module that is allowed to access these methods.)
640
+ function unsafeCastStringToDOMTopLevelType(topLevelType) {
641
+ return topLevelType;
642
+ }
643
+
644
+ var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
601
645
 
602
646
  /**
603
- * Checks if this event should be released back into the pool.
647
+ * Generate a mapping of standard vendor prefixes using the defined style property and event name.
604
648
  *
605
- * @return {boolean} True if this should not be released, false otherwise.
649
+ * @param {string} styleProp
650
+ * @param {string} eventName
651
+ * @returns {object}
606
652
  */
607
- isPersistent: functionThatReturnsFalse,
608
653
 
654
+ function makePrefixMap(styleProp, eventName) {
655
+ var prefixes = {};
656
+ prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
657
+ prefixes['Webkit' + styleProp] = 'webkit' + eventName;
658
+ prefixes['Moz' + styleProp] = 'moz' + eventName;
659
+ return prefixes;
660
+ }
609
661
  /**
610
- * `PooledClass` looks for `destructor` on each instance it releases.
662
+ * A list of event names to a configurable list of vendor prefixes.
611
663
  */
612
- destructor: function () {
613
- var Interface = this.constructor.Interface;
614
664
 
615
- for (var propName in Interface) {
616
- {
617
- Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
618
- }
619
- }
620
665
 
621
- this.dispatchConfig = null;
622
- this._targetInst = null;
623
- this.nativeEvent = null;
624
- this.isDefaultPrevented = functionThatReturnsFalse;
625
- this.isPropagationStopped = functionThatReturnsFalse;
626
- this._dispatchListeners = null;
627
- this._dispatchInstances = null;
666
+ var vendorPrefixes = {
667
+ animationend: makePrefixMap('Animation', 'AnimationEnd'),
668
+ animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
669
+ animationstart: makePrefixMap('Animation', 'AnimationStart'),
670
+ transitionend: makePrefixMap('Transition', 'TransitionEnd')
671
+ };
672
+ /**
673
+ * Event names that have already been detected and prefixed (if applicable).
674
+ */
628
675
 
629
- {
630
- Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
631
- Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
632
- Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
633
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
634
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
635
- }
636
- }
637
- });
676
+ var prefixedEventNames = {};
677
+ /**
678
+ * Element to check for prefixes on.
679
+ */
638
680
 
639
- SyntheticEvent.Interface = EventInterface;
640
- /**
641
- * Helper to reduce boilerplate when creating subclasses.
642
- */
681
+ var style = {};
682
+ /**
683
+ * Bootstrap if a DOM exists.
684
+ */
643
685
 
644
- SyntheticEvent.extend = function (Interface) {
645
- var Super = this;
686
+ if (canUseDOM) {
687
+ style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
688
+ // the un-prefixed "animation" and "transition" properties are defined on the
689
+ // style object but the events that fire will still be prefixed, so we need
690
+ // to check if the un-prefixed events are usable, and if not remove them from the map.
646
691
 
647
- var E = function () {};
692
+ if (!('AnimationEvent' in window)) {
693
+ delete vendorPrefixes.animationend.animation;
694
+ delete vendorPrefixes.animationiteration.animation;
695
+ delete vendorPrefixes.animationstart.animation;
696
+ } // Same as above
648
697
 
649
- E.prototype = Super.prototype;
650
- var prototype = new E();
651
698
 
652
- function Class() {
653
- return Super.apply(this, arguments);
699
+ if (!('TransitionEvent' in window)) {
700
+ delete vendorPrefixes.transitionend.transition;
701
+ }
654
702
  }
703
+ /**
704
+ * Attempts to determine the correct vendor prefixed event name.
705
+ *
706
+ * @param {string} eventName
707
+ * @returns {string}
708
+ */
655
709
 
656
- _assign(prototype, Class.prototype);
657
710
 
658
- Class.prototype = prototype;
659
- Class.prototype.constructor = Class;
660
- Class.Interface = _assign({}, Super.Interface, Interface);
661
- Class.extend = Super.extend;
662
- addEventPoolingTo(Class);
663
- return Class;
664
- };
711
+ function getVendorPrefixedEventName(eventName) {
712
+ if (prefixedEventNames[eventName]) {
713
+ return prefixedEventNames[eventName];
714
+ } else if (!vendorPrefixes[eventName]) {
715
+ return eventName;
716
+ }
665
717
 
666
- addEventPoolingTo(SyntheticEvent);
667
- /**
668
- * Helper to nullify syntheticEvent instance properties when destructing
669
- *
670
- * @param {String} propName
671
- * @param {?object} getVal
672
- * @return {object} defineProperty object
673
- */
718
+ var prefixMap = vendorPrefixes[eventName];
674
719
 
675
- function getPooledWarningPropertyDefinition(propName, getVal) {
676
- var isFunction = typeof getVal === 'function';
677
- return {
678
- configurable: true,
679
- set: set,
680
- get: get
681
- };
720
+ for (var styleProp in prefixMap) {
721
+ if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
722
+ return prefixedEventNames[eventName] = prefixMap[styleProp];
723
+ }
724
+ }
682
725
 
683
- function set(val) {
684
- var action = isFunction ? 'setting the method' : 'setting the property';
685
- warn(action, 'This is effectively a no-op');
686
- return val;
726
+ return eventName;
687
727
  }
688
728
 
689
- function get() {
690
- var action = isFunction ? 'accessing the method' : 'accessing the property';
691
- var result = isFunction ? 'This is a no-op function' : 'This is set to null';
692
- warn(action, result);
693
- return getVal;
694
- }
695
-
696
- function warn(action, result) {
697
- var warningCondition = false;
698
- !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;
699
- }
700
- }
701
-
702
- function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
703
- var EventConstructor = this;
704
-
705
- if (EventConstructor.eventPool.length) {
706
- var instance = EventConstructor.eventPool.pop();
707
- EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
708
- return instance;
709
- }
729
+ /**
730
+ * To identify top level events in ReactDOM, we use constants defined by this
731
+ * module. This is the only module that uses the unsafe* methods to express
732
+ * that the constants actually correspond to the browser event names. This lets
733
+ * us save some bundle size by avoiding a top level type -> event name map.
734
+ * The rest of ReactDOM code should import top level types from this file.
735
+ */
710
736
 
711
- return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
712
- }
737
+ var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
738
+ var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
739
+ var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
740
+ var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
741
+ var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
742
+ var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
743
+ var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
744
+ var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
745
+ var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
746
+ var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
747
+ var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
748
+ var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
749
+ var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
750
+ var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
751
+ var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
752
+ var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
753
+ var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
754
+ var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
755
+ var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
756
+ var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
757
+ var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
758
+ var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
759
+ var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
760
+ var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
761
+ var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
762
+ var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
763
+ var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
764
+ var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
765
+ var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
766
+ var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
767
+ var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
768
+ var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
769
+ var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
770
+ var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
771
+ var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
772
+ var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
773
+ var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
774
+ var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
775
+ var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
776
+ var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
777
+ var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
778
+ var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
779
+ var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
780
+ var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
781
+ var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
782
+ var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
783
+ var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
784
+ var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
785
+ var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
786
+ var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
787
+ var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
788
+ var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
789
+ var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
790
+ var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
791
+ var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
792
+ var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
793
+ var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
794
+ var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
795
+ var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
796
+ var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
797
+ var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
798
+ var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
799
+ var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
800
+ var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
801
+ var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
802
+ var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
803
+ var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
804
+ var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements.
805
+
806
+ var PLUGIN_EVENT_SYSTEM = 1;
807
+
808
+ var didWarnAboutMessageChannel = false;
809
+ var enqueueTaskImpl = null;
810
+ function enqueueTask(task) {
811
+ if (enqueueTaskImpl === null) {
812
+ try {
813
+ // read require off the module object to get around the bundlers.
814
+ // we don't want them to detect a require and bundle a Node polyfill.
815
+ var requireString = ('require' + Math.random()).slice(0, 7);
816
+ var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
817
+ // version of setImmediate, bypassing fake timers if any.
818
+
819
+ enqueueTaskImpl = nodeRequire('timers').setImmediate;
820
+ } catch (_err) {
821
+ // we're in a browser
822
+ // we can't use regular timers because they may still be faked
823
+ // so we try MessageChannel+postMessage instead
824
+ enqueueTaskImpl = function (callback) {
825
+ {
826
+ if (didWarnAboutMessageChannel === false) {
827
+ didWarnAboutMessageChannel = true;
713
828
 
714
- function releasePooledEvent(event) {
715
- var EventConstructor = this;
829
+ if (typeof MessageChannel === 'undefined') {
830
+ error('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.');
831
+ }
832
+ }
833
+ }
716
834
 
717
- if (!(event instanceof EventConstructor)) {
718
- {
719
- throw Error("Trying to release an event instance into a pool of a different type.");
835
+ var channel = new MessageChannel();
836
+ channel.port1.onmessage = callback;
837
+ channel.port2.postMessage(undefined);
838
+ };
839
+ }
720
840
  }
721
- }
722
-
723
- event.destructor();
724
841
 
725
- if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
726
- EventConstructor.eventPool.push(event);
842
+ return enqueueTaskImpl(task);
727
843
  }
728
- }
729
844
 
730
- function addEventPoolingTo(EventConstructor) {
731
- EventConstructor.eventPool = [];
732
- EventConstructor.getPooled = getPooledEvent;
733
- EventConstructor.release = releasePooledEvent;
734
- }
845
+ var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
846
+ var _ReactInternals$Sched = ReactInternals$1.Scheduler,
847
+ unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback,
848
+ unstable_now = _ReactInternals$Sched.unstable_now,
849
+ unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback,
850
+ unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield,
851
+ unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint,
852
+ unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode,
853
+ unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority,
854
+ unstable_next = _ReactInternals$Sched.unstable_next,
855
+ unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution,
856
+ unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution,
857
+ unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel,
858
+ unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority,
859
+ unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority,
860
+ unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority,
861
+ unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority,
862
+ unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority,
863
+ unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate,
864
+ unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting;
865
+
866
+ // ReactDOM.js, and ReactTestUtils.js:
867
+
868
+ var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events,
869
+
870
+ /* eslint-disable no-unused-vars */
871
+ getInstanceFromNode = _ReactDOM$__SECRET_IN[0],
872
+ getNodeFromInstance = _ReactDOM$__SECRET_IN[1],
873
+ getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2],
874
+ injectEventPluginsByName = _ReactDOM$__SECRET_IN[3],
875
+ eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4],
876
+ accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5],
877
+ accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6],
878
+ enqueueStateRestore = _ReactDOM$__SECRET_IN[7],
879
+ restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8],
880
+ dispatchEvent = _ReactDOM$__SECRET_IN[9],
881
+ runEventsInBatch = _ReactDOM$__SECRET_IN[10],
882
+
883
+ /* eslint-enable no-unused-vars */
884
+ flushPassiveEffects = _ReactDOM$__SECRET_IN[11],
885
+ IsThisRendererActing = _ReactDOM$__SECRET_IN[12];
886
+ var batchedUpdates = ReactDOM.unstable_batchedUpdates;
887
+ var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
888
+ // ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js
889
+
890
+ var isSchedulerMocked = typeof unstable_flushAllWithoutAsserting === 'function';
891
+
892
+ var flushWork = unstable_flushAllWithoutAsserting || function () {
893
+ var didFlushWork = false;
894
+
895
+ while (flushPassiveEffects()) {
896
+ didFlushWork = true;
897
+ }
735
898
 
736
- /**
737
- * Forked from fbjs/warning:
738
- * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
739
- *
740
- * Only change is we use console.warn instead of console.error,
741
- * and do nothing when 'console' is not supported.
742
- * This really simplifies the code.
743
- * ---
744
- * Similar to invariant but only logs a warning if the condition is not met.
745
- * This can be used to log issues in development environments in critical
746
- * paths. Removing the logging code for production environments will keep the
747
- * same logic and follow the same code paths.
748
- */
749
- var lowPriorityWarningWithoutStack = function () {};
899
+ return didFlushWork;
900
+ };
750
901
 
751
- {
752
- var printWarning = function (format) {
753
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
754
- args[_key - 1] = arguments[_key];
902
+ function flushWorkAndMicroTasks(onDone) {
903
+ try {
904
+ flushWork();
905
+ enqueueTask(function () {
906
+ if (flushWork()) {
907
+ flushWorkAndMicroTasks(onDone);
908
+ } else {
909
+ onDone();
910
+ }
911
+ });
912
+ } catch (err) {
913
+ onDone(err);
755
914
  }
915
+ } // we track the 'depth' of the act() calls with this counter,
916
+ // so we can tell if any async act() calls try to run in parallel.
756
917
 
757
- var argIndex = 0;
758
- var message = 'Warning: ' + format.replace(/%s/g, function () {
759
- return args[argIndex++];
760
- });
761
918
 
762
- if (typeof console !== 'undefined') {
763
- console.warn(message);
764
- }
919
+ var actingUpdatesScopeDepth = 0;
765
920
 
766
- try {
767
- // --- Welcome to debugging React ---
768
- // This error was thrown as a convenience so that you can use this stack
769
- // to find the callsite that caused this warning to fire.
770
- throw new Error(message);
771
- } catch (x) {}
772
- };
921
+ function act(callback) {
773
922
 
774
- lowPriorityWarningWithoutStack = function (condition, format) {
775
- if (format === undefined) {
776
- throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
777
- }
923
+ var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
924
+ var previousIsSomeRendererActing;
925
+ var previousIsThisRendererActing;
926
+ actingUpdatesScopeDepth++;
927
+ previousIsSomeRendererActing = IsSomeRendererActing.current;
928
+ previousIsThisRendererActing = IsThisRendererActing.current;
929
+ IsSomeRendererActing.current = true;
930
+ IsThisRendererActing.current = true;
778
931
 
779
- if (!condition) {
780
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
781
- args[_key2 - 2] = arguments[_key2];
782
- }
932
+ function onDone() {
933
+ actingUpdatesScopeDepth--;
934
+ IsSomeRendererActing.current = previousIsSomeRendererActing;
935
+ IsThisRendererActing.current = previousIsThisRendererActing;
783
936
 
784
- printWarning.apply(void 0, [format].concat(args));
937
+ {
938
+ if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
939
+ // if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
940
+ error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
941
+ }
942
+ }
785
943
  }
786
- };
787
- }
788
944
 
789
- var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
945
+ var result;
790
946
 
791
- /**
792
- * HTML nodeType values that represent the type of the node
793
- */
794
- var ELEMENT_NODE = 1;
795
-
796
- // Do not use the below two methods directly!
797
- // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
798
- // (It is the only module that is allowed to access these methods.)
799
- function unsafeCastStringToDOMTopLevelType(topLevelType) {
800
- return topLevelType;
801
- }
947
+ try {
948
+ result = batchedUpdates(callback);
949
+ } catch (error) {
950
+ // on sync errors, we still want to 'cleanup' and decrement actingUpdatesScopeDepth
951
+ onDone();
952
+ throw error;
953
+ }
802
954
 
803
- var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
955
+ if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
956
+ // setup a boolean that gets set to true only
957
+ // once this act() call is await-ed
958
+ var called = false;
804
959
 
805
- /**
806
- * Generate a mapping of standard vendor prefixes using the defined style property and event name.
807
- *
808
- * @param {string} styleProp
809
- * @param {string} eventName
810
- * @returns {object}
811
- */
960
+ {
961
+ if (typeof Promise !== 'undefined') {
962
+ //eslint-disable-next-line no-undef
963
+ Promise.resolve().then(function () {}).then(function () {
964
+ if (called === false) {
965
+ error('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 () => ...);');
966
+ }
967
+ });
968
+ }
969
+ } // in the async case, the returned thenable runs the callback, flushes
970
+ // effects and microtasks in a loop until flushPassiveEffects() === false,
971
+ // and cleans up
812
972
 
813
- function makePrefixMap(styleProp, eventName) {
814
- var prefixes = {};
815
- prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
816
- prefixes['Webkit' + styleProp] = 'webkit' + eventName;
817
- prefixes['Moz' + styleProp] = 'moz' + eventName;
818
- return prefixes;
819
- }
820
- /**
821
- * A list of event names to a configurable list of vendor prefixes.
822
- */
823
973
 
974
+ return {
975
+ then: function (resolve, reject) {
976
+ called = true;
977
+ result.then(function () {
978
+ if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
979
+ onDone();
980
+ resolve();
981
+ return;
982
+ } // we're about to exit the act() scope,
983
+ // now's the time to flush tasks/effects
824
984
 
825
- var vendorPrefixes = {
826
- animationend: makePrefixMap('Animation', 'AnimationEnd'),
827
- animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
828
- animationstart: makePrefixMap('Animation', 'AnimationStart'),
829
- transitionend: makePrefixMap('Transition', 'TransitionEnd')
830
- };
831
- /**
832
- * Event names that have already been detected and prefixed (if applicable).
833
- */
834
985
 
835
- var prefixedEventNames = {};
836
- /**
837
- * Element to check for prefixes on.
838
- */
986
+ flushWorkAndMicroTasks(function (err) {
987
+ onDone();
839
988
 
840
- var style = {};
841
- /**
842
- * Bootstrap if a DOM exists.
843
- */
989
+ if (err) {
990
+ reject(err);
991
+ } else {
992
+ resolve();
993
+ }
994
+ });
995
+ }, function (err) {
996
+ onDone();
997
+ reject(err);
998
+ });
999
+ }
1000
+ };
1001
+ } else {
1002
+ {
1003
+ if (result !== undefined) {
1004
+ error('The callback passed to act(...) function ' + 'must return undefined, or a Promise. You returned %s', result);
1005
+ }
1006
+ } // flush effects until none remain, and cleanup
844
1007
 
845
- if (canUseDOM) {
846
- style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
847
- // the un-prefixed "animation" and "transition" properties are defined on the
848
- // style object but the events that fire will still be prefixed, so we need
849
- // to check if the un-prefixed events are usable, and if not remove them from the map.
850
1008
 
851
- if (!('AnimationEvent' in window)) {
852
- delete vendorPrefixes.animationend.animation;
853
- delete vendorPrefixes.animationiteration.animation;
854
- delete vendorPrefixes.animationstart.animation;
855
- } // Same as above
1009
+ try {
1010
+ if (actingUpdatesScopeDepth === 1 && (isSchedulerMocked === false || previousIsSomeRendererActing === false)) {
1011
+ // we're about to exit the act() scope,
1012
+ // now's the time to flush effects
1013
+ flushWork();
1014
+ }
856
1015
 
1016
+ onDone();
1017
+ } catch (err) {
1018
+ onDone();
1019
+ throw err;
1020
+ } // in the sync case, the returned thenable only warns *if* await-ed
857
1021
 
858
- if (!('TransitionEvent' in window)) {
859
- delete vendorPrefixes.transitionend.transition;
860
- }
861
- }
862
- /**
863
- * Attempts to determine the correct vendor prefixed event name.
864
- *
865
- * @param {string} eventName
866
- * @returns {string}
867
- */
868
1022
 
1023
+ return {
1024
+ then: function (resolve) {
1025
+ {
1026
+ error('Do not await the result of calling act(...) with sync logic, it is not a Promise.');
1027
+ }
869
1028
 
870
- function getVendorPrefixedEventName(eventName) {
871
- if (prefixedEventNames[eventName]) {
872
- return prefixedEventNames[eventName];
873
- } else if (!vendorPrefixes[eventName]) {
874
- return eventName;
1029
+ resolve();
1030
+ }
1031
+ };
1032
+ }
875
1033
  }
876
1034
 
877
- var prefixMap = vendorPrefixes[eventName];
1035
+ var findDOMNode = ReactDOM.findDOMNode; // Keep in sync with ReactDOMUnstableNativeDependencies.js
1036
+ // ReactDOM.js, and ReactTestUtilsAct.js:
878
1037
 
879
- for (var styleProp in prefixMap) {
880
- if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
881
- return prefixedEventNames[eventName] = prefixMap[styleProp];
882
- }
883
- }
1038
+ var _ReactDOM$__SECRET_IN$1 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events,
1039
+ getInstanceFromNode$1 = _ReactDOM$__SECRET_IN$1[0],
884
1040
 
885
- return eventName;
886
- }
1041
+ /* eslint-disable no-unused-vars */
1042
+ getNodeFromInstance$1 = _ReactDOM$__SECRET_IN$1[1],
1043
+ getFiberCurrentPropsFromNode$1 = _ReactDOM$__SECRET_IN$1[2],
1044
+ injectEventPluginsByName$1 = _ReactDOM$__SECRET_IN$1[3],
887
1045
 
888
- /**
889
- * To identify top level events in ReactDOM, we use constants defined by this
890
- * module. This is the only module that uses the unsafe* methods to express
891
- * that the constants actually correspond to the browser event names. This lets
892
- * us save some bundle size by avoiding a top level type -> event name map.
893
- * The rest of ReactDOM code should import top level types from this file.
894
- */
1046
+ /* eslint-enable no-unused-vars */
1047
+ eventNameDispatchConfigs$1 = _ReactDOM$__SECRET_IN$1[4],
1048
+ accumulateTwoPhaseDispatches$1 = _ReactDOM$__SECRET_IN$1[5],
1049
+ accumulateDirectDispatches$1 = _ReactDOM$__SECRET_IN$1[6],
1050
+ enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[7],
1051
+ restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[8],
1052
+ dispatchEvent$1 = _ReactDOM$__SECRET_IN$1[9],
1053
+ runEventsInBatch$1 = _ReactDOM$__SECRET_IN$1[10],
895
1054
 
896
- var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
897
- var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
898
- var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
899
- var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
900
- var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
901
- var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
902
- var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
903
- var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
904
- var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
905
- var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
906
- var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
907
- var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
908
- var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
909
- var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
910
- var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
911
- var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
912
- var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
913
- var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
914
-
915
- var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
916
- var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
917
- var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
918
- var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
919
- var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
920
- var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
921
- var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
922
- var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
923
- var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
924
- var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
925
- var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
926
- var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
927
- var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
928
- var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
929
-
930
- var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
931
-
932
- var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
933
- var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
934
- var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
935
- var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
936
- var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
937
- var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
938
- var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
939
-
940
- var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
941
- var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
942
- var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
943
- var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
944
- var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
945
- var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
946
- var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
947
- var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
948
- var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
949
-
950
-
951
-
952
-
953
-
954
-
955
-
956
-
957
- var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
958
- var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
959
-
960
- var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
961
- var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
962
- var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
963
- var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
964
- var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
965
-
966
- var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
967
- var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
968
- var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
969
- var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
970
- var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
971
- var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
972
- var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
973
- var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
974
- var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
975
- var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
976
- var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
977
- var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements.
978
- // Note that events in this list will *not* be listened to at the top level
979
- // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
980
-
981
- var PLUGIN_EVENT_SYSTEM = 1;
982
-
983
- var didWarnAboutMessageChannel = false;
984
- var enqueueTask;
985
-
986
- try {
987
- // read require off the module object to get around the bundlers.
988
- // we don't want them to detect a require and bundle a Node polyfill.
989
- var requireString = ('require' + Math.random()).slice(0, 7);
990
- var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
991
- // version of setImmediate, bypassing fake timers if any.
992
-
993
- enqueueTask = nodeRequire('timers').setImmediate;
994
- } catch (_err) {
995
- // we're in a browser
996
- // we can't use regular timers because they may still be faked
997
- // so we try MessageChannel+postMessage instead
998
- enqueueTask = function (callback) {
999
- {
1000
- if (didWarnAboutMessageChannel === false) {
1001
- didWarnAboutMessageChannel = true;
1002
- !(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;
1003
- }
1004
- }
1055
+ /* eslint-disable no-unused-vars */
1056
+ flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[11],
1057
+ IsThisRendererActing$1
1058
+ /* eslint-enable no-unused-vars */
1059
+ = _ReactDOM$__SECRET_IN$1[12];
1005
1060
 
1006
- var channel = new MessageChannel();
1007
- channel.port1.onmessage = callback;
1008
- channel.port2.postMessage(undefined);
1009
- };
1010
- }
1011
-
1012
- var enqueueTask$1 = enqueueTask;
1013
-
1014
- var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1015
- var _ReactInternals$Sched = ReactInternals$1.Scheduler;
1016
- var unstable_cancelCallback = _ReactInternals$Sched.unstable_cancelCallback;
1017
- var unstable_now = _ReactInternals$Sched.unstable_now;
1018
- var unstable_scheduleCallback = _ReactInternals$Sched.unstable_scheduleCallback;
1019
- var unstable_shouldYield = _ReactInternals$Sched.unstable_shouldYield;
1020
- var unstable_requestPaint = _ReactInternals$Sched.unstable_requestPaint;
1021
- var unstable_getFirstCallbackNode = _ReactInternals$Sched.unstable_getFirstCallbackNode;
1022
- var unstable_runWithPriority = _ReactInternals$Sched.unstable_runWithPriority;
1023
- var unstable_next = _ReactInternals$Sched.unstable_next;
1024
- var unstable_continueExecution = _ReactInternals$Sched.unstable_continueExecution;
1025
- var unstable_pauseExecution = _ReactInternals$Sched.unstable_pauseExecution;
1026
- var unstable_getCurrentPriorityLevel = _ReactInternals$Sched.unstable_getCurrentPriorityLevel;
1027
- var unstable_ImmediatePriority = _ReactInternals$Sched.unstable_ImmediatePriority;
1028
- var unstable_UserBlockingPriority = _ReactInternals$Sched.unstable_UserBlockingPriority;
1029
- var unstable_NormalPriority = _ReactInternals$Sched.unstable_NormalPriority;
1030
- var unstable_LowPriority = _ReactInternals$Sched.unstable_LowPriority;
1031
- var unstable_IdlePriority = _ReactInternals$Sched.unstable_IdlePriority;
1032
- var unstable_forceFrameRate = _ReactInternals$Sched.unstable_forceFrameRate;
1033
- var unstable_flushAllWithoutAsserting = _ReactInternals$Sched.unstable_flushAllWithoutAsserting;
1034
-
1035
- // ReactDOM.js, and ReactTestUtils.js:
1036
-
1037
- var _ReactDOM$__SECRET_IN$1 = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
1038
- var getInstanceFromNode$1 = _ReactDOM$__SECRET_IN$1[0];
1039
- var getNodeFromInstance$1 = _ReactDOM$__SECRET_IN$1[1];
1040
- var getFiberCurrentPropsFromNode$1 = _ReactDOM$__SECRET_IN$1[2];
1041
- var injectEventPluginsByName$1 = _ReactDOM$__SECRET_IN$1[3];
1042
- var eventNameDispatchConfigs$1 = _ReactDOM$__SECRET_IN$1[4];
1043
- var accumulateTwoPhaseDispatches$1 = _ReactDOM$__SECRET_IN$1[5];
1044
- var accumulateDirectDispatches$1 = _ReactDOM$__SECRET_IN$1[6];
1045
- var enqueueStateRestore$1 = _ReactDOM$__SECRET_IN$1[7];
1046
- var restoreStateIfNeeded$1 = _ReactDOM$__SECRET_IN$1[8];
1047
- var dispatchEvent$1 = _ReactDOM$__SECRET_IN$1[9];
1048
- var runEventsInBatch$1 = _ReactDOM$__SECRET_IN$1[10];
1049
- var flushPassiveEffects$1 = _ReactDOM$__SECRET_IN$1[11];
1050
- var IsThisRendererActing$1 = _ReactDOM$__SECRET_IN$1[12];
1051
- var batchedUpdates = ReactDOM.unstable_batchedUpdates;
1052
- var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; // this implementation should be exactly the same in
1053
- // ReactTestUtilsAct.js, ReactTestRendererAct.js, createReactNoop.js
1054
-
1055
- var isSchedulerMocked = typeof unstable_flushAllWithoutAsserting === 'function';
1056
-
1057
- var flushWork = unstable_flushAllWithoutAsserting || function () {
1058
- var didFlushWork = false;
1059
-
1060
- while (flushPassiveEffects$1()) {
1061
- didFlushWork = true;
1062
- }
1061
+ function Event(suffix) {}
1063
1062
 
1064
- return didFlushWork;
1065
- };
1063
+ var hasWarnedAboutDeprecatedMockComponent = false;
1064
+ /**
1065
+ * @class ReactTestUtils
1066
+ */
1066
1067
 
1067
- function flushWorkAndMicroTasks(onDone) {
1068
- try {
1069
- flushWork();
1070
- enqueueTask$1(function () {
1071
- if (flushWork()) {
1072
- flushWorkAndMicroTasks(onDone);
1073
- } else {
1074
- onDone();
1075
- }
1076
- });
1077
- } catch (err) {
1078
- onDone(err);
1079
- }
1080
- } // we track the 'depth' of the act() calls with this counter,
1081
- // so we can tell if any async act() calls try to run in parallel.
1082
-
1083
-
1084
- var actingUpdatesScopeDepth = 0;
1085
- function act(callback) {
1086
- var previousActingUpdatesScopeDepth = actingUpdatesScopeDepth;
1087
- var previousIsSomeRendererActing;
1088
- var previousIsThisRendererActing;
1089
- actingUpdatesScopeDepth++;
1090
- previousIsSomeRendererActing = IsSomeRendererActing.current;
1091
- previousIsThisRendererActing = IsThisRendererActing$1.current;
1092
- IsSomeRendererActing.current = true;
1093
- IsThisRendererActing$1.current = true;
1094
-
1095
- function onDone() {
1096
- actingUpdatesScopeDepth--;
1097
- IsSomeRendererActing.current = previousIsSomeRendererActing;
1098
- IsThisRendererActing$1.current = previousIsThisRendererActing;
1068
+ /**
1069
+ * Simulates a top level event being dispatched from a raw event that occurred
1070
+ * on an `Element` node.
1071
+ * @param {number} topLevelType A number from `TopLevelEventTypes`
1072
+ * @param {!Element} node The dom to simulate an event occurring on.
1073
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
1074
+ */
1099
1075
 
1100
- {
1101
- if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
1102
- // if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
1103
- 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. ');
1104
- }
1105
- }
1076
+ function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
1077
+ fakeNativeEvent.target = node;
1078
+ dispatchEvent$1(topLevelType, PLUGIN_EVENT_SYSTEM, document, fakeNativeEvent);
1106
1079
  }
1080
+ /**
1081
+ * Simulates a top level event being dispatched from a raw event that occurred
1082
+ * on the `ReactDOMComponent` `comp`.
1083
+ * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
1084
+ * @param {!ReactDOMComponent} comp
1085
+ * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
1086
+ */
1107
1087
 
1108
- var result;
1109
1088
 
1110
- try {
1111
- result = batchedUpdates(callback);
1112
- } catch (error) {
1113
- // on sync errors, we still want to 'cleanup' and decrement actingUpdatesScopeDepth
1114
- onDone();
1115
- throw error;
1089
+ function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
1090
+ simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
1116
1091
  }
1117
1092
 
1118
- if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
1119
- // setup a boolean that gets set to true only
1120
- // once this act() call is await-ed
1121
- var called = false;
1122
-
1123
- {
1124
- if (typeof Promise !== 'undefined') {
1125
- //eslint-disable-next-line no-undef
1126
- Promise.resolve().then(function () {}).then(function () {
1127
- if (called === false) {
1128
- 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 () => ...);');
1129
- }
1130
- });
1131
- }
1132
- } // in the async case, the returned thenable runs the callback, flushes
1133
- // effects and microtasks in a loop until flushPassiveEffects() === false,
1134
- // and cleans up
1093
+ function findAllInRenderedFiberTreeInternal(fiber, test) {
1094
+ if (!fiber) {
1095
+ return [];
1096
+ }
1135
1097
 
1098
+ var currentParent = findCurrentFiberUsingSlowPath(fiber);
1136
1099
 
1137
- return {
1138
- then: function (resolve, reject) {
1139
- called = true;
1140
- result.then(function () {
1141
- if (actingUpdatesScopeDepth > 1 || isSchedulerMocked === true && previousIsSomeRendererActing === true) {
1142
- onDone();
1143
- resolve();
1144
- return;
1145
- } // we're about to exit the act() scope,
1146
- // now's the time to flush tasks/effects
1100
+ if (!currentParent) {
1101
+ return [];
1102
+ }
1147
1103
 
1104
+ var node = currentParent;
1105
+ var ret = [];
1148
1106
 
1149
- flushWorkAndMicroTasks(function (err) {
1150
- onDone();
1107
+ while (true) {
1108
+ if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
1109
+ var publicInst = node.stateNode;
1151
1110
 
1152
- if (err) {
1153
- reject(err);
1154
- } else {
1155
- resolve();
1156
- }
1157
- });
1158
- }, function (err) {
1159
- onDone();
1160
- reject(err);
1161
- });
1111
+ if (test(publicInst)) {
1112
+ ret.push(publicInst);
1113
+ }
1162
1114
  }
1163
- };
1164
- } else {
1165
- {
1166
- !(result === undefined) ? warningWithoutStack$1(false, 'The callback passed to act(...) function ' + 'must return undefined, or a Promise. You returned %s', result) : void 0;
1167
- } // flush effects until none remain, and cleanup
1168
-
1169
1115
 
1170
- try {
1171
- if (actingUpdatesScopeDepth === 1 && (isSchedulerMocked === false || previousIsSomeRendererActing === false)) {
1172
- // we're about to exit the act() scope,
1173
- // now's the time to flush effects
1174
- flushWork();
1116
+ if (node.child) {
1117
+ node.child.return = node;
1118
+ node = node.child;
1119
+ continue;
1175
1120
  }
1176
1121
 
1177
- onDone();
1178
- } catch (err) {
1179
- onDone();
1180
- throw err;
1181
- } // in the sync case, the returned thenable only warns *if* await-ed
1182
-
1122
+ if (node === currentParent) {
1123
+ return ret;
1124
+ }
1183
1125
 
1184
- return {
1185
- then: function (resolve) {
1186
- {
1187
- warningWithoutStack$1(false, 'Do not await the result of calling act(...) with sync logic, it is not a Promise.');
1126
+ while (!node.sibling) {
1127
+ if (!node.return || node.return === currentParent) {
1128
+ return ret;
1188
1129
  }
1189
1130
 
1190
- resolve();
1131
+ node = node.return;
1191
1132
  }
1192
- };
1193
- }
1194
- }
1195
-
1196
- var findDOMNode = ReactDOM.findDOMNode; // Keep in sync with ReactDOMUnstableNativeDependencies.js
1197
- // ReactDOM.js, and ReactTestUtilsAct.js:
1198
-
1199
- var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events;
1200
- var getInstanceFromNode = _ReactDOM$__SECRET_IN[0];
1201
- var getNodeFromInstance = _ReactDOM$__SECRET_IN[1];
1202
- var getFiberCurrentPropsFromNode = _ReactDOM$__SECRET_IN[2];
1203
- var injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
1204
- var eventNameDispatchConfigs = _ReactDOM$__SECRET_IN[4];
1205
- var accumulateTwoPhaseDispatches = _ReactDOM$__SECRET_IN[5];
1206
- var accumulateDirectDispatches = _ReactDOM$__SECRET_IN[6];
1207
- var enqueueStateRestore = _ReactDOM$__SECRET_IN[7];
1208
- var restoreStateIfNeeded = _ReactDOM$__SECRET_IN[8];
1209
- var dispatchEvent = _ReactDOM$__SECRET_IN[9];
1210
- var runEventsInBatch = _ReactDOM$__SECRET_IN[10];
1211
- var flushPassiveEffects = _ReactDOM$__SECRET_IN[11];
1212
- var IsThisRendererActing = _ReactDOM$__SECRET_IN[12];
1213
-
1214
- function Event(suffix) {}
1215
-
1216
- var hasWarnedAboutDeprecatedMockComponent = false;
1217
- /**
1218
- * @class ReactTestUtils
1219
- */
1220
-
1221
- /**
1222
- * Simulates a top level event being dispatched from a raw event that occurred
1223
- * on an `Element` node.
1224
- * @param {number} topLevelType A number from `TopLevelEventTypes`
1225
- * @param {!Element} node The dom to simulate an event occurring on.
1226
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
1227
- */
1228
-
1229
- function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
1230
- fakeNativeEvent.target = node;
1231
- dispatchEvent(topLevelType, PLUGIN_EVENT_SYSTEM, fakeNativeEvent);
1232
- }
1233
- /**
1234
- * Simulates a top level event being dispatched from a raw event that occurred
1235
- * on the `ReactDOMComponent` `comp`.
1236
- * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`.
1237
- * @param {!ReactDOMComponent} comp
1238
- * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
1239
- */
1240
-
1241
-
1242
- function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
1243
- simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
1244
- }
1245
-
1246
- function findAllInRenderedFiberTreeInternal(fiber, test) {
1247
- if (!fiber) {
1248
- return [];
1249
- }
1250
-
1251
- var currentParent = findCurrentFiberUsingSlowPath(fiber);
1252
-
1253
- if (!currentParent) {
1254
- return [];
1255
- }
1256
1133
 
1257
- var node = currentParent;
1258
- var ret = [];
1259
-
1260
- while (true) {
1261
- if (node.tag === HostComponent || node.tag === HostText || node.tag === ClassComponent || node.tag === FunctionComponent) {
1262
- var publicInst = node.stateNode;
1263
-
1264
- if (test(publicInst)) {
1265
- ret.push(publicInst);
1266
- }
1134
+ node.sibling.return = node.return;
1135
+ node = node.sibling;
1267
1136
  }
1137
+ }
1268
1138
 
1269
- if (node.child) {
1270
- node.child.return = node;
1271
- node = node.child;
1272
- continue;
1139
+ function validateClassInstance(inst, methodName) {
1140
+ if (!inst) {
1141
+ // This is probably too relaxed but it's existing behavior.
1142
+ return;
1273
1143
  }
1274
1144
 
1275
- if (node === currentParent) {
1276
- return ret;
1145
+ if (get(inst)) {
1146
+ // This is a public instance indeed.
1147
+ return;
1277
1148
  }
1278
1149
 
1279
- while (!node.sibling) {
1280
- if (!node.return || node.return === currentParent) {
1281
- return ret;
1282
- }
1150
+ var received;
1151
+ var stringified = '' + inst;
1283
1152
 
1284
- node = node.return;
1153
+ if (Array.isArray(inst)) {
1154
+ received = 'an array';
1155
+ } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
1156
+ received = 'a DOM node';
1157
+ } else if (stringified === '[object Object]') {
1158
+ received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
1159
+ } else {
1160
+ received = stringified;
1285
1161
  }
1286
1162
 
1287
- node.sibling.return = node.return;
1288
- node = node.sibling;
1289
- }
1290
- }
1291
-
1292
- function validateClassInstance(inst, methodName) {
1293
- if (!inst) {
1294
- // This is probably too relaxed but it's existing behavior.
1295
- return;
1296
- }
1297
-
1298
- if (get(inst)) {
1299
- // This is a public instance indeed.
1300
- return;
1301
- }
1302
-
1303
- var received;
1304
- var stringified = '' + inst;
1305
-
1306
- if (Array.isArray(inst)) {
1307
- received = 'an array';
1308
- } else if (inst && inst.nodeType === ELEMENT_NODE && inst.tagName) {
1309
- received = 'a DOM node';
1310
- } else if (stringified === '[object Object]') {
1311
- received = 'object with keys {' + Object.keys(inst).join(', ') + '}';
1312
- } else {
1313
- received = stringified;
1314
- }
1315
-
1316
- {
1317
1163
  {
1318
- throw Error(methodName + "(...): the first argument must be a React class instance. Instead received: " + received + ".");
1164
+ {
1165
+ throw Error( methodName + "(...): the first argument must be a React class instance. Instead received: " + received + "." );
1166
+ }
1319
1167
  }
1320
1168
  }
1321
- }
1322
- /**
1323
- * Utilities for making it easy to test React components.
1324
- *
1325
- * See https://reactjs.org/docs/test-utils.html
1326
- *
1327
- * Todo: Support the entire DOM.scry query syntax. For now, these simple
1328
- * utilities will suffice for testing purposes.
1329
- * @lends ReactTestUtils
1330
- */
1331
-
1169
+ /**
1170
+ * Utilities for making it easy to test React components.
1171
+ *
1172
+ * See https://reactjs.org/docs/test-utils.html
1173
+ *
1174
+ * Todo: Support the entire DOM.scry query syntax. For now, these simple
1175
+ * utilities will suffice for testing purposes.
1176
+ * @lends ReactTestUtils
1177
+ */
1332
1178
 
1333
- var ReactTestUtils = {
1334
- renderIntoDocument: function (element) {
1335
- var div = document.createElement('div'); // None of our tests actually require attaching the container to the
1336
- // DOM, and doing so creates a mess that we rely on test isolation to
1337
- // clean up, so we're going to stop honoring the name of this method
1338
- // (and probably rename it eventually) if no problems arise.
1339
- // document.documentElement.appendChild(div);
1340
-
1341
- return ReactDOM.render(element, div);
1342
- },
1343
- isElement: function (element) {
1344
- return React.isValidElement(element);
1345
- },
1346
- isElementOfType: function (inst, convenienceConstructor) {
1347
- return React.isValidElement(inst) && inst.type === convenienceConstructor;
1348
- },
1349
- isDOMComponent: function (inst) {
1350
- return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
1351
- },
1352
- isDOMComponentElement: function (inst) {
1353
- return !!(inst && React.isValidElement(inst) && !!inst.tagName);
1354
- },
1355
- isCompositeComponent: function (inst) {
1356
- if (ReactTestUtils.isDOMComponent(inst)) {
1357
- // Accessing inst.setState warns; just return false as that'll be what
1358
- // this returns when we have DOM nodes as refs directly
1359
- return false;
1360
- }
1361
1179
 
1362
- return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
1363
- },
1364
- isCompositeComponentWithType: function (inst, type) {
1365
- if (!ReactTestUtils.isCompositeComponent(inst)) {
1366
- return false;
1367
- }
1180
+ var ReactTestUtils = {
1181
+ renderIntoDocument: function (element) {
1182
+ var div = document.createElement('div'); // None of our tests actually require attaching the container to the
1183
+ // DOM, and doing so creates a mess that we rely on test isolation to
1184
+ // clean up, so we're going to stop honoring the name of this method
1185
+ // (and probably rename it eventually) if no problems arise.
1186
+ // document.documentElement.appendChild(div);
1187
+
1188
+ return ReactDOM.render(element, div);
1189
+ },
1190
+ isElement: function (element) {
1191
+ return React.isValidElement(element);
1192
+ },
1193
+ isElementOfType: function (inst, convenienceConstructor) {
1194
+ return React.isValidElement(inst) && inst.type === convenienceConstructor;
1195
+ },
1196
+ isDOMComponent: function (inst) {
1197
+ return !!(inst && inst.nodeType === ELEMENT_NODE && inst.tagName);
1198
+ },
1199
+ isDOMComponentElement: function (inst) {
1200
+ return !!(inst && React.isValidElement(inst) && !!inst.tagName);
1201
+ },
1202
+ isCompositeComponent: function (inst) {
1203
+ if (ReactTestUtils.isDOMComponent(inst)) {
1204
+ // Accessing inst.setState warns; just return false as that'll be what
1205
+ // this returns when we have DOM nodes as refs directly
1206
+ return false;
1207
+ }
1368
1208
 
1369
- var internalInstance = get(inst);
1370
- var constructor = internalInstance.type;
1371
- return constructor === type;
1372
- },
1373
- findAllInRenderedTree: function (inst, test) {
1374
- validateClassInstance(inst, 'findAllInRenderedTree');
1209
+ return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
1210
+ },
1211
+ isCompositeComponentWithType: function (inst, type) {
1212
+ if (!ReactTestUtils.isCompositeComponent(inst)) {
1213
+ return false;
1214
+ }
1375
1215
 
1376
- if (!inst) {
1377
- return [];
1378
- }
1216
+ var internalInstance = get(inst);
1217
+ var constructor = internalInstance.type;
1218
+ return constructor === type;
1219
+ },
1220
+ findAllInRenderedTree: function (inst, test) {
1221
+ validateClassInstance(inst, 'findAllInRenderedTree');
1379
1222
 
1380
- var internalInstance = get(inst);
1381
- return findAllInRenderedFiberTreeInternal(internalInstance, test);
1382
- },
1223
+ if (!inst) {
1224
+ return [];
1225
+ }
1383
1226
 
1384
- /**
1385
- * Finds all instance of components in the rendered tree that are DOM
1386
- * components with the class name matching `className`.
1387
- * @return {array} an array of all the matches.
1388
- */
1389
- scryRenderedDOMComponentsWithClass: function (root, classNames) {
1390
- validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
1391
- return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1392
- if (ReactTestUtils.isDOMComponent(inst)) {
1393
- var className = inst.className;
1227
+ var internalInstance = get(inst);
1228
+ return findAllInRenderedFiberTreeInternal(internalInstance, test);
1229
+ },
1394
1230
 
1395
- if (typeof className !== 'string') {
1396
- // SVG, probably.
1397
- className = inst.getAttribute('class') || '';
1398
- }
1231
+ /**
1232
+ * Finds all instance of components in the rendered tree that are DOM
1233
+ * components with the class name matching `className`.
1234
+ * @return {array} an array of all the matches.
1235
+ */
1236
+ scryRenderedDOMComponentsWithClass: function (root, classNames) {
1237
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithClass');
1238
+ return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1239
+ if (ReactTestUtils.isDOMComponent(inst)) {
1240
+ var className = inst.className;
1241
+
1242
+ if (typeof className !== 'string') {
1243
+ // SVG, probably.
1244
+ className = inst.getAttribute('class') || '';
1245
+ }
1399
1246
 
1400
- var classList = className.split(/\s+/);
1247
+ var classList = className.split(/\s+/);
1401
1248
 
1402
- if (!Array.isArray(classNames)) {
1403
- if (!(classNames !== undefined)) {
1404
- {
1405
- throw Error("TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.");
1249
+ if (!Array.isArray(classNames)) {
1250
+ if (!(classNames !== undefined)) {
1251
+ {
1252
+ throw Error( "TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument." );
1253
+ }
1406
1254
  }
1255
+
1256
+ classNames = classNames.split(/\s+/);
1407
1257
  }
1408
1258
 
1409
- classNames = classNames.split(/\s+/);
1259
+ return classNames.every(function (name) {
1260
+ return classList.indexOf(name) !== -1;
1261
+ });
1410
1262
  }
1411
1263
 
1412
- return classNames.every(function (name) {
1413
- return classList.indexOf(name) !== -1;
1414
- });
1415
- }
1264
+ return false;
1265
+ });
1266
+ },
1416
1267
 
1417
- return false;
1418
- });
1419
- },
1268
+ /**
1269
+ * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
1270
+ * and returns that one result, or throws exception if there is any other
1271
+ * number of matches besides one.
1272
+ * @return {!ReactDOMComponent} The one match.
1273
+ */
1274
+ findRenderedDOMComponentWithClass: function (root, className) {
1275
+ validateClassInstance(root, 'findRenderedDOMComponentWithClass');
1276
+ var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
1420
1277
 
1421
- /**
1422
- * Like scryRenderedDOMComponentsWithClass but expects there to be one result,
1423
- * and returns that one result, or throws exception if there is any other
1424
- * number of matches besides one.
1425
- * @return {!ReactDOMComponent} The one match.
1426
- */
1427
- findRenderedDOMComponentWithClass: function (root, className) {
1428
- validateClassInstance(root, 'findRenderedDOMComponentWithClass');
1429
- var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
1278
+ if (all.length !== 1) {
1279
+ throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
1280
+ }
1430
1281
 
1431
- if (all.length !== 1) {
1432
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
1433
- }
1282
+ return all[0];
1283
+ },
1434
1284
 
1435
- return all[0];
1436
- },
1285
+ /**
1286
+ * Finds all instance of components in the rendered tree that are DOM
1287
+ * components with the tag name matching `tagName`.
1288
+ * @return {array} an array of all the matches.
1289
+ */
1290
+ scryRenderedDOMComponentsWithTag: function (root, tagName) {
1291
+ validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
1292
+ return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1293
+ return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
1294
+ });
1295
+ },
1437
1296
 
1438
- /**
1439
- * Finds all instance of components in the rendered tree that are DOM
1440
- * components with the tag name matching `tagName`.
1441
- * @return {array} an array of all the matches.
1442
- */
1443
- scryRenderedDOMComponentsWithTag: function (root, tagName) {
1444
- validateClassInstance(root, 'scryRenderedDOMComponentsWithTag');
1445
- return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1446
- return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
1447
- });
1448
- },
1297
+ /**
1298
+ * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
1299
+ * and returns that one result, or throws exception if there is any other
1300
+ * number of matches besides one.
1301
+ * @return {!ReactDOMComponent} The one match.
1302
+ */
1303
+ findRenderedDOMComponentWithTag: function (root, tagName) {
1304
+ validateClassInstance(root, 'findRenderedDOMComponentWithTag');
1305
+ var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
1449
1306
 
1450
- /**
1451
- * Like scryRenderedDOMComponentsWithTag but expects there to be one result,
1452
- * and returns that one result, or throws exception if there is any other
1453
- * number of matches besides one.
1454
- * @return {!ReactDOMComponent} The one match.
1455
- */
1456
- findRenderedDOMComponentWithTag: function (root, tagName) {
1457
- validateClassInstance(root, 'findRenderedDOMComponentWithTag');
1458
- var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
1307
+ if (all.length !== 1) {
1308
+ throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
1309
+ }
1459
1310
 
1460
- if (all.length !== 1) {
1461
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
1462
- }
1311
+ return all[0];
1312
+ },
1463
1313
 
1464
- return all[0];
1465
- },
1314
+ /**
1315
+ * Finds all instances of components with type equal to `componentType`.
1316
+ * @return {array} an array of all the matches.
1317
+ */
1318
+ scryRenderedComponentsWithType: function (root, componentType) {
1319
+ validateClassInstance(root, 'scryRenderedComponentsWithType');
1320
+ return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1321
+ return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
1322
+ });
1323
+ },
1466
1324
 
1467
- /**
1468
- * Finds all instances of components with type equal to `componentType`.
1469
- * @return {array} an array of all the matches.
1470
- */
1471
- scryRenderedComponentsWithType: function (root, componentType) {
1472
- validateClassInstance(root, 'scryRenderedComponentsWithType');
1473
- return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
1474
- return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
1475
- });
1476
- },
1325
+ /**
1326
+ * Same as `scryRenderedComponentsWithType` but expects there to be one result
1327
+ * and returns that one result, or throws exception if there is any other
1328
+ * number of matches besides one.
1329
+ * @return {!ReactComponent} The one match.
1330
+ */
1331
+ findRenderedComponentWithType: function (root, componentType) {
1332
+ validateClassInstance(root, 'findRenderedComponentWithType');
1333
+ var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
1477
1334
 
1478
- /**
1479
- * Same as `scryRenderedComponentsWithType` but expects there to be one result
1480
- * and returns that one result, or throws exception if there is any other
1481
- * number of matches besides one.
1482
- * @return {!ReactComponent} The one match.
1483
- */
1484
- findRenderedComponentWithType: function (root, componentType) {
1485
- validateClassInstance(root, 'findRenderedComponentWithType');
1486
- var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
1335
+ if (all.length !== 1) {
1336
+ throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
1337
+ }
1487
1338
 
1488
- if (all.length !== 1) {
1489
- throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
1490
- }
1339
+ return all[0];
1340
+ },
1491
1341
 
1492
- return all[0];
1493
- },
1342
+ /**
1343
+ * Pass a mocked component module to this method to augment it with
1344
+ * useful methods that allow it to be used as a dummy React component.
1345
+ * Instead of rendering as usual, the component will become a simple
1346
+ * <div> containing any provided children.
1347
+ *
1348
+ * @param {object} module the mock function object exported from a
1349
+ * module that defines the component to be mocked
1350
+ * @param {?string} mockTagName optional dummy root tag name to return
1351
+ * from render method (overrides
1352
+ * module.mockTagName if provided)
1353
+ * @return {object} the ReactTestUtils object (for chaining)
1354
+ */
1355
+ mockComponent: function (module, mockTagName) {
1356
+ {
1357
+ if (!hasWarnedAboutDeprecatedMockComponent) {
1358
+ hasWarnedAboutDeprecatedMockComponent = true;
1494
1359
 
1360
+ warn('ReactTestUtils.mockComponent() is deprecated. ' + 'Use shallow rendering or jest.mock() instead.\n\n' + 'See https://fb.me/test-utils-mock-component for more information.');
1361
+ }
1362
+ }
1363
+
1364
+ mockTagName = mockTagName || module.mockTagName || 'div';
1365
+ module.prototype.render.mockImplementation(function () {
1366
+ return React.createElement(mockTagName, null, this.props.children);
1367
+ });
1368
+ return this;
1369
+ },
1370
+ nativeTouchData: function (x, y) {
1371
+ return {
1372
+ touches: [{
1373
+ pageX: x,
1374
+ pageY: y
1375
+ }]
1376
+ };
1377
+ },
1378
+ Simulate: null,
1379
+ SimulateNative: {},
1380
+ act: act
1381
+ };
1495
1382
  /**
1496
- * Pass a mocked component module to this method to augment it with
1497
- * useful methods that allow it to be used as a dummy React component.
1498
- * Instead of rendering as usual, the component will become a simple
1499
- * <div> containing any provided children.
1383
+ * Exports:
1500
1384
  *
1501
- * @param {object} module the mock function object exported from a
1502
- * module that defines the component to be mocked
1503
- * @param {?string} mockTagName optional dummy root tag name to return
1504
- * from render method (overrides
1505
- * module.mockTagName if provided)
1506
- * @return {object} the ReactTestUtils object (for chaining)
1385
+ * - `ReactTestUtils.Simulate.click(Element)`
1386
+ * - `ReactTestUtils.Simulate.mouseMove(Element)`
1387
+ * - `ReactTestUtils.Simulate.change(Element)`
1388
+ * - ... (All keys from event plugin `eventTypes` objects)
1507
1389
  */
1508
- mockComponent: function (module, mockTagName) {
1509
- if (!hasWarnedAboutDeprecatedMockComponent) {
1510
- hasWarnedAboutDeprecatedMockComponent = true;
1511
- lowPriorityWarningWithoutStack$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.');
1512
- }
1513
-
1514
- mockTagName = mockTagName || module.mockTagName || 'div';
1515
- module.prototype.render.mockImplementation(function () {
1516
- return React.createElement(mockTagName, null, this.props.children);
1517
- });
1518
- return this;
1519
- },
1520
- nativeTouchData: function (x, y) {
1521
- return {
1522
- touches: [{
1523
- pageX: x,
1524
- pageY: y
1525
- }]
1526
- };
1527
- },
1528
- Simulate: null,
1529
- SimulateNative: {},
1530
- act: act
1531
- };
1532
- /**
1533
- * Exports:
1534
- *
1535
- * - `ReactTestUtils.Simulate.click(Element)`
1536
- * - `ReactTestUtils.Simulate.mouseMove(Element)`
1537
- * - `ReactTestUtils.Simulate.change(Element)`
1538
- * - ... (All keys from event plugin `eventTypes` objects)
1539
- */
1540
1390
 
1541
- function makeSimulator(eventType) {
1542
- return function (domNode, eventData) {
1543
- if (!!React.isValidElement(domNode)) {
1544
- {
1545
- throw 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.");
1391
+ function makeSimulator(eventType) {
1392
+ return function (domNode, eventData) {
1393
+ if (!!React.isValidElement(domNode)) {
1394
+ {
1395
+ throw 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." );
1396
+ }
1546
1397
  }
1547
- }
1548
1398
 
1549
- if (!!ReactTestUtils.isCompositeComponent(domNode)) {
1550
- {
1551
- throw 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.");
1399
+ if (!!ReactTestUtils.isCompositeComponent(domNode)) {
1400
+ {
1401
+ throw 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." );
1402
+ }
1552
1403
  }
1553
- }
1554
-
1555
- var dispatchConfig = eventNameDispatchConfigs[eventType];
1556
- var fakeNativeEvent = new Event();
1557
- fakeNativeEvent.target = domNode;
1558
- fakeNativeEvent.type = eventType.toLowerCase(); // We don't use SyntheticEvent.getPooled in order to not have to worry about
1559
- // properly destroying any properties assigned from `eventData` upon release
1560
-
1561
- var targetInst = getInstanceFromNode(domNode);
1562
- var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode); // Since we aren't using pooling, always persist the event. This will make
1563
- // sure it's marked and won't warn when setting additional properties.
1564
1404
 
1565
- event.persist();
1405
+ var dispatchConfig = eventNameDispatchConfigs$1[eventType];
1406
+ var fakeNativeEvent = new Event();
1407
+ fakeNativeEvent.target = domNode;
1408
+ fakeNativeEvent.type = eventType.toLowerCase(); // We don't use SyntheticEvent.getPooled in order to not have to worry about
1409
+ // properly destroying any properties assigned from `eventData` upon release
1566
1410
 
1567
- _assign(event, eventData);
1411
+ var targetInst = getInstanceFromNode$1(domNode);
1412
+ var event = new SyntheticEvent(dispatchConfig, targetInst, fakeNativeEvent, domNode); // Since we aren't using pooling, always persist the event. This will make
1413
+ // sure it's marked and won't warn when setting additional properties.
1568
1414
 
1569
- if (dispatchConfig.phasedRegistrationNames) {
1570
- accumulateTwoPhaseDispatches(event);
1571
- } else {
1572
- accumulateDirectDispatches(event);
1573
- }
1415
+ event.persist();
1574
1416
 
1575
- ReactDOM.unstable_batchedUpdates(function () {
1576
- // Normally extractEvent enqueues a state restore, but we'll just always
1577
- // do that since we're by-passing it here.
1578
- enqueueStateRestore(domNode);
1579
- runEventsInBatch(event);
1580
- });
1581
- restoreStateIfNeeded();
1582
- };
1583
- }
1417
+ _assign(event, eventData);
1584
1418
 
1585
- function buildSimulators() {
1586
- ReactTestUtils.Simulate = {};
1587
- var eventType;
1419
+ if (dispatchConfig.phasedRegistrationNames) {
1420
+ accumulateTwoPhaseDispatches$1(event);
1421
+ } else {
1422
+ accumulateDirectDispatches$1(event);
1423
+ }
1588
1424
 
1589
- for (eventType in eventNameDispatchConfigs) {
1590
- /**
1591
- * @param {!Element|ReactDOMComponent} domComponentOrNode
1592
- * @param {?object} eventData Fake event data to use in SyntheticEvent.
1593
- */
1594
- ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
1425
+ ReactDOM.unstable_batchedUpdates(function () {
1426
+ // Normally extractEvent enqueues a state restore, but we'll just always
1427
+ // do that since we're by-passing it here.
1428
+ enqueueStateRestore$1(domNode);
1429
+ runEventsInBatch$1(event);
1430
+ });
1431
+ restoreStateIfNeeded$1();
1432
+ };
1595
1433
  }
1596
- }
1597
-
1598
- buildSimulators();
1599
- /**
1600
- * Exports:
1601
- *
1602
- * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
1603
- * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
1604
- * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
1605
- * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
1606
- * - ... (All keys from `BrowserEventConstants.topLevelTypes`)
1607
- *
1608
- * Note: Top level event types are a subset of the entire set of handler types
1609
- * (which include a broader set of "synthetic" events). For example, onDragDone
1610
- * is a synthetic event. Except when testing an event plugin or React's event
1611
- * handling code specifically, you probably want to use ReactTestUtils.Simulate
1612
- * to dispatch synthetic events.
1613
- */
1614
1434
 
1615
- function makeNativeSimulator(eventType, topLevelType) {
1616
- return function (domComponentOrNode, nativeEventData) {
1617
- var fakeNativeEvent = new Event(eventType);
1435
+ function buildSimulators() {
1436
+ ReactTestUtils.Simulate = {};
1437
+ var eventType;
1618
1438
 
1619
- _assign(fakeNativeEvent, nativeEventData);
1620
-
1621
- if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
1622
- simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
1623
- } else if (domComponentOrNode.tagName) {
1624
- // Will allow on actual dom nodes.
1625
- simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
1439
+ for (eventType in eventNameDispatchConfigs$1) {
1440
+ /**
1441
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
1442
+ * @param {?object} eventData Fake event data to use in SyntheticEvent.
1443
+ */
1444
+ ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
1626
1445
  }
1627
- };
1628
- }
1629
-
1630
- [[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) {
1631
- var topLevelType = _ref[0],
1632
- eventType = _ref[1];
1446
+ }
1633
1447
 
1448
+ buildSimulators();
1634
1449
  /**
1635
- * @param {!Element|ReactDOMComponent} domComponentOrNode
1636
- * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
1450
+ * Exports:
1451
+ *
1452
+ * - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)`
1453
+ * - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)`
1454
+ * - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)`
1455
+ * - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)`
1456
+ * - ... (All keys from `BrowserEventConstants.topLevelTypes`)
1457
+ *
1458
+ * Note: Top level event types are a subset of the entire set of handler types
1459
+ * (which include a broader set of "synthetic" events). For example, onDragDone
1460
+ * is a synthetic event. Except when testing an event plugin or React's event
1461
+ * handling code specifically, you probably want to use ReactTestUtils.Simulate
1462
+ * to dispatch synthetic events.
1637
1463
  */
1638
- ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
1639
- });
1640
1464
 
1465
+ function makeNativeSimulator(eventType, topLevelType) {
1466
+ return function (domComponentOrNode, nativeEventData) {
1467
+ var fakeNativeEvent = new Event(eventType);
1641
1468
 
1642
- var ReactTestUtils$2 = Object.freeze({
1643
- default: ReactTestUtils
1644
- });
1469
+ _assign(fakeNativeEvent, nativeEventData);
1645
1470
 
1646
- var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$2;
1471
+ if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
1472
+ simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
1473
+ } else if (domComponentOrNode.tagName) {
1474
+ // Will allow on actual dom nodes.
1475
+ simulateNativeEventOnNode(topLevelType, domComponentOrNode, fakeNativeEvent);
1476
+ }
1477
+ };
1478
+ }
1479
+
1480
+ [[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) {
1481
+ var topLevelType = _ref[0],
1482
+ eventType = _ref[1];
1483
+
1484
+ /**
1485
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
1486
+ * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
1487
+ */
1488
+ ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
1489
+ });
1647
1490
 
1648
- // TODO: decide on the top-level export form.
1649
- // This is hacky but makes it work with both Rollup and Jest.
1491
+ // TODO: decide on the top-level export form.
1492
+ // This is hacky but makes it work with both Rollup and Jest.
1650
1493
 
1651
1494
 
1652
- var testUtils = ReactTestUtils$3.default || ReactTestUtils$3;
1495
+ var testUtils = ReactTestUtils.default || ReactTestUtils;
1653
1496
 
1654
- return testUtils;
1497
+ return testUtils;
1655
1498
 
1656
1499
  })));