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