react-reconciler 0.21.0 → 0.23.0
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/build-info.json +4 -4
- package/cjs/react-reconciler-persistent.development.js +5301 -3344
- package/cjs/react-reconciler-persistent.production.min.js +176 -164
- package/cjs/react-reconciler-reflection.development.js +244 -114
- package/cjs/react-reconciler-reflection.production.min.js +7 -6
- package/cjs/react-reconciler.development.js +5317 -3389
- package/cjs/react-reconciler.production.min.js +176 -164
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.23.0
|
|
2
2
|
* react-reconciler-reflection.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -20,17 +20,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
20
20
|
var React = require('react');
|
|
21
21
|
|
|
22
22
|
// Do not require this module directly! Use normal `invariant` calls with
|
|
23
|
-
// template literal strings. The messages will be
|
|
24
|
-
// build
|
|
25
|
-
|
|
26
|
-
// Do not require this module directly! Use normal `invariant` calls with
|
|
27
|
-
// template literal strings. The messages will be converted to ReactError during
|
|
28
|
-
// build, and in production they will be minified.
|
|
29
|
-
|
|
30
|
-
function ReactError(error) {
|
|
31
|
-
error.name = 'Invariant Violation';
|
|
32
|
-
return error;
|
|
33
|
-
}
|
|
23
|
+
// template literal strings. The messages will be replaced with error codes
|
|
24
|
+
// during build.
|
|
34
25
|
|
|
35
26
|
/**
|
|
36
27
|
* Use invariant() to assert state which your program assumes to be true.
|
|
@@ -49,35 +40,37 @@ function ReactError(error) {
|
|
|
49
40
|
* paths. Removing the logging code for production environments will keep the
|
|
50
41
|
* same logic and follow the same code paths.
|
|
51
42
|
*/
|
|
52
|
-
|
|
53
43
|
var warningWithoutStack = function () {};
|
|
54
44
|
|
|
55
45
|
{
|
|
56
46
|
warningWithoutStack = function (condition, format) {
|
|
57
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
47
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
58
48
|
args[_key - 2] = arguments[_key];
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
if (format === undefined) {
|
|
62
52
|
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
63
53
|
}
|
|
54
|
+
|
|
64
55
|
if (args.length > 8) {
|
|
65
56
|
// Check before the condition to catch violations early.
|
|
66
57
|
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
67
58
|
}
|
|
59
|
+
|
|
68
60
|
if (condition) {
|
|
69
61
|
return;
|
|
70
62
|
}
|
|
63
|
+
|
|
71
64
|
if (typeof console !== 'undefined') {
|
|
72
65
|
var argsWithFormat = args.map(function (item) {
|
|
73
66
|
return '' + item;
|
|
74
67
|
});
|
|
75
|
-
argsWithFormat.unshift('Warning: ' + format);
|
|
76
|
-
|
|
77
|
-
// We intentionally don't use spread (or .apply) directly because it
|
|
68
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
78
69
|
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
70
|
+
|
|
79
71
|
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
80
72
|
}
|
|
73
|
+
|
|
81
74
|
try {
|
|
82
75
|
// --- Welcome to debugging React ---
|
|
83
76
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -109,21 +102,20 @@ var warningWithoutStack$1 = warningWithoutStack;
|
|
|
109
102
|
* supported we can rename it.
|
|
110
103
|
*/
|
|
111
104
|
|
|
112
|
-
|
|
113
105
|
function get(key) {
|
|
114
106
|
return key._reactInternalFiber;
|
|
115
107
|
}
|
|
116
108
|
|
|
117
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
118
|
-
|
|
119
|
-
// Prevent newer renderers from RTE when used with older react package versions.
|
|
109
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
|
|
120
110
|
// Current owner and dispatcher used to share the same ref,
|
|
121
111
|
// but PR #14548 split them out to better support the react-debug-tools package.
|
|
112
|
+
|
|
122
113
|
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
|
123
114
|
ReactSharedInternals.ReactCurrentDispatcher = {
|
|
124
115
|
current: null
|
|
125
116
|
};
|
|
126
117
|
}
|
|
118
|
+
|
|
127
119
|
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
128
120
|
ReactSharedInternals.ReactCurrentBatchConfig = {
|
|
129
121
|
suspense: null
|
|
@@ -134,25 +126,27 @@ if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
|
|
134
126
|
// nor polyfill, then a plain number is used for performance.
|
|
135
127
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
136
128
|
|
|
137
|
-
|
|
138
129
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
139
130
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
140
131
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
141
132
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
142
133
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
143
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
144
|
-
// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
134
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
145
135
|
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
146
136
|
|
|
147
137
|
|
|
138
|
+
|
|
148
139
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
149
140
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
150
141
|
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
151
142
|
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
152
143
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
153
144
|
|
|
154
|
-
|
|
145
|
+
{
|
|
146
|
+
|
|
147
|
+
}
|
|
155
148
|
|
|
149
|
+
var Resolved = 1;
|
|
156
150
|
|
|
157
151
|
function refineResolvedLazyComponent(lazyComponent) {
|
|
158
152
|
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
@@ -160,7 +154,7 @@ function refineResolvedLazyComponent(lazyComponent) {
|
|
|
160
154
|
|
|
161
155
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
162
156
|
var functionName = innerType.displayName || innerType.name || '';
|
|
163
|
-
return outerType.displayName || (functionName !== '' ? wrapperName +
|
|
157
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
164
158
|
}
|
|
165
159
|
|
|
166
160
|
function getComponentName(type) {
|
|
@@ -168,59 +162,79 @@ function getComponentName(type) {
|
|
|
168
162
|
// Host root, text node or just invalid type.
|
|
169
163
|
return null;
|
|
170
164
|
}
|
|
165
|
+
|
|
171
166
|
{
|
|
172
167
|
if (typeof type.tag === 'number') {
|
|
173
168
|
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
174
169
|
}
|
|
175
170
|
}
|
|
171
|
+
|
|
176
172
|
if (typeof type === 'function') {
|
|
177
173
|
return type.displayName || type.name || null;
|
|
178
174
|
}
|
|
175
|
+
|
|
179
176
|
if (typeof type === 'string') {
|
|
180
177
|
return type;
|
|
181
178
|
}
|
|
179
|
+
|
|
182
180
|
switch (type) {
|
|
183
181
|
case REACT_FRAGMENT_TYPE:
|
|
184
182
|
return 'Fragment';
|
|
183
|
+
|
|
185
184
|
case REACT_PORTAL_TYPE:
|
|
186
185
|
return 'Portal';
|
|
186
|
+
|
|
187
187
|
case REACT_PROFILER_TYPE:
|
|
188
|
-
return
|
|
188
|
+
return "Profiler";
|
|
189
|
+
|
|
189
190
|
case REACT_STRICT_MODE_TYPE:
|
|
190
191
|
return 'StrictMode';
|
|
192
|
+
|
|
191
193
|
case REACT_SUSPENSE_TYPE:
|
|
192
194
|
return 'Suspense';
|
|
195
|
+
|
|
193
196
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
194
197
|
return 'SuspenseList';
|
|
195
198
|
}
|
|
199
|
+
|
|
196
200
|
if (typeof type === 'object') {
|
|
197
201
|
switch (type.$$typeof) {
|
|
198
202
|
case REACT_CONTEXT_TYPE:
|
|
199
203
|
return 'Context.Consumer';
|
|
204
|
+
|
|
200
205
|
case REACT_PROVIDER_TYPE:
|
|
201
206
|
return 'Context.Provider';
|
|
207
|
+
|
|
202
208
|
case REACT_FORWARD_REF_TYPE:
|
|
203
209
|
return getWrappedName(type, type.render, 'ForwardRef');
|
|
210
|
+
|
|
204
211
|
case REACT_MEMO_TYPE:
|
|
205
212
|
return getComponentName(type.type);
|
|
213
|
+
|
|
206
214
|
case REACT_LAZY_TYPE:
|
|
207
215
|
{
|
|
208
216
|
var thenable = type;
|
|
209
217
|
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
218
|
+
|
|
210
219
|
if (resolvedThenable) {
|
|
211
220
|
return getComponentName(resolvedThenable);
|
|
212
221
|
}
|
|
222
|
+
|
|
213
223
|
break;
|
|
214
224
|
}
|
|
215
225
|
}
|
|
216
226
|
}
|
|
227
|
+
|
|
217
228
|
return null;
|
|
218
229
|
}
|
|
219
230
|
|
|
220
231
|
var ClassComponent = 1;
|
|
221
232
|
// Before we know whether it is function or class
|
|
233
|
+
|
|
222
234
|
var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
|
|
235
|
+
|
|
223
236
|
var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
|
|
237
|
+
|
|
224
238
|
var HostComponent = 5;
|
|
225
239
|
var HostText = 6;
|
|
226
240
|
|
|
@@ -229,7 +243,7 @@ var HostText = 6;
|
|
|
229
243
|
|
|
230
244
|
|
|
231
245
|
|
|
232
|
-
|
|
246
|
+
var SuspenseComponent = 13;
|
|
233
247
|
|
|
234
248
|
|
|
235
249
|
|
|
@@ -239,11 +253,15 @@ var HostText = 6;
|
|
|
239
253
|
var FundamentalComponent = 20;
|
|
240
254
|
|
|
241
255
|
// Don't change these two values. They're used by React Dev Tools.
|
|
242
|
-
var NoEffect =
|
|
256
|
+
var NoEffect =
|
|
257
|
+
/* */
|
|
258
|
+
0;
|
|
259
|
+
// You can change the rest (and add more).
|
|
243
260
|
|
|
261
|
+
var Placement =
|
|
262
|
+
/* */
|
|
263
|
+
2;
|
|
244
264
|
|
|
245
|
-
// You can change the rest (and add more).
|
|
246
|
-
var Placement = /* */2;
|
|
247
265
|
|
|
248
266
|
|
|
249
267
|
|
|
@@ -252,55 +270,136 @@ var Placement = /* */2;
|
|
|
252
270
|
|
|
253
271
|
|
|
254
272
|
|
|
273
|
+
var Hydrating =
|
|
274
|
+
/* */
|
|
275
|
+
1024;
|
|
276
|
+
// Passive & Update & Callback & Ref & Snapshot
|
|
255
277
|
|
|
278
|
+
// Union of all host effects
|
|
256
279
|
|
|
257
|
-
//
|
|
280
|
+
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
258
281
|
|
|
282
|
+
// In some cases, StrictMode should also double-render lifecycles.
|
|
283
|
+
// This can be confusing for tests though,
|
|
284
|
+
// And it can be bad for performance in production.
|
|
285
|
+
// This feature flag can be used to control the behavior:
|
|
259
286
|
|
|
260
|
-
//
|
|
287
|
+
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
288
|
+
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
261
289
|
|
|
262
|
-
|
|
290
|
+
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
291
|
+
|
|
292
|
+
// Gather advanced timing metrics for Profiler subtrees.
|
|
263
293
|
|
|
264
|
-
|
|
265
|
-
var MOUNTED = 2;
|
|
266
|
-
var UNMOUNTED = 3;
|
|
294
|
+
// Trace which interactions trigger each commit.
|
|
267
295
|
|
|
268
|
-
|
|
296
|
+
// SSR experiments
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
// Only used in www builds.
|
|
300
|
+
|
|
301
|
+
// Only used in www builds.
|
|
302
|
+
|
|
303
|
+
// Disable javascript: URL strings in href for XSS protection.
|
|
304
|
+
|
|
305
|
+
// React Fire: prevent the value and checked attributes from syncing
|
|
306
|
+
// with their related DOM properties
|
|
307
|
+
|
|
308
|
+
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
309
|
+
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// Experimental React Flare event system and event components support.
|
|
313
|
+
|
|
314
|
+
// Experimental Host Component support.
|
|
315
|
+
|
|
316
|
+
var enableFundamentalAPI = false; // Experimental Scope support.
|
|
317
|
+
|
|
318
|
+
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
319
|
+
|
|
320
|
+
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
|
|
321
|
+
// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
|
|
322
|
+
|
|
323
|
+
// For tests, we flush suspense fallbacks in an act scope;
|
|
324
|
+
// *except* in some of our own tests, where we test incremental loading states.
|
|
325
|
+
|
|
326
|
+
// Add a callback property to suspense to notify which promises are currently
|
|
327
|
+
// in the update queue. This allows reporting and tracing of what is causing
|
|
328
|
+
// the user to see a loading state.
|
|
329
|
+
// Also allows hydration callbacks to fire when a dehydrated boundary gets
|
|
330
|
+
// hydrated or deleted.
|
|
331
|
+
|
|
332
|
+
// Part of the simplification of React.createElement so we can eventually move
|
|
333
|
+
// from React.createElement to React.jsx
|
|
334
|
+
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
|
335
|
+
|
|
336
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
337
|
+
function getNearestMountedFiber(fiber) {
|
|
269
338
|
var node = fiber;
|
|
339
|
+
var nearestMounted = fiber;
|
|
340
|
+
|
|
270
341
|
if (!fiber.alternate) {
|
|
271
342
|
// If there is no alternate, this might be a new tree that isn't inserted
|
|
272
343
|
// yet. If it is, then it will have a pending insertion effect on it.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if ((node.effectTag & Placement) !== NoEffect) {
|
|
279
|
-
|
|
344
|
+
var nextNode = node;
|
|
345
|
+
|
|
346
|
+
do {
|
|
347
|
+
node = nextNode;
|
|
348
|
+
|
|
349
|
+
if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
|
|
350
|
+
// This is an insertion or in-progress hydration. The nearest possible
|
|
351
|
+
// mounted fiber is the parent but we need to continue to figure out
|
|
352
|
+
// if that one is still mounted.
|
|
353
|
+
nearestMounted = node.return;
|
|
280
354
|
}
|
|
281
|
-
|
|
355
|
+
|
|
356
|
+
nextNode = node.return;
|
|
357
|
+
} while (nextNode);
|
|
282
358
|
} else {
|
|
283
359
|
while (node.return) {
|
|
284
360
|
node = node.return;
|
|
285
361
|
}
|
|
286
362
|
}
|
|
363
|
+
|
|
287
364
|
if (node.tag === HostRoot) {
|
|
288
365
|
// TODO: Check if this was a nested HostRoot when used with
|
|
289
366
|
// renderContainerIntoSubtree.
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
// If we didn't hit the root, that means that we're in an disconnected tree
|
|
367
|
+
return nearestMounted;
|
|
368
|
+
} // If we didn't hit the root, that means that we're in an disconnected tree
|
|
293
369
|
// that has been unmounted.
|
|
294
|
-
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
return null;
|
|
295
373
|
}
|
|
374
|
+
function getSuspenseInstanceFromFiber(fiber) {
|
|
375
|
+
if (fiber.tag === SuspenseComponent) {
|
|
376
|
+
var suspenseState = fiber.memoizedState;
|
|
377
|
+
|
|
378
|
+
if (suspenseState === null) {
|
|
379
|
+
var current = fiber.alternate;
|
|
296
380
|
|
|
381
|
+
if (current !== null) {
|
|
382
|
+
suspenseState = current.memoizedState;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (suspenseState !== null) {
|
|
387
|
+
return suspenseState.dehydrated;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
function getContainerFromFiber(fiber) {
|
|
394
|
+
return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
|
|
395
|
+
}
|
|
297
396
|
function isFiberMounted(fiber) {
|
|
298
|
-
return
|
|
397
|
+
return getNearestMountedFiber(fiber) === fiber;
|
|
299
398
|
}
|
|
300
|
-
|
|
301
399
|
function isMounted(component) {
|
|
302
400
|
{
|
|
303
401
|
var owner = ReactCurrentOwner.current;
|
|
402
|
+
|
|
304
403
|
if (owner !== null && owner.tag === ClassComponent) {
|
|
305
404
|
var ownerFiber = owner;
|
|
306
405
|
var instance = ownerFiber.stateNode;
|
|
@@ -310,92 +409,103 @@ function isMounted(component) {
|
|
|
310
409
|
}
|
|
311
410
|
|
|
312
411
|
var fiber = get(component);
|
|
412
|
+
|
|
313
413
|
if (!fiber) {
|
|
314
414
|
return false;
|
|
315
415
|
}
|
|
316
|
-
|
|
416
|
+
|
|
417
|
+
return getNearestMountedFiber(fiber) === fiber;
|
|
317
418
|
}
|
|
318
419
|
|
|
319
420
|
function assertIsMounted(fiber) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
throw ReactError(Error('Unable to find node on an unmounted component.'));
|
|
324
|
-
}
|
|
421
|
+
if (!(getNearestMountedFiber(fiber) === fiber)) {
|
|
422
|
+
{
|
|
423
|
+
throw Error("Unable to find node on an unmounted component.");
|
|
325
424
|
}
|
|
326
|
-
}
|
|
425
|
+
}
|
|
327
426
|
}
|
|
328
427
|
|
|
329
428
|
function findCurrentFiberUsingSlowPath(fiber) {
|
|
330
429
|
var alternate = fiber.alternate;
|
|
430
|
+
|
|
331
431
|
if (!alternate) {
|
|
332
432
|
// If there is no alternate, then we only need to check if it is mounted.
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
433
|
+
var nearestMounted = getNearestMountedFiber(fiber);
|
|
434
|
+
|
|
435
|
+
if (!(nearestMounted !== null)) {
|
|
436
|
+
{
|
|
437
|
+
throw Error("Unable to find node on an unmounted component.");
|
|
339
438
|
}
|
|
340
|
-
}
|
|
341
|
-
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (nearestMounted !== fiber) {
|
|
342
442
|
return null;
|
|
343
443
|
}
|
|
444
|
+
|
|
344
445
|
return fiber;
|
|
345
|
-
}
|
|
346
|
-
// If we have two possible branches, we'll walk backwards up to the root
|
|
446
|
+
} // If we have two possible branches, we'll walk backwards up to the root
|
|
347
447
|
// to see what path the root points to. On the way we may hit one of the
|
|
348
448
|
// special cases and we'll deal with them.
|
|
449
|
+
|
|
450
|
+
|
|
349
451
|
var a = fiber;
|
|
350
452
|
var b = alternate;
|
|
453
|
+
|
|
351
454
|
while (true) {
|
|
352
455
|
var parentA = a.return;
|
|
456
|
+
|
|
353
457
|
if (parentA === null) {
|
|
354
458
|
// We're at the root.
|
|
355
459
|
break;
|
|
356
460
|
}
|
|
461
|
+
|
|
357
462
|
var parentB = parentA.alternate;
|
|
463
|
+
|
|
358
464
|
if (parentB === null) {
|
|
359
465
|
// There is no alternate. This is an unusual case. Currently, it only
|
|
360
466
|
// happens when a Suspense component is hidden. An extra fragment fiber
|
|
361
467
|
// is inserted in between the Suspense fiber and its children. Skip
|
|
362
468
|
// over this extra fragment fiber and proceed to the next parent.
|
|
363
469
|
var nextParent = parentA.return;
|
|
470
|
+
|
|
364
471
|
if (nextParent !== null) {
|
|
365
472
|
a = b = nextParent;
|
|
366
473
|
continue;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
break;
|
|
370
|
-
}
|
|
474
|
+
} // If there's no parent, we're at the root.
|
|
475
|
+
|
|
371
476
|
|
|
372
|
-
|
|
477
|
+
break;
|
|
478
|
+
} // If both copies of the parent fiber point to the same child, we can
|
|
373
479
|
// assume that the child is current. This happens when we bailout on low
|
|
374
480
|
// priority: the bailed out fiber's child reuses the current child.
|
|
481
|
+
|
|
482
|
+
|
|
375
483
|
if (parentA.child === parentB.child) {
|
|
376
484
|
var child = parentA.child;
|
|
485
|
+
|
|
377
486
|
while (child) {
|
|
378
487
|
if (child === a) {
|
|
379
488
|
// We've determined that A is the current branch.
|
|
380
489
|
assertIsMounted(parentA);
|
|
381
490
|
return fiber;
|
|
382
491
|
}
|
|
492
|
+
|
|
383
493
|
if (child === b) {
|
|
384
494
|
// We've determined that B is the current branch.
|
|
385
495
|
assertIsMounted(parentA);
|
|
386
496
|
return alternate;
|
|
387
497
|
}
|
|
498
|
+
|
|
388
499
|
child = child.sibling;
|
|
389
|
-
}
|
|
390
|
-
// We should never have an alternate for any mounting node. So the only
|
|
500
|
+
} // We should never have an alternate for any mounting node. So the only
|
|
391
501
|
// way this could possibly happen is if this was unmounted, if at all.
|
|
392
|
-
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
{
|
|
393
505
|
{
|
|
394
|
-
|
|
395
|
-
throw ReactError(Error('Unable to find node on an unmounted component.'));
|
|
396
|
-
}
|
|
506
|
+
throw Error("Unable to find node on an unmounted component.");
|
|
397
507
|
}
|
|
398
|
-
}
|
|
508
|
+
}
|
|
399
509
|
}
|
|
400
510
|
|
|
401
511
|
if (a.return !== b.return) {
|
|
@@ -413,6 +523,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|
|
413
523
|
// Search parent A's child set
|
|
414
524
|
var didFindChild = false;
|
|
415
525
|
var _child = parentA.child;
|
|
526
|
+
|
|
416
527
|
while (_child) {
|
|
417
528
|
if (_child === a) {
|
|
418
529
|
didFindChild = true;
|
|
@@ -420,17 +531,21 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|
|
420
531
|
b = parentB;
|
|
421
532
|
break;
|
|
422
533
|
}
|
|
534
|
+
|
|
423
535
|
if (_child === b) {
|
|
424
536
|
didFindChild = true;
|
|
425
537
|
b = parentA;
|
|
426
538
|
a = parentB;
|
|
427
539
|
break;
|
|
428
540
|
}
|
|
541
|
+
|
|
429
542
|
_child = _child.sibling;
|
|
430
543
|
}
|
|
544
|
+
|
|
431
545
|
if (!didFindChild) {
|
|
432
546
|
// Search parent B's child set
|
|
433
547
|
_child = parentB.child;
|
|
548
|
+
|
|
434
549
|
while (_child) {
|
|
435
550
|
if (_child === a) {
|
|
436
551
|
didFindChild = true;
|
|
@@ -438,57 +553,58 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|
|
438
553
|
b = parentA;
|
|
439
554
|
break;
|
|
440
555
|
}
|
|
556
|
+
|
|
441
557
|
if (_child === b) {
|
|
442
558
|
didFindChild = true;
|
|
443
559
|
b = parentB;
|
|
444
560
|
a = parentA;
|
|
445
561
|
break;
|
|
446
562
|
}
|
|
563
|
+
|
|
447
564
|
_child = _child.sibling;
|
|
448
565
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
566
|
+
|
|
567
|
+
if (!didFindChild) {
|
|
568
|
+
{
|
|
569
|
+
throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
|
|
454
570
|
}
|
|
455
|
-
}
|
|
571
|
+
}
|
|
456
572
|
}
|
|
457
573
|
}
|
|
458
574
|
|
|
459
|
-
(
|
|
460
|
-
if (!(a.alternate === b)) {
|
|
461
|
-
{
|
|
462
|
-
throw ReactError(Error('Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.'));
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
})();
|
|
466
|
-
}
|
|
467
|
-
// If the root is not a host container, we're in a disconnected tree. I.e.
|
|
468
|
-
// unmounted.
|
|
469
|
-
(function () {
|
|
470
|
-
if (!(a.tag === HostRoot)) {
|
|
575
|
+
if (!(a.alternate === b)) {
|
|
471
576
|
{
|
|
472
|
-
throw
|
|
577
|
+
throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
|
|
473
578
|
}
|
|
474
579
|
}
|
|
475
|
-
}
|
|
580
|
+
} // If the root is not a host container, we're in a disconnected tree. I.e.
|
|
581
|
+
// unmounted.
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
if (!(a.tag === HostRoot)) {
|
|
585
|
+
{
|
|
586
|
+
throw Error("Unable to find node on an unmounted component.");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
476
590
|
if (a.stateNode.current === a) {
|
|
477
591
|
// We've determined that A is the current branch.
|
|
478
592
|
return fiber;
|
|
479
|
-
}
|
|
480
|
-
|
|
593
|
+
} // Otherwise B has to be current branch.
|
|
594
|
+
|
|
595
|
+
|
|
481
596
|
return alternate;
|
|
482
597
|
}
|
|
483
|
-
|
|
484
598
|
function findCurrentHostFiber(parent) {
|
|
485
599
|
var currentParent = findCurrentFiberUsingSlowPath(parent);
|
|
600
|
+
|
|
486
601
|
if (!currentParent) {
|
|
487
602
|
return null;
|
|
488
|
-
}
|
|
603
|
+
} // Next we'll drill down this component to find the first HostComponent/Text.
|
|
604
|
+
|
|
489
605
|
|
|
490
|
-
// Next we'll drill down this component to find the first HostComponent/Text.
|
|
491
606
|
var node = currentParent;
|
|
607
|
+
|
|
492
608
|
while (true) {
|
|
493
609
|
if (node.tag === HostComponent || node.tag === HostText) {
|
|
494
610
|
return node;
|
|
@@ -497,56 +613,70 @@ function findCurrentHostFiber(parent) {
|
|
|
497
613
|
node = node.child;
|
|
498
614
|
continue;
|
|
499
615
|
}
|
|
616
|
+
|
|
500
617
|
if (node === currentParent) {
|
|
501
618
|
return null;
|
|
502
619
|
}
|
|
620
|
+
|
|
503
621
|
while (!node.sibling) {
|
|
504
622
|
if (!node.return || node.return === currentParent) {
|
|
505
623
|
return null;
|
|
506
624
|
}
|
|
625
|
+
|
|
507
626
|
node = node.return;
|
|
508
627
|
}
|
|
628
|
+
|
|
509
629
|
node.sibling.return = node.return;
|
|
510
630
|
node = node.sibling;
|
|
511
|
-
}
|
|
512
|
-
// Flow needs the return null here, but ESLint complains about it.
|
|
631
|
+
} // Flow needs the return null here, but ESLint complains about it.
|
|
513
632
|
// eslint-disable-next-line no-unreachable
|
|
633
|
+
|
|
634
|
+
|
|
514
635
|
return null;
|
|
515
636
|
}
|
|
516
|
-
|
|
517
637
|
function findCurrentHostFiberWithNoPortals(parent) {
|
|
518
638
|
var currentParent = findCurrentFiberUsingSlowPath(parent);
|
|
639
|
+
|
|
519
640
|
if (!currentParent) {
|
|
520
641
|
return null;
|
|
521
|
-
}
|
|
642
|
+
} // Next we'll drill down this component to find the first HostComponent/Text.
|
|
643
|
+
|
|
522
644
|
|
|
523
|
-
// Next we'll drill down this component to find the first HostComponent/Text.
|
|
524
645
|
var node = currentParent;
|
|
646
|
+
|
|
525
647
|
while (true) {
|
|
526
|
-
if (node.tag === HostComponent || node.tag === HostText || node.tag === FundamentalComponent) {
|
|
648
|
+
if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
|
|
527
649
|
return node;
|
|
528
650
|
} else if (node.child && node.tag !== HostPortal) {
|
|
529
651
|
node.child.return = node;
|
|
530
652
|
node = node.child;
|
|
531
653
|
continue;
|
|
532
654
|
}
|
|
655
|
+
|
|
533
656
|
if (node === currentParent) {
|
|
534
657
|
return null;
|
|
535
658
|
}
|
|
659
|
+
|
|
536
660
|
while (!node.sibling) {
|
|
537
661
|
if (!node.return || node.return === currentParent) {
|
|
538
662
|
return null;
|
|
539
663
|
}
|
|
664
|
+
|
|
540
665
|
node = node.return;
|
|
541
666
|
}
|
|
667
|
+
|
|
542
668
|
node.sibling.return = node.return;
|
|
543
669
|
node = node.sibling;
|
|
544
|
-
}
|
|
545
|
-
// Flow needs the return null here, but ESLint complains about it.
|
|
670
|
+
} // Flow needs the return null here, but ESLint complains about it.
|
|
546
671
|
// eslint-disable-next-line no-unreachable
|
|
672
|
+
|
|
673
|
+
|
|
547
674
|
return null;
|
|
548
675
|
}
|
|
549
676
|
|
|
677
|
+
exports.getNearestMountedFiber = getNearestMountedFiber;
|
|
678
|
+
exports.getSuspenseInstanceFromFiber = getSuspenseInstanceFromFiber;
|
|
679
|
+
exports.getContainerFromFiber = getContainerFromFiber;
|
|
550
680
|
exports.isFiberMounted = isFiberMounted;
|
|
551
681
|
exports.isMounted = isMounted;
|
|
552
682
|
exports.findCurrentFiberUsingSlowPath = findCurrentFiberUsingSlowPath;
|