react-test-renderer 16.4.0 → 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.
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0
1
+ /** @license React v16.4.1
2
2
  * react-test-renderer-shallow.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -261,10 +261,10 @@ var ReactShallowRenderer = function () {
261
261
 
262
262
 
263
263
  if (typeof type.getDerivedStateFromProps === 'function') {
264
- var partialState = type.getDerivedStateFromProps.call(null, props, this._instance.state);
264
+ var oldState = this._newState || this._instance.state;
265
+ var partialState = type.getDerivedStateFromProps.call(null, props, oldState);
265
266
 
266
267
  if (partialState != null) {
267
- var oldState = this._newState || this._instance.state;
268
268
  var newState = _assign({}, oldState, partialState);
269
269
  this._instance.state = this._newState = newState;
270
270
  }
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0
1
+ /** @license React v16.4.1
2
2
  * react-test-renderer-shallow.production.min.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -8,18 +8,18 @@
8
8
  */
9
9
 
10
10
  'use strict';var e=require("object-assign"),f=require("fbjs/lib/invariant"),l=require("react"),m=require("react-is"),n=require("fbjs/lib/emptyObject"),p=require("fbjs/lib/shallowEqual"),q=require("prop-types/checkPropTypes");
11
- function r(b){for(var a=arguments.length-1,c="https://reactjs.org/docs/error-decoder.html?invariant="+b,d=0;d<a;d++)c+="&args[]="+encodeURIComponent(arguments[d+1]);f(!1,"Minified React error #"+b+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",c)}
12
- var t="function"===typeof Symbol&&Symbol.for,u=t?Symbol.for("react.portal"):60106,x=t?Symbol.for("react.fragment"):60107,y=t?Symbol.for("react.strict_mode"):60108,z=t?Symbol.for("react.profiler"):60114,A=t?Symbol.for("react.provider"):60109,B=t?Symbol.for("react.context"):60110,C=t?Symbol.for("react.async_mode"):60111,D=t?Symbol.for("react.forward_ref"):60112,E=t?Symbol.for("react.timeout"):60113;
13
- function F(b){var a=b.type;if("function"===typeof a)return a.displayName||a.name;if("string"===typeof a)return a;switch(a){case C:return"AsyncMode";case B:return"Context.Consumer";case x:return"ReactFragment";case u:return"ReactPortal";case z:return"Profiler("+b.pendingProps.id+")";case A:return"Context.Provider";case y:return"StrictMode";case E:return"Timeout"}if("object"===typeof a&&null!==a)switch(a.$$typeof){case D:return b=a.render.displayName||a.render.name||"",""!==b?"ForwardRef("+b+")":"ForwardRef"}return null}
14
- function G(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function");}
15
- var K=function(){function b(){G(this,b);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new H(this)}b.prototype.getMountedInstance=function(){return this._instance};b.prototype.getRenderOutput=function(){return this._rendered};b.prototype.render=function(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:n;l.isValidElement(a)?void 0:r("12","function"===typeof a?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
16
- "");"string"===typeof a.type?r("13",a.type):void 0;m.isForwardRef(a)||"function"===typeof a.type?void 0:r("249",Array.isArray(a.type)?"array":null===a.type?"null":typeof a.type);if(!this._rendering){this._rendering=!0;this._element=a;var d=a.type.contextTypes;if(d){var b={},g;for(g in d)b[g]=c[g];c=b}else c=n;this._context=c;this._instance?this._updateClassComponent(a,this._context):m.isForwardRef(a)?this._rendered=a.type.render(a.props,a.ref):(c=a.type,c.prototype&&c.prototype.isReactComponent?(this._instance=
17
- new a.type(a.props,this._context,this._updater),this._updateStateFromStaticLifecycle(a.props),a.type.hasOwnProperty("contextTypes")&&(I=a,c=a.type,d=(d=this._instance)&&d.constructor,q(a.type.contextTypes,this._context,"context",c.displayName||d&&d.displayName||c.name||d&&d.name||null,J),I=null),this._mountClassComponent(a,this._context)):this._rendered=a.type(a.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};b.prototype.unmount=function(){this._instance&&
18
- "function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=null};b.prototype._mountClassComponent=function(a,c){this._instance.context=c;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)c=this._newState,"function"!==
19
- 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()),c!==this._newState&&(this._instance.state=this._newState||n);this._rendered=this._instance.render()};b.prototype._updateClassComponent=function(a,c){var b=a.props,v=a.type,g=this._instance.state||n,w=this._instance.props;
20
- w!==b&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(b,c),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(b,c));this._updateStateFromStaticLifecycle(b);var h=this._newState||g,k=!0;this._forcedUpdate?(k=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?
21
- k=!!this._instance.shouldComponentUpdate(b,h,c):v.prototype&&v.prototype.isPureReactComponent&&(k=!p(w,b)||!p(g,h));k&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(b,h,c),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(b,h,c));this._instance.context=c;this._instance.props=b;this._instance.state=
22
- h;k&&(this._rendered=this._instance.render())};b.prototype._updateStateFromStaticLifecycle=function(a){var c=this._element.type;"function"===typeof c.getDerivedStateFromProps&&(a=c.getDerivedStateFromProps.call(null,a,this._instance.state),null!=a&&(a=e({},this._newState||this._instance.state,a),this._instance.state=this._newState=a))};return b}();K.createRenderer=function(){return new K};
23
- var H=function(){function b(a){G(this,b);this._renderer=a;this._callbacks=[]}b.prototype._enqueueCallback=function(a,c){"function"===typeof a&&c&&this._callbacks.push({callback:a,publicInstance:c})};b.prototype._invokeCallbacks=function(){var a=this._callbacks;this._callbacks=[];a.forEach(function(a){a.callback.call(a.publicInstance)})};b.prototype.isMounted=function(){return!!this._renderer._element};b.prototype.enqueueForceUpdate=function(a,c){this._enqueueCallback(c,a);this._renderer._forcedUpdate=
24
- !0;this._renderer.render(this._renderer._element,this._renderer._context)};b.prototype.enqueueReplaceState=function(a,c,b){this._enqueueCallback(b,a);this._renderer._newState=c;this._renderer.render(this._renderer._element,this._renderer._context)};b.prototype.enqueueSetState=function(a,b,d){this._enqueueCallback(d,a);d=this._renderer._newState||a.state;"function"===typeof b&&(b=b.call(a,d,a.props));null!==b&&void 0!==b&&(this._renderer._newState=e({},d,b),this._renderer.render(this._renderer._element,
25
- this._renderer._context))};return b}(),I=null;function J(){var b="";if(I){var a=null==I?"#empty":"string"===typeof I||"number"===typeof I?"#text":"string"===typeof I.type?I.type:I.type.displayName||I.type.name||"Unknown",c=I._owner,d=I._source;c=c&&F(c);a="\n in "+(a||"Unknown")+(d?" (at "+d.fileName.replace(/^.*[\\\/]/,"")+":"+d.lineNumber+")":c?" (created by "+c+")":"");b+=a}return b}var L={default:K},M=L&&K||L;module.exports=M.default?M.default:M;
11
+ function r(d){for(var a=arguments.length-1,b="https://reactjs.org/docs/error-decoder.html?invariant="+d,c=0;c<a;c++)b+="&args[]="+encodeURIComponent(arguments[c+1]);f(!1,"Minified React error #"+d+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",b)}
12
+ var t="function"===typeof Symbol&&Symbol.for,u=t?Symbol.for("react.portal"):60106,w=t?Symbol.for("react.fragment"):60107,x=t?Symbol.for("react.strict_mode"):60108,y=t?Symbol.for("react.profiler"):60114,z=t?Symbol.for("react.provider"):60109,A=t?Symbol.for("react.context"):60110,B=t?Symbol.for("react.async_mode"):60111,C=t?Symbol.for("react.forward_ref"):60112,D=t?Symbol.for("react.timeout"):60113;
13
+ function E(d){var a=d.type;if("function"===typeof a)return a.displayName||a.name;if("string"===typeof a)return a;switch(a){case B:return"AsyncMode";case A:return"Context.Consumer";case w:return"ReactFragment";case u:return"ReactPortal";case y:return"Profiler("+d.pendingProps.id+")";case z:return"Context.Provider";case x:return"StrictMode";case D:return"Timeout"}if("object"===typeof a&&null!==a)switch(a.$$typeof){case C:return d=a.render.displayName||a.render.name||"",""!==d?"ForwardRef("+d+")":"ForwardRef"}return null}
14
+ function F(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function");}
15
+ var J=function(){function d(){F(this,d);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new G(this)}d.prototype.getMountedInstance=function(){return this._instance};d.prototype.getRenderOutput=function(){return this._rendered};d.prototype.render=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:n;l.isValidElement(a)?void 0:r("12","function"===typeof a?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
16
+ "");"string"===typeof a.type?r("13",a.type):void 0;m.isForwardRef(a)||"function"===typeof a.type?void 0:r("249",Array.isArray(a.type)?"array":null===a.type?"null":typeof a.type);if(!this._rendering){this._rendering=!0;this._element=a;var c=a.type.contextTypes;if(c){var d={},g;for(g in c)d[g]=b[g];b=d}else b=n;this._context=b;this._instance?this._updateClassComponent(a,this._context):m.isForwardRef(a)?this._rendered=a.type.render(a.props,a.ref):(b=a.type,b.prototype&&b.prototype.isReactComponent?(this._instance=
17
+ new a.type(a.props,this._context,this._updater),this._updateStateFromStaticLifecycle(a.props),a.type.hasOwnProperty("contextTypes")&&(H=a,b=a.type,c=(c=this._instance)&&c.constructor,q(a.type.contextTypes,this._context,"context",b.displayName||c&&c.displayName||b.name||c&&c.name||null,I),H=null),this._mountClassComponent(a,this._context)):this._rendered=a.type(a.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};d.prototype.unmount=function(){this._instance&&
18
+ "function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=null};d.prototype._mountClassComponent=function(a,b){this._instance.context=b;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)b=this._newState,"function"!==
19
+ 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()),b!==this._newState&&(this._instance.state=this._newState||n);this._rendered=this._instance.render()};d.prototype._updateClassComponent=function(a,b){var c=a.props,d=a.type,g=this._instance.state||n,v=this._instance.props;
20
+ v!==c&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(c,b),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(c,b));this._updateStateFromStaticLifecycle(c);var h=this._newState||g,k=!0;this._forcedUpdate?(k=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?
21
+ k=!!this._instance.shouldComponentUpdate(c,h,b):d.prototype&&d.prototype.isPureReactComponent&&(k=!p(v,c)||!p(g,h));k&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(c,h,b),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(c,h,b));this._instance.context=b;this._instance.props=c;this._instance.state=
22
+ h;k&&(this._rendered=this._instance.render())};d.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 d}();J.createRenderer=function(){return new J};
23
+ var G=function(){function d(a){F(this,d);this._renderer=a;this._callbacks=[]}d.prototype._enqueueCallback=function(a,b){"function"===typeof a&&b&&this._callbacks.push({callback:a,publicInstance:b})};d.prototype._invokeCallbacks=function(){var a=this._callbacks;this._callbacks=[];a.forEach(function(a){a.callback.call(a.publicInstance)})};d.prototype.isMounted=function(){return!!this._renderer._element};d.prototype.enqueueForceUpdate=function(a,b){this._enqueueCallback(b,a);this._renderer._forcedUpdate=
24
+ !0;this._renderer.render(this._renderer._element,this._renderer._context)};d.prototype.enqueueReplaceState=function(a,b,c){this._enqueueCallback(c,a);this._renderer._newState=b;this._renderer.render(this._renderer._element,this._renderer._context)};d.prototype.enqueueSetState=function(a,b,c){this._enqueueCallback(c,a);c=this._renderer._newState||a.state;"function"===typeof b&&(b=b.call(a,c,a.props));null!==b&&void 0!==b&&(this._renderer._newState=e({},c,b),this._renderer.render(this._renderer._element,
25
+ this._renderer._context))};return d}(),H=null;function I(){var d="";if(H){var a=null==H?"#empty":"string"===typeof H||"number"===typeof H?"#text":"string"===typeof H.type?H.type:H.type.displayName||H.type.name||"Unknown",b=H._owner,c=H._source;b=b&&E(b);a="\n in "+(a||"Unknown")+(c?" (at "+c.fileName.replace(/^.*[\\\/]/,"")+":"+c.lineNumber+")":b?" (created by "+b+")":"");d+=a}return d}var K={default:J},L=K&&J||K;module.exports=L.default?L.default:L;
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0
1
+ /** @license React v16.4.1
2
2
  * react-test-renderer.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -343,7 +343,8 @@ var yieldedValues = null;
343
343
 
344
344
  function scheduleDeferredCallback$1(callback, options) {
345
345
  scheduledCallback = callback;
346
- return 0;
346
+ var fakeCallbackId = 0;
347
+ return fakeCallbackId;
347
348
  }
348
349
 
349
350
  function cancelDeferredCallback$1(timeoutID) {
@@ -403,7 +404,19 @@ function flushThrough(expectedValues) {
403
404
  }
404
405
  if (yieldedValues === null) {
405
406
  // Always return an array.
406
- return [];
407
+ yieldedValues = [];
408
+ }
409
+ for (var i = 0; i < expectedValues.length; i++) {
410
+ var expectedValue = '"' + expectedValues[i] + '"';
411
+ var yieldedValue = i < yieldedValues.length ? '"' + yieldedValues[i] + '"' : 'nothing';
412
+ if (yieldedValue !== expectedValue) {
413
+ var error = new Error('flushThrough expected to yield ' + expectedValue + ', but ' + yieldedValue + ' was yielded');
414
+ // Attach expected and yielded arrays,
415
+ // So the caller could pretty print the diff (if desired).
416
+ error.expectedValues = expectedValues;
417
+ error.actualValues = yieldedValues;
418
+ throw error;
419
+ }
407
420
  }
408
421
  return yieldedValues;
409
422
  }
@@ -690,7 +703,6 @@ var warnAboutDeprecatedLifecycles = false;
690
703
  var warnAboutLegacyContextAPI = false;
691
704
  var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
692
705
  var enableProfilerTimer = false;
693
- var fireGetDerivedStateFromPropsOnStateUpdates = true;
694
706
 
695
707
  // Only used in www builds.
696
708
 
@@ -1493,6 +1505,8 @@ function FiberNode(tag, pendingProps, key, mode) {
1493
1505
  this.alternate = null;
1494
1506
 
1495
1507
  if (enableProfilerTimer) {
1508
+ this.actualDuration = 0;
1509
+ this.actualStartTime = 0;
1496
1510
  this.selfBaseTime = 0;
1497
1511
  this.treeBaseTime = 0;
1498
1512
  }
@@ -1563,6 +1577,15 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
1563
1577
  workInProgress.nextEffect = null;
1564
1578
  workInProgress.firstEffect = null;
1565
1579
  workInProgress.lastEffect = null;
1580
+
1581
+ if (enableProfilerTimer) {
1582
+ // We intentionally reset, rather than copy, actualDuration & actualStartTime.
1583
+ // This prevents time from endlessly accumulating in new commits.
1584
+ // This has the downside of resetting values for different priority renders,
1585
+ // But works for yielding (the common case) and should support resuming.
1586
+ workInProgress.actualDuration = 0;
1587
+ workInProgress.actualStartTime = 0;
1588
+ }
1566
1589
  }
1567
1590
 
1568
1591
  workInProgress.expirationTime = expirationTime;
@@ -1688,13 +1711,6 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
1688
1711
  var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
1689
1712
  fiber.type = REACT_PROFILER_TYPE;
1690
1713
  fiber.expirationTime = expirationTime;
1691
- if (enableProfilerTimer) {
1692
- fiber.stateNode = {
1693
- elapsedPauseTimeAtStart: 0,
1694
- duration: 0,
1695
- startTime: 0
1696
- };
1697
- }
1698
1714
 
1699
1715
  return fiber;
1700
1716
  }
@@ -1758,6 +1774,8 @@ function assignFiberPropertiesInDEV(target, source) {
1758
1774
  target.expirationTime = source.expirationTime;
1759
1775
  target.alternate = source.alternate;
1760
1776
  if (enableProfilerTimer) {
1777
+ target.actualDuration = source.actualDuration;
1778
+ target.actualStartTime = source.actualStartTime;
1761
1779
  target.selfBaseTime = source.selfBaseTime;
1762
1780
  target.treeBaseTime = source.treeBaseTime;
1763
1781
  }
@@ -3183,9 +3201,9 @@ function markActualRenderTimeStarted(fiber) {
3183
3201
  {
3184
3202
  fiberStack$1.push(fiber);
3185
3203
  }
3186
- var stateNode = fiber.stateNode;
3187
- stateNode.elapsedPauseTimeAtStart = totalElapsedPauseTime;
3188
- stateNode.startTime = now();
3204
+
3205
+ fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime;
3206
+ fiber.actualStartTime = now();
3189
3207
  }
3190
3208
 
3191
3209
  function pauseActualRenderTimerIfRunning() {
@@ -3202,10 +3220,10 @@ function recordElapsedActualRenderTime(fiber) {
3202
3220
  return;
3203
3221
  }
3204
3222
  {
3205
- !(fiber === fiberStack$1.pop()) ? warning(false, 'Unexpected Fiber popped.') : void 0;
3223
+ !(fiber === fiberStack$1.pop()) ? warning(false, 'Unexpected Fiber (%s) popped.', getComponentName(fiber)) : void 0;
3206
3224
  }
3207
- var stateNode = fiber.stateNode;
3208
- stateNode.duration += now() - (totalElapsedPauseTime - stateNode.elapsedPauseTimeAtStart) - stateNode.startTime;
3225
+
3226
+ fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration;
3209
3227
  }
3210
3228
 
3211
3229
  function resetActualRenderTimer() {
@@ -3812,10 +3830,8 @@ function updateClassInstance(current, workInProgress, renderExpirationTime) {
3812
3830
  }
3813
3831
 
3814
3832
  if (typeof getDerivedStateFromProps === 'function') {
3815
- if (fireGetDerivedStateFromPropsOnStateUpdates || oldProps !== newProps) {
3816
- applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
3817
- newState = workInProgress.memoizedState;
3818
- }
3833
+ applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
3834
+ newState = workInProgress.memoizedState;
3819
3835
  }
3820
3836
 
3821
3837
  var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
@@ -4697,7 +4713,8 @@ function ChildReconciler(shouldTrackSideEffects) {
4697
4713
  // Handle top level unkeyed fragments as if they were arrays.
4698
4714
  // This leads to an ambiguity between <>{[...]}</> and <>...</>.
4699
4715
  // We treat the ambiguous cases above the same.
4700
- if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
4716
+ var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
4717
+ if (isUnkeyedTopLevelFragment) {
4701
4718
  newChild = newChild.props.children;
4702
4719
  }
4703
4720
 
@@ -4734,7 +4751,7 @@ function ChildReconciler(shouldTrackSideEffects) {
4734
4751
  warnOnFunctionType();
4735
4752
  }
4736
4753
  }
4737
- if (typeof newChild === 'undefined') {
4754
+ if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
4738
4755
  // If the new child is undefined, and the return fiber is a composite
4739
4756
  // component, throw an error. If Fiber return types are disabled,
4740
4757
  // we already threw above.
@@ -5146,11 +5163,6 @@ function updateMode(current, workInProgress) {
5146
5163
  function updateProfiler(current, workInProgress) {
5147
5164
  var nextProps = workInProgress.pendingProps;
5148
5165
  if (enableProfilerTimer) {
5149
- // Start render timer here and push start time onto queue
5150
- markActualRenderTimeStarted(workInProgress);
5151
-
5152
- // Let the "complete" phase know to stop the timer,
5153
- // And the scheduler to record the measured time.
5154
5166
  workInProgress.effectTag |= Update;
5155
5167
  }
5156
5168
  if (workInProgress.memoizedProps === nextProps) {
@@ -5858,11 +5870,6 @@ function bailoutOnLowPriority(current, workInProgress) {
5858
5870
  case ContextProvider:
5859
5871
  pushProvider(workInProgress);
5860
5872
  break;
5861
- case Profiler:
5862
- if (enableProfilerTimer) {
5863
- markActualRenderTimeStarted(workInProgress);
5864
- }
5865
- break;
5866
5873
  }
5867
5874
  // TODO: What if this is currently in progress?
5868
5875
  // How can that happen? How is this not being cloned?
@@ -5881,6 +5888,12 @@ function memoizeState(workInProgress, nextState) {
5881
5888
  }
5882
5889
 
5883
5890
  function beginWork(current, workInProgress, renderExpirationTime) {
5891
+ if (enableProfilerTimer) {
5892
+ if (workInProgress.mode & ProfileMode) {
5893
+ markActualRenderTimeStarted(workInProgress);
5894
+ }
5895
+ }
5896
+
5884
5897
  if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) {
5885
5898
  return bailoutOnLowPriority(current, workInProgress);
5886
5899
  }
@@ -6085,6 +6098,13 @@ if (supportsMutation) {
6085
6098
 
6086
6099
  function completeWork(current, workInProgress, renderExpirationTime) {
6087
6100
  var newProps = workInProgress.pendingProps;
6101
+
6102
+ if (enableProfilerTimer) {
6103
+ if (workInProgress.mode & ProfileMode) {
6104
+ recordElapsedActualRenderTime(workInProgress);
6105
+ }
6106
+ }
6107
+
6088
6108
  switch (workInProgress.tag) {
6089
6109
  case FunctionalComponent:
6090
6110
  return null;
@@ -6217,9 +6237,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
6217
6237
  case Mode:
6218
6238
  return null;
6219
6239
  case Profiler:
6220
- if (enableProfilerTimer) {
6221
- recordElapsedActualRenderTime(workInProgress);
6222
- }
6223
6240
  return null;
6224
6241
  case HostPortal:
6225
6242
  popHostContainer(workInProgress);
@@ -6947,11 +6964,7 @@ function commitWork(current, finishedWork) {
6947
6964
  {
6948
6965
  if (enableProfilerTimer) {
6949
6966
  var onRender = finishedWork.memoizedProps.onRender;
6950
- onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.stateNode.duration, finishedWork.treeBaseTime, finishedWork.stateNode.startTime, getCommitTime());
6951
-
6952
- // Reset actualTime after successful commit.
6953
- // By default, we append to this time to account for errors and pauses.
6954
- finishedWork.stateNode.duration = 0;
6967
+ onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseTime, finishedWork.actualStartTime, getCommitTime());
6955
6968
  }
6956
6969
  return;
6957
6970
  }
@@ -7158,6 +7171,12 @@ function throwException(root, returnFiber, sourceFiber, value, renderIsExpired,
7158
7171
  }
7159
7172
 
7160
7173
  function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
7174
+ if (enableProfilerTimer) {
7175
+ if (workInProgress.mode & ProfileMode) {
7176
+ recordElapsedActualRenderTime(workInProgress);
7177
+ }
7178
+ }
7179
+
7161
7180
  switch (workInProgress.tag) {
7162
7181
  case ClassComponent:
7163
7182
  {
@@ -7206,6 +7225,14 @@ function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
7206
7225
  }
7207
7226
 
7208
7227
  function unwindInterruptedWork(interruptedWork) {
7228
+ if (enableProfilerTimer) {
7229
+ if (interruptedWork.mode & ProfileMode) {
7230
+ // Resume in case we're picking up on work that was paused.
7231
+ resumeActualRenderTimerIfPaused();
7232
+ recordElapsedActualRenderTime(interruptedWork);
7233
+ }
7234
+ }
7235
+
7209
7236
  switch (interruptedWork.tag) {
7210
7237
  case ClassComponent:
7211
7238
  {
@@ -7229,13 +7256,6 @@ function unwindInterruptedWork(interruptedWork) {
7229
7256
  case ContextProvider:
7230
7257
  popProvider(interruptedWork);
7231
7258
  break;
7232
- case Profiler:
7233
- if (enableProfilerTimer) {
7234
- // Resume in case we're picking up on work that was paused.
7235
- resumeActualRenderTimerIfPaused();
7236
- recordElapsedActualRenderTime(interruptedWork);
7237
- }
7238
- break;
7239
7259
  default:
7240
7260
  break;
7241
7261
  }
@@ -7372,6 +7392,10 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
7372
7392
  clearCaughtError();
7373
7393
 
7374
7394
  if (enableProfilerTimer) {
7395
+ if (failedUnitOfWork.mode & ProfileMode) {
7396
+ recordElapsedActualRenderTime(failedUnitOfWork);
7397
+ }
7398
+
7375
7399
  // Stop "base" render timer again (after the re-thrown error).
7376
7400
  stopBaseRenderTimerIfRunning();
7377
7401
  }
@@ -7605,6 +7629,8 @@ function commitRoot(finishedWork) {
7605
7629
  stopCommitSnapshotEffectsTimer();
7606
7630
 
7607
7631
  if (enableProfilerTimer) {
7632
+ // Mark the current commit time to be shared by all Profilers in this batch.
7633
+ // This enables them to be grouped later.
7608
7634
  recordCommitTime();
7609
7635
  }
7610
7636
 
@@ -8133,7 +8159,7 @@ function captureCommitPhaseError(fiber, error) {
8133
8159
  function computeAsyncExpiration(currentTime) {
8134
8160
  // Given the current clock time, returns an expiration time. We use rounding
8135
8161
  // to batch like updates together.
8136
- // Should complete within ~1000ms. 1200ms max.
8162
+ // Should complete within ~5000ms. 5250ms max.
8137
8163
  var expirationMs = 5000;
8138
8164
  var bucketSizeMs = 250;
8139
8165
  return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
@@ -8288,7 +8314,7 @@ var firstScheduledRoot = null;
8288
8314
  var lastScheduledRoot = null;
8289
8315
 
8290
8316
  var callbackExpirationTime = NoWork;
8291
- var callbackID = -1;
8317
+ var callbackID = void 0;
8292
8318
  var isRendering = false;
8293
8319
  var nextFlushedRoot = null;
8294
8320
  var nextFlushedExpirationTime = NoWork;
@@ -8316,9 +8342,11 @@ function scheduleCallbackWithExpiration(expirationTime) {
8316
8342
  // Existing callback has sufficient timeout. Exit.
8317
8343
  return;
8318
8344
  } else {
8319
- // Existing callback has insufficient timeout. Cancel and schedule a
8320
- // new one.
8321
- cancelDeferredCallback(callbackID);
8345
+ if (callbackID !== null) {
8346
+ // Existing callback has insufficient timeout. Cancel and schedule a
8347
+ // new one.
8348
+ cancelDeferredCallback(callbackID);
8349
+ }
8322
8350
  }
8323
8351
  // The request callback timer is already running. Don't start a new one.
8324
8352
  } else {
@@ -8507,7 +8535,7 @@ function performWork(minExpirationTime, isAsync, dl) {
8507
8535
  // If we're inside a callback, set this to false since we just completed it.
8508
8536
  if (deadline !== null) {
8509
8537
  callbackExpirationTime = NoWork;
8510
- callbackID = -1;
8538
+ callbackID = null;
8511
8539
  }
8512
8540
  // If there's work left over, schedule a new callback.
8513
8541
  if (nextFlushedExpirationTime !== NoWork) {
@@ -8561,7 +8589,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
8561
8589
  // This root is already complete. We can commit it.
8562
8590
  completeRoot(root, finishedWork, expirationTime);
8563
8591
  } else {
8564
- root.finishedWork = null;
8565
8592
  finishedWork = renderRoot(root, expirationTime, false);
8566
8593
  if (finishedWork !== null) {
8567
8594
  // We've completed the root. Commit it.
@@ -8575,7 +8602,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
8575
8602
  // This root is already complete. We can commit it.
8576
8603
  completeRoot(root, _finishedWork, expirationTime);
8577
8604
  } else {
8578
- root.finishedWork = null;
8579
8605
  _finishedWork = renderRoot(root, expirationTime, true);
8580
8606
  if (_finishedWork !== null) {
8581
8607
  // We've completed the root. Check the deadline one more time
@@ -9035,7 +9061,44 @@ function wrapFiber(fiber) {
9035
9061
  return wrapper;
9036
9062
  }
9037
9063
 
9038
- var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef]);
9064
+ var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef,
9065
+ // Normally skipped, but used when there's more than one root child.
9066
+ HostRoot]);
9067
+
9068
+ function getChildren(parent) {
9069
+ var children = [];
9070
+ var startingNode = parent;
9071
+ var node = startingNode;
9072
+ if (node.child === null) {
9073
+ return children;
9074
+ }
9075
+ node.child.return = node;
9076
+ node = node.child;
9077
+ outer: while (true) {
9078
+ var descend = false;
9079
+ if (validWrapperTypes.has(node.tag)) {
9080
+ children.push(wrapFiber(node));
9081
+ } else if (node.tag === HostText) {
9082
+ children.push('' + node.memoizedProps);
9083
+ } else {
9084
+ descend = true;
9085
+ }
9086
+ if (descend && node.child !== null) {
9087
+ node.child.return = node;
9088
+ node = node.child;
9089
+ continue;
9090
+ }
9091
+ while (node.sibling === null) {
9092
+ if (node.return === startingNode) {
9093
+ break outer;
9094
+ }
9095
+ node = node.return;
9096
+ }
9097
+ node.sibling.return = node.return;
9098
+ node = node.sibling;
9099
+ }
9100
+ return children;
9101
+ }
9039
9102
 
9040
9103
  var ReactTestInstance = function () {
9041
9104
  ReactTestInstance.prototype._currentFiber = function _currentFiber() {
@@ -9112,6 +9175,13 @@ var ReactTestInstance = function () {
9112
9175
  var parent = this._fiber.return;
9113
9176
  while (parent !== null) {
9114
9177
  if (validWrapperTypes.has(parent.tag)) {
9178
+ if (parent.tag === HostRoot) {
9179
+ // Special case: we only "materialize" instances for roots
9180
+ // if they have more than a single child. So we'll check that now.
9181
+ if (getChildren(parent).length < 2) {
9182
+ return null;
9183
+ }
9184
+ }
9115
9185
  return wrapFiber(parent);
9116
9186
  }
9117
9187
  parent = parent.return;
@@ -9121,38 +9191,7 @@ var ReactTestInstance = function () {
9121
9191
  }, {
9122
9192
  key: 'children',
9123
9193
  get: function () {
9124
- var children = [];
9125
- var startingNode = this._currentFiber();
9126
- var node = startingNode;
9127
- if (node.child === null) {
9128
- return children;
9129
- }
9130
- node.child.return = node;
9131
- node = node.child;
9132
- outer: while (true) {
9133
- var descend = false;
9134
- if (validWrapperTypes.has(node.tag)) {
9135
- children.push(wrapFiber(node));
9136
- } else if (node.tag === HostText) {
9137
- children.push('' + node.memoizedProps);
9138
- } else {
9139
- descend = true;
9140
- }
9141
- if (descend && node.child !== null) {
9142
- node.child.return = node;
9143
- node = node.child;
9144
- continue;
9145
- }
9146
- while (node.sibling === null) {
9147
- if (node.return === startingNode) {
9148
- break outer;
9149
- }
9150
- node = node.return;
9151
- }
9152
- node.sibling.return = node.return;
9153
- node = node.sibling;
9154
- }
9155
- return children;
9194
+ return getChildren(this._currentFiber());
9156
9195
  }
9157
9196
  }]);
9158
9197
 
@@ -9277,10 +9316,20 @@ var ReactTestRendererFiber = {
9277
9316
  configurable: true,
9278
9317
  enumerable: true,
9279
9318
  get: function () {
9280
- if (root === null || root.current.child === null) {
9319
+ if (root === null) {
9281
9320
  throw new Error("Can't access .root on unmounted test renderer");
9282
9321
  }
9283
- return wrapFiber(root.current.child);
9322
+ var children = getChildren(root.current);
9323
+ if (children.length === 0) {
9324
+ throw new Error("Can't access .root on unmounted test renderer");
9325
+ } else if (children.length === 1) {
9326
+ // Normally, we skip the root and just give you the child.
9327
+ return children[0];
9328
+ } else {
9329
+ // However, we give you the root if there's more than one root child.
9330
+ // We could make this the behavior for all cases but it would be a breaking change.
9331
+ return wrapFiber(root.current);
9332
+ }
9284
9333
  }
9285
9334
  });
9286
9335