react-dom 17.0.0-rc.2 → 17.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v17.0.0-rc.2
1
+ /** @license React v17.0.2
2
2
  * react-dom.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -4148,7 +4148,7 @@
4148
4148
 
4149
4149
  // Don't change these two values. They're used by React Dev Tools.
4150
4150
  var NoFlags =
4151
- /* */
4151
+ /* */
4152
4152
  0;
4153
4153
  var PerformedWork =
4154
4154
  /* */
@@ -4184,6 +4184,10 @@
4184
4184
  var Passive =
4185
4185
  /* */
4186
4186
  512; // TODO (effects) Remove this bit once the new reconciler is synced to the old.
4187
+
4188
+ var PassiveUnmountPendingDev =
4189
+ /* */
4190
+ 8192;
4187
4191
  var Hydrating =
4188
4192
  /* */
4189
4193
  1024;
@@ -4208,33 +4212,6 @@
4208
4212
  var ForceUpdateForLegacySuspense =
4209
4213
  /* */
4210
4214
  16384; // Static tags describe aspects of a fiber that are not specific to a render,
4211
- // e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
4212
- // This enables us to defer more work in the unmount case,
4213
- // since we can defer traversing the tree during layout to look for Passive effects,
4214
- // and instead rely on the static flag as a signal that there may be cleanup work.
4215
-
4216
- var PassiveStatic =
4217
- /* */
4218
- 32768; // Union of side effect groupings as pertains to subtreeFlags
4219
-
4220
- var BeforeMutationMask =
4221
- /* */
4222
- 778;
4223
- var MutationMask =
4224
- /* */
4225
- 1182;
4226
- var LayoutMask =
4227
- /* */
4228
- 164;
4229
- var PassiveMask =
4230
- /* */
4231
- 520; // Union of tags that don't get reset on clones.
4232
- // This allows certain concepts to persist without recalculting them,
4233
- // e.g. whether a subtree contains passive effects or portals.
4234
-
4235
- var StaticMask =
4236
- /* */
4237
- 32768;
4238
4215
 
4239
4216
  var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
4240
4217
  function getNearestMountedFiber(fiber) {
@@ -5790,7 +5767,15 @@
5790
5767
  return a !== NoLane && a < b ? a : b;
5791
5768
  }
5792
5769
  function createLaneMap(initial) {
5793
- return new Array(TotalLanes).fill(initial);
5770
+ // Intentionally pushing one by one.
5771
+ // https://v8.dev/blog/elements-kinds#avoid-creating-holes
5772
+ var laneMap = [];
5773
+
5774
+ for (var i = 0; i < TotalLanes; i++) {
5775
+ laneMap.push(initial);
5776
+ }
5777
+
5778
+ return laneMap;
5794
5779
  }
5795
5780
  function markRootUpdated(root, updateLane, eventTime) {
5796
5781
  root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But
@@ -5831,9 +5816,6 @@
5831
5816
  function markRootPinged(root, pingedLanes, eventTime) {
5832
5817
  root.pingedLanes |= root.suspendedLanes & pingedLanes;
5833
5818
  }
5834
- function markRootExpired(root, expiredLanes) {
5835
- root.expiredLanes |= expiredLanes & root.pendingLanes;
5836
- }
5837
5819
  function markDiscreteUpdatesExpired(root) {
5838
5820
  root.expiredLanes |= InputDiscreteLanes & root.pendingLanes;
5839
5821
  }
@@ -6179,136 +6161,144 @@
6179
6161
  return 0;
6180
6162
  }
6181
6163
 
6182
- /**
6183
- * @interface Event
6184
- * @see http://www.w3.org/TR/DOM-Level-3-Events/
6185
- */
6186
- var EventInterface = {
6187
- eventPhase: 0,
6188
- bubbles: 0,
6189
- cancelable: 0,
6190
- timeStamp: function (event) {
6191
- return event.timeStamp || Date.now();
6192
- },
6193
- defaultPrevented: 0,
6194
- isTrusted: 0
6195
- };
6196
-
6197
6164
  function functionThatReturnsTrue() {
6198
6165
  return true;
6199
6166
  }
6200
6167
 
6201
6168
  function functionThatReturnsFalse() {
6202
6169
  return false;
6203
- }
6204
- /**
6205
- * Synthetic events are dispatched by event plugins, typically in response to a
6206
- * top-level event delegation handler.
6207
- *
6208
- * These systems should generally use pooling to reduce the frequency of garbage
6209
- * collection. The system should check `isPersistent` to determine whether the
6210
- * event should be released into the pool after being dispatched. Users that
6211
- * need a persisted event should invoke `persist`.
6212
- *
6213
- * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
6214
- * normalizing browser quirks. Subclasses do not necessarily have to implement a
6215
- * DOM interface; custom application-specific events can also subclass this.
6216
- */
6170
+ } // This is intentionally a factory so that we have different returned constructors.
6171
+ // If we had a single constructor, it would be megamorphic and engines would deopt.
6217
6172
 
6218
6173
 
6219
- function SyntheticEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
6220
- var Interface = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : EventInterface;
6221
- this._reactName = reactName;
6222
- this._targetInst = targetInst;
6223
- this.type = reactEventType;
6224
- this.nativeEvent = nativeEvent;
6225
- this.target = nativeEventTarget;
6226
- this.currentTarget = null;
6174
+ function createSyntheticEvent(Interface) {
6175
+ /**
6176
+ * Synthetic events are dispatched by event plugins, typically in response to a
6177
+ * top-level event delegation handler.
6178
+ *
6179
+ * These systems should generally use pooling to reduce the frequency of garbage
6180
+ * collection. The system should check `isPersistent` to determine whether the
6181
+ * event should be released into the pool after being dispatched. Users that
6182
+ * need a persisted event should invoke `persist`.
6183
+ *
6184
+ * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
6185
+ * normalizing browser quirks. Subclasses do not necessarily have to implement a
6186
+ * DOM interface; custom application-specific events can also subclass this.
6187
+ */
6188
+ function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
6189
+ this._reactName = reactName;
6190
+ this._targetInst = targetInst;
6191
+ this.type = reactEventType;
6192
+ this.nativeEvent = nativeEvent;
6193
+ this.target = nativeEventTarget;
6194
+ this.currentTarget = null;
6195
+
6196
+ for (var _propName in Interface) {
6197
+ if (!Interface.hasOwnProperty(_propName)) {
6198
+ continue;
6199
+ }
6200
+
6201
+ var normalize = Interface[_propName];
6227
6202
 
6228
- for (var _propName in Interface) {
6229
- if (!Interface.hasOwnProperty(_propName)) {
6230
- continue;
6203
+ if (normalize) {
6204
+ this[_propName] = normalize(nativeEvent);
6205
+ } else {
6206
+ this[_propName] = nativeEvent[_propName];
6207
+ }
6231
6208
  }
6232
6209
 
6233
- var normalize = Interface[_propName];
6210
+ var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
6234
6211
 
6235
- if (normalize) {
6236
- this[_propName] = normalize(nativeEvent);
6212
+ if (defaultPrevented) {
6213
+ this.isDefaultPrevented = functionThatReturnsTrue;
6237
6214
  } else {
6238
- this[_propName] = nativeEvent[_propName];
6215
+ this.isDefaultPrevented = functionThatReturnsFalse;
6239
6216
  }
6217
+
6218
+ this.isPropagationStopped = functionThatReturnsFalse;
6219
+ return this;
6240
6220
  }
6241
6221
 
6242
- var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
6222
+ _assign(SyntheticBaseEvent.prototype, {
6223
+ preventDefault: function () {
6224
+ this.defaultPrevented = true;
6225
+ var event = this.nativeEvent;
6243
6226
 
6244
- if (defaultPrevented) {
6245
- this.isDefaultPrevented = functionThatReturnsTrue;
6246
- } else {
6247
- this.isDefaultPrevented = functionThatReturnsFalse;
6248
- }
6227
+ if (!event) {
6228
+ return;
6229
+ }
6249
6230
 
6250
- this.isPropagationStopped = functionThatReturnsFalse;
6251
- return this;
6252
- }
6231
+ if (event.preventDefault) {
6232
+ event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
6233
+ } else if (typeof event.returnValue !== 'unknown') {
6234
+ event.returnValue = false;
6235
+ }
6253
6236
 
6254
- _assign(SyntheticEvent.prototype, {
6255
- preventDefault: function () {
6256
- this.defaultPrevented = true;
6257
- var event = this.nativeEvent;
6237
+ this.isDefaultPrevented = functionThatReturnsTrue;
6238
+ },
6239
+ stopPropagation: function () {
6240
+ var event = this.nativeEvent;
6258
6241
 
6259
- if (!event) {
6260
- return;
6261
- }
6242
+ if (!event) {
6243
+ return;
6244
+ }
6262
6245
 
6263
- if (event.preventDefault) {
6264
- event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
6265
- } else if (typeof event.returnValue !== 'unknown') {
6266
- event.returnValue = false;
6267
- }
6246
+ if (event.stopPropagation) {
6247
+ event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE
6248
+ } else if (typeof event.cancelBubble !== 'unknown') {
6249
+ // The ChangeEventPlugin registers a "propertychange" event for
6250
+ // IE. This event does not support bubbling or cancelling, and
6251
+ // any references to cancelBubble throw "Member not found". A
6252
+ // typeof check of "unknown" circumvents this issue (and is also
6253
+ // IE specific).
6254
+ event.cancelBubble = true;
6255
+ }
6268
6256
 
6269
- this.isDefaultPrevented = functionThatReturnsTrue;
6270
- },
6271
- stopPropagation: function () {
6272
- var event = this.nativeEvent;
6257
+ this.isPropagationStopped = functionThatReturnsTrue;
6258
+ },
6273
6259
 
6274
- if (!event) {
6275
- return;
6276
- }
6260
+ /**
6261
+ * We release all dispatched `SyntheticEvent`s after each event loop, adding
6262
+ * them back into the pool. This allows a way to hold onto a reference that
6263
+ * won't be added back into the pool.
6264
+ */
6265
+ persist: function () {// Modern event system doesn't use pooling.
6266
+ },
6277
6267
 
6278
- if (event.stopPropagation) {
6279
- event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE
6280
- } else if (typeof event.cancelBubble !== 'unknown') {
6281
- // The ChangeEventPlugin registers a "propertychange" event for
6282
- // IE. This event does not support bubbling or cancelling, and
6283
- // any references to cancelBubble throw "Member not found". A
6284
- // typeof check of "unknown" circumvents this issue (and is also
6285
- // IE specific).
6286
- event.cancelBubble = true;
6287
- }
6268
+ /**
6269
+ * Checks if this event should be released back into the pool.
6270
+ *
6271
+ * @return {boolean} True if this should not be released, false otherwise.
6272
+ */
6273
+ isPersistent: functionThatReturnsTrue
6274
+ });
6288
6275
 
6289
- this.isPropagationStopped = functionThatReturnsTrue;
6290
- },
6276
+ return SyntheticBaseEvent;
6277
+ }
6278
+ /**
6279
+ * @interface Event
6280
+ * @see http://www.w3.org/TR/DOM-Level-3-Events/
6281
+ */
6291
6282
 
6292
- /**
6293
- * We release all dispatched `SyntheticEvent`s after each event loop, adding
6294
- * them back into the pool. This allows a way to hold onto a reference that
6295
- * won't be added back into the pool.
6296
- */
6297
- persist: function () {// Modern event system doesn't use pooling.
6298
- },
6299
6283
 
6300
- /**
6301
- * Checks if this event should be released back into the pool.
6302
- *
6303
- * @return {boolean} True if this should not be released, false otherwise.
6304
- */
6305
- isPersistent: functionThatReturnsTrue
6306
- });
6284
+ var EventInterface = {
6285
+ eventPhase: 0,
6286
+ bubbles: 0,
6287
+ cancelable: 0,
6288
+ timeStamp: function (event) {
6289
+ return event.timeStamp || Date.now();
6290
+ },
6291
+ defaultPrevented: 0,
6292
+ isTrusted: 0
6293
+ };
6294
+ var SyntheticEvent = createSyntheticEvent(EventInterface);
6307
6295
 
6308
6296
  var UIEventInterface = _assign({}, EventInterface, {
6309
6297
  view: 0,
6310
6298
  detail: 0
6311
6299
  });
6300
+
6301
+ var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
6312
6302
  var lastMovementX;
6313
6303
  var lastMovementY;
6314
6304
  var lastMouseEvent;
@@ -6369,6 +6359,8 @@
6369
6359
  return lastMovementY;
6370
6360
  }
6371
6361
  });
6362
+
6363
+ var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
6372
6364
  /**
6373
6365
  * @interface DragEvent
6374
6366
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -6377,6 +6369,8 @@
6377
6369
  var DragEventInterface = _assign({}, MouseEventInterface, {
6378
6370
  dataTransfer: 0
6379
6371
  });
6372
+
6373
+ var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
6380
6374
  /**
6381
6375
  * @interface FocusEvent
6382
6376
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -6385,6 +6379,8 @@
6385
6379
  var FocusEventInterface = _assign({}, UIEventInterface, {
6386
6380
  relatedTarget: 0
6387
6381
  });
6382
+
6383
+ var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
6388
6384
  /**
6389
6385
  * @interface Event
6390
6386
  * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
@@ -6396,6 +6392,8 @@
6396
6392
  elapsedTime: 0,
6397
6393
  pseudoElement: 0
6398
6394
  });
6395
+
6396
+ var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
6399
6397
  /**
6400
6398
  * @interface Event
6401
6399
  * @see http://www.w3.org/TR/clipboard-apis/
@@ -6406,6 +6404,8 @@
6406
6404
  return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
6407
6405
  }
6408
6406
  });
6407
+
6408
+ var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
6409
6409
  /**
6410
6410
  * @interface Event
6411
6411
  * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
@@ -6414,6 +6414,8 @@
6414
6414
  var CompositionEventInterface = _assign({}, EventInterface, {
6415
6415
  data: 0
6416
6416
  });
6417
+
6418
+ var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
6417
6419
  /**
6418
6420
  * @interface Event
6419
6421
  * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
@@ -6421,7 +6423,7 @@
6421
6423
  */
6422
6424
  // Happens to share the same list for now.
6423
6425
 
6424
- var InputEventInterface = CompositionEventInterface;
6426
+ var SyntheticInputEvent = SyntheticCompositionEvent;
6425
6427
  /**
6426
6428
  * Normalization of deprecated HTML5 `key` values
6427
6429
  * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
@@ -6605,6 +6607,8 @@
6605
6607
  return 0;
6606
6608
  }
6607
6609
  });
6610
+
6611
+ var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
6608
6612
  /**
6609
6613
  * @interface PointerEvent
6610
6614
  * @see http://www.w3.org/TR/pointerevents/
@@ -6622,6 +6626,8 @@
6622
6626
  pointerType: 0,
6623
6627
  isPrimary: 0
6624
6628
  });
6629
+
6630
+ var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
6625
6631
  /**
6626
6632
  * @interface TouchEvent
6627
6633
  * @see http://www.w3.org/TR/touch-events/
@@ -6637,6 +6643,8 @@
6637
6643
  shiftKey: 0,
6638
6644
  getModifierState: getEventModifierState
6639
6645
  });
6646
+
6647
+ var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
6640
6648
  /**
6641
6649
  * @interface Event
6642
6650
  * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
@@ -6648,6 +6656,8 @@
6648
6656
  elapsedTime: 0,
6649
6657
  pseudoElement: 0
6650
6658
  });
6659
+
6660
+ var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
6651
6661
  /**
6652
6662
  * @interface WheelEvent
6653
6663
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
@@ -6671,6 +6681,8 @@
6671
6681
  deltaMode: 0
6672
6682
  });
6673
6683
 
6684
+ var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
6685
+
6674
6686
  var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
6675
6687
 
6676
6688
  var START_KEYCODE = 229;
@@ -6835,18 +6847,25 @@
6835
6847
  }
6836
6848
  }
6837
6849
 
6838
- var event = new SyntheticEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget, CompositionEventInterface);
6839
- accumulateTwoPhaseListeners(targetInst, dispatchQueue, event);
6850
+ var listeners = accumulateTwoPhaseListeners(targetInst, eventType);
6840
6851
 
6841
- if (fallbackData) {
6842
- // Inject data generated from fallback path into the synthetic event.
6843
- // This matches the property of native CompositionEventInterface.
6844
- event.data = fallbackData;
6845
- } else {
6846
- var customData = getDataFromCustomEvent(nativeEvent);
6852
+ if (listeners.length > 0) {
6853
+ var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget);
6854
+ dispatchQueue.push({
6855
+ event: event,
6856
+ listeners: listeners
6857
+ });
6847
6858
 
6848
- if (customData !== null) {
6849
- event.data = customData;
6859
+ if (fallbackData) {
6860
+ // Inject data generated from fallback path into the synthetic event.
6861
+ // This matches the property of native CompositionEventInterface.
6862
+ event.data = fallbackData;
6863
+ } else {
6864
+ var customData = getDataFromCustomEvent(nativeEvent);
6865
+
6866
+ if (customData !== null) {
6867
+ event.data = customData;
6868
+ }
6850
6869
  }
6851
6870
  }
6852
6871
  }
@@ -6988,9 +7007,16 @@
6988
7007
  return null;
6989
7008
  }
6990
7009
 
6991
- var event = new SyntheticEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget, InputEventInterface);
6992
- accumulateTwoPhaseListeners(targetInst, dispatchQueue, event);
6993
- event.data = chars;
7010
+ var listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput');
7011
+
7012
+ if (listeners.length > 0) {
7013
+ var event = new SyntheticInputEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget);
7014
+ dispatchQueue.push({
7015
+ event: event,
7016
+ listeners: listeners
7017
+ });
7018
+ event.data = chars;
7019
+ }
6994
7020
  }
6995
7021
  /**
6996
7022
  * Create an `onBeforeInput` event to match
@@ -7088,10 +7114,17 @@
7088
7114
  }
7089
7115
 
7090
7116
  function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) {
7091
- var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target); // Flag this event loop as needing state restore.
7092
-
7117
+ // Flag this event loop as needing state restore.
7093
7118
  enqueueStateRestore(target);
7094
- accumulateTwoPhaseListeners(inst, dispatchQueue, event);
7119
+ var listeners = accumulateTwoPhaseListeners(inst, 'onChange');
7120
+
7121
+ if (listeners.length > 0) {
7122
+ var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target);
7123
+ dispatchQueue.push({
7124
+ event: event,
7125
+ listeners: listeners
7126
+ });
7127
+ }
7095
7128
  }
7096
7129
  /**
7097
7130
  * For IE shims
@@ -7401,13 +7434,13 @@
7401
7434
  return;
7402
7435
  }
7403
7436
 
7404
- var eventInterface = MouseEventInterface;
7437
+ var SyntheticEventCtor = SyntheticMouseEvent;
7405
7438
  var leaveEventType = 'onMouseLeave';
7406
7439
  var enterEventType = 'onMouseEnter';
7407
7440
  var eventTypePrefix = 'mouse';
7408
7441
 
7409
7442
  if (domEventName === 'pointerout' || domEventName === 'pointerover') {
7410
- eventInterface = PointerEventInterface;
7443
+ SyntheticEventCtor = SyntheticPointerEvent;
7411
7444
  leaveEventType = 'onPointerLeave';
7412
7445
  enterEventType = 'onPointerEnter';
7413
7446
  eventTypePrefix = 'pointer';
@@ -7415,7 +7448,7 @@
7415
7448
 
7416
7449
  var fromNode = from == null ? win : getNodeFromInstance(from);
7417
7450
  var toNode = to == null ? win : getNodeFromInstance(to);
7418
- var leave = new SyntheticEvent(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget, eventInterface);
7451
+ var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget);
7419
7452
  leave.target = fromNode;
7420
7453
  leave.relatedTarget = toNode;
7421
7454
  var enter = null; // We should only process this nativeEvent if we are processing
@@ -7424,7 +7457,7 @@
7424
7457
  var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget);
7425
7458
 
7426
7459
  if (nativeTargetInst === targetInst) {
7427
- var enterEvent = new SyntheticEvent(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget, eventInterface);
7460
+ var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget);
7428
7461
  enterEvent.target = toNode;
7429
7462
  enterEvent.relatedTarget = fromNode;
7430
7463
  enter = enterEvent;
@@ -7957,9 +7990,16 @@
7957
7990
 
7958
7991
  if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
7959
7992
  lastSelection = currentSelection;
7960
- var syntheticEvent = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget);
7961
- syntheticEvent.target = activeElement$1;
7962
- accumulateTwoPhaseListeners(activeElementInst$1, dispatchQueue, syntheticEvent);
7993
+ var listeners = accumulateTwoPhaseListeners(activeElementInst$1, 'onSelect');
7994
+
7995
+ if (listeners.length > 0) {
7996
+ var event = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget);
7997
+ dispatchQueue.push({
7998
+ event: event,
7999
+ listeners: listeners
8000
+ });
8001
+ event.target = activeElement$1;
8002
+ }
7963
8003
  }
7964
8004
  }
7965
8005
  /**
@@ -8041,7 +8081,7 @@
8041
8081
  return;
8042
8082
  }
8043
8083
 
8044
- var EventInterface;
8084
+ var SyntheticEventCtor = SyntheticEvent;
8045
8085
  var reactEventType = domEventName;
8046
8086
 
8047
8087
  switch (domEventName) {
@@ -8057,22 +8097,22 @@
8057
8097
 
8058
8098
  case 'keydown':
8059
8099
  case 'keyup':
8060
- EventInterface = KeyboardEventInterface;
8100
+ SyntheticEventCtor = SyntheticKeyboardEvent;
8061
8101
  break;
8062
8102
 
8063
8103
  case 'focusin':
8064
8104
  reactEventType = 'focus';
8065
- EventInterface = FocusEventInterface;
8105
+ SyntheticEventCtor = SyntheticFocusEvent;
8066
8106
  break;
8067
8107
 
8068
8108
  case 'focusout':
8069
8109
  reactEventType = 'blur';
8070
- EventInterface = FocusEventInterface;
8110
+ SyntheticEventCtor = SyntheticFocusEvent;
8071
8111
  break;
8072
8112
 
8073
8113
  case 'beforeblur':
8074
8114
  case 'afterblur':
8075
- EventInterface = FocusEventInterface;
8115
+ SyntheticEventCtor = SyntheticFocusEvent;
8076
8116
  break;
8077
8117
 
8078
8118
  case 'click':
@@ -8095,7 +8135,7 @@
8095
8135
  case 'mouseout':
8096
8136
  case 'mouseover':
8097
8137
  case 'contextmenu':
8098
- EventInterface = MouseEventInterface;
8138
+ SyntheticEventCtor = SyntheticMouseEvent;
8099
8139
  break;
8100
8140
 
8101
8141
  case 'drag':
@@ -8106,38 +8146,38 @@
8106
8146
  case 'dragover':
8107
8147
  case 'dragstart':
8108
8148
  case 'drop':
8109
- EventInterface = DragEventInterface;
8149
+ SyntheticEventCtor = SyntheticDragEvent;
8110
8150
  break;
8111
8151
 
8112
8152
  case 'touchcancel':
8113
8153
  case 'touchend':
8114
8154
  case 'touchmove':
8115
8155
  case 'touchstart':
8116
- EventInterface = TouchEventInterface;
8156
+ SyntheticEventCtor = SyntheticTouchEvent;
8117
8157
  break;
8118
8158
 
8119
8159
  case ANIMATION_END:
8120
8160
  case ANIMATION_ITERATION:
8121
8161
  case ANIMATION_START:
8122
- EventInterface = AnimationEventInterface;
8162
+ SyntheticEventCtor = SyntheticAnimationEvent;
8123
8163
  break;
8124
8164
 
8125
8165
  case TRANSITION_END:
8126
- EventInterface = TransitionEventInterface;
8166
+ SyntheticEventCtor = SyntheticTransitionEvent;
8127
8167
  break;
8128
8168
 
8129
8169
  case 'scroll':
8130
- EventInterface = UIEventInterface;
8170
+ SyntheticEventCtor = SyntheticUIEvent;
8131
8171
  break;
8132
8172
 
8133
8173
  case 'wheel':
8134
- EventInterface = WheelEventInterface;
8174
+ SyntheticEventCtor = SyntheticWheelEvent;
8135
8175
  break;
8136
8176
 
8137
8177
  case 'copy':
8138
8178
  case 'cut':
8139
8179
  case 'paste':
8140
- EventInterface = ClipboardEventInterface;
8180
+ SyntheticEventCtor = SyntheticClipboardEvent;
8141
8181
  break;
8142
8182
 
8143
8183
  case 'gotpointercapture':
@@ -8148,11 +8188,10 @@
8148
8188
  case 'pointerout':
8149
8189
  case 'pointerover':
8150
8190
  case 'pointerup':
8151
- EventInterface = PointerEventInterface;
8191
+ SyntheticEventCtor = SyntheticPointerEvent;
8152
8192
  break;
8153
8193
  }
8154
8194
 
8155
- var event = new SyntheticEvent(reactName, reactEventType, null, nativeEvent, nativeEventTarget, EventInterface);
8156
8195
  var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
8157
8196
 
8158
8197
  {
@@ -8165,7 +8204,18 @@
8165
8204
  // Then we can remove this special list.
8166
8205
  // This is a breaking change that can wait until React 18.
8167
8206
  domEventName === 'scroll';
8168
- accumulateSinglePhaseListeners(targetInst, dispatchQueue, event, inCapturePhase, accumulateTargetOnly);
8207
+
8208
+ var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly);
8209
+
8210
+ if (_listeners.length > 0) {
8211
+ // Intentionally create event lazily.
8212
+ var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget);
8213
+
8214
+ dispatchQueue.push({
8215
+ event: _event,
8216
+ listeners: _listeners
8217
+ });
8218
+ }
8169
8219
  }
8170
8220
  }
8171
8221
 
@@ -8497,19 +8547,12 @@
8497
8547
  };
8498
8548
  }
8499
8549
 
8500
- function createDispatchEntry(event, listeners) {
8501
- return {
8502
- event: event,
8503
- listeners: listeners
8504
- };
8505
- }
8506
-
8507
- function accumulateSinglePhaseListeners(targetFiber, dispatchQueue, event, inCapturePhase, accumulateTargetOnly) {
8508
- var bubbled = event._reactName;
8509
- var captured = bubbled !== null ? bubbled + 'Capture' : null;
8550
+ function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) {
8551
+ var captureName = reactName !== null ? reactName + 'Capture' : null;
8552
+ var reactEventName = inCapturePhase ? captureName : reactName;
8510
8553
  var listeners = [];
8511
8554
  var instance = targetFiber;
8512
- var targetType = event.nativeEvent.type; // Accumulate all instances and listeners via the target -> root path.
8555
+ var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path.
8513
8556
 
8514
8557
  while (instance !== null) {
8515
8558
  var _instance2 = instance,
@@ -8517,22 +8560,14 @@
8517
8560
  tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e. <div>)
8518
8561
 
8519
8562
  if (tag === HostComponent && stateNode !== null) {
8520
- var currentTarget = stateNode;
8521
-
8563
+ lastHostComponent = stateNode; // createEventHandle listeners
8522
8564
 
8523
- if (captured !== null && inCapturePhase) {
8524
- var captureListener = getListener(instance, captured);
8525
8565
 
8526
- if (captureListener != null) {
8527
- listeners.push(createDispatchListener(instance, captureListener, currentTarget));
8528
- }
8529
- }
8530
-
8531
- if (bubbled !== null && !inCapturePhase) {
8532
- var bubbleListener = getListener(instance, bubbled);
8566
+ if (reactEventName !== null) {
8567
+ var listener = getListener(instance, reactEventName);
8533
8568
 
8534
- if (bubbleListener != null) {
8535
- listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
8569
+ if (listener != null) {
8570
+ listeners.push(createDispatchListener(instance, listener, lastHostComponent));
8536
8571
  }
8537
8572
  }
8538
8573
  } // If we are only accumulating events for the target, then we don't
@@ -8547,9 +8582,7 @@
8547
8582
  instance = instance.return;
8548
8583
  }
8549
8584
 
8550
- if (listeners.length !== 0) {
8551
- dispatchQueue.push(createDispatchEntry(event, listeners));
8552
- }
8585
+ return listeners;
8553
8586
  } // We should only use this function for:
8554
8587
  // - BeforeInputEventPlugin
8555
8588
  // - ChangeEventPlugin
@@ -8558,9 +8591,8 @@
8558
8591
  // in the bubble phase, so we need to accumulate two
8559
8592
  // phase event listeners (via emulation).
8560
8593
 
8561
- function accumulateTwoPhaseListeners(targetFiber, dispatchQueue, event) {
8562
- var bubbled = event._reactName;
8563
- var captured = bubbled !== null ? bubbled + 'Capture' : null;
8594
+ function accumulateTwoPhaseListeners(targetFiber, reactName) {
8595
+ var captureName = reactName + 'Capture';
8564
8596
  var listeners = [];
8565
8597
  var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path.
8566
8598
 
@@ -8570,31 +8602,24 @@
8570
8602
  tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e. <div>)
8571
8603
 
8572
8604
  if (tag === HostComponent && stateNode !== null) {
8573
- var currentTarget = stateNode; // Standard React on* listeners, i.e. onClick prop
8574
-
8575
- if (captured !== null) {
8576
- var captureListener = getListener(instance, captured);
8605
+ var currentTarget = stateNode;
8606
+ var captureListener = getListener(instance, captureName);
8577
8607
 
8578
- if (captureListener != null) {
8579
- listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
8580
- }
8608
+ if (captureListener != null) {
8609
+ listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
8581
8610
  }
8582
8611
 
8583
- if (bubbled !== null) {
8584
- var bubbleListener = getListener(instance, bubbled);
8612
+ var bubbleListener = getListener(instance, reactName);
8585
8613
 
8586
- if (bubbleListener != null) {
8587
- listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
8588
- }
8614
+ if (bubbleListener != null) {
8615
+ listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
8589
8616
  }
8590
8617
  }
8591
8618
 
8592
8619
  instance = instance.return;
8593
8620
  }
8594
8621
 
8595
- if (listeners.length !== 0) {
8596
- dispatchQueue.push(createDispatchEntry(event, listeners));
8597
- }
8622
+ return listeners;
8598
8623
  }
8599
8624
 
8600
8625
  function getParent(inst) {
@@ -8705,7 +8730,10 @@
8705
8730
  }
8706
8731
 
8707
8732
  if (listeners.length !== 0) {
8708
- dispatchQueue.push(createDispatchEntry(event, listeners));
8733
+ dispatchQueue.push({
8734
+ event: event,
8735
+ listeners: listeners
8736
+ });
8709
8737
  }
8710
8738
  } // We should only use this function for:
8711
8739
  // - EnterLeaveEventPlugin
@@ -8751,11 +8779,6 @@
8751
8779
 
8752
8780
  {
8753
8781
  warnedUnknownTags = {
8754
- // Chrome is the only major browser not shipping <time>. But as of July
8755
- // 2017 it intends to ship it due to widespread usage. We intentionally
8756
- // *don't* warn for <time> even if it's unrecognized by Chrome because
8757
- // it soon will be, and many apps have been using it anyway.
8758
- time: true,
8759
8782
  // There are working polyfills for <dialog>. Let people use it.
8760
8783
  dialog: true,
8761
8784
  // Electron ships a custom <webview> tag to display external web content in
@@ -11313,7 +11336,7 @@
11313
11336
  Scheduler_cancelCallback(node);
11314
11337
  }
11315
11338
 
11316
- return flushSyncCallbackQueueImpl();
11339
+ flushSyncCallbackQueueImpl();
11317
11340
  }
11318
11341
 
11319
11342
  function flushSyncCallbackQueueImpl() {
@@ -11349,30 +11372,11 @@
11349
11372
  isFlushingSyncQueue = false;
11350
11373
  }
11351
11374
  }
11352
-
11353
- return true;
11354
- } else {
11355
- return false;
11356
11375
  }
11357
11376
  }
11358
11377
 
11359
- var NoFlags$1 =
11360
- /* */
11361
- 0; // Represents whether effect should fire.
11362
-
11363
- var HasEffect =
11364
- /* */
11365
- 1; // Represents the phase in which the effect (not the clean-up) fires.
11366
-
11367
- var Layout =
11368
- /* */
11369
- 2;
11370
- var Passive$1 =
11371
- /* */
11372
- 4;
11373
-
11374
11378
  // TODO: this is special because it gets imported during build.
11375
- var ReactVersion = '17.0.0-rc.2';
11379
+ var ReactVersion = '17.0.2';
11376
11380
 
11377
11381
  var NoMode = 0;
11378
11382
  var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
@@ -11431,7 +11435,7 @@
11431
11435
  var didWarnAboutUnsafeLifecycles = new Set();
11432
11436
 
11433
11437
  ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
11434
- // Dedupe strategy: Warn once per component.
11438
+ // Dedup strategy: Warn once per component.
11435
11439
  if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
11436
11440
  return;
11437
11441
  }
@@ -13283,16 +13287,24 @@
13283
13287
  if (!shouldTrackSideEffects) {
13284
13288
  // Noop.
13285
13289
  return;
13286
- }
13290
+ } // Deletions are added in reversed order so we add it to the front.
13291
+ // At this point, the return fiber's effect list is empty except for
13292
+ // deletions, so we can just append the deletion to the list. The remaining
13293
+ // effects aren't added until the complete phase. Once we implement
13294
+ // resuming, this may not be true.
13295
+
13287
13296
 
13288
- var deletions = returnFiber.deletions;
13297
+ var last = returnFiber.lastEffect;
13289
13298
 
13290
- if (deletions === null) {
13291
- returnFiber.deletions = [childToDelete];
13292
- returnFiber.flags |= Deletion;
13299
+ if (last !== null) {
13300
+ last.nextEffect = childToDelete;
13301
+ returnFiber.lastEffect = childToDelete;
13293
13302
  } else {
13294
- deletions.push(childToDelete);
13303
+ returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
13295
13304
  }
13305
+
13306
+ childToDelete.nextEffect = null;
13307
+ childToDelete.flags = Deletion;
13296
13308
  }
13297
13309
 
13298
13310
  function deleteRemainingChildren(returnFiber, currentFirstChild) {
@@ -14348,13 +14360,6 @@
14348
14360
  pop(suspenseStackCursor, fiber);
14349
14361
  }
14350
14362
 
14351
- // A non-null SuspenseState means that it is blocked for one reason or another.
14352
- // - A non-null dehydrated field means it's blocked pending hydration.
14353
- // - A non-null dehydrated field can use isSuspenseInstancePending or
14354
- // isSuspenseInstanceFallback to query the reason for being dehydrated.
14355
- // - A null dehydrated field means it's blocked by something suspending and
14356
- // we're currently showing a fallback instead.
14357
-
14358
14363
  function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
14359
14364
  // If it was the primary children that just suspended, capture and render the
14360
14365
  // fallback. Otherwise, don't capture and bubble to the next boundary.
@@ -14436,6 +14441,21 @@
14436
14441
  return null;
14437
14442
  }
14438
14443
 
14444
+ var NoFlags$1 =
14445
+ /* */
14446
+ 0; // Represents whether effect should fire.
14447
+
14448
+ var HasEffect =
14449
+ /* */
14450
+ 1; // Represents the phase in which the effect (not the clean-up) fires.
14451
+
14452
+ var Layout =
14453
+ /* */
14454
+ 2;
14455
+ var Passive$1 =
14456
+ /* */
14457
+ 4;
14458
+
14439
14459
  // This may have been an insertion or a hydration.
14440
14460
 
14441
14461
  var hydrationParentFiber = null;
@@ -14467,14 +14487,17 @@
14467
14487
  var childToDelete = createFiberFromHostInstanceForDeletion();
14468
14488
  childToDelete.stateNode = instance;
14469
14489
  childToDelete.return = returnFiber;
14470
- var deletions = returnFiber.deletions;
14471
-
14472
- if (deletions === null) {
14473
- returnFiber.deletions = [childToDelete]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions)
14474
-
14475
- returnFiber.flags |= Deletion;
14490
+ childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
14491
+ // these children are not part of the reconciliation list of children.
14492
+ // Even if we abort and rereconcile the children, that will try to hydrate
14493
+ // again and the nodes are still in the host tree so these will be
14494
+ // recreated.
14495
+
14496
+ if (returnFiber.lastEffect !== null) {
14497
+ returnFiber.lastEffect.nextEffect = childToDelete;
14498
+ returnFiber.lastEffect = childToDelete;
14476
14499
  } else {
14477
- deletions.push(childToDelete);
14500
+ returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
14478
14501
  }
14479
14502
  }
14480
14503
 
@@ -15740,7 +15763,7 @@
15740
15763
  }
15741
15764
  }
15742
15765
 
15743
- return mountEffectImpl(Passive | PassiveStatic, Passive$1, create, deps);
15766
+ return mountEffectImpl(Update | Passive, Passive$1, create, deps);
15744
15767
  }
15745
15768
 
15746
15769
  function updateEffect(create, deps) {
@@ -15751,7 +15774,7 @@
15751
15774
  }
15752
15775
  }
15753
15776
 
15754
- return updateEffectImpl(Passive, Passive$1, create, deps);
15777
+ return updateEffectImpl(Update | Passive, Passive$1, create, deps);
15755
15778
  }
15756
15779
 
15757
15780
  function mountLayoutEffect(create, deps) {
@@ -16034,7 +16057,7 @@
16034
16057
  var setId = mountState(id)[1];
16035
16058
 
16036
16059
  if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) {
16037
- currentlyRenderingFiber$1.flags |= Passive | PassiveStatic;
16060
+ currentlyRenderingFiber$1.flags |= Update | Passive;
16038
16061
  pushEffect(HasEffect | Passive$1, function () {
16039
16062
  setId(makeId());
16040
16063
  }, undefined, null);
@@ -17310,8 +17333,7 @@
17310
17333
 
17311
17334
  function updateProfiler(current, workInProgress, renderLanes) {
17312
17335
  {
17313
- // TODO: Only call onRender et al if subtree has effects
17314
- workInProgress.flags |= Update | Passive; // Reset effect durations for the next eventual effect phase.
17336
+ workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase.
17315
17337
  // These are reset during render to allow the DevTools commit hook a chance to read them,
17316
17338
 
17317
17339
  var stateNode = workInProgress.stateNode;
@@ -17972,7 +17994,8 @@
17972
17994
  return {
17973
17995
  baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes)
17974
17996
  };
17975
- }
17997
+ } // TODO: Probably should inline this back
17998
+
17976
17999
 
17977
18000
  function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) {
17978
18001
  // If we're already showing a fallback, there are cases where we need to
@@ -18063,17 +18086,41 @@
18063
18086
  tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
18064
18087
  }
18065
18088
 
18089
+ var nextPrimaryChildren = nextProps.children;
18090
+ var nextFallbackChildren = nextProps.fallback;
18091
+
18066
18092
  if (showFallback) {
18067
- var nextPrimaryChildren = nextProps.children;
18068
- var nextFallbackChildren = nextProps.fallback;
18069
18093
  var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
18070
18094
  var primaryChildFragment = workInProgress.child;
18071
18095
  primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes);
18072
18096
  workInProgress.memoizedState = SUSPENDED_MARKER;
18073
18097
  return fallbackFragment;
18098
+ } else if (typeof nextProps.unstable_expectedLoadTime === 'number') {
18099
+ // This is a CPU-bound tree. Skip this tree and show a placeholder to
18100
+ // unblock the surrounding content. Then immediately retry after the
18101
+ // initial commit.
18102
+ var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
18103
+
18104
+ var _primaryChildFragment = workInProgress.child;
18105
+ _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes);
18106
+ workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to
18107
+ // get it started back up to attempt the next item. While in terms of
18108
+ // priority this work has the same priority as this current render, it's
18109
+ // not part of the same transition once the transition has committed. If
18110
+ // it's sync, we still want to yield so that it can be painted.
18111
+ // Conceptually, this is really the same as pinging. We can use any
18112
+ // RetryLane even if it's the one currently rendering since we're leaving
18113
+ // it behind on this node.
18114
+
18115
+ workInProgress.lanes = SomeRetryLane;
18116
+
18117
+ {
18118
+ markSpawnedWork(SomeRetryLane);
18119
+ }
18120
+
18121
+ return _fallbackFragment;
18074
18122
  } else {
18075
- var _nextPrimaryChildren = nextProps.children;
18076
- return mountSuspensePrimaryChildren(workInProgress, _nextPrimaryChildren, renderLanes);
18123
+ return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren, renderLanes);
18077
18124
  }
18078
18125
  } else {
18079
18126
  // This is an update.
@@ -18085,37 +18132,37 @@
18085
18132
 
18086
18133
  if (showFallback) {
18087
18134
  var _nextFallbackChildren2 = nextProps.fallback;
18088
- var _nextPrimaryChildren3 = nextProps.children;
18135
+ var _nextPrimaryChildren2 = nextProps.children;
18089
18136
 
18090
- var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren3, _nextFallbackChildren2, renderLanes);
18137
+ var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes);
18091
18138
 
18092
- var _primaryChildFragment2 = workInProgress.child;
18139
+ var _primaryChildFragment3 = workInProgress.child;
18093
18140
  var prevOffscreenState = current.child.memoizedState;
18094
- _primaryChildFragment2.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
18095
- _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes);
18141
+ _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
18142
+ _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes);
18096
18143
  workInProgress.memoizedState = SUSPENDED_MARKER;
18097
18144
  return _fallbackChildFragment;
18098
18145
  } else {
18099
- var _nextPrimaryChildren4 = nextProps.children;
18146
+ var _nextPrimaryChildren3 = nextProps.children;
18100
18147
 
18101
- var _primaryChildFragment3 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren4, renderLanes);
18148
+ var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes);
18102
18149
 
18103
18150
  workInProgress.memoizedState = null;
18104
- return _primaryChildFragment3;
18151
+ return _primaryChildFragment4;
18105
18152
  }
18106
18153
  } else {
18107
18154
  // The current tree is not already showing a fallback.
18108
18155
  if (showFallback) {
18109
18156
  // Timed out.
18110
18157
  var _nextFallbackChildren3 = nextProps.fallback;
18111
- var _nextPrimaryChildren5 = nextProps.children;
18158
+ var _nextPrimaryChildren4 = nextProps.children;
18112
18159
 
18113
- var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren5, _nextFallbackChildren3, renderLanes);
18160
+ var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes);
18114
18161
 
18115
- var _primaryChildFragment4 = workInProgress.child;
18162
+ var _primaryChildFragment5 = workInProgress.child;
18116
18163
  var _prevOffscreenState = current.child.memoizedState;
18117
- _primaryChildFragment4.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
18118
- _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the
18164
+ _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
18165
+ _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the
18119
18166
  // fallback children.
18120
18167
 
18121
18168
  workInProgress.memoizedState = SUSPENDED_MARKER;
@@ -18123,12 +18170,12 @@
18123
18170
  } else {
18124
18171
  // Still haven't timed out. Continue rendering the children, like we
18125
18172
  // normally do.
18126
- var _nextPrimaryChildren6 = nextProps.children;
18173
+ var _nextPrimaryChildren5 = nextProps.children;
18127
18174
 
18128
- var _primaryChildFragment5 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren6, renderLanes);
18175
+ var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes);
18129
18176
 
18130
18177
  workInProgress.memoizedState = null;
18131
- return _primaryChildFragment5;
18178
+ return _primaryChildFragment6;
18132
18179
  }
18133
18180
  }
18134
18181
  }
@@ -18210,15 +18257,9 @@
18210
18257
 
18211
18258
  if (currentFallbackChildFragment !== null) {
18212
18259
  // Delete the fallback child fragment
18213
- var deletions = workInProgress.deletions;
18214
-
18215
- if (deletions === null) {
18216
- workInProgress.deletions = [currentFallbackChildFragment]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions)
18217
-
18218
- workInProgress.flags |= Deletion;
18219
- } else {
18220
- deletions.push(currentFallbackChildFragment);
18221
- }
18260
+ currentFallbackChildFragment.nextEffect = null;
18261
+ currentFallbackChildFragment.flags = Deletion;
18262
+ workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
18222
18263
  }
18223
18264
 
18224
18265
  workInProgress.child = primaryChildFragment;
@@ -18260,16 +18301,24 @@
18260
18301
  primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration;
18261
18302
  } // The fallback fiber was added as a deletion effect during the first pass.
18262
18303
  // However, since we're going to remain on the fallback, we no longer want
18263
- // to delete it.
18304
+ // to delete it. So we need to remove it from the list. Deletions are stored
18305
+ // on the same list as effects. We want to keep the effects from the primary
18306
+ // tree. So we copy the primary child fragment's effect list, which does not
18307
+ // include the fallback deletion effect.
18264
18308
 
18265
18309
 
18266
- workInProgress.deletions = null;
18267
- } else {
18268
- primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps); // Since we're reusing a current tree, we need to reuse the flags, too.
18269
- // (We don't do this in legacy mode, because in legacy mode we don't re-use
18270
- // the current tree; see previous branch.)
18310
+ var progressedLastEffect = primaryChildFragment.lastEffect;
18271
18311
 
18272
- primaryChildFragment.subtreeFlags = currentPrimaryChildFragment.subtreeFlags & StaticMask;
18312
+ if (progressedLastEffect !== null) {
18313
+ workInProgress.firstEffect = primaryChildFragment.firstEffect;
18314
+ workInProgress.lastEffect = progressedLastEffect;
18315
+ progressedLastEffect.nextEffect = null;
18316
+ } else {
18317
+ // TODO: Reset this somewhere else? Lol legacy mode is so weird.
18318
+ workInProgress.firstEffect = workInProgress.lastEffect = null;
18319
+ }
18320
+ } else {
18321
+ primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps);
18273
18322
  }
18274
18323
 
18275
18324
  var fallbackChildFragment;
@@ -18472,7 +18521,7 @@
18472
18521
  }
18473
18522
  }
18474
18523
 
18475
- function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
18524
+ function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
18476
18525
  var renderState = workInProgress.memoizedState;
18477
18526
 
18478
18527
  if (renderState === null) {
@@ -18482,7 +18531,8 @@
18482
18531
  renderingStartTime: 0,
18483
18532
  last: lastContentRow,
18484
18533
  tail: tail,
18485
- tailMode: tailMode
18534
+ tailMode: tailMode,
18535
+ lastEffect: lastEffectBeforeRendering
18486
18536
  };
18487
18537
  } else {
18488
18538
  // We can reuse the existing object from previous renders.
@@ -18492,6 +18542,7 @@
18492
18542
  renderState.last = lastContentRow;
18493
18543
  renderState.tail = tail;
18494
18544
  renderState.tailMode = tailMode;
18545
+ renderState.lastEffect = lastEffectBeforeRendering;
18495
18546
  }
18496
18547
  } // This can end up rendering this component multiple passes.
18497
18548
  // The first pass splits the children fibers into two sets. A head and tail.
@@ -18556,7 +18607,7 @@
18556
18607
  }
18557
18608
 
18558
18609
  initSuspenseListRenderState(workInProgress, false, // isBackwards
18559
- tail, lastContentRow, tailMode);
18610
+ tail, lastContentRow, tailMode, workInProgress.lastEffect);
18560
18611
  break;
18561
18612
  }
18562
18613
 
@@ -18588,7 +18639,7 @@
18588
18639
 
18589
18640
  initSuspenseListRenderState(workInProgress, true, // isBackwards
18590
18641
  _tail, null, // last
18591
- tailMode);
18642
+ tailMode, workInProgress.lastEffect);
18592
18643
  break;
18593
18644
  }
18594
18645
 
@@ -18597,7 +18648,7 @@
18597
18648
  initSuspenseListRenderState(workInProgress, false, // isBackwards
18598
18649
  null, // tail
18599
18650
  null, // last
18600
- undefined);
18651
+ undefined, workInProgress.lastEffect);
18601
18652
  break;
18602
18653
  }
18603
18654
 
@@ -18803,16 +18854,17 @@
18803
18854
  // Since the old fiber is disconnected, we have to schedule it manually.
18804
18855
 
18805
18856
 
18806
- var deletions = returnFiber.deletions;
18857
+ var last = returnFiber.lastEffect;
18807
18858
 
18808
- if (deletions === null) {
18809
- returnFiber.deletions = [current]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions)
18810
-
18811
- returnFiber.flags |= Deletion;
18859
+ if (last !== null) {
18860
+ last.nextEffect = current;
18861
+ returnFiber.lastEffect = current;
18812
18862
  } else {
18813
- deletions.push(current);
18863
+ returnFiber.firstEffect = returnFiber.lastEffect = current;
18814
18864
  }
18815
18865
 
18866
+ current.nextEffect = null;
18867
+ current.flags = Deletion;
18816
18868
  newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
18817
18869
 
18818
18870
  return newWorkInProgress;
@@ -18878,11 +18930,10 @@
18878
18930
  case Profiler:
18879
18931
  {
18880
18932
  // Profiler should only call onRender when one of its descendants actually rendered.
18881
- // TODO: Only call onRender et al if subtree has effects
18882
18933
  var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);
18883
18934
 
18884
18935
  if (hasChildWork) {
18885
- workInProgress.flags |= Passive | Update;
18936
+ workInProgress.flags |= Update;
18886
18937
  } // Reset effect durations for the next eventual effect phase.
18887
18938
  // These are reset during render to allow the DevTools commit hook a chance to read them,
18888
18939
 
@@ -18966,6 +19017,7 @@
18966
19017
  // update in the past but didn't complete it.
18967
19018
  renderState.rendering = null;
18968
19019
  renderState.tail = null;
19020
+ renderState.lastEffect = null;
18969
19021
  }
18970
19022
 
18971
19023
  pushSuspenseContext(workInProgress, suspenseStackCursor.current);
@@ -19217,7 +19269,7 @@
19217
19269
  }
19218
19270
  };
19219
19271
 
19220
- updateHostContainer = function (current, workInProgress) {// Noop
19272
+ updateHostContainer = function (workInProgress) {// Noop
19221
19273
  };
19222
19274
 
19223
19275
  updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
@@ -19338,92 +19390,6 @@
19338
19390
  }
19339
19391
  }
19340
19392
 
19341
- function bubbleProperties(completedWork) {
19342
- var didBailout = completedWork.alternate !== null && completedWork.alternate.child === completedWork.child;
19343
- var newChildLanes = NoLanes;
19344
- var subtreeFlags = NoFlags;
19345
-
19346
- if (!didBailout) {
19347
- // Bubble up the earliest expiration time.
19348
- if ( (completedWork.mode & ProfileMode) !== NoMode) {
19349
- // In profiling mode, resetChildExpirationTime is also used to reset
19350
- // profiler durations.
19351
- var actualDuration = completedWork.actualDuration;
19352
- var treeBaseDuration = completedWork.selfBaseDuration;
19353
- var child = completedWork.child;
19354
-
19355
- while (child !== null) {
19356
- newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
19357
- subtreeFlags |= child.subtreeFlags;
19358
- subtreeFlags |= child.flags; // When a fiber is cloned, its actualDuration is reset to 0. This value will
19359
- // only be updated if work is done on the fiber (i.e. it doesn't bailout).
19360
- // When work is done, it should bubble to the parent's actualDuration. If
19361
- // the fiber has not been cloned though, (meaning no work was done), then
19362
- // this value will reflect the amount of time spent working on a previous
19363
- // render. In that case it should not bubble. We determine whether it was
19364
- // cloned by comparing the child pointer.
19365
-
19366
- actualDuration += child.actualDuration;
19367
- treeBaseDuration += child.treeBaseDuration;
19368
- child = child.sibling;
19369
- }
19370
-
19371
- completedWork.actualDuration = actualDuration;
19372
- completedWork.treeBaseDuration = treeBaseDuration;
19373
- } else {
19374
- var _child = completedWork.child;
19375
-
19376
- while (_child !== null) {
19377
- newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
19378
- subtreeFlags |= _child.subtreeFlags;
19379
- subtreeFlags |= _child.flags;
19380
- _child = _child.sibling;
19381
- }
19382
- }
19383
-
19384
- completedWork.subtreeFlags |= subtreeFlags;
19385
- } else {
19386
- // Bubble up the earliest expiration time.
19387
- if ( (completedWork.mode & ProfileMode) !== NoMode) {
19388
- // In profiling mode, resetChildExpirationTime is also used to reset
19389
- // profiler durations.
19390
- var _treeBaseDuration = completedWork.selfBaseDuration;
19391
- var _child2 = completedWork.child;
19392
-
19393
- while (_child2 !== null) {
19394
- newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child2.lanes, _child2.childLanes)); // "Static" flags share the lifetime of the fiber/hook they belong to,
19395
- // so we should bubble those up even during a bailout. All the other
19396
- // flags have a lifetime only of a single render + commit, so we should
19397
- // ignore them.
19398
-
19399
- subtreeFlags |= _child2.subtreeFlags & StaticMask;
19400
- subtreeFlags |= _child2.flags & StaticMask;
19401
- _treeBaseDuration += _child2.treeBaseDuration;
19402
- _child2 = _child2.sibling;
19403
- }
19404
-
19405
- completedWork.treeBaseDuration = _treeBaseDuration;
19406
- } else {
19407
- var _child3 = completedWork.child;
19408
-
19409
- while (_child3 !== null) {
19410
- newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child3.lanes, _child3.childLanes)); // "Static" flags share the lifetime of the fiber/hook they belong to,
19411
- // so we should bubble those up even during a bailout. All the other
19412
- // flags have a lifetime only of a single render + commit, so we should
19413
- // ignore them.
19414
-
19415
- subtreeFlags |= _child3.subtreeFlags & StaticMask;
19416
- subtreeFlags |= _child3.flags & StaticMask;
19417
- _child3 = _child3.sibling;
19418
- }
19419
- }
19420
-
19421
- completedWork.subtreeFlags |= subtreeFlags;
19422
- }
19423
-
19424
- completedWork.childLanes = newChildLanes;
19425
- }
19426
-
19427
19393
  function completeWork(current, workInProgress, renderLanes) {
19428
19394
  var newProps = workInProgress.pendingProps;
19429
19395
 
@@ -19438,7 +19404,6 @@
19438
19404
  case Profiler:
19439
19405
  case ContextConsumer:
19440
19406
  case MemoComponent:
19441
- bubbleProperties(workInProgress);
19442
19407
  return null;
19443
19408
 
19444
19409
  case ClassComponent:
@@ -19449,7 +19414,6 @@
19449
19414
  popContext(workInProgress);
19450
19415
  }
19451
19416
 
19452
- bubbleProperties(workInProgress);
19453
19417
  return null;
19454
19418
  }
19455
19419
 
@@ -19483,8 +19447,7 @@
19483
19447
  }
19484
19448
  }
19485
19449
 
19486
- updateHostContainer(current, workInProgress);
19487
- bubbleProperties(workInProgress);
19450
+ updateHostContainer(workInProgress);
19488
19451
  return null;
19489
19452
  }
19490
19453
 
@@ -19509,7 +19472,6 @@
19509
19472
  } // This can happen when we abort work.
19510
19473
 
19511
19474
 
19512
- bubbleProperties(workInProgress);
19513
19475
  return null;
19514
19476
  }
19515
19477
 
@@ -19546,7 +19508,6 @@
19546
19508
  }
19547
19509
  }
19548
19510
 
19549
- bubbleProperties(workInProgress);
19550
19511
  return null;
19551
19512
  }
19552
19513
 
@@ -19584,7 +19545,6 @@
19584
19545
  }
19585
19546
  }
19586
19547
 
19587
- bubbleProperties(workInProgress);
19588
19548
  return null;
19589
19549
  }
19590
19550
 
@@ -19599,8 +19559,7 @@
19599
19559
 
19600
19560
  if ( (workInProgress.mode & ProfileMode) !== NoMode) {
19601
19561
  transferActualDuration(workInProgress);
19602
- } // Don't bubble properties in this case.
19603
-
19562
+ }
19604
19563
 
19605
19564
  return workInProgress;
19606
19565
  }
@@ -19657,40 +19616,22 @@
19657
19616
  }
19658
19617
  }
19659
19618
 
19660
- bubbleProperties(workInProgress);
19661
-
19662
- {
19663
- if ((workInProgress.mode & ProfileMode) !== NoMode) {
19664
- if (nextDidTimeout) {
19665
- // Don't count time spent in a timed out Suspense subtree as part of the base duration.
19666
- var _primaryChildFragment2 = workInProgress.child;
19667
-
19668
- if (_primaryChildFragment2 !== null) {
19669
- // $FlowFixMe Flow doens't support type casting in combiation with the -= operator
19670
- workInProgress.treeBaseDuration -= _primaryChildFragment2.treeBaseDuration;
19671
- }
19672
- }
19673
- }
19674
- }
19675
-
19676
19619
  return null;
19677
19620
  }
19678
19621
 
19679
19622
  case HostPortal:
19680
19623
  popHostContainer(workInProgress);
19681
- updateHostContainer(current, workInProgress);
19624
+ updateHostContainer(workInProgress);
19682
19625
 
19683
19626
  if (current === null) {
19684
19627
  preparePortalMount(workInProgress.stateNode.containerInfo);
19685
19628
  }
19686
19629
 
19687
- bubbleProperties(workInProgress);
19688
19630
  return null;
19689
19631
 
19690
19632
  case ContextProvider:
19691
19633
  // Pop provider fiber
19692
19634
  popProvider(workInProgress);
19693
- bubbleProperties(workInProgress);
19694
19635
  return null;
19695
19636
 
19696
19637
  case IncompleteClassComponent:
@@ -19703,7 +19644,6 @@
19703
19644
  popContext(workInProgress);
19704
19645
  }
19705
19646
 
19706
- bubbleProperties(workInProgress);
19707
19647
  return null;
19708
19648
  }
19709
19649
 
@@ -19715,7 +19655,6 @@
19715
19655
  if (renderState === null) {
19716
19656
  // We're running in the default, "independent" mode.
19717
19657
  // We don't do anything in this mode.
19718
- bubbleProperties(workInProgress);
19719
19658
  return null;
19720
19659
  }
19721
19660
 
@@ -19765,15 +19704,19 @@
19765
19704
  workInProgress.flags |= Update;
19766
19705
  } // Rerender the whole list, but this time, we'll force fallbacks
19767
19706
  // to stay in place.
19768
- // Reset the child fibers to their original state.
19707
+ // Reset the effect list before doing the second pass since that's now invalid.
19708
+
19769
19709
 
19710
+ if (renderState.lastEffect === null) {
19711
+ workInProgress.firstEffect = null;
19712
+ }
19713
+
19714
+ workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
19770
19715
 
19771
- workInProgress.subtreeFlags = NoFlags;
19772
19716
  resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
19773
19717
  // rerender the children.
19774
19718
 
19775
- pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback)); // Don't bubble properties in this case.
19776
-
19719
+ pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
19777
19720
  return workInProgress.child;
19778
19721
  }
19779
19722
 
@@ -19827,8 +19770,16 @@
19827
19770
 
19828
19771
  if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating.
19829
19772
  ) {
19830
- // We're done.
19831
- bubbleProperties(workInProgress);
19773
+ // We need to delete the row we just rendered.
19774
+ // Reset the effect list to what it was before we rendered this
19775
+ // child. The nested children have already appended themselves.
19776
+ var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
19777
+
19778
+ if (lastEffect !== null) {
19779
+ lastEffect.nextEffect = null;
19780
+ } // We're done.
19781
+
19782
+
19832
19783
  return null;
19833
19784
  }
19834
19785
  } else if ( // The time it took to render last row is greater than the remaining
@@ -19841,16 +19792,19 @@
19841
19792
  workInProgress.flags |= DidCapture;
19842
19793
  didSuspendAlready = true;
19843
19794
  cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
19844
- // to get it started back up to attempt the next item. If we can show
19845
- // them, then they really have the same priority as this render.
19846
- // So we'll pick it back up the very next render pass once we've had
19847
- // an opportunity to yield for paint.
19848
-
19849
- workInProgress.lanes = SomeRetryLane;
19850
-
19851
- {
19852
- markSpawnedWork(SomeRetryLane);
19853
- }
19795
+ // to get it started back up to attempt the next item. While in terms
19796
+ // of priority this work has the same priority as this current render,
19797
+ // it's not part of the same transition once the transition has
19798
+ // committed. If it's sync, we still want to yield so that it can be
19799
+ // painted. Conceptually, this is really the same as pinging.
19800
+ // We can use any RetryLane even if it's the one currently rendering
19801
+ // since we're leaving it behind on this node.
19802
+
19803
+ workInProgress.lanes = SomeRetryLane;
19804
+
19805
+ {
19806
+ markSpawnedWork(SomeRetryLane);
19807
+ }
19854
19808
  }
19855
19809
  }
19856
19810
 
@@ -19881,6 +19835,7 @@
19881
19835
  var next = renderState.tail;
19882
19836
  renderState.rendering = next;
19883
19837
  renderState.tail = next.sibling;
19838
+ renderState.lastEffect = workInProgress.lastEffect;
19884
19839
  renderState.renderingStartTime = now();
19885
19840
  next.sibling = null; // Restore the context.
19886
19841
  // TODO: We can probably just avoid popping it instead and only
@@ -19895,12 +19850,10 @@
19895
19850
  }
19896
19851
 
19897
19852
  pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
19898
- // Don't bubble properties in this case.
19899
19853
 
19900
19854
  return next;
19901
19855
  }
19902
19856
 
19903
- bubbleProperties(workInProgress);
19904
19857
  return null;
19905
19858
  }
19906
19859
 
@@ -19924,21 +19877,16 @@
19924
19877
  case LegacyHiddenComponent:
19925
19878
  {
19926
19879
  popRenderLanes(workInProgress);
19927
- var _nextState = workInProgress.memoizedState;
19928
- var nextIsHidden = _nextState !== null;
19929
19880
 
19930
19881
  if (current !== null) {
19882
+ var _nextState = workInProgress.memoizedState;
19931
19883
  var _prevState = current.memoizedState;
19932
19884
  var prevIsHidden = _prevState !== null;
19885
+ var nextIsHidden = _nextState !== null;
19933
19886
 
19934
19887
  if (prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding') {
19935
19888
  workInProgress.flags |= Update;
19936
19889
  }
19937
- } // Don't bubble properties for hidden children.
19938
-
19939
-
19940
- if (!nextIsHidden || includesSomeLane(subtreeRenderLanes, OffscreenLane) || (workInProgress.mode & ConcurrentMode) === NoMode) {
19941
- bubbleProperties(workInProgress);
19942
19890
  }
19943
19891
 
19944
19892
  return null;
@@ -20292,7 +20240,9 @@
20292
20240
 
20293
20241
  function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) {
20294
20242
  // The source fiber did not complete.
20295
- sourceFiber.flags |= Incomplete;
20243
+ sourceFiber.flags |= Incomplete; // Its effect list is no longer valid.
20244
+
20245
+ sourceFiber.firstEffect = sourceFiber.lastEffect = null;
20296
20246
 
20297
20247
  if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
20298
20248
  // This is a wakeable.
@@ -20495,18 +20445,18 @@
20495
20445
  }; // Capture errors so they don't interrupt unmounting.
20496
20446
 
20497
20447
 
20498
- function safelyCallComponentWillUnmount(current, instance, nearestMountedAncestor) {
20448
+ function safelyCallComponentWillUnmount(current, instance) {
20499
20449
  {
20500
20450
  invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
20501
20451
 
20502
20452
  if (hasCaughtError()) {
20503
20453
  var unmountError = clearCaughtError();
20504
- captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
20454
+ captureCommitPhaseError(current, unmountError);
20505
20455
  }
20506
20456
  }
20507
20457
  }
20508
20458
 
20509
- function safelyDetachRef(current, nearestMountedAncestor) {
20459
+ function safelyDetachRef(current) {
20510
20460
  var ref = current.ref;
20511
20461
 
20512
20462
  if (ref !== null) {
@@ -20516,7 +20466,7 @@
20516
20466
 
20517
20467
  if (hasCaughtError()) {
20518
20468
  var refError = clearCaughtError();
20519
- captureCommitPhaseError(current, nearestMountedAncestor, refError);
20469
+ captureCommitPhaseError(current, refError);
20520
20470
  }
20521
20471
  }
20522
20472
  } else {
@@ -20525,13 +20475,13 @@
20525
20475
  }
20526
20476
  }
20527
20477
 
20528
- function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
20478
+ function safelyCallDestroy(current, destroy) {
20529
20479
  {
20530
20480
  invokeGuardedCallback(null, destroy, null);
20531
20481
 
20532
20482
  if (hasCaughtError()) {
20533
20483
  var error = clearCaughtError();
20534
- captureCommitPhaseError(current, nearestMountedAncestor, error);
20484
+ captureCommitPhaseError(current, error);
20535
20485
  }
20536
20486
  }
20537
20487
  }
@@ -20614,7 +20564,7 @@
20614
20564
  }
20615
20565
  }
20616
20566
 
20617
- function commitHookEffectListUnmount(tag, finishedWork, nearestMountedAncestor) {
20567
+ function commitHookEffectListUnmount(tag, finishedWork) {
20618
20568
  var updateQueue = finishedWork.updateQueue;
20619
20569
  var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
20620
20570
 
@@ -20629,45 +20579,13 @@
20629
20579
  effect.destroy = undefined;
20630
20580
 
20631
20581
  if (destroy !== undefined) {
20632
- safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
20582
+ destroy();
20633
20583
  }
20634
20584
  }
20635
20585
 
20636
20586
  effect = effect.next;
20637
20587
  } while (effect !== firstEffect);
20638
20588
  }
20639
- } // TODO: Remove this duplication.
20640
-
20641
-
20642
- function commitHookEffectListUnmount2( // Tags to check for when deciding whether to unmount. e.g. to skip over layout effects
20643
- hookFlags, fiber, nearestMountedAncestor) {
20644
- var updateQueue = fiber.updateQueue;
20645
- var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
20646
-
20647
- if (lastEffect !== null) {
20648
- var firstEffect = lastEffect.next;
20649
- var effect = firstEffect;
20650
-
20651
- do {
20652
- var _effect = effect,
20653
- next = _effect.next,
20654
- tag = _effect.tag;
20655
-
20656
- if ((tag & hookFlags) === hookFlags) {
20657
- var destroy = effect.destroy;
20658
-
20659
- if (destroy !== undefined) {
20660
- effect.destroy = undefined;
20661
-
20662
- {
20663
- safelyCallDestroy(fiber, nearestMountedAncestor, destroy);
20664
- }
20665
- }
20666
- }
20667
-
20668
- effect = next;
20669
- } while (effect !== firstEffect);
20670
- }
20671
20589
  }
20672
20590
 
20673
20591
  function commitHookEffectListMount(tag, finishedWork) {
@@ -20708,14 +20626,8 @@
20708
20626
  }
20709
20627
  }
20710
20628
 
20711
- function invokePassiveEffectCreate(effect) {
20712
- var create = effect.create;
20713
- effect.destroy = create();
20714
- } // TODO: Remove this duplication.
20715
-
20716
-
20717
- function commitHookEffectListMount2(fiber) {
20718
- var updateQueue = fiber.updateQueue;
20629
+ function schedulePassiveEffects(finishedWork) {
20630
+ var updateQueue = finishedWork.updateQueue;
20719
20631
  var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
20720
20632
 
20721
20633
  if (lastEffect !== null) {
@@ -20723,27 +20635,13 @@
20723
20635
  var effect = firstEffect;
20724
20636
 
20725
20637
  do {
20726
- var _effect2 = effect,
20727
- next = _effect2.next,
20728
- tag = _effect2.tag;
20638
+ var _effect = effect,
20639
+ next = _effect.next,
20640
+ tag = _effect.tag;
20729
20641
 
20730
20642
  if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) {
20731
- {
20732
- {
20733
- invokeGuardedCallback(null, invokePassiveEffectCreate, null, effect);
20734
- }
20735
-
20736
- if (hasCaughtError()) {
20737
- if (!(fiber !== null)) {
20738
- {
20739
- throw Error( "Should be working on an effect." );
20740
- }
20741
- }
20742
-
20743
- var error = clearCaughtError();
20744
- captureCommitPhaseError(fiber, fiber.return, error);
20745
- }
20746
- }
20643
+ enqueuePendingPassiveHookEffectUnmount(finishedWork, effect);
20644
+ enqueuePendingPassiveHookEffectMount(finishedWork, effect);
20747
20645
  }
20748
20646
 
20749
20647
  effect = next;
@@ -20766,10 +20664,7 @@
20766
20664
  commitHookEffectListMount(Layout | HasEffect, finishedWork);
20767
20665
  }
20768
20666
 
20769
- if ((finishedWork.subtreeFlags & PassiveMask) !== NoFlags) {
20770
- schedulePassiveEffectCallback();
20771
- }
20772
-
20667
+ schedulePassiveEffects(finishedWork);
20773
20668
  return;
20774
20669
  }
20775
20670
 
@@ -21035,7 +20930,7 @@
21035
20930
  // interrupt deletion, so it's okay
21036
20931
 
21037
20932
 
21038
- function commitUnmount(finishedRoot, current, nearestMountedAncestor, renderPriorityLevel) {
20933
+ function commitUnmount(finishedRoot, current, renderPriorityLevel) {
21039
20934
  onCommitUnmount(current);
21040
20935
 
21041
20936
  switch (current.tag) {
@@ -21055,14 +20950,16 @@
21055
20950
  var effect = firstEffect;
21056
20951
 
21057
20952
  do {
21058
- var _effect3 = effect,
21059
- destroy = _effect3.destroy,
21060
- tag = _effect3.tag;
20953
+ var _effect2 = effect,
20954
+ destroy = _effect2.destroy,
20955
+ tag = _effect2.tag;
21061
20956
 
21062
20957
  if (destroy !== undefined) {
21063
- if ((tag & Layout) !== NoFlags$1) {
20958
+ if ((tag & Passive$1) !== NoFlags$1) {
20959
+ enqueuePendingPassiveHookEffectUnmount(current, effect);
20960
+ } else {
21064
20961
  {
21065
- safelyCallDestroy(current, nearestMountedAncestor, destroy);
20962
+ safelyCallDestroy(current, destroy);
21066
20963
  }
21067
20964
  }
21068
20965
  }
@@ -21077,11 +20974,11 @@
21077
20974
 
21078
20975
  case ClassComponent:
21079
20976
  {
21080
- safelyDetachRef(current, nearestMountedAncestor);
20977
+ safelyDetachRef(current);
21081
20978
  var instance = current.stateNode;
21082
20979
 
21083
20980
  if (typeof instance.componentWillUnmount === 'function') {
21084
- safelyCallComponentWillUnmount(current, instance, nearestMountedAncestor);
20981
+ safelyCallComponentWillUnmount(current, instance);
21085
20982
  }
21086
20983
 
21087
20984
  return;
@@ -21089,7 +20986,7 @@
21089
20986
 
21090
20987
  case HostComponent:
21091
20988
  {
21092
- safelyDetachRef(current, nearestMountedAncestor);
20989
+ safelyDetachRef(current);
21093
20990
  return;
21094
20991
  }
21095
20992
 
@@ -21099,7 +20996,7 @@
21099
20996
  // We are also not using this parent because
21100
20997
  // the portal will get pushed immediately.
21101
20998
  {
21102
- unmountHostComponents(finishedRoot, current, nearestMountedAncestor);
20999
+ unmountHostComponents(finishedRoot, current);
21103
21000
  }
21104
21001
 
21105
21002
  return;
@@ -21125,7 +21022,7 @@
21125
21022
  }
21126
21023
  }
21127
21024
 
21128
- function commitNestedUnmounts(finishedRoot, root, nearestMountedAncestor, renderPriorityLevel) {
21025
+ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
21129
21026
  // While we're inside a removed host node we don't want to call
21130
21027
  // removeChild on the inner nodes because they're removed by the top
21131
21028
  // call anyway. We also want to call componentWillUnmount on all
@@ -21134,7 +21031,7 @@
21134
21031
  var node = root;
21135
21032
 
21136
21033
  while (true) {
21137
- commitUnmount(finishedRoot, node, nearestMountedAncestor); // Visit children because they may contain more composite or host nodes.
21034
+ commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes.
21138
21035
  // Skip portals because commitUnmount() currently visits them recursively.
21139
21036
 
21140
21037
  if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
@@ -21163,26 +21060,33 @@
21163
21060
  }
21164
21061
 
21165
21062
  function detachFiberMutation(fiber) {
21166
- // Cut off the return pointer to disconnect it from the tree.
21167
- // This enables us to detect and warn against state updates on an unmounted component.
21168
- // It also prevents events from bubbling from within disconnected components.
21169
- //
21170
- // Ideally, we should also clear the child pointer of the parent alternate to let this
21063
+ // Cut off the return pointers to disconnect it from the tree. Ideally, we
21064
+ // should clear the child pointer of the parent alternate to let this
21171
21065
  // get GC:ed but we don't know which for sure which parent is the current
21172
- // one so we'll settle for GC:ing the subtree of this child.
21173
- // This child itself will be GC:ed when the parent updates the next time.
21066
+ // one so we'll settle for GC:ing the subtree of this child. This child
21067
+ // itself will be GC:ed when the parent updates the next time.
21068
+ // Note: we cannot null out sibling here, otherwise it can cause issues
21069
+ // with findDOMNode and how it requires the sibling field to carry out
21070
+ // traversal in a later effect. See PR #16820. We now clear the sibling
21071
+ // field after effects, see: detachFiberAfterEffects.
21174
21072
  //
21175
- // Note that we can't clear child or sibling pointers yet.
21176
- // They're needed for passive effects and for findDOMNode.
21177
- // We defer those fields, and all other cleanup, to the passive phase (see detachFiberAfterEffects).
21178
- var alternate = fiber.alternate;
21073
+ // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects.
21074
+ // It may be required if the current component is an error boundary,
21075
+ // and one of its descendants throws while unmounting a passive effect.
21076
+ fiber.alternate = null;
21077
+ fiber.child = null;
21078
+ fiber.dependencies = null;
21079
+ fiber.firstEffect = null;
21080
+ fiber.lastEffect = null;
21081
+ fiber.memoizedProps = null;
21082
+ fiber.memoizedState = null;
21083
+ fiber.pendingProps = null;
21084
+ fiber.return = null;
21085
+ fiber.updateQueue = null;
21179
21086
 
21180
- if (alternate !== null) {
21181
- alternate.return = null;
21182
- fiber.alternate = null;
21087
+ {
21088
+ fiber._debugOwner = null;
21183
21089
  }
21184
-
21185
- fiber.return = null;
21186
21090
  }
21187
21091
 
21188
21092
  function getHostParentFiber(fiber) {
@@ -21364,7 +21268,7 @@
21364
21268
  }
21365
21269
  }
21366
21270
 
21367
- function unmountHostComponents(finishedRoot, current, nearestMountedAncestor, renderPriorityLevel) {
21271
+ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
21368
21272
  // We only have the top Fiber that was deleted but we need to recurse down its
21369
21273
  // children to find all the terminal nodes.
21370
21274
  var node = current; // Each iteration, currentParent is populated with node's host parent if not
@@ -21413,7 +21317,7 @@
21413
21317
  }
21414
21318
 
21415
21319
  if (node.tag === HostComponent || node.tag === HostText) {
21416
- commitNestedUnmounts(finishedRoot, node, nearestMountedAncestor); // After all the children have unmounted, it is now safe to remove the
21320
+ commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the
21417
21321
  // node from the tree.
21418
21322
 
21419
21323
  if (currentParentIsContainer) {
@@ -21434,7 +21338,7 @@
21434
21338
  continue;
21435
21339
  }
21436
21340
  } else {
21437
- commitUnmount(finishedRoot, node, nearestMountedAncestor); // Visit children because we may find more host components below.
21341
+ commitUnmount(finishedRoot, node); // Visit children because we may find more host components below.
21438
21342
 
21439
21343
  if (node.child !== null) {
21440
21344
  node.child.return = node;
@@ -21466,11 +21370,11 @@
21466
21370
  }
21467
21371
  }
21468
21372
 
21469
- function commitDeletion(finishedRoot, current, nearestMountedAncestor, renderPriorityLevel) {
21373
+ function commitDeletion(finishedRoot, current, renderPriorityLevel) {
21470
21374
  {
21471
21375
  // Recursively delete all host nodes from the parent.
21472
21376
  // Detach refs and call componentWillUnmount() on the whole subtree.
21473
- unmountHostComponents(finishedRoot, current, nearestMountedAncestor);
21377
+ unmountHostComponents(finishedRoot, current);
21474
21378
  }
21475
21379
 
21476
21380
  var alternate = current.alternate;
@@ -21496,7 +21400,7 @@
21496
21400
  // e.g. a destroy function in one component should never override a ref set
21497
21401
  // by a create function in another component during the same commit.
21498
21402
  {
21499
- commitHookEffectListUnmount(Layout | HasEffect, finishedWork, finishedWork.return);
21403
+ commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
21500
21404
  }
21501
21405
 
21502
21406
  return;
@@ -21712,42 +21616,6 @@
21712
21616
  resetTextContent(current.stateNode);
21713
21617
  }
21714
21618
 
21715
- function commitPassiveWork(finishedWork) {
21716
- switch (finishedWork.tag) {
21717
- case FunctionComponent:
21718
- case ForwardRef:
21719
- case SimpleMemoComponent:
21720
- case Block:
21721
- {
21722
- commitHookEffectListUnmount2(Passive$1 | HasEffect, finishedWork, finishedWork.return);
21723
- break;
21724
- }
21725
- }
21726
- }
21727
-
21728
- function commitPassiveUnmount(current, nearestMountedAncestor) {
21729
- switch (current.tag) {
21730
- case FunctionComponent:
21731
- case ForwardRef:
21732
- case SimpleMemoComponent:
21733
- case Block:
21734
- commitHookEffectListUnmount2(Passive$1, current, nearestMountedAncestor);
21735
- }
21736
- }
21737
-
21738
- function commitPassiveLifeCycles(finishedRoot, finishedWork) {
21739
- switch (finishedWork.tag) {
21740
- case FunctionComponent:
21741
- case ForwardRef:
21742
- case SimpleMemoComponent:
21743
- case Block:
21744
- {
21745
- commitHookEffectListMount2(finishedWork);
21746
- break;
21747
- }
21748
- }
21749
- }
21750
-
21751
21619
  var COMPONENT_TYPE = 0;
21752
21620
  var HAS_PSEUDO_CLASS_TYPE = 1;
21753
21621
  var ROLE_TYPE = 2;
@@ -21858,6 +21726,7 @@
21858
21726
  function getRenderTargetTime() {
21859
21727
  return workInProgressRootRenderTargetTime;
21860
21728
  }
21729
+ var nextEffect = null;
21861
21730
  var hasUncaughtError = false;
21862
21731
  var firstUncaughtError = null;
21863
21732
  var legacyErrorBoundariesThatAlreadyFailed = null;
@@ -21865,6 +21734,8 @@
21865
21734
  var rootWithPendingPassiveEffects = null;
21866
21735
  var pendingPassiveEffectsRenderPriority = NoPriority$1;
21867
21736
  var pendingPassiveEffectsLanes = NoLanes;
21737
+ var pendingPassiveHookEffectsMount = [];
21738
+ var pendingPassiveHookEffectsUnmount = [];
21868
21739
  var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
21869
21740
 
21870
21741
  var NESTED_UPDATE_LIMIT = 50;
@@ -22187,7 +22058,7 @@
22187
22058
  // goes through Scheduler.
22188
22059
 
22189
22060
 
22190
- function performConcurrentWorkOnRoot(root, didTimeout) {
22061
+ function performConcurrentWorkOnRoot(root) {
22191
22062
  // Since we know we're in a React event, we can clear the current
22192
22063
  // event time. The next update will compute a new event time.
22193
22064
  currentEventTime = NoTimestamp;
@@ -22223,18 +22094,6 @@
22223
22094
  if (lanes === NoLanes) {
22224
22095
  // Defensive coding. This is never expected to happen.
22225
22096
  return null;
22226
- } // TODO: We only check `didTimeout` defensively, to account for a Scheduler
22227
- // bug we're still investigating. Once the bug in Scheduler is fixed,
22228
- // we can remove this, since we track expiration ourselves.
22229
-
22230
-
22231
- if ( didTimeout) {
22232
- // Something expired. Flush synchronously until there's no expired
22233
- // work left.
22234
- markRootExpired(root, lanes); // This will schedule a synchronous callback.
22235
-
22236
- ensureRootIsScheduled(root, now());
22237
- return null;
22238
22097
  }
22239
22098
 
22240
22099
  var exitStatus = renderRootConcurrent(root, lanes);
@@ -22995,6 +22854,46 @@
22995
22854
  workInProgress = next;
22996
22855
  return;
22997
22856
  }
22857
+
22858
+ resetChildLanes(completedWork);
22859
+
22860
+ if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
22861
+ (returnFiber.flags & Incomplete) === NoFlags) {
22862
+ // Append all the effects of the subtree and this fiber onto the effect
22863
+ // list of the parent. The completion order of the children affects the
22864
+ // side-effect order.
22865
+ if (returnFiber.firstEffect === null) {
22866
+ returnFiber.firstEffect = completedWork.firstEffect;
22867
+ }
22868
+
22869
+ if (completedWork.lastEffect !== null) {
22870
+ if (returnFiber.lastEffect !== null) {
22871
+ returnFiber.lastEffect.nextEffect = completedWork.firstEffect;
22872
+ }
22873
+
22874
+ returnFiber.lastEffect = completedWork.lastEffect;
22875
+ } // If this fiber had side-effects, we append it AFTER the children's
22876
+ // side-effects. We can perform certain side-effects earlier if needed,
22877
+ // by doing multiple passes over the effect list. We don't want to
22878
+ // schedule our own side-effect on our own list because if end up
22879
+ // reusing children we'll schedule this effect onto itself since we're
22880
+ // at the end.
22881
+
22882
+
22883
+ var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect
22884
+ // list. PerformedWork effect is read by React DevTools but shouldn't be
22885
+ // committed.
22886
+
22887
+ if (flags > PerformedWork) {
22888
+ if (returnFiber.lastEffect !== null) {
22889
+ returnFiber.lastEffect.nextEffect = completedWork;
22890
+ } else {
22891
+ returnFiber.firstEffect = completedWork;
22892
+ }
22893
+
22894
+ returnFiber.lastEffect = completedWork;
22895
+ }
22896
+ }
22998
22897
  } else {
22999
22898
  // This fiber did not complete because something threw. Pop values off
23000
22899
  // the stack without entering the complete phase. If this is a boundary,
@@ -23028,10 +22927,9 @@
23028
22927
  }
23029
22928
 
23030
22929
  if (returnFiber !== null) {
23031
- // Mark the parent fiber as incomplete
22930
+ // Mark the parent fiber as incomplete and clear its effect list.
22931
+ returnFiber.firstEffect = returnFiber.lastEffect = null;
23032
22932
  returnFiber.flags |= Incomplete;
23033
- returnFiber.subtreeFlags = NoFlags;
23034
- returnFiber.deletions = null;
23035
22933
  }
23036
22934
  }
23037
22935
 
@@ -23055,6 +22953,68 @@
23055
22953
  }
23056
22954
  }
23057
22955
 
22956
+ function resetChildLanes(completedWork) {
22957
+ if ( // TODO: Move this check out of the hot path by moving `resetChildLanes`
22958
+ // to switch statement in `completeWork`.
22959
+ (completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) {
22960
+ // The children of this component are hidden. Don't bubble their
22961
+ // expiration times.
22962
+ return;
22963
+ }
22964
+
22965
+ var newChildLanes = NoLanes; // Bubble up the earliest expiration time.
22966
+
22967
+ if ( (completedWork.mode & ProfileMode) !== NoMode) {
22968
+ // In profiling mode, resetChildExpirationTime is also used to reset
22969
+ // profiler durations.
22970
+ var actualDuration = completedWork.actualDuration;
22971
+ var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
22972
+ // only be updated if work is done on the fiber (i.e. it doesn't bailout).
22973
+ // When work is done, it should bubble to the parent's actualDuration. If
22974
+ // the fiber has not been cloned though, (meaning no work was done), then
22975
+ // this value will reflect the amount of time spent working on a previous
22976
+ // render. In that case it should not bubble. We determine whether it was
22977
+ // cloned by comparing the child pointer.
22978
+
22979
+ var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
22980
+ var child = completedWork.child;
22981
+
22982
+ while (child !== null) {
22983
+ newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
22984
+
22985
+ if (shouldBubbleActualDurations) {
22986
+ actualDuration += child.actualDuration;
22987
+ }
22988
+
22989
+ treeBaseDuration += child.treeBaseDuration;
22990
+ child = child.sibling;
22991
+ }
22992
+
22993
+ var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null;
22994
+
22995
+ if (isTimedOutSuspense) {
22996
+ // Don't count time spent in a timed out Suspense subtree as part of the base duration.
22997
+ var primaryChildFragment = completedWork.child;
22998
+
22999
+ if (primaryChildFragment !== null) {
23000
+ treeBaseDuration -= primaryChildFragment.treeBaseDuration;
23001
+ }
23002
+ }
23003
+
23004
+ completedWork.actualDuration = actualDuration;
23005
+ completedWork.treeBaseDuration = treeBaseDuration;
23006
+ } else {
23007
+ var _child = completedWork.child;
23008
+
23009
+ while (_child !== null) {
23010
+ newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
23011
+ _child = _child.sibling;
23012
+ }
23013
+ }
23014
+
23015
+ completedWork.childLanes = newChildLanes;
23016
+ }
23017
+
23058
23018
  function commitRoot(root) {
23059
23019
  var renderPriorityLevel = getCurrentPriorityLevel();
23060
23020
  runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel));
@@ -23118,17 +23078,28 @@
23118
23078
  workInProgressRoot = null;
23119
23079
  workInProgress = null;
23120
23080
  workInProgressRootRenderLanes = NoLanes;
23121
- } // Check if there are any effects in the whole tree.
23122
- // TODO: This is left over from the effect list implementation, where we had
23123
- // to check for the existence of `firstEffect` to satsify Flow. I think the
23124
- // only other reason this optimization exists is because it affects profiling.
23125
- // Reconsider whether this is necessary.
23081
+ } // Get the list of effects.
23126
23082
 
23127
23083
 
23128
- var subtreeHasEffects = (finishedWork.subtreeFlags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
23129
- var rootHasEffect = (finishedWork.flags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoFlags;
23084
+ var firstEffect;
23130
23085
 
23131
- if (subtreeHasEffects || rootHasEffect) {
23086
+ if (finishedWork.flags > PerformedWork) {
23087
+ // A fiber's effect list consists only of its children, not itself. So if
23088
+ // the root has an effect, we need to add it to the end of the list. The
23089
+ // resulting list is the set that would belong to the root's parent, if it
23090
+ // had one; that is, all the effects in the tree including the root.
23091
+ if (finishedWork.lastEffect !== null) {
23092
+ finishedWork.lastEffect.nextEffect = finishedWork;
23093
+ firstEffect = finishedWork.firstEffect;
23094
+ } else {
23095
+ firstEffect = finishedWork;
23096
+ }
23097
+ } else {
23098
+ // There is no effect on the root.
23099
+ firstEffect = finishedWork.firstEffect;
23100
+ }
23101
+
23102
+ if (firstEffect !== null) {
23132
23103
 
23133
23104
  var prevExecutionContext = executionContext;
23134
23105
  executionContext |= CommitContext;
@@ -23143,7 +23114,26 @@
23143
23114
 
23144
23115
  focusedInstanceHandle = prepareForCommit(root.containerInfo);
23145
23116
  shouldFireAfterActiveInstanceBlur = false;
23146
- commitBeforeMutationEffects(finishedWork); // We no longer need to track the active instance fiber
23117
+ nextEffect = firstEffect;
23118
+
23119
+ do {
23120
+ {
23121
+ invokeGuardedCallback(null, commitBeforeMutationEffects, null);
23122
+
23123
+ if (hasCaughtError()) {
23124
+ if (!(nextEffect !== null)) {
23125
+ {
23126
+ throw Error( "Should be working on an effect." );
23127
+ }
23128
+ }
23129
+
23130
+ var error = clearCaughtError();
23131
+ captureCommitPhaseError(nextEffect, error);
23132
+ nextEffect = nextEffect.nextEffect;
23133
+ }
23134
+ }
23135
+ } while (nextEffect !== null); // We no longer need to track the active instance fiber
23136
+
23147
23137
 
23148
23138
  focusedInstanceHandle = null;
23149
23139
 
@@ -23154,7 +23144,26 @@
23154
23144
  } // The next phase is the mutation phase, where we mutate the host tree.
23155
23145
 
23156
23146
 
23157
- commitMutationEffects(finishedWork, root, renderPriorityLevel);
23147
+ nextEffect = firstEffect;
23148
+
23149
+ do {
23150
+ {
23151
+ invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
23152
+
23153
+ if (hasCaughtError()) {
23154
+ if (!(nextEffect !== null)) {
23155
+ {
23156
+ throw Error( "Should be working on an effect." );
23157
+ }
23158
+ }
23159
+
23160
+ var _error = clearCaughtError();
23161
+
23162
+ captureCommitPhaseError(nextEffect, _error);
23163
+ nextEffect = nextEffect.nextEffect;
23164
+ }
23165
+ }
23166
+ } while (nextEffect !== null);
23158
23167
 
23159
23168
  resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
23160
23169
  // the mutation phase, so that the previous tree is still current during
@@ -23162,21 +23171,32 @@
23162
23171
  // work is current during componentDidMount/Update.
23163
23172
 
23164
23173
  root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
23174
+ // the host tree after it's been mutated. The idiomatic use case for this is
23175
+ // layout, but class component lifecycles also fire here for legacy reasons.
23165
23176
 
23166
- commitLayoutEffects(finishedWork, root, lanes);
23177
+ nextEffect = firstEffect;
23167
23178
 
23179
+ do {
23180
+ {
23181
+ invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes);
23168
23182
 
23169
- if ((finishedWork.subtreeFlags & PassiveMask) !== NoFlags || (finishedWork.flags & PassiveMask) !== NoFlags) {
23170
- if (!rootDoesHavePassiveEffects) {
23171
- rootDoesHavePassiveEffects = true;
23172
- scheduleCallback(NormalPriority$1, function () {
23173
- flushPassiveEffects();
23174
- return null;
23175
- });
23183
+ if (hasCaughtError()) {
23184
+ if (!(nextEffect !== null)) {
23185
+ {
23186
+ throw Error( "Should be working on an effect." );
23187
+ }
23188
+ }
23189
+
23190
+ var _error2 = clearCaughtError();
23191
+
23192
+ captureCommitPhaseError(nextEffect, _error2);
23193
+ nextEffect = nextEffect.nextEffect;
23194
+ }
23176
23195
  }
23177
- } // Tell Scheduler to yield at the end of the frame, so the browser has an
23178
- // opportunity to paint.
23196
+ } while (nextEffect !== null);
23179
23197
 
23198
+ nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
23199
+ // opportunity to paint.
23180
23200
 
23181
23201
  requestPaint();
23182
23202
 
@@ -23205,6 +23225,22 @@
23205
23225
  rootWithPendingPassiveEffects = root;
23206
23226
  pendingPassiveEffectsLanes = lanes;
23207
23227
  pendingPassiveEffectsRenderPriority = renderPriorityLevel;
23228
+ } else {
23229
+ // We are done with the effect chain at this point so let's clear the
23230
+ // nextEffect pointers to assist with GC. If we have passive effects, we'll
23231
+ // clear this in flushPassiveEffects.
23232
+ nextEffect = firstEffect;
23233
+
23234
+ while (nextEffect !== null) {
23235
+ var nextNextEffect = nextEffect.nextEffect;
23236
+ nextEffect.nextEffect = null;
23237
+
23238
+ if (nextEffect.flags & Deletion) {
23239
+ detachFiberAfterEffects(nextEffect);
23240
+ }
23241
+
23242
+ nextEffect = nextNextEffect;
23243
+ }
23208
23244
  } // Read this again, since an effect might have updated it
23209
23245
 
23210
23246
 
@@ -23264,9 +23300,9 @@
23264
23300
 
23265
23301
  if (hasUncaughtError) {
23266
23302
  hasUncaughtError = false;
23267
- var error = firstUncaughtError;
23303
+ var _error3 = firstUncaughtError;
23268
23304
  firstUncaughtError = null;
23269
- throw error;
23305
+ throw _error3;
23270
23306
  }
23271
23307
 
23272
23308
  if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
@@ -23284,255 +23320,151 @@
23284
23320
  return null;
23285
23321
  }
23286
23322
 
23287
- function commitBeforeMutationEffects(firstChild) {
23288
- var fiber = firstChild;
23289
-
23290
- while (fiber !== null) {
23291
- if (fiber.deletions !== null) {
23292
- commitBeforeMutationEffectsDeletions(fiber.deletions);
23293
- }
23294
-
23295
- if (fiber.child !== null) {
23296
- var primarySubtreeFlags = fiber.subtreeFlags & BeforeMutationMask;
23323
+ function commitBeforeMutationEffects() {
23324
+ while (nextEffect !== null) {
23325
+ var current = nextEffect.alternate;
23297
23326
 
23298
- if (primarySubtreeFlags !== NoFlags) {
23299
- commitBeforeMutationEffects(fiber.child);
23327
+ if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
23328
+ if ((nextEffect.flags & Deletion) !== NoFlags) {
23329
+ if (doesFiberContain(nextEffect, focusedInstanceHandle)) {
23330
+ shouldFireAfterActiveInstanceBlur = true;
23331
+ }
23332
+ } else {
23333
+ // TODO: Move this out of the hot path using a dedicated effect tag.
23334
+ if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) {
23335
+ shouldFireAfterActiveInstanceBlur = true;
23336
+ }
23300
23337
  }
23301
23338
  }
23302
23339
 
23303
- {
23304
- setCurrentFiber(fiber);
23305
- invokeGuardedCallback(null, commitBeforeMutationEffectsImpl, null, fiber);
23306
-
23307
- if (hasCaughtError()) {
23308
- var error = clearCaughtError();
23309
- captureCommitPhaseError(fiber, fiber.return, error);
23310
- }
23340
+ var flags = nextEffect.flags;
23311
23341
 
23342
+ if ((flags & Snapshot) !== NoFlags) {
23343
+ setCurrentFiber(nextEffect);
23344
+ commitBeforeMutationLifeCycles(current, nextEffect);
23312
23345
  resetCurrentFiber();
23313
23346
  }
23314
23347
 
23315
- fiber = fiber.sibling;
23316
- }
23317
- }
23318
-
23319
- function commitBeforeMutationEffectsImpl(fiber) {
23320
- var current = fiber.alternate;
23321
- var flags = fiber.flags;
23322
-
23323
- if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
23324
- // Check to see if the focused element was inside of a hidden (Suspense) subtree.
23325
- // TODO: Move this out of the hot path using a dedicated effect tag.
23326
- if (fiber.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, fiber) && doesFiberContain(fiber, focusedInstanceHandle)) {
23327
- shouldFireAfterActiveInstanceBlur = true;
23328
- }
23329
- }
23330
-
23331
- if ((flags & Snapshot) !== NoFlags) {
23332
- setCurrentFiber(fiber);
23333
- commitBeforeMutationLifeCycles(current, fiber);
23334
- resetCurrentFiber();
23335
- }
23336
-
23337
- if ((flags & Passive) !== NoFlags) {
23338
- // If there are passive effects, schedule a callback to flush at
23339
- // the earliest opportunity.
23340
- if (!rootDoesHavePassiveEffects) {
23341
- rootDoesHavePassiveEffects = true;
23342
- scheduleCallback(NormalPriority$1, function () {
23343
- flushPassiveEffects();
23344
- return null;
23345
- });
23346
- }
23347
- }
23348
- }
23349
-
23350
- function commitBeforeMutationEffectsDeletions(deletions) {
23351
- for (var i = 0; i < deletions.length; i++) {
23352
- var fiber = deletions[i]; // TODO (effects) It would be nice to avoid calling doesFiberContain()
23353
- // Maybe we can repurpose one of the subtreeFlags positions for this instead?
23354
- // Use it to store which part of the tree the focused instance is in?
23355
- // This assumes we can safely determine that instance during the "render" phase.
23356
-
23357
- if (doesFiberContain(fiber, focusedInstanceHandle)) {
23358
- shouldFireAfterActiveInstanceBlur = true;
23359
- }
23360
- }
23361
- }
23362
-
23363
- function commitMutationEffects(firstChild, root, renderPriorityLevel) {
23364
- var fiber = firstChild;
23365
-
23366
- while (fiber !== null) {
23367
- var deletions = fiber.deletions;
23368
-
23369
- if (deletions !== null) {
23370
- commitMutationEffectsDeletions(deletions, fiber, root, renderPriorityLevel);
23371
- }
23372
-
23373
- if (fiber.child !== null) {
23374
- var mutationFlags = fiber.subtreeFlags & MutationMask;
23375
-
23376
- if (mutationFlags !== NoFlags) {
23377
- commitMutationEffects(fiber.child, root, renderPriorityLevel);
23378
- }
23379
- }
23380
-
23381
- {
23382
- setCurrentFiber(fiber);
23383
- invokeGuardedCallback(null, commitMutationEffectsImpl, null, fiber, root, renderPriorityLevel);
23384
-
23385
- if (hasCaughtError()) {
23386
- var error = clearCaughtError();
23387
- captureCommitPhaseError(fiber, fiber.return, error);
23348
+ if ((flags & Passive) !== NoFlags) {
23349
+ // If there are passive effects, schedule a callback to flush at
23350
+ // the earliest opportunity.
23351
+ if (!rootDoesHavePassiveEffects) {
23352
+ rootDoesHavePassiveEffects = true;
23353
+ scheduleCallback(NormalPriority$1, function () {
23354
+ flushPassiveEffects();
23355
+ return null;
23356
+ });
23388
23357
  }
23389
-
23390
- resetCurrentFiber();
23391
23358
  }
23392
23359
 
23393
- fiber = fiber.sibling;
23360
+ nextEffect = nextEffect.nextEffect;
23394
23361
  }
23395
23362
  }
23396
23363
 
23397
- function commitMutationEffectsImpl(fiber, root, renderPriorityLevel) {
23398
- var flags = fiber.flags;
23399
-
23400
- if (flags & ContentReset) {
23401
- commitResetTextContent(fiber);
23402
- }
23403
-
23404
- if (flags & Ref) {
23405
- var current = fiber.alternate;
23364
+ function commitMutationEffects(root, renderPriorityLevel) {
23365
+ // TODO: Should probably move the bulk of this function to commitWork.
23366
+ while (nextEffect !== null) {
23367
+ setCurrentFiber(nextEffect);
23368
+ var flags = nextEffect.flags;
23406
23369
 
23407
- if (current !== null) {
23408
- commitDetachRef(current);
23370
+ if (flags & ContentReset) {
23371
+ commitResetTextContent(nextEffect);
23409
23372
  }
23410
- } // The following switch statement is only concerned about placement,
23411
- // updates, and deletions. To avoid needing to add a case for every possible
23412
- // bitmap value, we remove the secondary effects from the effect tag and
23413
- // switch on that value.
23414
23373
 
23374
+ if (flags & Ref) {
23375
+ var current = nextEffect.alternate;
23415
23376
 
23416
- var primaryFlags = flags & (Placement | Update | Hydrating);
23377
+ if (current !== null) {
23378
+ commitDetachRef(current);
23379
+ }
23380
+ } // The following switch statement is only concerned about placement,
23381
+ // updates, and deletions. To avoid needing to add a case for every possible
23382
+ // bitmap value, we remove the secondary effects from the effect tag and
23383
+ // switch on that value.
23417
23384
 
23418
- switch (primaryFlags) {
23419
- case Placement:
23420
- {
23421
- commitPlacement(fiber); // Clear the "placement" from effect tag so that we know that this is
23422
- // inserted, before any life-cycles like componentDidMount gets called.
23423
- // TODO: findDOMNode doesn't rely on this any more but isMounted does
23424
- // and isMounted is deprecated anyway so we should be able to kill this.
23425
23385
 
23426
- fiber.flags &= ~Placement;
23427
- break;
23428
- }
23386
+ var primaryFlags = flags & (Placement | Update | Deletion | Hydrating);
23429
23387
 
23430
- case PlacementAndUpdate:
23431
- {
23432
- // Placement
23433
- commitPlacement(fiber); // Clear the "placement" from effect tag so that we know that this is
23434
- // inserted, before any life-cycles like componentDidMount gets called.
23388
+ switch (primaryFlags) {
23389
+ case Placement:
23390
+ {
23391
+ commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
23392
+ // inserted, before any life-cycles like componentDidMount gets called.
23393
+ // TODO: findDOMNode doesn't rely on this any more but isMounted does
23394
+ // and isMounted is deprecated anyway so we should be able to kill this.
23435
23395
 
23436
- fiber.flags &= ~Placement; // Update
23396
+ nextEffect.flags &= ~Placement;
23397
+ break;
23398
+ }
23437
23399
 
23438
- var _current = fiber.alternate;
23439
- commitWork(_current, fiber);
23440
- break;
23441
- }
23400
+ case PlacementAndUpdate:
23401
+ {
23402
+ // Placement
23403
+ commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
23404
+ // inserted, before any life-cycles like componentDidMount gets called.
23442
23405
 
23443
- case Hydrating:
23444
- {
23445
- fiber.flags &= ~Hydrating;
23446
- break;
23447
- }
23406
+ nextEffect.flags &= ~Placement; // Update
23448
23407
 
23449
- case HydratingAndUpdate:
23450
- {
23451
- fiber.flags &= ~Hydrating; // Update
23408
+ var _current = nextEffect.alternate;
23409
+ commitWork(_current, nextEffect);
23410
+ break;
23411
+ }
23452
23412
 
23453
- var _current2 = fiber.alternate;
23454
- commitWork(_current2, fiber);
23455
- break;
23456
- }
23413
+ case Hydrating:
23414
+ {
23415
+ nextEffect.flags &= ~Hydrating;
23416
+ break;
23417
+ }
23457
23418
 
23458
- case Update:
23459
- {
23460
- var _current3 = fiber.alternate;
23461
- commitWork(_current3, fiber);
23462
- break;
23463
- }
23464
- }
23465
- }
23419
+ case HydratingAndUpdate:
23420
+ {
23421
+ nextEffect.flags &= ~Hydrating; // Update
23466
23422
 
23467
- function commitMutationEffectsDeletions(deletions, nearestMountedAncestor, root, renderPriorityLevel) {
23468
- for (var i = 0; i < deletions.length; i++) {
23469
- var childToDelete = deletions[i];
23423
+ var _current2 = nextEffect.alternate;
23424
+ commitWork(_current2, nextEffect);
23425
+ break;
23426
+ }
23470
23427
 
23471
- {
23472
- invokeGuardedCallback(null, commitDeletion, null, root, childToDelete, nearestMountedAncestor, renderPriorityLevel);
23428
+ case Update:
23429
+ {
23430
+ var _current3 = nextEffect.alternate;
23431
+ commitWork(_current3, nextEffect);
23432
+ break;
23433
+ }
23473
23434
 
23474
- if (hasCaughtError()) {
23475
- var error = clearCaughtError();
23476
- captureCommitPhaseError(childToDelete, nearestMountedAncestor, error);
23477
- }
23435
+ case Deletion:
23436
+ {
23437
+ commitDeletion(root, nextEffect);
23438
+ break;
23439
+ }
23478
23440
  }
23479
- }
23480
- }
23481
23441
 
23482
- function schedulePassiveEffectCallback() {
23483
- if (!rootDoesHavePassiveEffects) {
23484
- rootDoesHavePassiveEffects = true;
23485
- scheduleCallback(NormalPriority$1, function () {
23486
- flushPassiveEffects();
23487
- return null;
23488
- });
23442
+ resetCurrentFiber();
23443
+ nextEffect = nextEffect.nextEffect;
23489
23444
  }
23490
23445
  }
23491
23446
 
23492
- function commitLayoutEffects(firstChild, root, committedLanes) {
23493
- var fiber = firstChild;
23447
+ function commitLayoutEffects(root, committedLanes) {
23494
23448
 
23495
- while (fiber !== null) {
23496
- if (fiber.child !== null) {
23497
- var primarySubtreeFlags = fiber.subtreeFlags & LayoutMask;
23498
23449
 
23499
- if (primarySubtreeFlags !== NoFlags) {
23500
- commitLayoutEffects(fiber.child, root, committedLanes);
23501
- }
23450
+ while (nextEffect !== null) {
23451
+ setCurrentFiber(nextEffect);
23452
+ var flags = nextEffect.flags;
23453
+
23454
+ if (flags & (Update | Callback)) {
23455
+ var current = nextEffect.alternate;
23456
+ commitLifeCycles(root, current, nextEffect);
23502
23457
  }
23503
23458
 
23504
23459
  {
23505
- setCurrentFiber(fiber);
23506
- invokeGuardedCallback(null, commitLayoutEffectsImpl, null, fiber, root, committedLanes);
23507
-
23508
- if (hasCaughtError()) {
23509
- var error = clearCaughtError();
23510
- captureCommitPhaseError(fiber, fiber.return, error);
23460
+ if (flags & Ref) {
23461
+ commitAttachRef(nextEffect);
23511
23462
  }
23512
-
23513
- resetCurrentFiber();
23514
23463
  }
23515
23464
 
23516
- fiber = fiber.sibling;
23517
- }
23518
- }
23519
-
23520
- function commitLayoutEffectsImpl(fiber, root, committedLanes) {
23521
- var flags = fiber.flags;
23522
- setCurrentFiber(fiber);
23523
-
23524
- if (flags & (Update | Callback)) {
23525
- var current = fiber.alternate;
23526
- commitLifeCycles(root, current, fiber);
23527
- }
23528
-
23529
- {
23530
- if (flags & Ref) {
23531
- commitAttachRef(fiber);
23532
- }
23465
+ resetCurrentFiber();
23466
+ nextEffect = nextEffect.nextEffect;
23533
23467
  }
23534
-
23535
- resetCurrentFiber();
23536
23468
  }
23537
23469
 
23538
23470
  function flushPassiveEffects() {
@@ -23548,87 +23480,41 @@
23548
23480
 
23549
23481
  return false;
23550
23482
  }
23483
+ function enqueuePendingPassiveHookEffectMount(fiber, effect) {
23484
+ pendingPassiveHookEffectsMount.push(effect, fiber);
23551
23485
 
23552
- function flushPassiveMountEffects(root, firstChild) {
23553
- var fiber = firstChild;
23554
-
23555
- while (fiber !== null) {
23556
- var primarySubtreeFlags = fiber.subtreeFlags & PassiveMask;
23557
-
23558
- if (fiber.child !== null && primarySubtreeFlags !== NoFlags) {
23559
- flushPassiveMountEffects(root, fiber.child);
23560
- }
23561
-
23562
- if ((fiber.flags & Passive) !== NoFlags) {
23563
- setCurrentFiber(fiber);
23564
- commitPassiveLifeCycles(root, fiber);
23565
- resetCurrentFiber();
23566
- }
23567
-
23568
- fiber = fiber.sibling;
23486
+ if (!rootDoesHavePassiveEffects) {
23487
+ rootDoesHavePassiveEffects = true;
23488
+ scheduleCallback(NormalPriority$1, function () {
23489
+ flushPassiveEffects();
23490
+ return null;
23491
+ });
23569
23492
  }
23570
23493
  }
23494
+ function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
23495
+ pendingPassiveHookEffectsUnmount.push(effect, fiber);
23571
23496
 
23572
- function flushPassiveUnmountEffects(firstChild) {
23573
- var fiber = firstChild;
23574
-
23575
- while (fiber !== null) {
23576
- var deletions = fiber.deletions;
23577
-
23578
- if (deletions !== null) {
23579
- for (var i = 0; i < deletions.length; i++) {
23580
- var fiberToDelete = deletions[i];
23581
- flushPassiveUnmountEffectsInsideOfDeletedTree(fiberToDelete, fiber); // Now that passive effects have been processed, it's safe to detach lingering pointers.
23582
-
23583
- detachFiberAfterEffects(fiberToDelete);
23584
- }
23585
- }
23586
-
23587
- var child = fiber.child;
23588
-
23589
- if (child !== null) {
23590
- // If any children have passive effects then traverse the subtree.
23591
- // Note that this requires checking subtreeFlags of the current Fiber,
23592
- // rather than the subtreeFlags/effectsTag of the first child,
23593
- // since that would not cover passive effects in siblings.
23594
- var passiveFlags = fiber.subtreeFlags & PassiveMask;
23595
-
23596
- if (passiveFlags !== NoFlags) {
23597
- flushPassiveUnmountEffects(child);
23598
- }
23599
- }
23600
-
23601
- var primaryFlags = fiber.flags & Passive;
23497
+ {
23498
+ fiber.flags |= PassiveUnmountPendingDev;
23499
+ var alternate = fiber.alternate;
23602
23500
 
23603
- if (primaryFlags !== NoFlags) {
23604
- setCurrentFiber(fiber);
23605
- commitPassiveWork(fiber);
23606
- resetCurrentFiber();
23501
+ if (alternate !== null) {
23502
+ alternate.flags |= PassiveUnmountPendingDev;
23607
23503
  }
23608
-
23609
- fiber = fiber.sibling;
23610
23504
  }
23611
- }
23612
-
23613
- function flushPassiveUnmountEffectsInsideOfDeletedTree(fiberToDelete, nearestMountedAncestor) {
23614
- if ((fiberToDelete.subtreeFlags & PassiveStatic) !== NoFlags) {
23615
- // If any children have passive effects then traverse the subtree.
23616
- // Note that this requires checking subtreeFlags of the current Fiber,
23617
- // rather than the subtreeFlags/effectsTag of the first child,
23618
- // since that would not cover passive effects in siblings.
23619
- var child = fiberToDelete.child;
23620
23505
 
23621
- while (child !== null) {
23622
- flushPassiveUnmountEffectsInsideOfDeletedTree(child, nearestMountedAncestor);
23623
- child = child.sibling;
23624
- }
23506
+ if (!rootDoesHavePassiveEffects) {
23507
+ rootDoesHavePassiveEffects = true;
23508
+ scheduleCallback(NormalPriority$1, function () {
23509
+ flushPassiveEffects();
23510
+ return null;
23511
+ });
23625
23512
  }
23513
+ }
23626
23514
 
23627
- if ((fiberToDelete.flags & PassiveStatic) !== NoFlags) {
23628
- setCurrentFiber(fiberToDelete);
23629
- commitPassiveUnmount(fiberToDelete, nearestMountedAncestor);
23630
- resetCurrentFiber();
23631
- }
23515
+ function invokePassiveEffectCreate(effect) {
23516
+ var create = effect.create;
23517
+ effect.destroy = create();
23632
23518
  }
23633
23519
 
23634
23520
  function flushPassiveEffectsImpl() {
@@ -23659,9 +23545,97 @@
23659
23545
  // e.g. a destroy function in one component may unintentionally override a ref
23660
23546
  // value set by a create function in another component.
23661
23547
  // Layout effects have the same constraint.
23548
+ // First pass: Destroy stale passive effects.
23549
+
23550
+ var unmountEffects = pendingPassiveHookEffectsUnmount;
23551
+ pendingPassiveHookEffectsUnmount = [];
23552
+
23553
+ for (var i = 0; i < unmountEffects.length; i += 2) {
23554
+ var _effect = unmountEffects[i];
23555
+ var fiber = unmountEffects[i + 1];
23556
+ var destroy = _effect.destroy;
23557
+ _effect.destroy = undefined;
23558
+
23559
+ {
23560
+ fiber.flags &= ~PassiveUnmountPendingDev;
23561
+ var alternate = fiber.alternate;
23562
+
23563
+ if (alternate !== null) {
23564
+ alternate.flags &= ~PassiveUnmountPendingDev;
23565
+ }
23566
+ }
23567
+
23568
+ if (typeof destroy === 'function') {
23569
+ {
23570
+ setCurrentFiber(fiber);
23571
+
23572
+ {
23573
+ invokeGuardedCallback(null, destroy, null);
23574
+ }
23575
+
23576
+ if (hasCaughtError()) {
23577
+ if (!(fiber !== null)) {
23578
+ {
23579
+ throw Error( "Should be working on an effect." );
23580
+ }
23581
+ }
23582
+
23583
+ var error = clearCaughtError();
23584
+ captureCommitPhaseError(fiber, error);
23585
+ }
23586
+
23587
+ resetCurrentFiber();
23588
+ }
23589
+ }
23590
+ } // Second pass: Create new passive effects.
23662
23591
 
23663
- flushPassiveUnmountEffects(root.current);
23664
- flushPassiveMountEffects(root, root.current);
23592
+
23593
+ var mountEffects = pendingPassiveHookEffectsMount;
23594
+ pendingPassiveHookEffectsMount = [];
23595
+
23596
+ for (var _i = 0; _i < mountEffects.length; _i += 2) {
23597
+ var _effect2 = mountEffects[_i];
23598
+ var _fiber = mountEffects[_i + 1];
23599
+
23600
+ {
23601
+ setCurrentFiber(_fiber);
23602
+
23603
+ {
23604
+ invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2);
23605
+ }
23606
+
23607
+ if (hasCaughtError()) {
23608
+ if (!(_fiber !== null)) {
23609
+ {
23610
+ throw Error( "Should be working on an effect." );
23611
+ }
23612
+ }
23613
+
23614
+ var _error4 = clearCaughtError();
23615
+
23616
+ captureCommitPhaseError(_fiber, _error4);
23617
+ }
23618
+
23619
+ resetCurrentFiber();
23620
+ }
23621
+ } // Note: This currently assumes there are no passive effects on the root fiber
23622
+ // because the root is not part of its own effect list.
23623
+ // This could change in the future.
23624
+
23625
+
23626
+ var effect = root.current.firstEffect;
23627
+
23628
+ while (effect !== null) {
23629
+ var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
23630
+
23631
+ effect.nextEffect = null;
23632
+
23633
+ if (effect.flags & Deletion) {
23634
+ detachFiberAfterEffects(effect);
23635
+ }
23636
+
23637
+ effect = nextNextEffect;
23638
+ }
23665
23639
 
23666
23640
  {
23667
23641
  popInteractions(prevInteractions);
@@ -23714,7 +23688,7 @@
23714
23688
  }
23715
23689
  }
23716
23690
 
23717
- function captureCommitPhaseError(sourceFiber, nearestMountedAncestor, error) {
23691
+ function captureCommitPhaseError(sourceFiber, error) {
23718
23692
  if (sourceFiber.tag === HostRoot) {
23719
23693
  // Error was thrown at the root. There is no parent, so the root
23720
23694
  // itself should capture it.
@@ -23722,11 +23696,7 @@
23722
23696
  return;
23723
23697
  }
23724
23698
 
23725
- var fiber = null;
23726
-
23727
- {
23728
- fiber = nearestMountedAncestor;
23729
- }
23699
+ var fiber = sourceFiber.return;
23730
23700
 
23731
23701
  while (fiber !== null) {
23732
23702
  if (fiber.tag === HostRoot) {
@@ -23747,6 +23717,20 @@
23747
23717
  markRootUpdated(root, SyncLane, eventTime);
23748
23718
  ensureRootIsScheduled(root, eventTime);
23749
23719
  schedulePendingInteractions(root, SyncLane);
23720
+ } else {
23721
+ // This component has already been unmounted.
23722
+ // We can't schedule any follow up work for the root because the fiber is already unmounted,
23723
+ // but we can still call the log-only boundary so the error isn't swallowed.
23724
+ //
23725
+ // TODO This is only a temporary bandaid for the old reconciler fork.
23726
+ // We can delete this special case once the new fork is merged.
23727
+ if (typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
23728
+ try {
23729
+ instance.componentDidCatch(error, errorInfo);
23730
+ } catch (errorToIgnore) {// TODO Ignore this error? Rethrow it?
23731
+ // This is kind of an edge case.
23732
+ }
23733
+ }
23750
23734
  }
23751
23735
 
23752
23736
  return;
@@ -23929,29 +23913,12 @@
23929
23913
  if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
23930
23914
  // Only warn for user-defined components, not internal ones like Suspense.
23931
23915
  return;
23932
- }
23933
-
23934
- if ((fiber.flags & PassiveStatic) !== NoFlags) {
23935
- var updateQueue = fiber.updateQueue;
23936
-
23937
- if (updateQueue !== null) {
23938
- var lastEffect = updateQueue.lastEffect;
23916
+ } // If there are pending passive effects unmounts for this Fiber,
23917
+ // we can assume that they would have prevented this update.
23939
23918
 
23940
- if (lastEffect !== null) {
23941
- var firstEffect = lastEffect.next;
23942
- var effect = firstEffect;
23943
23919
 
23944
- do {
23945
- if (effect.destroy !== undefined) {
23946
- if ((effect.tag & Passive$1) !== NoFlags$1) {
23947
- return;
23948
- }
23949
- }
23950
-
23951
- effect = effect.next;
23952
- } while (effect !== firstEffect);
23953
- }
23954
- }
23920
+ if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) {
23921
+ return;
23955
23922
  } // We show the whole stack but dedupe on the top component's name because
23956
23923
  // the problematic code almost always lies inside that component.
23957
23924
 
@@ -24306,21 +24273,8 @@
24306
24273
  var actingUpdatesScopeDepth = 0;
24307
24274
 
24308
24275
  function detachFiberAfterEffects(fiber) {
24309
- // Null out fields to improve GC for references that may be lingering (e.g. DevTools).
24310
- // Note that we already cleared the return pointer in detachFiberMutation().
24311
- fiber.child = null;
24312
- fiber.deletions = null;
24313
- fiber.dependencies = null;
24314
- fiber.memoizedProps = null;
24315
- fiber.memoizedState = null;
24316
- fiber.pendingProps = null;
24317
24276
  fiber.sibling = null;
24318
24277
  fiber.stateNode = null;
24319
- fiber.updateQueue = null;
24320
-
24321
- {
24322
- fiber._debugOwner = null;
24323
- }
24324
24278
  }
24325
24279
 
24326
24280
  var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
@@ -24760,8 +24714,9 @@
24760
24714
  this.mode = mode; // Effects
24761
24715
 
24762
24716
  this.flags = NoFlags;
24763
- this.subtreeFlags = NoFlags;
24764
- this.deletions = null;
24717
+ this.nextEffect = null;
24718
+ this.firstEffect = null;
24719
+ this.lastEffect = null;
24765
24720
  this.lanes = NoLanes;
24766
24721
  this.childLanes = NoLanes;
24767
24722
  this.alternate = null;
@@ -24878,9 +24833,13 @@
24878
24833
  workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type.
24879
24834
 
24880
24835
  workInProgress.type = current.type; // We already have an alternate.
24836
+ // Reset the effect tag.
24837
+
24838
+ workInProgress.flags = NoFlags; // The effect list is no longer valid.
24881
24839
 
24882
- workInProgress.subtreeFlags = NoFlags;
24883
- workInProgress.deletions = null;
24840
+ workInProgress.nextEffect = null;
24841
+ workInProgress.firstEffect = null;
24842
+ workInProgress.lastEffect = null;
24884
24843
 
24885
24844
  {
24886
24845
  // We intentionally reset, rather than copy, actualDuration & actualStartTime.
@@ -24890,11 +24849,8 @@
24890
24849
  workInProgress.actualDuration = 0;
24891
24850
  workInProgress.actualStartTime = -1;
24892
24851
  }
24893
- } // Reset all effects except static ones.
24894
- // Static effects are not specific to a render.
24895
-
24852
+ }
24896
24853
 
24897
- workInProgress.flags = current.flags & StaticMask;
24898
24854
  workInProgress.childLanes = current.childLanes;
24899
24855
  workInProgress.lanes = current.lanes;
24900
24856
  workInProgress.child = current.child;
@@ -24950,7 +24906,11 @@
24950
24906
  // avoid doing another reconciliation.
24951
24907
  // Reset the effect tag but keep any Placement tags, since that's something
24952
24908
  // that child fiber is setting, not the reconciliation.
24953
- workInProgress.flags &= Placement;
24909
+ workInProgress.flags &= Placement; // The effect list is no longer valid.
24910
+
24911
+ workInProgress.nextEffect = null;
24912
+ workInProgress.firstEffect = null;
24913
+ workInProgress.lastEffect = null;
24954
24914
  var current = workInProgress.alternate;
24955
24915
 
24956
24916
  if (current === null) {
@@ -24958,7 +24918,6 @@
24958
24918
  workInProgress.childLanes = NoLanes;
24959
24919
  workInProgress.lanes = renderLanes;
24960
24920
  workInProgress.child = null;
24961
- workInProgress.subtreeFlags = NoFlags;
24962
24921
  workInProgress.memoizedProps = null;
24963
24922
  workInProgress.memoizedState = null;
24964
24923
  workInProgress.updateQueue = null;
@@ -24976,8 +24935,6 @@
24976
24935
  workInProgress.childLanes = current.childLanes;
24977
24936
  workInProgress.lanes = current.lanes;
24978
24937
  workInProgress.child = current.child;
24979
- workInProgress.subtreeFlags = current.subtreeFlags;
24980
- workInProgress.deletions = null;
24981
24938
  workInProgress.memoizedProps = current.memoizedProps;
24982
24939
  workInProgress.memoizedState = current.memoizedState;
24983
24940
  workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type.
@@ -25298,8 +25255,9 @@
25298
25255
  target.dependencies = source.dependencies;
25299
25256
  target.mode = source.mode;
25300
25257
  target.flags = source.flags;
25301
- target.subtreeFlags = source.subtreeFlags;
25302
- target.deletions = source.deletions;
25258
+ target.nextEffect = source.nextEffect;
25259
+ target.firstEffect = source.firstEffect;
25260
+ target.lastEffect = source.lastEffect;
25303
25261
  target.lanes = source.lanes;
25304
25262
  target.childLanes = source.childLanes;
25305
25263
  target.alternate = source.alternate;