react-test-renderer 16.4.0-alpha.0911da3 → 16.4.1

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.
@@ -0,0 +1,762 @@
1
+ /** @license React v16.4.1
2
+ * react-test-renderer-shallow.development.js
3
+ *
4
+ * Copyright (c) 2013-present, Facebook, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ (function (global, factory) {
13
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
14
+ typeof define === 'function' && define.amd ? define(['react'], factory) :
15
+ (global.ReactShallowRenderer = factory(global.React));
16
+ }(this, (function (React) { 'use strict';
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
+ /**
33
+ * Use invariant() to assert state which your program assumes to be true.
34
+ *
35
+ * Provide sprintf-style format (only %s is supported) and arguments
36
+ * to provide information about what broke and what you were
37
+ * expecting.
38
+ *
39
+ * The invariant message will be stripped in production, but the invariant
40
+ * will remain to ensure logic does not differ in production.
41
+ */
42
+
43
+ var validateFormat = function validateFormat(format) {};
44
+
45
+ {
46
+ validateFormat = function validateFormat(format) {
47
+ if (format === undefined) {
48
+ throw new Error('invariant requires an error message argument');
49
+ }
50
+ };
51
+ }
52
+
53
+ function invariant(condition, format, a, b, c, d, e, f) {
54
+ validateFormat(format);
55
+
56
+ if (!condition) {
57
+ var error;
58
+ if (format === undefined) {
59
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
60
+ } else {
61
+ var args = [a, b, c, d, e, f];
62
+ var argIndex = 0;
63
+ error = new Error(format.replace(/%s/g, function () {
64
+ return args[argIndex++];
65
+ }));
66
+ error.name = 'Invariant Violation';
67
+ }
68
+
69
+ error.framesToPop = 1; // we don't care about invariant's own frame
70
+ throw error;
71
+ }
72
+ }
73
+
74
+ var invariant_1 = invariant;
75
+
76
+ // Relying on the `invariant()` implementation lets us
77
+ // have preserve the format and params in the www builds.
78
+
79
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
80
+ // nor polyfill, then a plain number is used for performance.
81
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
82
+
83
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
84
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
85
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
86
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
87
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
88
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
89
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
90
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
91
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
92
+ var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1;
93
+
94
+ function typeOf(object) {
95
+ if (typeof object === 'object' && object !== null) {
96
+ var $$typeof = object.$$typeof;
97
+
98
+ switch ($$typeof) {
99
+ case REACT_ELEMENT_TYPE:
100
+ var type = object.type;
101
+
102
+ switch (type) {
103
+ case REACT_ASYNC_MODE_TYPE:
104
+ case REACT_FRAGMENT_TYPE:
105
+ case REACT_PROFILER_TYPE:
106
+ case REACT_STRICT_MODE_TYPE:
107
+ return type;
108
+ default:
109
+ var $$typeofType = type && type.$$typeof;
110
+
111
+ switch ($$typeofType) {
112
+ case REACT_CONTEXT_TYPE:
113
+ case REACT_FORWARD_REF_TYPE:
114
+ case REACT_PROVIDER_TYPE:
115
+ return $$typeofType;
116
+ default:
117
+ return $$typeof;
118
+ }
119
+ }
120
+ case REACT_PORTAL_TYPE:
121
+ return $$typeof;
122
+ }
123
+ }
124
+
125
+ return undefined;
126
+ }
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ function isForwardRef(object) {
143
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
144
+ }
145
+
146
+ var describeComponentFrame = function (name, source, ownerName) {
147
+ return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
148
+ };
149
+
150
+ function getComponentName(fiber) {
151
+ var type = fiber.type;
152
+
153
+ if (typeof type === 'function') {
154
+ return type.displayName || type.name;
155
+ }
156
+ if (typeof type === 'string') {
157
+ return type;
158
+ }
159
+ switch (type) {
160
+ case REACT_ASYNC_MODE_TYPE:
161
+ return 'AsyncMode';
162
+ case REACT_CONTEXT_TYPE:
163
+ return 'Context.Consumer';
164
+ case REACT_FRAGMENT_TYPE:
165
+ return 'ReactFragment';
166
+ case REACT_PORTAL_TYPE:
167
+ return 'ReactPortal';
168
+ case REACT_PROFILER_TYPE:
169
+ return 'Profiler(' + fiber.pendingProps.id + ')';
170
+ case REACT_PROVIDER_TYPE:
171
+ return 'Context.Provider';
172
+ case REACT_STRICT_MODE_TYPE:
173
+ return 'StrictMode';
174
+ case REACT_TIMEOUT_TYPE:
175
+ return 'Timeout';
176
+ }
177
+ if (typeof type === 'object' && type !== null) {
178
+ switch (type.$$typeof) {
179
+ case REACT_FORWARD_REF_TYPE:
180
+ var functionName = type.render.displayName || type.render.name || '';
181
+ return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
182
+ }
183
+ }
184
+ return null;
185
+ }
186
+
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
+ /*eslint-disable no-self-compare */
216
+
217
+
218
+
219
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
220
+
221
+ /**
222
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
223
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
224
+ */
225
+ function is(x, y) {
226
+ // SameValue algorithm
227
+ if (x === y) {
228
+ // Steps 1-5, 7-10
229
+ // Steps 6.b-6.e: +0 != -0
230
+ // Added the nonzero y check to make Flow happy, but it is redundant
231
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
232
+ } else {
233
+ // Step 6.a: NaN == NaN
234
+ return x !== x && y !== y;
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Performs equality by iterating through keys on an object and returning false
240
+ * when any key has values which are not strictly equal between the arguments.
241
+ * Returns true when the values of all keys are strictly equal.
242
+ */
243
+ function shallowEqual(objA, objB) {
244
+ if (is(objA, objB)) {
245
+ return true;
246
+ }
247
+
248
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
249
+ return false;
250
+ }
251
+
252
+ var keysA = Object.keys(objA);
253
+ var keysB = Object.keys(objB);
254
+
255
+ if (keysA.length !== keysB.length) {
256
+ return false;
257
+ }
258
+
259
+ // Test for A's keys different from B.
260
+ for (var i = 0; i < keysA.length; i++) {
261
+ if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
262
+ return false;
263
+ }
264
+ }
265
+
266
+ return true;
267
+ }
268
+
269
+ var shallowEqual_1 = shallowEqual;
270
+
271
+ /**
272
+ * Copyright (c) 2013-present, Facebook, Inc.
273
+ *
274
+ * This source code is licensed under the MIT license found in the
275
+ * LICENSE file in the root directory of this source tree.
276
+ *
277
+ *
278
+ */
279
+
280
+ function makeEmptyFunction(arg) {
281
+ return function () {
282
+ return arg;
283
+ };
284
+ }
285
+
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
+
304
+ var emptyFunction_1 = emptyFunction;
305
+
306
+ /**
307
+ * Copyright (c) 2014-present, Facebook, Inc.
308
+ *
309
+ * This source code is licensed under the MIT license found in the
310
+ * LICENSE file in the root directory of this source tree.
311
+ *
312
+ */
313
+
314
+
315
+
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;
326
+
327
+ {
328
+ var printWarning = function printWarning(format) {
329
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
330
+ args[_key - 1] = arguments[_key];
331
+ }
332
+
333
+ var argIndex = 0;
334
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
335
+ return args[argIndex++];
336
+ });
337
+ if (typeof console !== 'undefined') {
338
+ console.error(message);
339
+ }
340
+ try {
341
+ // --- Welcome to debugging React ---
342
+ // This error was thrown as a convenience so that you can use this stack
343
+ // to find the callsite that caused this warning to fire.
344
+ throw new Error(message);
345
+ } catch (x) {}
346
+ };
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
+ }
397
+
398
+ /**
399
+ * Assert that the values match with the type specs.
400
+ * Error messages are memorized and will only be shown once.
401
+ *
402
+ * @param {object} typeSpecs Map of name to a ReactPropType
403
+ * @param {object} values Runtime values that need to be type-checked
404
+ * @param {string} location e.g. "prop", "context", "child context"
405
+ * @param {string} componentName Name of the component for error messages.
406
+ * @param {?Function} getStack Returns the component stack.
407
+ * @private
408
+ */
409
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
410
+ {
411
+ for (var typeSpecName in typeSpecs) {
412
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
413
+ var error;
414
+ // Prop type validation may throw. In case they do, we don't want to
415
+ // fail the render phase where it didn't fail before. So we log it.
416
+ // After these have been cleaned up, we'll let them throw.
417
+ try {
418
+ // This is intentionally an invariant that gets caught. It's the same
419
+ // behavior as without this statement except with a better message.
420
+ invariant$2(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]);
421
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
422
+ } catch (ex) {
423
+ error = ex;
424
+ }
425
+ warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
426
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
427
+ // Only monitor this failure once because there tends to be a lot of the
428
+ // same error.
429
+ loggedTypeFailures[error.message] = true;
430
+
431
+ var stack = getStack ? getStack() : '';
432
+
433
+ warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+
440
+ var checkPropTypes_1 = checkPropTypes;
441
+
442
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
443
+
444
+ var ReactShallowRenderer = function () {
445
+ function ReactShallowRenderer() {
446
+ _classCallCheck(this, ReactShallowRenderer);
447
+
448
+ this._context = null;
449
+ this._element = null;
450
+ this._instance = null;
451
+ this._newState = null;
452
+ this._rendered = null;
453
+ this._rendering = false;
454
+ this._forcedUpdate = false;
455
+ this._updater = new Updater(this);
456
+ }
457
+
458
+ ReactShallowRenderer.prototype.getMountedInstance = function getMountedInstance() {
459
+ return this._instance;
460
+ };
461
+
462
+ ReactShallowRenderer.prototype.getRenderOutput = function getRenderOutput() {
463
+ return this._rendered;
464
+ };
465
+
466
+ ReactShallowRenderer.prototype.render = function render(element) {
467
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyObject_1;
468
+
469
+ !React.isValidElement(element) ? invariant_1(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
+ // Show a special message for host elements since it's a common case.
471
+ !(typeof element.type !== 'string') ? invariant_1(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;
472
+ !(isForwardRef(element) || typeof element.type === 'function') ? invariant_1(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
+
474
+ if (this._rendering) {
475
+ return;
476
+ }
477
+
478
+ this._rendering = true;
479
+ this._element = element;
480
+ this._context = getMaskedContext(element.type.contextTypes, context);
481
+
482
+ if (this._instance) {
483
+ this._updateClassComponent(element, this._context);
484
+ } else {
485
+ if (isForwardRef(element)) {
486
+ this._rendered = element.type.render(element.props, element.ref);
487
+ } else if (shouldConstruct(element.type)) {
488
+ this._instance = new element.type(element.props, this._context, this._updater);
489
+
490
+ this._updateStateFromStaticLifecycle(element.props);
491
+
492
+ if (element.type.hasOwnProperty('contextTypes')) {
493
+ currentlyValidatingElement = element;
494
+
495
+ checkPropTypes_1(element.type.contextTypes, this._context, 'context', getName(element.type, this._instance), getStackAddendum);
496
+
497
+ currentlyValidatingElement = null;
498
+ }
499
+
500
+ this._mountClassComponent(element, this._context);
501
+ } else {
502
+ this._rendered = element.type(element.props, this._context);
503
+ }
504
+ }
505
+
506
+ this._rendering = false;
507
+ this._updater._invokeCallbacks();
508
+
509
+ return this.getRenderOutput();
510
+ };
511
+
512
+ ReactShallowRenderer.prototype.unmount = function unmount() {
513
+ if (this._instance) {
514
+ if (typeof this._instance.componentWillUnmount === 'function') {
515
+ this._instance.componentWillUnmount();
516
+ }
517
+ }
518
+
519
+ this._context = null;
520
+ this._element = null;
521
+ this._newState = null;
522
+ this._rendered = null;
523
+ this._instance = null;
524
+ };
525
+
526
+ ReactShallowRenderer.prototype._mountClassComponent = function _mountClassComponent(element, context) {
527
+ this._instance.context = context;
528
+ this._instance.props = element.props;
529
+ this._instance.state = this._instance.state || null;
530
+ this._instance.updater = this._updater;
531
+
532
+ if (typeof this._instance.UNSAFE_componentWillMount === 'function' || typeof this._instance.componentWillMount === 'function') {
533
+ var beforeState = this._newState;
534
+
535
+ // In order to support react-lifecycles-compat polyfilled components,
536
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
537
+ if (typeof element.type.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
538
+ if (typeof this._instance.componentWillMount === 'function') {
539
+ this._instance.componentWillMount();
540
+ }
541
+ if (typeof this._instance.UNSAFE_componentWillMount === 'function') {
542
+ this._instance.UNSAFE_componentWillMount();
543
+ }
544
+ }
545
+
546
+ // setState may have been called during cWM
547
+ if (beforeState !== this._newState) {
548
+ this._instance.state = this._newState || emptyObject_1;
549
+ }
550
+ }
551
+
552
+ this._rendered = this._instance.render();
553
+ // Intentionally do not call componentDidMount()
554
+ // because DOM refs are not available.
555
+ };
556
+
557
+ ReactShallowRenderer.prototype._updateClassComponent = function _updateClassComponent(element, context) {
558
+ var props = element.props,
559
+ type = element.type;
560
+
561
+
562
+ var oldState = this._instance.state || emptyObject_1;
563
+ var oldProps = this._instance.props;
564
+
565
+ if (oldProps !== props) {
566
+ // In order to support react-lifecycles-compat polyfilled components,
567
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
568
+ if (typeof element.type.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
569
+ if (typeof this._instance.componentWillReceiveProps === 'function') {
570
+ this._instance.componentWillReceiveProps(props, context);
571
+ }
572
+ if (typeof this._instance.UNSAFE_componentWillReceiveProps === 'function') {
573
+ this._instance.UNSAFE_componentWillReceiveProps(props, context);
574
+ }
575
+ }
576
+ }
577
+ this._updateStateFromStaticLifecycle(props);
578
+
579
+ // Read state after cWRP in case it calls setState
580
+ var state = this._newState || oldState;
581
+
582
+ var shouldUpdate = true;
583
+ if (this._forcedUpdate) {
584
+ shouldUpdate = true;
585
+ this._forcedUpdate = false;
586
+ } else if (typeof this._instance.shouldComponentUpdate === 'function') {
587
+ shouldUpdate = !!this._instance.shouldComponentUpdate(props, state, context);
588
+ } else if (type.prototype && type.prototype.isPureReactComponent) {
589
+ shouldUpdate = !shallowEqual_1(oldProps, props) || !shallowEqual_1(oldState, state);
590
+ }
591
+
592
+ if (shouldUpdate) {
593
+ // In order to support react-lifecycles-compat polyfilled components,
594
+ // Unsafe lifecycles should not be invoked for components using the new APIs.
595
+ if (typeof element.type.getDerivedStateFromProps !== 'function' && typeof this._instance.getSnapshotBeforeUpdate !== 'function') {
596
+ if (typeof this._instance.componentWillUpdate === 'function') {
597
+ this._instance.componentWillUpdate(props, state, context);
598
+ }
599
+ if (typeof this._instance.UNSAFE_componentWillUpdate === 'function') {
600
+ this._instance.UNSAFE_componentWillUpdate(props, state, context);
601
+ }
602
+ }
603
+ }
604
+
605
+ this._instance.context = context;
606
+ this._instance.props = props;
607
+ this._instance.state = state;
608
+
609
+ if (shouldUpdate) {
610
+ this._rendered = this._instance.render();
611
+ }
612
+ // Intentionally do not call componentDidUpdate()
613
+ // because DOM refs are not available.
614
+ };
615
+
616
+ ReactShallowRenderer.prototype._updateStateFromStaticLifecycle = function _updateStateFromStaticLifecycle(props) {
617
+ var type = this._element.type;
618
+
619
+
620
+ if (typeof type.getDerivedStateFromProps === 'function') {
621
+ var oldState = this._newState || this._instance.state;
622
+ var partialState = type.getDerivedStateFromProps.call(null, props, oldState);
623
+
624
+ if (partialState != null) {
625
+ var newState = _assign({}, oldState, partialState);
626
+ this._instance.state = this._newState = newState;
627
+ }
628
+ }
629
+ };
630
+
631
+ return ReactShallowRenderer;
632
+ }();
633
+
634
+ ReactShallowRenderer.createRenderer = function () {
635
+ return new ReactShallowRenderer();
636
+ };
637
+
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
+ var currentlyValidatingElement = null;
705
+
706
+ function getDisplayName(element) {
707
+ if (element == null) {
708
+ return '#empty';
709
+ } else if (typeof element === 'string' || typeof element === 'number') {
710
+ return '#text';
711
+ } else if (typeof element.type === 'string') {
712
+ return element.type;
713
+ } else {
714
+ return element.type.displayName || element.type.name || 'Unknown';
715
+ }
716
+ }
717
+
718
+ function getStackAddendum() {
719
+ var stack = '';
720
+ if (currentlyValidatingElement) {
721
+ var name = getDisplayName(currentlyValidatingElement);
722
+ var owner = currentlyValidatingElement._owner;
723
+ stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
724
+ }
725
+ return stack;
726
+ }
727
+
728
+ function getName(type, instance) {
729
+ var constructor = instance && instance.constructor;
730
+ return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
731
+ }
732
+
733
+ function shouldConstruct(Component) {
734
+ return !!(Component.prototype && Component.prototype.isReactComponent);
735
+ }
736
+
737
+ function getMaskedContext(contextTypes, unmaskedContext) {
738
+ if (!contextTypes) {
739
+ return emptyObject_1;
740
+ }
741
+ var context = {};
742
+ for (var key in contextTypes) {
743
+ context[key] = unmaskedContext[key];
744
+ }
745
+ return context;
746
+ }
747
+
748
+
749
+
750
+ var ReactShallowRenderer$2 = Object.freeze({
751
+ default: ReactShallowRenderer
752
+ });
753
+
754
+ var ReactShallowRenderer$3 = ( ReactShallowRenderer$2 && ReactShallowRenderer ) || ReactShallowRenderer$2;
755
+
756
+ // TODO: decide on the top-level export form.
757
+ // This is hacky but makes it work with both Rollup and Jest.
758
+ var shallow = ReactShallowRenderer$3.default ? ReactShallowRenderer$3.default : ReactShallowRenderer$3;
759
+
760
+ return shallow;
761
+
762
+ })));