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.
- package/cjs/react-test-renderer-shallow.development.js +3 -3
- package/cjs/react-test-renderer-shallow.production.min.js +16 -16
- package/cjs/react-test-renderer.development.js +140 -91
- package/cjs/react-test-renderer.production.min.js +100 -99
- package/package.json +2 -2
- package/umd/react-test-renderer-shallow.development.js +3 -3
- package/umd/react-test-renderer-shallow.production.min.js +12 -12
- package/umd/react-test-renderer.development.js +140 -91
- package/umd/react-test-renderer.production.min.js +92 -92
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.4.
|
|
1
|
+
/** @license React v16.4.1
|
|
2
2
|
* react-test-renderer.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -509,7 +509,8 @@ var yieldedValues = null;
|
|
|
509
509
|
|
|
510
510
|
function scheduleDeferredCallback$1(callback, options) {
|
|
511
511
|
scheduledCallback = callback;
|
|
512
|
-
|
|
512
|
+
var fakeCallbackId = 0;
|
|
513
|
+
return fakeCallbackId;
|
|
513
514
|
}
|
|
514
515
|
|
|
515
516
|
function cancelDeferredCallback$1(timeoutID) {
|
|
@@ -569,7 +570,19 @@ function flushThrough(expectedValues) {
|
|
|
569
570
|
}
|
|
570
571
|
if (yieldedValues === null) {
|
|
571
572
|
// Always return an array.
|
|
572
|
-
|
|
573
|
+
yieldedValues = [];
|
|
574
|
+
}
|
|
575
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
576
|
+
var expectedValue = '"' + expectedValues[i] + '"';
|
|
577
|
+
var yieldedValue = i < yieldedValues.length ? '"' + yieldedValues[i] + '"' : 'nothing';
|
|
578
|
+
if (yieldedValue !== expectedValue) {
|
|
579
|
+
var error = new Error('flushThrough expected to yield ' + expectedValue + ', but ' + yieldedValue + ' was yielded');
|
|
580
|
+
// Attach expected and yielded arrays,
|
|
581
|
+
// So the caller could pretty print the diff (if desired).
|
|
582
|
+
error.expectedValues = expectedValues;
|
|
583
|
+
error.actualValues = yieldedValues;
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
573
586
|
}
|
|
574
587
|
return yieldedValues;
|
|
575
588
|
}
|
|
@@ -929,7 +942,6 @@ var warnAboutDeprecatedLifecycles = false;
|
|
|
929
942
|
var warnAboutLegacyContextAPI = false;
|
|
930
943
|
var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
|
|
931
944
|
var enableProfilerTimer = false;
|
|
932
|
-
var fireGetDerivedStateFromPropsOnStateUpdates = true;
|
|
933
945
|
|
|
934
946
|
// Only used in www builds.
|
|
935
947
|
|
|
@@ -1732,6 +1744,8 @@ function FiberNode(tag, pendingProps, key, mode) {
|
|
|
1732
1744
|
this.alternate = null;
|
|
1733
1745
|
|
|
1734
1746
|
if (enableProfilerTimer) {
|
|
1747
|
+
this.actualDuration = 0;
|
|
1748
|
+
this.actualStartTime = 0;
|
|
1735
1749
|
this.selfBaseTime = 0;
|
|
1736
1750
|
this.treeBaseTime = 0;
|
|
1737
1751
|
}
|
|
@@ -1802,6 +1816,15 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
|
|
|
1802
1816
|
workInProgress.nextEffect = null;
|
|
1803
1817
|
workInProgress.firstEffect = null;
|
|
1804
1818
|
workInProgress.lastEffect = null;
|
|
1819
|
+
|
|
1820
|
+
if (enableProfilerTimer) {
|
|
1821
|
+
// We intentionally reset, rather than copy, actualDuration & actualStartTime.
|
|
1822
|
+
// This prevents time from endlessly accumulating in new commits.
|
|
1823
|
+
// This has the downside of resetting values for different priority renders,
|
|
1824
|
+
// But works for yielding (the common case) and should support resuming.
|
|
1825
|
+
workInProgress.actualDuration = 0;
|
|
1826
|
+
workInProgress.actualStartTime = 0;
|
|
1827
|
+
}
|
|
1805
1828
|
}
|
|
1806
1829
|
|
|
1807
1830
|
workInProgress.expirationTime = expirationTime;
|
|
@@ -1927,13 +1950,6 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
|
|
|
1927
1950
|
var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
|
1928
1951
|
fiber.type = REACT_PROFILER_TYPE;
|
|
1929
1952
|
fiber.expirationTime = expirationTime;
|
|
1930
|
-
if (enableProfilerTimer) {
|
|
1931
|
-
fiber.stateNode = {
|
|
1932
|
-
elapsedPauseTimeAtStart: 0,
|
|
1933
|
-
duration: 0,
|
|
1934
|
-
startTime: 0
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
1953
|
|
|
1938
1954
|
return fiber;
|
|
1939
1955
|
}
|
|
@@ -1997,6 +2013,8 @@ function assignFiberPropertiesInDEV(target, source) {
|
|
|
1997
2013
|
target.expirationTime = source.expirationTime;
|
|
1998
2014
|
target.alternate = source.alternate;
|
|
1999
2015
|
if (enableProfilerTimer) {
|
|
2016
|
+
target.actualDuration = source.actualDuration;
|
|
2017
|
+
target.actualStartTime = source.actualStartTime;
|
|
2000
2018
|
target.selfBaseTime = source.selfBaseTime;
|
|
2001
2019
|
target.treeBaseTime = source.treeBaseTime;
|
|
2002
2020
|
}
|
|
@@ -3422,9 +3440,9 @@ function markActualRenderTimeStarted(fiber) {
|
|
|
3422
3440
|
{
|
|
3423
3441
|
fiberStack$1.push(fiber);
|
|
3424
3442
|
}
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3443
|
+
|
|
3444
|
+
fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime;
|
|
3445
|
+
fiber.actualStartTime = now();
|
|
3428
3446
|
}
|
|
3429
3447
|
|
|
3430
3448
|
function pauseActualRenderTimerIfRunning() {
|
|
@@ -3441,10 +3459,10 @@ function recordElapsedActualRenderTime(fiber) {
|
|
|
3441
3459
|
return;
|
|
3442
3460
|
}
|
|
3443
3461
|
{
|
|
3444
|
-
!(fiber === fiberStack$1.pop()) ? warning_1(false, 'Unexpected Fiber popped.') : void 0;
|
|
3462
|
+
!(fiber === fiberStack$1.pop()) ? warning_1(false, 'Unexpected Fiber (%s) popped.', getComponentName(fiber)) : void 0;
|
|
3445
3463
|
}
|
|
3446
|
-
|
|
3447
|
-
|
|
3464
|
+
|
|
3465
|
+
fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration;
|
|
3448
3466
|
}
|
|
3449
3467
|
|
|
3450
3468
|
function resetActualRenderTimer() {
|
|
@@ -4117,10 +4135,8 @@ function updateClassInstance(current, workInProgress, renderExpirationTime) {
|
|
|
4117
4135
|
}
|
|
4118
4136
|
|
|
4119
4137
|
if (typeof getDerivedStateFromProps === 'function') {
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
newState = workInProgress.memoizedState;
|
|
4123
|
-
}
|
|
4138
|
+
applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
|
|
4139
|
+
newState = workInProgress.memoizedState;
|
|
4124
4140
|
}
|
|
4125
4141
|
|
|
4126
4142
|
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
|
|
@@ -5002,7 +5018,8 @@ function ChildReconciler(shouldTrackSideEffects) {
|
|
|
5002
5018
|
// Handle top level unkeyed fragments as if they were arrays.
|
|
5003
5019
|
// This leads to an ambiguity between <>{[...]}</> and <>...</>.
|
|
5004
5020
|
// We treat the ambiguous cases above the same.
|
|
5005
|
-
|
|
5021
|
+
var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
|
5022
|
+
if (isUnkeyedTopLevelFragment) {
|
|
5006
5023
|
newChild = newChild.props.children;
|
|
5007
5024
|
}
|
|
5008
5025
|
|
|
@@ -5039,7 +5056,7 @@ function ChildReconciler(shouldTrackSideEffects) {
|
|
|
5039
5056
|
warnOnFunctionType();
|
|
5040
5057
|
}
|
|
5041
5058
|
}
|
|
5042
|
-
if (typeof newChild === 'undefined') {
|
|
5059
|
+
if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
|
|
5043
5060
|
// If the new child is undefined, and the return fiber is a composite
|
|
5044
5061
|
// component, throw an error. If Fiber return types are disabled,
|
|
5045
5062
|
// we already threw above.
|
|
@@ -5451,11 +5468,6 @@ function updateMode(current, workInProgress) {
|
|
|
5451
5468
|
function updateProfiler(current, workInProgress) {
|
|
5452
5469
|
var nextProps = workInProgress.pendingProps;
|
|
5453
5470
|
if (enableProfilerTimer) {
|
|
5454
|
-
// Start render timer here and push start time onto queue
|
|
5455
|
-
markActualRenderTimeStarted(workInProgress);
|
|
5456
|
-
|
|
5457
|
-
// Let the "complete" phase know to stop the timer,
|
|
5458
|
-
// And the scheduler to record the measured time.
|
|
5459
5471
|
workInProgress.effectTag |= Update;
|
|
5460
5472
|
}
|
|
5461
5473
|
if (workInProgress.memoizedProps === nextProps) {
|
|
@@ -6163,11 +6175,6 @@ function bailoutOnLowPriority(current, workInProgress) {
|
|
|
6163
6175
|
case ContextProvider:
|
|
6164
6176
|
pushProvider(workInProgress);
|
|
6165
6177
|
break;
|
|
6166
|
-
case Profiler:
|
|
6167
|
-
if (enableProfilerTimer) {
|
|
6168
|
-
markActualRenderTimeStarted(workInProgress);
|
|
6169
|
-
}
|
|
6170
|
-
break;
|
|
6171
6178
|
}
|
|
6172
6179
|
// TODO: What if this is currently in progress?
|
|
6173
6180
|
// How can that happen? How is this not being cloned?
|
|
@@ -6186,6 +6193,12 @@ function memoizeState(workInProgress, nextState) {
|
|
|
6186
6193
|
}
|
|
6187
6194
|
|
|
6188
6195
|
function beginWork(current, workInProgress, renderExpirationTime) {
|
|
6196
|
+
if (enableProfilerTimer) {
|
|
6197
|
+
if (workInProgress.mode & ProfileMode) {
|
|
6198
|
+
markActualRenderTimeStarted(workInProgress);
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6201
|
+
|
|
6189
6202
|
if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) {
|
|
6190
6203
|
return bailoutOnLowPriority(current, workInProgress);
|
|
6191
6204
|
}
|
|
@@ -6390,6 +6403,13 @@ if (supportsMutation) {
|
|
|
6390
6403
|
|
|
6391
6404
|
function completeWork(current, workInProgress, renderExpirationTime) {
|
|
6392
6405
|
var newProps = workInProgress.pendingProps;
|
|
6406
|
+
|
|
6407
|
+
if (enableProfilerTimer) {
|
|
6408
|
+
if (workInProgress.mode & ProfileMode) {
|
|
6409
|
+
recordElapsedActualRenderTime(workInProgress);
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
6412
|
+
|
|
6393
6413
|
switch (workInProgress.tag) {
|
|
6394
6414
|
case FunctionalComponent:
|
|
6395
6415
|
return null;
|
|
@@ -6522,9 +6542,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
|
|
|
6522
6542
|
case Mode:
|
|
6523
6543
|
return null;
|
|
6524
6544
|
case Profiler:
|
|
6525
|
-
if (enableProfilerTimer) {
|
|
6526
|
-
recordElapsedActualRenderTime(workInProgress);
|
|
6527
|
-
}
|
|
6528
6545
|
return null;
|
|
6529
6546
|
case HostPortal:
|
|
6530
6547
|
popHostContainer(workInProgress);
|
|
@@ -7252,11 +7269,7 @@ function commitWork(current, finishedWork) {
|
|
|
7252
7269
|
{
|
|
7253
7270
|
if (enableProfilerTimer) {
|
|
7254
7271
|
var onRender = finishedWork.memoizedProps.onRender;
|
|
7255
|
-
onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.
|
|
7256
|
-
|
|
7257
|
-
// Reset actualTime after successful commit.
|
|
7258
|
-
// By default, we append to this time to account for errors and pauses.
|
|
7259
|
-
finishedWork.stateNode.duration = 0;
|
|
7272
|
+
onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseTime, finishedWork.actualStartTime, getCommitTime());
|
|
7260
7273
|
}
|
|
7261
7274
|
return;
|
|
7262
7275
|
}
|
|
@@ -7463,6 +7476,12 @@ function throwException(root, returnFiber, sourceFiber, value, renderIsExpired,
|
|
|
7463
7476
|
}
|
|
7464
7477
|
|
|
7465
7478
|
function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
|
|
7479
|
+
if (enableProfilerTimer) {
|
|
7480
|
+
if (workInProgress.mode & ProfileMode) {
|
|
7481
|
+
recordElapsedActualRenderTime(workInProgress);
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
|
|
7466
7485
|
switch (workInProgress.tag) {
|
|
7467
7486
|
case ClassComponent:
|
|
7468
7487
|
{
|
|
@@ -7511,6 +7530,14 @@ function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
|
|
|
7511
7530
|
}
|
|
7512
7531
|
|
|
7513
7532
|
function unwindInterruptedWork(interruptedWork) {
|
|
7533
|
+
if (enableProfilerTimer) {
|
|
7534
|
+
if (interruptedWork.mode & ProfileMode) {
|
|
7535
|
+
// Resume in case we're picking up on work that was paused.
|
|
7536
|
+
resumeActualRenderTimerIfPaused();
|
|
7537
|
+
recordElapsedActualRenderTime(interruptedWork);
|
|
7538
|
+
}
|
|
7539
|
+
}
|
|
7540
|
+
|
|
7514
7541
|
switch (interruptedWork.tag) {
|
|
7515
7542
|
case ClassComponent:
|
|
7516
7543
|
{
|
|
@@ -7534,13 +7561,6 @@ function unwindInterruptedWork(interruptedWork) {
|
|
|
7534
7561
|
case ContextProvider:
|
|
7535
7562
|
popProvider(interruptedWork);
|
|
7536
7563
|
break;
|
|
7537
|
-
case Profiler:
|
|
7538
|
-
if (enableProfilerTimer) {
|
|
7539
|
-
// Resume in case we're picking up on work that was paused.
|
|
7540
|
-
resumeActualRenderTimerIfPaused();
|
|
7541
|
-
recordElapsedActualRenderTime(interruptedWork);
|
|
7542
|
-
}
|
|
7543
|
-
break;
|
|
7544
7564
|
default:
|
|
7545
7565
|
break;
|
|
7546
7566
|
}
|
|
@@ -7677,6 +7697,10 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
|
|
7677
7697
|
clearCaughtError();
|
|
7678
7698
|
|
|
7679
7699
|
if (enableProfilerTimer) {
|
|
7700
|
+
if (failedUnitOfWork.mode & ProfileMode) {
|
|
7701
|
+
recordElapsedActualRenderTime(failedUnitOfWork);
|
|
7702
|
+
}
|
|
7703
|
+
|
|
7680
7704
|
// Stop "base" render timer again (after the re-thrown error).
|
|
7681
7705
|
stopBaseRenderTimerIfRunning();
|
|
7682
7706
|
}
|
|
@@ -7910,6 +7934,8 @@ function commitRoot(finishedWork) {
|
|
|
7910
7934
|
stopCommitSnapshotEffectsTimer();
|
|
7911
7935
|
|
|
7912
7936
|
if (enableProfilerTimer) {
|
|
7937
|
+
// Mark the current commit time to be shared by all Profilers in this batch.
|
|
7938
|
+
// This enables them to be grouped later.
|
|
7913
7939
|
recordCommitTime();
|
|
7914
7940
|
}
|
|
7915
7941
|
|
|
@@ -8438,7 +8464,7 @@ function captureCommitPhaseError(fiber, error) {
|
|
|
8438
8464
|
function computeAsyncExpiration(currentTime) {
|
|
8439
8465
|
// Given the current clock time, returns an expiration time. We use rounding
|
|
8440
8466
|
// to batch like updates together.
|
|
8441
|
-
// Should complete within ~
|
|
8467
|
+
// Should complete within ~5000ms. 5250ms max.
|
|
8442
8468
|
var expirationMs = 5000;
|
|
8443
8469
|
var bucketSizeMs = 250;
|
|
8444
8470
|
return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
|
|
@@ -8593,7 +8619,7 @@ var firstScheduledRoot = null;
|
|
|
8593
8619
|
var lastScheduledRoot = null;
|
|
8594
8620
|
|
|
8595
8621
|
var callbackExpirationTime = NoWork;
|
|
8596
|
-
var callbackID =
|
|
8622
|
+
var callbackID = void 0;
|
|
8597
8623
|
var isRendering = false;
|
|
8598
8624
|
var nextFlushedRoot = null;
|
|
8599
8625
|
var nextFlushedExpirationTime = NoWork;
|
|
@@ -8621,9 +8647,11 @@ function scheduleCallbackWithExpiration(expirationTime) {
|
|
|
8621
8647
|
// Existing callback has sufficient timeout. Exit.
|
|
8622
8648
|
return;
|
|
8623
8649
|
} else {
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8650
|
+
if (callbackID !== null) {
|
|
8651
|
+
// Existing callback has insufficient timeout. Cancel and schedule a
|
|
8652
|
+
// new one.
|
|
8653
|
+
cancelDeferredCallback(callbackID);
|
|
8654
|
+
}
|
|
8627
8655
|
}
|
|
8628
8656
|
// The request callback timer is already running. Don't start a new one.
|
|
8629
8657
|
} else {
|
|
@@ -8812,7 +8840,7 @@ function performWork(minExpirationTime, isAsync, dl) {
|
|
|
8812
8840
|
// If we're inside a callback, set this to false since we just completed it.
|
|
8813
8841
|
if (deadline !== null) {
|
|
8814
8842
|
callbackExpirationTime = NoWork;
|
|
8815
|
-
callbackID =
|
|
8843
|
+
callbackID = null;
|
|
8816
8844
|
}
|
|
8817
8845
|
// If there's work left over, schedule a new callback.
|
|
8818
8846
|
if (nextFlushedExpirationTime !== NoWork) {
|
|
@@ -8866,7 +8894,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
|
|
|
8866
8894
|
// This root is already complete. We can commit it.
|
|
8867
8895
|
completeRoot(root, finishedWork, expirationTime);
|
|
8868
8896
|
} else {
|
|
8869
|
-
root.finishedWork = null;
|
|
8870
8897
|
finishedWork = renderRoot(root, expirationTime, false);
|
|
8871
8898
|
if (finishedWork !== null) {
|
|
8872
8899
|
// We've completed the root. Commit it.
|
|
@@ -8880,7 +8907,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
|
|
|
8880
8907
|
// This root is already complete. We can commit it.
|
|
8881
8908
|
completeRoot(root, _finishedWork, expirationTime);
|
|
8882
8909
|
} else {
|
|
8883
|
-
root.finishedWork = null;
|
|
8884
8910
|
_finishedWork = renderRoot(root, expirationTime, true);
|
|
8885
8911
|
if (_finishedWork !== null) {
|
|
8886
8912
|
// We've completed the root. Check the deadline one more time
|
|
@@ -9340,7 +9366,44 @@ function wrapFiber(fiber) {
|
|
|
9340
9366
|
return wrapper;
|
|
9341
9367
|
}
|
|
9342
9368
|
|
|
9343
|
-
var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef
|
|
9369
|
+
var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef,
|
|
9370
|
+
// Normally skipped, but used when there's more than one root child.
|
|
9371
|
+
HostRoot]);
|
|
9372
|
+
|
|
9373
|
+
function getChildren(parent) {
|
|
9374
|
+
var children = [];
|
|
9375
|
+
var startingNode = parent;
|
|
9376
|
+
var node = startingNode;
|
|
9377
|
+
if (node.child === null) {
|
|
9378
|
+
return children;
|
|
9379
|
+
}
|
|
9380
|
+
node.child.return = node;
|
|
9381
|
+
node = node.child;
|
|
9382
|
+
outer: while (true) {
|
|
9383
|
+
var descend = false;
|
|
9384
|
+
if (validWrapperTypes.has(node.tag)) {
|
|
9385
|
+
children.push(wrapFiber(node));
|
|
9386
|
+
} else if (node.tag === HostText) {
|
|
9387
|
+
children.push('' + node.memoizedProps);
|
|
9388
|
+
} else {
|
|
9389
|
+
descend = true;
|
|
9390
|
+
}
|
|
9391
|
+
if (descend && node.child !== null) {
|
|
9392
|
+
node.child.return = node;
|
|
9393
|
+
node = node.child;
|
|
9394
|
+
continue;
|
|
9395
|
+
}
|
|
9396
|
+
while (node.sibling === null) {
|
|
9397
|
+
if (node.return === startingNode) {
|
|
9398
|
+
break outer;
|
|
9399
|
+
}
|
|
9400
|
+
node = node.return;
|
|
9401
|
+
}
|
|
9402
|
+
node.sibling.return = node.return;
|
|
9403
|
+
node = node.sibling;
|
|
9404
|
+
}
|
|
9405
|
+
return children;
|
|
9406
|
+
}
|
|
9344
9407
|
|
|
9345
9408
|
var ReactTestInstance = function () {
|
|
9346
9409
|
ReactTestInstance.prototype._currentFiber = function _currentFiber() {
|
|
@@ -9417,6 +9480,13 @@ var ReactTestInstance = function () {
|
|
|
9417
9480
|
var parent = this._fiber.return;
|
|
9418
9481
|
while (parent !== null) {
|
|
9419
9482
|
if (validWrapperTypes.has(parent.tag)) {
|
|
9483
|
+
if (parent.tag === HostRoot) {
|
|
9484
|
+
// Special case: we only "materialize" instances for roots
|
|
9485
|
+
// if they have more than a single child. So we'll check that now.
|
|
9486
|
+
if (getChildren(parent).length < 2) {
|
|
9487
|
+
return null;
|
|
9488
|
+
}
|
|
9489
|
+
}
|
|
9420
9490
|
return wrapFiber(parent);
|
|
9421
9491
|
}
|
|
9422
9492
|
parent = parent.return;
|
|
@@ -9426,38 +9496,7 @@ var ReactTestInstance = function () {
|
|
|
9426
9496
|
}, {
|
|
9427
9497
|
key: 'children',
|
|
9428
9498
|
get: function () {
|
|
9429
|
-
|
|
9430
|
-
var startingNode = this._currentFiber();
|
|
9431
|
-
var node = startingNode;
|
|
9432
|
-
if (node.child === null) {
|
|
9433
|
-
return children;
|
|
9434
|
-
}
|
|
9435
|
-
node.child.return = node;
|
|
9436
|
-
node = node.child;
|
|
9437
|
-
outer: while (true) {
|
|
9438
|
-
var descend = false;
|
|
9439
|
-
if (validWrapperTypes.has(node.tag)) {
|
|
9440
|
-
children.push(wrapFiber(node));
|
|
9441
|
-
} else if (node.tag === HostText) {
|
|
9442
|
-
children.push('' + node.memoizedProps);
|
|
9443
|
-
} else {
|
|
9444
|
-
descend = true;
|
|
9445
|
-
}
|
|
9446
|
-
if (descend && node.child !== null) {
|
|
9447
|
-
node.child.return = node;
|
|
9448
|
-
node = node.child;
|
|
9449
|
-
continue;
|
|
9450
|
-
}
|
|
9451
|
-
while (node.sibling === null) {
|
|
9452
|
-
if (node.return === startingNode) {
|
|
9453
|
-
break outer;
|
|
9454
|
-
}
|
|
9455
|
-
node = node.return;
|
|
9456
|
-
}
|
|
9457
|
-
node.sibling.return = node.return;
|
|
9458
|
-
node = node.sibling;
|
|
9459
|
-
}
|
|
9460
|
-
return children;
|
|
9499
|
+
return getChildren(this._currentFiber());
|
|
9461
9500
|
}
|
|
9462
9501
|
}]);
|
|
9463
9502
|
|
|
@@ -9582,10 +9621,20 @@ var ReactTestRendererFiber = {
|
|
|
9582
9621
|
configurable: true,
|
|
9583
9622
|
enumerable: true,
|
|
9584
9623
|
get: function () {
|
|
9585
|
-
if (root === null
|
|
9624
|
+
if (root === null) {
|
|
9586
9625
|
throw new Error("Can't access .root on unmounted test renderer");
|
|
9587
9626
|
}
|
|
9588
|
-
|
|
9627
|
+
var children = getChildren(root.current);
|
|
9628
|
+
if (children.length === 0) {
|
|
9629
|
+
throw new Error("Can't access .root on unmounted test renderer");
|
|
9630
|
+
} else if (children.length === 1) {
|
|
9631
|
+
// Normally, we skip the root and just give you the child.
|
|
9632
|
+
return children[0];
|
|
9633
|
+
} else {
|
|
9634
|
+
// However, we give you the root if there's more than one root child.
|
|
9635
|
+
// We could make this the behavior for all cases but it would be a breaking change.
|
|
9636
|
+
return wrapFiber(root.current);
|
|
9637
|
+
}
|
|
9589
9638
|
}
|
|
9590
9639
|
});
|
|
9591
9640
|
|