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