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
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -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.
|
|
@@ -16,20 +16,172 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
var _assign = require('object-assign');
|
|
19
|
-
var invariant = require('fbjs/lib/invariant');
|
|
20
19
|
var React = require('react');
|
|
21
20
|
var reactIs = require('react-is');
|
|
22
|
-
var emptyObject = require('fbjs/lib/emptyObject');
|
|
23
|
-
var shallowEqual = require('fbjs/lib/shallowEqual');
|
|
24
21
|
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
25
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
25
|
+
*
|
|
26
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
27
|
+
* to provide information about what broke and what you were
|
|
28
|
+
* expecting.
|
|
29
|
+
*
|
|
30
|
+
* The invariant message will be stripped in production, but the invariant
|
|
31
|
+
* will remain to ensure logic does not differ in production.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
var validateFormat = function () {};
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
validateFormat = function (format) {
|
|
38
|
+
if (format === undefined) {
|
|
39
|
+
throw new Error('invariant requires an error message argument');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function invariant(condition, format, a, b, c, d, e, f) {
|
|
45
|
+
validateFormat(format);
|
|
46
|
+
|
|
47
|
+
if (!condition) {
|
|
48
|
+
var error = void 0;
|
|
49
|
+
if (format === undefined) {
|
|
50
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
51
|
+
} else {
|
|
52
|
+
var args = [a, b, c, d, e, f];
|
|
53
|
+
var argIndex = 0;
|
|
54
|
+
error = new Error(format.replace(/%s/g, function () {
|
|
55
|
+
return args[argIndex++];
|
|
56
|
+
}));
|
|
57
|
+
error.name = 'Invariant Violation';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
26
65
|
// Relying on the `invariant()` implementation lets us
|
|
27
|
-
//
|
|
66
|
+
// preserve the format and params in the www builds.
|
|
67
|
+
|
|
68
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
28
69
|
|
|
29
70
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
30
|
-
|
|
71
|
+
var sourceInfo = '';
|
|
72
|
+
if (source) {
|
|
73
|
+
var path = source.fileName;
|
|
74
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
75
|
+
{
|
|
76
|
+
// In DEV, include code for a common special case:
|
|
77
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
78
|
+
if (/^index\./.test(fileName)) {
|
|
79
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
80
|
+
if (match) {
|
|
81
|
+
var pathBeforeSlash = match[1];
|
|
82
|
+
if (pathBeforeSlash) {
|
|
83
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
84
|
+
fileName = folderName + '/' + fileName;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
90
|
+
} else if (ownerName) {
|
|
91
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
92
|
+
}
|
|
93
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
31
94
|
};
|
|
32
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
98
|
+
* This can be used to log issues in development environments in critical
|
|
99
|
+
* paths. Removing the logging code for production environments will keep the
|
|
100
|
+
* same logic and follow the same code paths.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
var warningWithoutStack = function () {};
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
warningWithoutStack = function (condition, format) {
|
|
107
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
108
|
+
args[_key - 2] = arguments[_key];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (format === undefined) {
|
|
112
|
+
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
113
|
+
}
|
|
114
|
+
if (args.length > 8) {
|
|
115
|
+
// Check before the condition to catch violations early.
|
|
116
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
117
|
+
}
|
|
118
|
+
if (condition) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (typeof console !== 'undefined') {
|
|
122
|
+
var _args$map = args.map(function (item) {
|
|
123
|
+
return '' + item;
|
|
124
|
+
}),
|
|
125
|
+
a = _args$map[0],
|
|
126
|
+
b = _args$map[1],
|
|
127
|
+
c = _args$map[2],
|
|
128
|
+
d = _args$map[3],
|
|
129
|
+
e = _args$map[4],
|
|
130
|
+
f = _args$map[5],
|
|
131
|
+
g = _args$map[6],
|
|
132
|
+
h = _args$map[7];
|
|
133
|
+
|
|
134
|
+
var message = 'Warning: ' + format;
|
|
135
|
+
|
|
136
|
+
// We intentionally don't use spread (or .apply) because it breaks IE9:
|
|
137
|
+
// https://github.com/facebook/react/issues/13610
|
|
138
|
+
switch (args.length) {
|
|
139
|
+
case 0:
|
|
140
|
+
console.error(message);
|
|
141
|
+
break;
|
|
142
|
+
case 1:
|
|
143
|
+
console.error(message, a);
|
|
144
|
+
break;
|
|
145
|
+
case 2:
|
|
146
|
+
console.error(message, a, b);
|
|
147
|
+
break;
|
|
148
|
+
case 3:
|
|
149
|
+
console.error(message, a, b, c);
|
|
150
|
+
break;
|
|
151
|
+
case 4:
|
|
152
|
+
console.error(message, a, b, c, d);
|
|
153
|
+
break;
|
|
154
|
+
case 5:
|
|
155
|
+
console.error(message, a, b, c, d, e);
|
|
156
|
+
break;
|
|
157
|
+
case 6:
|
|
158
|
+
console.error(message, a, b, c, d, e, f);
|
|
159
|
+
break;
|
|
160
|
+
case 7:
|
|
161
|
+
console.error(message, a, b, c, d, e, f, g);
|
|
162
|
+
break;
|
|
163
|
+
case 8:
|
|
164
|
+
console.error(message, a, b, c, d, e, f, g, h);
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
// --- Welcome to debugging React ---
|
|
172
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
173
|
+
// to find the callsite that caused this warning to fire.
|
|
174
|
+
var argIndex = 0;
|
|
175
|
+
var _message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
176
|
+
return args[argIndex++];
|
|
177
|
+
});
|
|
178
|
+
throw new Error(_message);
|
|
179
|
+
} catch (x) {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
var warningWithoutStack$1 = warningWithoutStack;
|
|
184
|
+
|
|
33
185
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
34
186
|
// nor polyfill, then a plain number is used for performance.
|
|
35
187
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
@@ -43,13 +195,29 @@ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
|
43
195
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
44
196
|
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
45
197
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
46
|
-
var
|
|
198
|
+
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
|
|
199
|
+
|
|
200
|
+
var Resolved = 1;
|
|
201
|
+
|
|
47
202
|
|
|
48
|
-
function getComponentName(fiber) {
|
|
49
|
-
var type = fiber.type;
|
|
50
203
|
|
|
204
|
+
|
|
205
|
+
function refineResolvedThenable(thenable) {
|
|
206
|
+
return thenable._reactStatus === Resolved ? thenable._reactResult : null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getComponentName(type) {
|
|
210
|
+
if (type == null) {
|
|
211
|
+
// Host root, text node or just invalid type.
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
{
|
|
215
|
+
if (typeof type.tag === 'number') {
|
|
216
|
+
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
51
219
|
if (typeof type === 'function') {
|
|
52
|
-
return type.displayName || type.name;
|
|
220
|
+
return type.displayName || type.name || null;
|
|
53
221
|
}
|
|
54
222
|
if (typeof type === 'string') {
|
|
55
223
|
return type;
|
|
@@ -57,33 +225,164 @@ function getComponentName(fiber) {
|
|
|
57
225
|
switch (type) {
|
|
58
226
|
case REACT_ASYNC_MODE_TYPE:
|
|
59
227
|
return 'AsyncMode';
|
|
60
|
-
case REACT_CONTEXT_TYPE:
|
|
61
|
-
return 'Context.Consumer';
|
|
62
228
|
case REACT_FRAGMENT_TYPE:
|
|
63
|
-
return '
|
|
229
|
+
return 'Fragment';
|
|
64
230
|
case REACT_PORTAL_TYPE:
|
|
65
|
-
return '
|
|
231
|
+
return 'Portal';
|
|
66
232
|
case REACT_PROFILER_TYPE:
|
|
67
|
-
return 'Profiler
|
|
68
|
-
case REACT_PROVIDER_TYPE:
|
|
69
|
-
return 'Context.Provider';
|
|
233
|
+
return 'Profiler';
|
|
70
234
|
case REACT_STRICT_MODE_TYPE:
|
|
71
235
|
return 'StrictMode';
|
|
72
|
-
case
|
|
73
|
-
return '
|
|
236
|
+
case REACT_PLACEHOLDER_TYPE:
|
|
237
|
+
return 'Placeholder';
|
|
74
238
|
}
|
|
75
|
-
if (typeof type === 'object'
|
|
239
|
+
if (typeof type === 'object') {
|
|
76
240
|
switch (type.$$typeof) {
|
|
241
|
+
case REACT_CONTEXT_TYPE:
|
|
242
|
+
return 'Context.Consumer';
|
|
243
|
+
case REACT_PROVIDER_TYPE:
|
|
244
|
+
return 'Context.Provider';
|
|
77
245
|
case REACT_FORWARD_REF_TYPE:
|
|
78
|
-
var
|
|
79
|
-
|
|
246
|
+
var renderFn = type.render;
|
|
247
|
+
var functionName = renderFn.displayName || renderFn.name || '';
|
|
248
|
+
return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
|
|
249
|
+
}
|
|
250
|
+
if (typeof type.then === 'function') {
|
|
251
|
+
var thenable = type;
|
|
252
|
+
var resolvedThenable = refineResolvedThenable(thenable);
|
|
253
|
+
if (resolvedThenable) {
|
|
254
|
+
return getComponentName(resolvedThenable);
|
|
255
|
+
}
|
|
80
256
|
}
|
|
81
257
|
}
|
|
82
258
|
return null;
|
|
83
259
|
}
|
|
84
260
|
|
|
261
|
+
/*eslint-disable no-self-compare */
|
|
262
|
+
|
|
263
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
267
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
268
|
+
*/
|
|
269
|
+
function is(x, y) {
|
|
270
|
+
// SameValue algorithm
|
|
271
|
+
if (x === y) {
|
|
272
|
+
// Steps 1-5, 7-10
|
|
273
|
+
// Steps 6.b-6.e: +0 != -0
|
|
274
|
+
// Added the nonzero y check to make Flow happy, but it is redundant
|
|
275
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
276
|
+
} else {
|
|
277
|
+
// Step 6.a: NaN == NaN
|
|
278
|
+
return x !== x && y !== y;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Performs equality by iterating through keys on an object and returning false
|
|
284
|
+
* when any key has values which are not strictly equal between the arguments.
|
|
285
|
+
* Returns true when the values of all keys are strictly equal.
|
|
286
|
+
*/
|
|
287
|
+
function shallowEqual(objA, objB) {
|
|
288
|
+
if (is(objA, objB)) {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
var keysA = Object.keys(objA);
|
|
297
|
+
var keysB = Object.keys(objB);
|
|
298
|
+
|
|
299
|
+
if (keysA.length !== keysB.length) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Test for A's keys different from B.
|
|
304
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
305
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
|
|
85
313
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
86
314
|
|
|
315
|
+
var emptyObject = {};
|
|
316
|
+
{
|
|
317
|
+
Object.freeze(emptyObject);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
var Updater = function () {
|
|
321
|
+
function Updater(renderer) {
|
|
322
|
+
_classCallCheck(this, Updater);
|
|
323
|
+
|
|
324
|
+
this._renderer = renderer;
|
|
325
|
+
this._callbacks = [];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
Updater.prototype._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
329
|
+
if (typeof callback === 'function' && publicInstance) {
|
|
330
|
+
this._callbacks.push({
|
|
331
|
+
callback: callback,
|
|
332
|
+
publicInstance: publicInstance
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
Updater.prototype._invokeCallbacks = function _invokeCallbacks() {
|
|
338
|
+
var callbacks = this._callbacks;
|
|
339
|
+
this._callbacks = [];
|
|
340
|
+
|
|
341
|
+
callbacks.forEach(function (_ref) {
|
|
342
|
+
var callback = _ref.callback,
|
|
343
|
+
publicInstance = _ref.publicInstance;
|
|
344
|
+
|
|
345
|
+
callback.call(publicInstance);
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
Updater.prototype.isMounted = function isMounted(publicInstance) {
|
|
350
|
+
return !!this._renderer._element;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
Updater.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
354
|
+
this._enqueueCallback(callback, publicInstance);
|
|
355
|
+
this._renderer._forcedUpdate = true;
|
|
356
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
Updater.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
360
|
+
this._enqueueCallback(callback, publicInstance);
|
|
361
|
+
this._renderer._newState = completeState;
|
|
362
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
Updater.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
366
|
+
this._enqueueCallback(callback, publicInstance);
|
|
367
|
+
var currentState = this._renderer._newState || publicInstance.state;
|
|
368
|
+
|
|
369
|
+
if (typeof partialState === 'function') {
|
|
370
|
+
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Null and undefined are treated as no-ops.
|
|
374
|
+
if (partialState === null || partialState === undefined) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
this._renderer._newState = _assign({}, currentState, partialState);
|
|
379
|
+
|
|
380
|
+
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
return Updater;
|
|
384
|
+
}();
|
|
385
|
+
|
|
87
386
|
var ReactShallowRenderer = function () {
|
|
88
387
|
function ReactShallowRenderer() {
|
|
89
388
|
_classCallCheck(this, ReactShallowRenderer);
|
|
@@ -142,7 +441,7 @@ var ReactShallowRenderer = function () {
|
|
|
142
441
|
|
|
143
442
|
this._mountClassComponent(element, this._context);
|
|
144
443
|
} else {
|
|
145
|
-
this._rendered = element.type(element.props, this._context);
|
|
444
|
+
this._rendered = element.type.call(undefined, element.props, this._context);
|
|
146
445
|
}
|
|
147
446
|
}
|
|
148
447
|
|
|
@@ -278,72 +577,6 @@ ReactShallowRenderer.createRenderer = function () {
|
|
|
278
577
|
return new ReactShallowRenderer();
|
|
279
578
|
};
|
|
280
579
|
|
|
281
|
-
var Updater = function () {
|
|
282
|
-
function Updater(renderer) {
|
|
283
|
-
_classCallCheck(this, Updater);
|
|
284
|
-
|
|
285
|
-
this._renderer = renderer;
|
|
286
|
-
this._callbacks = [];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
Updater.prototype._enqueueCallback = function _enqueueCallback(callback, publicInstance) {
|
|
290
|
-
if (typeof callback === 'function' && publicInstance) {
|
|
291
|
-
this._callbacks.push({
|
|
292
|
-
callback: callback,
|
|
293
|
-
publicInstance: publicInstance
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
Updater.prototype._invokeCallbacks = function _invokeCallbacks() {
|
|
299
|
-
var callbacks = this._callbacks;
|
|
300
|
-
this._callbacks = [];
|
|
301
|
-
|
|
302
|
-
callbacks.forEach(function (_ref) {
|
|
303
|
-
var callback = _ref.callback,
|
|
304
|
-
publicInstance = _ref.publicInstance;
|
|
305
|
-
|
|
306
|
-
callback.call(publicInstance);
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
Updater.prototype.isMounted = function isMounted(publicInstance) {
|
|
311
|
-
return !!this._renderer._element;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
Updater.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) {
|
|
315
|
-
this._enqueueCallback(callback, publicInstance);
|
|
316
|
-
this._renderer._forcedUpdate = true;
|
|
317
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
Updater.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
|
|
321
|
-
this._enqueueCallback(callback, publicInstance);
|
|
322
|
-
this._renderer._newState = completeState;
|
|
323
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
Updater.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) {
|
|
327
|
-
this._enqueueCallback(callback, publicInstance);
|
|
328
|
-
var currentState = this._renderer._newState || publicInstance.state;
|
|
329
|
-
|
|
330
|
-
if (typeof partialState === 'function') {
|
|
331
|
-
partialState = partialState.call(publicInstance, currentState, publicInstance.props);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Null and undefined are treated as no-ops.
|
|
335
|
-
if (partialState === null || partialState === undefined) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
this._renderer._newState = _assign({}, currentState, partialState);
|
|
340
|
-
|
|
341
|
-
this._renderer.render(this._renderer._element, this._renderer._context);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
return Updater;
|
|
345
|
-
}();
|
|
346
|
-
|
|
347
580
|
var currentlyValidatingElement = null;
|
|
348
581
|
|
|
349
582
|
function getDisplayName(element) {
|
|
@@ -363,7 +596,7 @@ function getStackAddendum() {
|
|
|
363
596
|
if (currentlyValidatingElement) {
|
|
364
597
|
var name = getDisplayName(currentlyValidatingElement);
|
|
365
598
|
var owner = currentlyValidatingElement._owner;
|
|
366
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
|
599
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
367
600
|
}
|
|
368
601
|
return stack;
|
|
369
602
|
}
|
|
@@ -398,7 +631,7 @@ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer )
|
|
|
398
631
|
|
|
399
632
|
// TODO: decide on the top-level export form.
|
|
400
633
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
401
|
-
var shallow = ReactShallowRenderer$3.default
|
|
634
|
+
var shallow = ReactShallowRenderer$3.default || ReactShallowRenderer$3;
|
|
402
635
|
|
|
403
636
|
module.exports = shallow;
|
|
404
637
|
})();
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.5.2
|
|
2
2
|
* react-test-renderer-shallow.production.min.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.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
'use strict';var e=require("object-assign"),
|
|
11
|
-
function r(
|
|
12
|
-
var t="function"===typeof Symbol&&Symbol.for,u
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
typeof
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
10
|
+
'use strict';var e=require("object-assign"),g=require("react"),n=require("react-is"),p=require("prop-types/checkPropTypes");function q(a,b,d,c,f,h,m,k){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[d,c,f,h,m,k],D=0;a=Error(b.replace(/%s/g,function(){return l[D++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
|
|
11
|
+
function r(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);q(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}
|
|
12
|
+
var t=/^(.*)[\\\/]/,u="function"===typeof Symbol&&Symbol.for,v=u?Symbol.for("react.portal"):60106,w=u?Symbol.for("react.fragment"):60107,x=u?Symbol.for("react.strict_mode"):60108,y=u?Symbol.for("react.profiler"):60114,z=u?Symbol.for("react.provider"):60109,A=u?Symbol.for("react.context"):60110,B=u?Symbol.for("react.async_mode"):60111,C=u?Symbol.for("react.forward_ref"):60112,E=u?Symbol.for("react.placeholder"):60113;
|
|
13
|
+
function F(a){if(null==a)return null;if("function"===typeof a)return a.displayName||a.name||null;if("string"===typeof a)return a;switch(a){case B:return"AsyncMode";case w:return"Fragment";case v:return"Portal";case y:return"Profiler";case x:return"StrictMode";case E:return"Placeholder"}if("object"===typeof a){switch(a.$$typeof){case A:return"Context.Consumer";case z:return"Context.Provider";case C:var b=a.render;b=b.displayName||b.name||"";return a.displayName||(""!==b?"ForwardRef("+b+")":"ForwardRef")}if("function"===
|
|
14
|
+
typeof a.then&&(a=1===a._reactStatus?a._reactResult:null))return F(a)}return null}var G=Object.prototype.hasOwnProperty;function H(a,b){return a===b?0!==a||0!==b||1/a===1/b:a!==a&&b!==b}function I(a,b){if(H(a,b))return!0;if("object"!==typeof a||null===a||"object"!==typeof b||null===b)return!1;var d=Object.keys(a),c=Object.keys(b);if(d.length!==c.length)return!1;for(c=0;c<d.length;c++)if(!G.call(b,d[c])||!H(a[d[c]],b[d[c]]))return!1;return!0}
|
|
15
|
+
function J(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function");}
|
|
16
|
+
var K={},L=function(){function a(b){J(this,a);this._renderer=b;this._callbacks=[]}a.prototype._enqueueCallback=function(b,a){"function"===typeof b&&a&&this._callbacks.push({callback:b,publicInstance:a})};a.prototype._invokeCallbacks=function(){var b=this._callbacks;this._callbacks=[];b.forEach(function(b){b.callback.call(b.publicInstance)})};a.prototype.isMounted=function(){return!!this._renderer._element};a.prototype.enqueueForceUpdate=function(b,a){this._enqueueCallback(a,b);this._renderer._forcedUpdate=
|
|
17
|
+
!0;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueReplaceState=function(b,a,c){this._enqueueCallback(c,b);this._renderer._newState=a;this._renderer.render(this._renderer._element,this._renderer._context)};a.prototype.enqueueSetState=function(b,a,c){this._enqueueCallback(c,b);c=this._renderer._newState||b.state;"function"===typeof a&&(a=a.call(b,c,b.props));null!==a&&void 0!==a&&(this._renderer._newState=e({},c,a),this._renderer.render(this._renderer._element,
|
|
18
|
+
this._renderer._context))};return a}(),O=function(){function a(){J(this,a);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new L(this)}a.prototype.getMountedInstance=function(){return this._instance};a.prototype.getRenderOutput=function(){return this._rendered};a.prototype.render=function(b){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:K;g.isValidElement(b)?void 0:r("12","function"===typeof b?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
|
|
19
|
+
"");"string"===typeof b.type?r("13",b.type):void 0;n.isForwardRef(b)||"function"===typeof b.type?void 0:r("249",Array.isArray(b.type)?"array":null===b.type?"null":typeof b.type);if(!this._rendering){this._rendering=!0;this._element=b;var c=b.type.contextTypes;if(c){var f={},h;for(h in c)f[h]=a[h];a=f}else a=K;this._context=a;this._instance?this._updateClassComponent(b,this._context):n.isForwardRef(b)?this._rendered=b.type.render(b.props,b.ref):(a=b.type,a.prototype&&a.prototype.isReactComponent?(this._instance=
|
|
20
|
+
new b.type(b.props,this._context,this._updater),this._updateStateFromStaticLifecycle(b.props),b.type.hasOwnProperty("contextTypes")&&(M=b,a=b.type,c=(c=this._instance)&&c.constructor,p(b.type.contextTypes,this._context,"context",a.displayName||c&&c.displayName||a.name||c&&c.name||null,N),M=null),this._mountClassComponent(b,this._context)):this._rendered=b.type.call(void 0,b.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};a.prototype.unmount=
|
|
21
|
+
function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=null};a.prototype._mountClassComponent=function(a,d){this._instance.context=d;this._instance.props=a.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)d=
|
|
22
|
+
this._newState,"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),d!==this._newState&&(this._instance.state=this._newState||K);this._rendered=this._instance.render()};a.prototype._updateClassComponent=function(a,d){var b=a.props,f=a.type,h=this._instance.state||
|
|
23
|
+
K,m=this._instance.props;m!==b&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(b,d),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(b,d));this._updateStateFromStaticLifecycle(b);var k=this._newState||h,l=!0;this._forcedUpdate?(l=!0,this._forcedUpdate=!1):"function"===
|
|
24
|
+
typeof this._instance.shouldComponentUpdate?l=!!this._instance.shouldComponentUpdate(b,k,d):f.prototype&&f.prototype.isPureReactComponent&&(l=!I(m,b)||!I(h,k));l&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(b,k,d),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(b,k,d));this._instance.context=
|
|
25
|
+
d;this._instance.props=b;this._instance.state=k;l&&(this._rendered=this._instance.render())};a.prototype._updateStateFromStaticLifecycle=function(a){var b=this._element.type;if("function"===typeof b.getDerivedStateFromProps){var c=this._newState||this._instance.state;a=b.getDerivedStateFromProps.call(null,a,c);null!=a&&(c=e({},c,a),this._instance.state=this._newState=c)}};return a}();O.createRenderer=function(){return new O};var M=null;
|
|
26
|
+
function N(){var a="";if(M){var b=null==M?"#empty":"string"===typeof M||"number"===typeof M?"#text":"string"===typeof M.type?M.type:M.type.displayName||M.type.name||"Unknown",d=M._owner,c=M._source;d=d&&F(d.type);var f="";c?f=" (at "+c.fileName.replace(t,"")+":"+c.lineNumber+")":d&&(f=" (created by "+d+")");a+="\n in "+(b||"Unknown")+f}return a}var P={default:O},Q=P&&O||P;module.exports=Q.default||Q;
|