react-test-renderer 16.4.1 → 16.5.2
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/LICENSE +1 -1
- package/cjs/react-test-renderer-shallow.development.js +325 -92
- package/cjs/react-test-renderer-shallow.production.min.js +19 -18
- package/cjs/react-test-renderer.development.js +3053 -1859
- package/cjs/react-test-renderer.production.min.js +123 -113
- package/package.json +4 -4
- package/umd/react-test-renderer-shallow.development.js +277 -245
- package/umd/react-test-renderer-shallow.production.min.js +15 -15
- package/umd/react-test-renderer.development.js +3021 -2015
- package/umd/react-test-renderer.production.min.js +104 -94
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.5.2
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -15,20 +15,6 @@
|
|
|
15
15
|
(global.ReactShallowRenderer = factory(global.React));
|
|
16
16
|
}(this, (function (React) { 'use strict';
|
|
17
17
|
|
|
18
|
-
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
19
|
-
|
|
20
|
-
var _assign = ReactInternals.assign;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the MIT license found in the
|
|
26
|
-
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
18
|
/**
|
|
33
19
|
* Use invariant() to assert state which your program assumes to be true.
|
|
34
20
|
*
|
|
@@ -40,10 +26,10 @@ var _assign = ReactInternals.assign;
|
|
|
40
26
|
* will remain to ensure logic does not differ in production.
|
|
41
27
|
*/
|
|
42
28
|
|
|
43
|
-
var validateFormat = function
|
|
29
|
+
var validateFormat = function () {};
|
|
44
30
|
|
|
45
31
|
{
|
|
46
|
-
validateFormat = function
|
|
32
|
+
validateFormat = function (format) {
|
|
47
33
|
if (format === undefined) {
|
|
48
34
|
throw new Error('invariant requires an error message argument');
|
|
49
35
|
}
|
|
@@ -54,7 +40,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
54
40
|
validateFormat(format);
|
|
55
41
|
|
|
56
42
|
if (!condition) {
|
|
57
|
-
var error;
|
|
43
|
+
var error = void 0;
|
|
58
44
|
if (format === undefined) {
|
|
59
45
|
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
60
46
|
} else {
|
|
@@ -71,10 +57,12 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
71
57
|
}
|
|
72
58
|
}
|
|
73
59
|
|
|
74
|
-
var invariant_1 = invariant;
|
|
75
|
-
|
|
76
60
|
// Relying on the `invariant()` implementation lets us
|
|
77
|
-
//
|
|
61
|
+
// preserve the format and params in the www builds.
|
|
62
|
+
|
|
63
|
+
var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
64
|
+
|
|
65
|
+
var _assign = ReactInternals.assign;
|
|
78
66
|
|
|
79
67
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
80
68
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -89,7 +77,7 @@ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
|
89
77
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
90
78
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
91
79
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
92
|
-
var
|
|
80
|
+
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
|
|
93
81
|
|
|
94
82
|
function typeOf(object) {
|
|
95
83
|
if (typeof object === 'object' && object !== null) {
|
|
@@ -143,15 +131,144 @@ function isForwardRef(object) {
|
|
|
143
131
|
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
144
132
|
}
|
|
145
133
|
|
|
134
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
135
|
+
|
|
146
136
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
147
|
-
|
|
137
|
+
var sourceInfo = '';
|
|
138
|
+
if (source) {
|
|
139
|
+
var path = source.fileName;
|
|
140
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
141
|
+
{
|
|
142
|
+
// In DEV, include code for a common special case:
|
|
143
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
144
|
+
if (/^index\./.test(fileName)) {
|
|
145
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
146
|
+
if (match) {
|
|
147
|
+
var pathBeforeSlash = match[1];
|
|
148
|
+
if (pathBeforeSlash) {
|
|
149
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
150
|
+
fileName = folderName + '/' + fileName;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
156
|
+
} else if (ownerName) {
|
|
157
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
158
|
+
}
|
|
159
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
148
160
|
};
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
164
|
+
* This can be used to log issues in development environments in critical
|
|
165
|
+
* paths. Removing the logging code for production environments will keep the
|
|
166
|
+
* same logic and follow the same code paths.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
var warningWithoutStack = function () {};
|
|
152
170
|
|
|
171
|
+
{
|
|
172
|
+
warningWithoutStack = function (condition, format) {
|
|
173
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
174
|
+
args[_key - 2] = arguments[_key];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (format === undefined) {
|
|
178
|
+
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
179
|
+
}
|
|
180
|
+
if (args.length > 8) {
|
|
181
|
+
// Check before the condition to catch violations early.
|
|
182
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
183
|
+
}
|
|
184
|
+
if (condition) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (typeof console !== 'undefined') {
|
|
188
|
+
var _args$map = args.map(function (item) {
|
|
189
|
+
return '' + item;
|
|
190
|
+
}),
|
|
191
|
+
a = _args$map[0],
|
|
192
|
+
b = _args$map[1],
|
|
193
|
+
c = _args$map[2],
|
|
194
|
+
d = _args$map[3],
|
|
195
|
+
e = _args$map[4],
|
|
196
|
+
f = _args$map[5],
|
|
197
|
+
g = _args$map[6],
|
|
198
|
+
h = _args$map[7];
|
|
199
|
+
|
|
200
|
+
var message = 'Warning: ' + format;
|
|
201
|
+
|
|
202
|
+
// We intentionally don't use spread (or .apply) because it breaks IE9:
|
|
203
|
+
// https://github.com/facebook/react/issues/13610
|
|
204
|
+
switch (args.length) {
|
|
205
|
+
case 0:
|
|
206
|
+
console.error(message);
|
|
207
|
+
break;
|
|
208
|
+
case 1:
|
|
209
|
+
console.error(message, a);
|
|
210
|
+
break;
|
|
211
|
+
case 2:
|
|
212
|
+
console.error(message, a, b);
|
|
213
|
+
break;
|
|
214
|
+
case 3:
|
|
215
|
+
console.error(message, a, b, c);
|
|
216
|
+
break;
|
|
217
|
+
case 4:
|
|
218
|
+
console.error(message, a, b, c, d);
|
|
219
|
+
break;
|
|
220
|
+
case 5:
|
|
221
|
+
console.error(message, a, b, c, d, e);
|
|
222
|
+
break;
|
|
223
|
+
case 6:
|
|
224
|
+
console.error(message, a, b, c, d, e, f);
|
|
225
|
+
break;
|
|
226
|
+
case 7:
|
|
227
|
+
console.error(message, a, b, c, d, e, f, g);
|
|
228
|
+
break;
|
|
229
|
+
case 8:
|
|
230
|
+
console.error(message, a, b, c, d, e, f, g, h);
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
// --- Welcome to debugging React ---
|
|
238
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
239
|
+
// to find the callsite that caused this warning to fire.
|
|
240
|
+
var argIndex = 0;
|
|
241
|
+
var _message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
242
|
+
return args[argIndex++];
|
|
243
|
+
});
|
|
244
|
+
throw new Error(_message);
|
|
245
|
+
} catch (x) {}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var warningWithoutStack$1 = warningWithoutStack;
|
|
250
|
+
|
|
251
|
+
var Resolved = 1;
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
function refineResolvedThenable(thenable) {
|
|
257
|
+
return thenable._reactStatus === Resolved ? thenable._reactResult : null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function getComponentName(type) {
|
|
261
|
+
if (type == null) {
|
|
262
|
+
// Host root, text node or just invalid type.
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
{
|
|
266
|
+
if (typeof type.tag === 'number') {
|
|
267
|
+
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
153
270
|
if (typeof type === 'function') {
|
|
154
|
-
return type.displayName || type.name;
|
|
271
|
+
return type.displayName || type.name || null;
|
|
155
272
|
}
|
|
156
273
|
if (typeof type === 'string') {
|
|
157
274
|
return type;
|
|
@@ -159,63 +276,41 @@ function getComponentName(fiber) {
|
|
|
159
276
|
switch (type) {
|
|
160
277
|
case REACT_ASYNC_MODE_TYPE:
|
|
161
278
|
return 'AsyncMode';
|
|
162
|
-
case REACT_CONTEXT_TYPE:
|
|
163
|
-
return 'Context.Consumer';
|
|
164
279
|
case REACT_FRAGMENT_TYPE:
|
|
165
|
-
return '
|
|
280
|
+
return 'Fragment';
|
|
166
281
|
case REACT_PORTAL_TYPE:
|
|
167
|
-
return '
|
|
282
|
+
return 'Portal';
|
|
168
283
|
case REACT_PROFILER_TYPE:
|
|
169
|
-
return 'Profiler
|
|
170
|
-
case REACT_PROVIDER_TYPE:
|
|
171
|
-
return 'Context.Provider';
|
|
284
|
+
return 'Profiler';
|
|
172
285
|
case REACT_STRICT_MODE_TYPE:
|
|
173
286
|
return 'StrictMode';
|
|
174
|
-
case
|
|
175
|
-
return '
|
|
287
|
+
case REACT_PLACEHOLDER_TYPE:
|
|
288
|
+
return 'Placeholder';
|
|
176
289
|
}
|
|
177
|
-
if (typeof type === 'object'
|
|
290
|
+
if (typeof type === 'object') {
|
|
178
291
|
switch (type.$$typeof) {
|
|
292
|
+
case REACT_CONTEXT_TYPE:
|
|
293
|
+
return 'Context.Consumer';
|
|
294
|
+
case REACT_PROVIDER_TYPE:
|
|
295
|
+
return 'Context.Provider';
|
|
179
296
|
case REACT_FORWARD_REF_TYPE:
|
|
180
|
-
var
|
|
181
|
-
|
|
297
|
+
var renderFn = type.render;
|
|
298
|
+
var functionName = renderFn.displayName || renderFn.name || '';
|
|
299
|
+
return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
|
|
300
|
+
}
|
|
301
|
+
if (typeof type.then === 'function') {
|
|
302
|
+
var thenable = type;
|
|
303
|
+
var resolvedThenable = refineResolvedThenable(thenable);
|
|
304
|
+
if (resolvedThenable) {
|
|
305
|
+
return getComponentName(resolvedThenable);
|
|
306
|
+
}
|
|
182
307
|
}
|
|
183
308
|
}
|
|
184
309
|
return null;
|
|
185
310
|
}
|
|
186
311
|
|
|
187
|
-
/**
|
|
188
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
189
|
-
*
|
|
190
|
-
* This source code is licensed under the MIT license found in the
|
|
191
|
-
* LICENSE file in the root directory of this source tree.
|
|
192
|
-
*
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var emptyObject = {};
|
|
198
|
-
|
|
199
|
-
{
|
|
200
|
-
Object.freeze(emptyObject);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var emptyObject_1 = emptyObject;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
207
|
-
*
|
|
208
|
-
* This source code is licensed under the MIT license found in the
|
|
209
|
-
* LICENSE file in the root directory of this source tree.
|
|
210
|
-
*
|
|
211
|
-
* @typechecks
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
312
|
/*eslint-disable no-self-compare */
|
|
216
313
|
|
|
217
|
-
|
|
218
|
-
|
|
219
314
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
220
315
|
|
|
221
316
|
/**
|
|
@@ -266,74 +361,36 @@ function shallowEqual(objA, objB) {
|
|
|
266
361
|
return true;
|
|
267
362
|
}
|
|
268
363
|
|
|
269
|
-
var shallowEqual_1 = shallowEqual;
|
|
270
|
-
|
|
271
364
|
/**
|
|
272
365
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
273
366
|
*
|
|
274
367
|
* This source code is licensed under the MIT license found in the
|
|
275
368
|
* LICENSE file in the root directory of this source tree.
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
369
|
*/
|
|
279
370
|
|
|
280
|
-
function makeEmptyFunction(arg) {
|
|
281
|
-
return function () {
|
|
282
|
-
return arg;
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
371
|
|
|
286
|
-
/**
|
|
287
|
-
* This function accepts and discards inputs; it has no side effects. This is
|
|
288
|
-
* primarily useful idiomatically for overridable function endpoints which
|
|
289
|
-
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
290
|
-
*/
|
|
291
|
-
var emptyFunction = function emptyFunction() {};
|
|
292
|
-
|
|
293
|
-
emptyFunction.thatReturns = makeEmptyFunction;
|
|
294
|
-
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
295
|
-
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
296
|
-
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
297
|
-
emptyFunction.thatReturnsThis = function () {
|
|
298
|
-
return this;
|
|
299
|
-
};
|
|
300
|
-
emptyFunction.thatReturnsArgument = function (arg) {
|
|
301
|
-
return arg;
|
|
302
|
-
};
|
|
303
372
|
|
|
304
|
-
var
|
|
373
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
374
|
+
|
|
375
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
305
376
|
|
|
306
377
|
/**
|
|
307
|
-
* Copyright (c)
|
|
378
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
308
379
|
*
|
|
309
380
|
* This source code is licensed under the MIT license found in the
|
|
310
381
|
* LICENSE file in the root directory of this source tree.
|
|
311
|
-
*
|
|
312
382
|
*/
|
|
313
383
|
|
|
314
384
|
|
|
315
385
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Similar to invariant but only logs a warning if the condition is not met.
|
|
320
|
-
* This can be used to log issues in development environments in critical
|
|
321
|
-
* paths. Removing the logging code for production environments will keep the
|
|
322
|
-
* same logic and follow the same code paths.
|
|
323
|
-
*/
|
|
324
|
-
|
|
325
|
-
var warning$1 = emptyFunction_1;
|
|
386
|
+
var printWarning = function() {};
|
|
326
387
|
|
|
327
388
|
{
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
args[_key - 1] = arguments[_key];
|
|
331
|
-
}
|
|
389
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
390
|
+
var loggedTypeFailures = {};
|
|
332
391
|
|
|
333
|
-
|
|
334
|
-
var message = 'Warning: ' +
|
|
335
|
-
return args[argIndex++];
|
|
336
|
-
});
|
|
392
|
+
printWarning = function(text) {
|
|
393
|
+
var message = 'Warning: ' + text;
|
|
337
394
|
if (typeof console !== 'undefined') {
|
|
338
395
|
console.error(message);
|
|
339
396
|
}
|
|
@@ -344,55 +401,6 @@ var warning$1 = emptyFunction_1;
|
|
|
344
401
|
throw new Error(message);
|
|
345
402
|
} catch (x) {}
|
|
346
403
|
};
|
|
347
|
-
|
|
348
|
-
warning$1 = function warning(condition, format) {
|
|
349
|
-
if (format === undefined) {
|
|
350
|
-
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
354
|
-
return; // Ignore CompositeComponent proptype check.
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (!condition) {
|
|
358
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
359
|
-
args[_key2 - 2] = arguments[_key2];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
printWarning.apply(undefined, [format].concat(args));
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
var warning_1 = warning$1;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
371
|
-
*
|
|
372
|
-
* This source code is licensed under the MIT license found in the
|
|
373
|
-
* LICENSE file in the root directory of this source tree.
|
|
374
|
-
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
379
|
-
|
|
380
|
-
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
384
|
-
*
|
|
385
|
-
* This source code is licensed under the MIT license found in the
|
|
386
|
-
* LICENSE file in the root directory of this source tree.
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
{
|
|
392
|
-
var invariant$2 = invariant_1;
|
|
393
|
-
var warning = warning_1;
|
|
394
|
-
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
395
|
-
var loggedTypeFailures = {};
|
|
396
404
|
}
|
|
397
405
|
|
|
398
406
|
/**
|
|
@@ -417,12 +425,29 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
417
425
|
try {
|
|
418
426
|
// This is intentionally an invariant that gets caught. It's the same
|
|
419
427
|
// behavior as without this statement except with a better message.
|
|
420
|
-
|
|
428
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
429
|
+
var err = Error(
|
|
430
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
431
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
432
|
+
);
|
|
433
|
+
err.name = 'Invariant Violation';
|
|
434
|
+
throw err;
|
|
435
|
+
}
|
|
421
436
|
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
422
437
|
} catch (ex) {
|
|
423
438
|
error = ex;
|
|
424
439
|
}
|
|
425
|
-
|
|
440
|
+
if (error && !(error instanceof Error)) {
|
|
441
|
+
printWarning(
|
|
442
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
443
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
444
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
445
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
446
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
447
|
+
'shape all require an argument).'
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
}
|
|
426
451
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
427
452
|
// Only monitor this failure once because there tends to be a lot of the
|
|
428
453
|
// same error.
|
|
@@ -430,7 +455,9 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
430
455
|
|
|
431
456
|
var stack = getStack ? getStack() : '';
|
|
432
457
|
|
|
433
|
-
|
|
458
|
+
printWarning(
|
|
459
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
460
|
+
);
|
|
434
461
|
}
|
|
435
462
|
}
|
|
436
463
|
}
|
|
@@ -441,6 +468,77 @@ var checkPropTypes_1 = checkPropTypes;
|
|
|
441
468
|
|
|
442
469
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
443
470
|
|
|
471
|
+
var emptyObject = {};
|
|
472
|
+
{
|
|
473
|
+
Object.freeze(emptyObject);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
var Updater = function () {
|
|
477
|
+
function Updater(renderer) {
|
|
478
|
+
_classCallCheck(this, Updater);
|
|
479
|
+
|
|
480
|
+
this._renderer = renderer;
|
|
481
|
+
this._callbacks = [];
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
Updater.prototype._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
485
|
+
if (typeof callback === 'function' && publicInstance) {
|
|
486
|
+
this._callbacks.push({
|
|
487
|
+
callback: callback,
|
|
488
|
+
publicInstance: publicInstance
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
Updater.prototype._invokeCallbacks = function _invokeCallbacks() {
|
|
494
|
+
var callbacks = this._callbacks;
|
|
495
|
+
this._callbacks = [];
|
|
496
|
+
|
|
497
|
+
callbacks.forEach(function (_ref) {
|
|
498
|
+
var callback = _ref.callback,
|
|
499
|
+
publicInstance = _ref.publicInstance;
|
|
500
|
+
|
|
501
|
+
callback.call(publicInstance);
|
|
502
|
+
});
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
Updater.prototype.isMounted = function isMounted(publicInstance) {
|
|
506
|
+
return !!this._renderer._element;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
Updater.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
510
|
+
this._enqueueCallback(callback, publicInstance);
|
|
511
|
+
this._renderer._forcedUpdate = true;
|
|
512
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
Updater.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
516
|
+
this._enqueueCallback(callback, publicInstance);
|
|
517
|
+
this._renderer._newState = completeState;
|
|
518
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
Updater.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
522
|
+
this._enqueueCallback(callback, publicInstance);
|
|
523
|
+
var currentState = this._renderer._newState || publicInstance.state;
|
|
524
|
+
|
|
525
|
+
if (typeof partialState === 'function') {
|
|
526
|
+
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// Null and undefined are treated as no-ops.
|
|
530
|
+
if (partialState === null || partialState === undefined) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
this._renderer._newState = _assign({}, currentState, partialState);
|
|
535
|
+
|
|
536
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
return Updater;
|
|
540
|
+
}();
|
|
541
|
+
|
|
444
542
|
var ReactShallowRenderer = function () {
|
|
445
543
|
function ReactShallowRenderer() {
|
|
446
544
|
_classCallCheck(this, ReactShallowRenderer);
|
|
@@ -464,12 +562,12 @@ var ReactShallowRenderer = function () {
|
|
|
464
562
|
};
|
|
465
563
|
|
|
466
564
|
ReactShallowRenderer.prototype.render = function render(element) {
|
|
467
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
565
|
+
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject;
|
|
468
566
|
|
|
469
|
-
!React.isValidElement(element) ?
|
|
567
|
+
!React.isValidElement(element) ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : void 0;
|
|
470
568
|
// Show a special message for host elements since it's a common case.
|
|
471
|
-
!(typeof element.type !== 'string') ?
|
|
472
|
-
!(isForwardRef(element) || typeof element.type === 'function') ?
|
|
569
|
+
!(typeof element.type !== 'string') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, not primitives (%s). Instead of calling `.render(el)` and inspecting the rendered output, look at `el.props` directly instead.', element.type) : void 0;
|
|
570
|
+
!(isForwardRef(element) || typeof element.type === 'function') ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom components, but the provided element type was `%s`.', Array.isArray(element.type) ? 'array' : element.type === null ? 'null' : typeof element.type) : void 0;
|
|
473
571
|
|
|
474
572
|
if (this._rendering) {
|
|
475
573
|
return;
|
|
@@ -499,7 +597,7 @@ var ReactShallowRenderer = function () {
|
|
|
499
597
|
|
|
500
598
|
this._mountClassComponent(element, this._context);
|
|
501
599
|
} else {
|
|
502
|
-
this._rendered = element.type(element.props, this._context);
|
|
600
|
+
this._rendered = element.type.call(undefined, element.props, this._context);
|
|
503
601
|
}
|
|
504
602
|
}
|
|
505
603
|
|
|
@@ -545,7 +643,7 @@ var ReactShallowRenderer = function () {
|
|
|
545
643
|
|
|
546
644
|
// setState may have been called during cWM
|
|
547
645
|
if (beforeState !== this._newState) {
|
|
548
|
-
this._instance.state = this._newState ||
|
|
646
|
+
this._instance.state = this._newState || emptyObject;
|
|
549
647
|
}
|
|
550
648
|
}
|
|
551
649
|
|
|
@@ -559,7 +657,7 @@ var ReactShallowRenderer = function () {
|
|
|
559
657
|
type = element.type;
|
|
560
658
|
|
|
561
659
|
|
|
562
|
-
var oldState = this._instance.state ||
|
|
660
|
+
var oldState = this._instance.state || emptyObject;
|
|
563
661
|
var oldProps = this._instance.props;
|
|
564
662
|
|
|
565
663
|
if (oldProps !== props) {
|
|
@@ -586,7 +684,7 @@ var ReactShallowRenderer = function () {
|
|
|
586
684
|
} else if (typeof this._instance.shouldComponentUpdate === 'function') {
|
|
587
685
|
shouldUpdate = !!this._instance.shouldComponentUpdate(props, state, context);
|
|
588
686
|
} else if (type.prototype && type.prototype.isPureReactComponent) {
|
|
589
|
-
shouldUpdate = !
|
|
687
|
+
shouldUpdate = !shallowEqual(oldProps, props) || !shallowEqual(oldState, state);
|
|
590
688
|
}
|
|
591
689
|
|
|
592
690
|
if (shouldUpdate) {
|
|
@@ -635,72 +733,6 @@ ReactShallowRenderer.createRenderer = function () {
|
|
|
635
733
|
return new ReactShallowRenderer();
|
|
636
734
|
};
|
|
637
735
|
|
|
638
|
-
var Updater = function () {
|
|
639
|
-
function Updater(renderer) {
|
|
640
|
-
_classCallCheck(this, Updater);
|
|
641
|
-
|
|
642
|
-
this._renderer = renderer;
|
|
643
|
-
this._callbacks = [];
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
Updater.prototype._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
647
|
-
if (typeof callback === 'function' && publicInstance) {
|
|
648
|
-
this._callbacks.push({
|
|
649
|
-
callback: callback,
|
|
650
|
-
publicInstance: publicInstance
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
Updater.prototype._invokeCallbacks = function _invokeCallbacks() {
|
|
656
|
-
var callbacks = this._callbacks;
|
|
657
|
-
this._callbacks = [];
|
|
658
|
-
|
|
659
|
-
callbacks.forEach(function (_ref) {
|
|
660
|
-
var callback = _ref.callback,
|
|
661
|
-
publicInstance = _ref.publicInstance;
|
|
662
|
-
|
|
663
|
-
callback.call(publicInstance);
|
|
664
|
-
});
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
Updater.prototype.isMounted = function isMounted(publicInstance) {
|
|
668
|
-
return !!this._renderer._element;
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
Updater.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
672
|
-
this._enqueueCallback(callback, publicInstance);
|
|
673
|
-
this._renderer._forcedUpdate = true;
|
|
674
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
Updater.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
678
|
-
this._enqueueCallback(callback, publicInstance);
|
|
679
|
-
this._renderer._newState = completeState;
|
|
680
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
Updater.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
684
|
-
this._enqueueCallback(callback, publicInstance);
|
|
685
|
-
var currentState = this._renderer._newState || publicInstance.state;
|
|
686
|
-
|
|
687
|
-
if (typeof partialState === 'function') {
|
|
688
|
-
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// Null and undefined are treated as no-ops.
|
|
692
|
-
if (partialState === null || partialState === undefined) {
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
this._renderer._newState = _assign({}, currentState, partialState);
|
|
697
|
-
|
|
698
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
699
|
-
};
|
|
700
|
-
|
|
701
|
-
return Updater;
|
|
702
|
-
}();
|
|
703
|
-
|
|
704
736
|
var currentlyValidatingElement = null;
|
|
705
737
|
|
|
706
738
|
function getDisplayName(element) {
|
|
@@ -720,7 +752,7 @@ function getStackAddendum() {
|
|
|
720
752
|
if (currentlyValidatingElement) {
|
|
721
753
|
var name = getDisplayName(currentlyValidatingElement);
|
|
722
754
|
var owner = currentlyValidatingElement._owner;
|
|
723
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
|
755
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
724
756
|
}
|
|
725
757
|
return stack;
|
|
726
758
|
}
|
|
@@ -736,7 +768,7 @@ function shouldConstruct(Component) {
|
|
|
736
768
|
|
|
737
769
|
function getMaskedContext(contextTypes, unmaskedContext) {
|
|
738
770
|
if (!contextTypes) {
|
|
739
|
-
return
|
|
771
|
+
return emptyObject;
|
|
740
772
|
}
|
|
741
773
|
var context = {};
|
|
742
774
|
for (var key in contextTypes) {
|
|
@@ -755,7 +787,7 @@ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer )
|
|
|
755
787
|
|
|
756
788
|
// TODO: decide on the top-level export form.
|
|
757
789
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
758
|
-
var shallow = ReactShallowRenderer$3.default
|
|
790
|
+
var shallow = ReactShallowRenderer$3.default || ReactShallowRenderer$3;
|
|
759
791
|
|
|
760
792
|
return shallow;
|
|
761
793
|
|