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