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