react-dom 16.1.0 → 16.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v16.1.0
1
+ /** @license React v16.2.1
2
2
  * react-dom.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -9,6 +9,8 @@
9
9
 
10
10
  'use strict';
11
11
 
12
+
13
+
12
14
  if (process.env.NODE_ENV !== "production") {
13
15
  (function() {
14
16
  'use strict';
@@ -18,7 +20,7 @@ var invariant = require('fbjs/lib/invariant');
18
20
  var warning = require('fbjs/lib/warning');
19
21
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
20
22
  var _assign = require('object-assign');
21
- var emptyFunction$1 = require('fbjs/lib/emptyFunction');
23
+ var emptyFunction = require('fbjs/lib/emptyFunction');
22
24
  var EventListener = require('fbjs/lib/EventListener');
23
25
  var getActiveElement = require('fbjs/lib/getActiveElement');
24
26
  var shallowEqual = require('fbjs/lib/shallowEqual');
@@ -251,13 +253,13 @@ var HTMLDOMPropertyConfig = {
251
253
  // name warnings.
252
254
  Properties: {
253
255
  allowFullScreen: HAS_BOOLEAN_VALUE,
254
- autoFocus: HAS_STRING_BOOLEAN_VALUE,
255
256
  // specifies target context for links with `preload` type
256
257
  async: HAS_BOOLEAN_VALUE,
257
- // autoFocus is polyfilled/normalized by AutoFocusUtils
258
- // autoFocus: HAS_BOOLEAN_VALUE,
258
+ // Note: there is a special case that prevents it from being written to the DOM
259
+ // on the client side because the browsers are inconsistent. Instead we call focus().
260
+ autoFocus: HAS_BOOLEAN_VALUE,
259
261
  autoPlay: HAS_BOOLEAN_VALUE,
260
- capture: HAS_BOOLEAN_VALUE,
262
+ capture: HAS_OVERLOADED_BOOLEAN_VALUE,
261
263
  checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
262
264
  cols: HAS_POSITIVE_NUMERIC_VALUE,
263
265
  contentEditable: HAS_STRING_BOOLEAN_VALUE,
@@ -1099,6 +1101,11 @@ function processEventQueue(simulated) {
1099
1101
  // events get enqueued while processing.
1100
1102
  var processingEventQueue = eventQueue;
1101
1103
  eventQueue = null;
1104
+
1105
+ if (!processingEventQueue) {
1106
+ return;
1107
+ }
1108
+
1102
1109
  if (simulated) {
1103
1110
  forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
1104
1111
  } else {
@@ -1560,7 +1567,7 @@ var EventInterface = {
1560
1567
  type: null,
1561
1568
  target: null,
1562
1569
  // currentTarget is set when dispatching; no use in copying it here
1563
- currentTarget: emptyFunction$1.thatReturnsNull,
1570
+ currentTarget: emptyFunction.thatReturnsNull,
1564
1571
  eventPhase: null,
1565
1572
  bubbles: null,
1566
1573
  cancelable: null,
@@ -1623,11 +1630,11 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
1623
1630
 
1624
1631
  var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
1625
1632
  if (defaultPrevented) {
1626
- this.isDefaultPrevented = emptyFunction$1.thatReturnsTrue;
1633
+ this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
1627
1634
  } else {
1628
- this.isDefaultPrevented = emptyFunction$1.thatReturnsFalse;
1635
+ this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
1629
1636
  }
1630
- this.isPropagationStopped = emptyFunction$1.thatReturnsFalse;
1637
+ this.isPropagationStopped = emptyFunction.thatReturnsFalse;
1631
1638
  return this;
1632
1639
  }
1633
1640
 
@@ -1644,7 +1651,7 @@ _assign(SyntheticEvent.prototype, {
1644
1651
  } else if (typeof event.returnValue !== 'unknown') {
1645
1652
  event.returnValue = false;
1646
1653
  }
1647
- this.isDefaultPrevented = emptyFunction$1.thatReturnsTrue;
1654
+ this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
1648
1655
  },
1649
1656
 
1650
1657
  stopPropagation: function () {
@@ -1664,7 +1671,7 @@ _assign(SyntheticEvent.prototype, {
1664
1671
  event.cancelBubble = true;
1665
1672
  }
1666
1673
 
1667
- this.isPropagationStopped = emptyFunction$1.thatReturnsTrue;
1674
+ this.isPropagationStopped = emptyFunction.thatReturnsTrue;
1668
1675
  },
1669
1676
 
1670
1677
  /**
@@ -1673,7 +1680,7 @@ _assign(SyntheticEvent.prototype, {
1673
1680
  * won't be added back into the pool.
1674
1681
  */
1675
1682
  persist: function () {
1676
- this.isPersistent = emptyFunction$1.thatReturnsTrue;
1683
+ this.isPersistent = emptyFunction.thatReturnsTrue;
1677
1684
  },
1678
1685
 
1679
1686
  /**
@@ -1681,7 +1688,7 @@ _assign(SyntheticEvent.prototype, {
1681
1688
  *
1682
1689
  * @return {boolean} True if this should not be released, false otherwise.
1683
1690
  */
1684
- isPersistent: emptyFunction$1.thatReturnsFalse,
1691
+ isPersistent: emptyFunction.thatReturnsFalse,
1685
1692
 
1686
1693
  /**
1687
1694
  * `PooledClass` looks for `destructor` on each instance it releases.
@@ -1698,8 +1705,8 @@ _assign(SyntheticEvent.prototype, {
1698
1705
  }
1699
1706
  {
1700
1707
  Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
1701
- Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction$1));
1702
- Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction$1));
1708
+ Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction));
1709
+ Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction));
1703
1710
  }
1704
1711
  }
1705
1712
  });
@@ -3714,17 +3721,7 @@ function listenTo(registrationName, contentDocumentHandle) {
3714
3721
  for (var i = 0; i < dependencies.length; i++) {
3715
3722
  var dependency = dependencies[i];
3716
3723
  if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
3717
- if (dependency === 'topWheel') {
3718
- if (isEventSupported('wheel')) {
3719
- trapBubbledEvent('topWheel', 'wheel', mountAt);
3720
- } else if (isEventSupported('mousewheel')) {
3721
- trapBubbledEvent('topWheel', 'mousewheel', mountAt);
3722
- } else {
3723
- // Firefox needs to capture a different mouse scroll event.
3724
- // @see http://www.quirksmode.org/dom/events/tests/scroll.html
3725
- trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt);
3726
- }
3727
- } else if (dependency === 'topScroll') {
3724
+ if (dependency === 'topScroll') {
3728
3725
  trapCapturedEvent('topScroll', 'scroll', mountAt);
3729
3726
  } else if (dependency === 'topFocus' || dependency === 'topBlur') {
3730
3727
  trapCapturedEvent('topFocus', 'focus', mountAt);
@@ -3834,10 +3831,10 @@ function getOffsets(outerNode) {
3834
3831
  return null;
3835
3832
  }
3836
3833
 
3837
- var anchorNode = selection.anchorNode;
3838
- var anchorOffset = selection.anchorOffset;
3839
- var focusNode$$1 = selection.focusNode;
3840
- var focusOffset = selection.focusOffset;
3834
+ var anchorNode = selection.anchorNode,
3835
+ anchorOffset = selection.anchorOffset,
3836
+ focusNode$$1 = selection.focusNode,
3837
+ focusOffset = selection.focusOffset;
3841
3838
 
3842
3839
  // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
3843
3840
  // up/down buttons on an <input type="number">. Anonymous divs do not seem to
@@ -3846,6 +3843,7 @@ function getOffsets(outerNode) {
3846
3843
  // is to access a property that typically works for non-anonymous divs and
3847
3844
  // catch any error that may otherwise arise. See
3848
3845
  // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
3846
+
3849
3847
  try {
3850
3848
  /* eslint-disable no-unused-expressions */
3851
3849
  anchorNode.nodeType;
@@ -4764,8 +4762,6 @@ injection$1.injectEventPluginsByName({
4764
4762
 
4765
4763
  var enableAsyncSubtreeAPI = true;
4766
4764
  var enableAsyncSchedulingByDefaultInReactDOM = false;
4767
- // Exports React.Fragment
4768
- var enableReactFragment = false;
4769
4765
  // Exports ReactDOM.createRoot
4770
4766
  var enableCreateRoot = false;
4771
4767
  var enableUserTimingAPI = true;
@@ -4777,6 +4773,9 @@ var enableNoopReconciler = false;
4777
4773
  // Experimental persistent mode (CS):
4778
4774
  var enablePersistentReconciler = false;
4779
4775
 
4776
+ // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
4777
+ var debugRenderPhaseSideEffects = false;
4778
+
4780
4779
  // Only used in www builds.
4781
4780
 
4782
4781
  var valueStack = [];
@@ -4957,6 +4956,7 @@ var hasScheduledUpdateInCurrentCommit = false;
4957
4956
  var hasScheduledUpdateInCurrentPhase = false;
4958
4957
  var commitCountInCurrentWorkLoop = 0;
4959
4958
  var effectCountInCurrentCommit = 0;
4959
+ var isWaitingForCallback = false;
4960
4960
  // During commits, we only show a measurement once per method name
4961
4961
  // to avoid stretch the commit phase with measurement overhead.
4962
4962
  var labelsInCurrentCommit = new Set();
@@ -5115,6 +5115,25 @@ function recordScheduleUpdate() {
5115
5115
  }
5116
5116
  }
5117
5117
 
5118
+ function startRequestCallbackTimer() {
5119
+ if (enableUserTimingAPI) {
5120
+ if (supportsUserTiming && !isWaitingForCallback) {
5121
+ isWaitingForCallback = true;
5122
+ beginMark('(Waiting for async callback...)');
5123
+ }
5124
+ }
5125
+ }
5126
+
5127
+ function stopRequestCallbackTimer(didExpire) {
5128
+ if (enableUserTimingAPI) {
5129
+ if (supportsUserTiming) {
5130
+ isWaitingForCallback = false;
5131
+ var warning$$1 = didExpire ? 'React was blocked by main thread' : null;
5132
+ endMark('(Waiting for async callback...)', '(Waiting for async callback...)', warning$$1);
5133
+ }
5134
+ }
5135
+ }
5136
+
5118
5137
  function startWorkTimer(fiber) {
5119
5138
  if (enableUserTimingAPI) {
5120
5139
  if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
@@ -5537,6 +5556,10 @@ function msToExpirationTime(ms) {
5537
5556
  return (ms / UNIT_SIZE | 0) + MAGIC_NUMBER_OFFSET;
5538
5557
  }
5539
5558
 
5559
+ function expirationTimeToMs(expirationTime) {
5560
+ return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE;
5561
+ }
5562
+
5540
5563
  function ceiling(num, precision) {
5541
5564
  return ((num / precision | 0) + 1) * precision;
5542
5565
  }
@@ -5553,8 +5576,7 @@ var AsyncUpdates = 1;
5553
5576
  try {
5554
5577
  var nonExtensibleObject = Object.preventExtensions({});
5555
5578
  /* eslint-disable no-new */
5556
- new Map([[nonExtensibleObject, null]]);
5557
- new Set([nonExtensibleObject]);
5579
+
5558
5580
  /* eslint-enable no-new */
5559
5581
  } catch (e) {
5560
5582
  // TODO: Consider warning about bad polyfills
@@ -5721,7 +5743,7 @@ function createFiberFromElement(element, internalContextTag, expirationTime) {
5721
5743
  var info = '';
5722
5744
  {
5723
5745
  if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
5724
- info += ' You likely forgot to export your component from the file ' + "it's defined in.";
5746
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
5725
5747
  }
5726
5748
  var ownerName = owner ? getComponentName(owner) : null;
5727
5749
  if (ownerName) {
@@ -5991,6 +6013,12 @@ function getStateFromUpdate(update, instance, prevState, props) {
5991
6013
  var partialState = update.partialState;
5992
6014
  if (typeof partialState === 'function') {
5993
6015
  var updateFn = partialState;
6016
+
6017
+ // Invoke setState callback an extra time to help detect side-effects.
6018
+ if (debugRenderPhaseSideEffects) {
6019
+ updateFn.call(instance, prevState, props);
6020
+ }
6021
+
5994
6022
  return updateFn.call(instance, prevState, props);
5995
6023
  } else {
5996
6024
  return partialState;
@@ -6236,6 +6264,11 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6236
6264
  var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
6237
6265
  stopPhaseTimer();
6238
6266
 
6267
+ // Simulate an async bailout/interruption by invoking lifecycle twice.
6268
+ if (debugRenderPhaseSideEffects) {
6269
+ instance.shouldComponentUpdate(newProps, newState, newContext);
6270
+ }
6271
+
6239
6272
  {
6240
6273
  warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');
6241
6274
  }
@@ -6292,10 +6325,10 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6292
6325
 
6293
6326
  var state = instance.state;
6294
6327
  if (state && (typeof state !== 'object' || isArray(state))) {
6295
- invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));
6328
+ warning(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));
6296
6329
  }
6297
6330
  if (typeof instance.getChildContext === 'function') {
6298
- !(typeof workInProgress.type.childContextTypes === 'object') ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().', getComponentName(workInProgress)) : void 0;
6331
+ warning(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));
6299
6332
  }
6300
6333
  }
6301
6334
 
@@ -6335,9 +6368,13 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6335
6368
  startPhaseTimer(workInProgress, 'componentWillMount');
6336
6369
  var oldState = instance.state;
6337
6370
  instance.componentWillMount();
6338
-
6339
6371
  stopPhaseTimer();
6340
6372
 
6373
+ // Simulate an async bailout/interruption by invoking lifecycle twice.
6374
+ if (debugRenderPhaseSideEffects) {
6375
+ instance.componentWillMount();
6376
+ }
6377
+
6341
6378
  if (oldState !== instance.state) {
6342
6379
  {
6343
6380
  warning(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));
@@ -6352,6 +6389,11 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6352
6389
  instance.componentWillReceiveProps(newProps, newContext);
6353
6390
  stopPhaseTimer();
6354
6391
 
6392
+ // Simulate an async bailout/interruption by invoking lifecycle twice.
6393
+ if (debugRenderPhaseSideEffects) {
6394
+ instance.componentWillReceiveProps(newProps, newContext);
6395
+ }
6396
+
6355
6397
  if (instance.state !== oldState) {
6356
6398
  {
6357
6399
  var componentName = getComponentName(workInProgress) || 'Component';
@@ -6561,6 +6603,11 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6561
6603
  startPhaseTimer(workInProgress, 'componentWillUpdate');
6562
6604
  instance.componentWillUpdate(newProps, newState, newContext);
6563
6605
  stopPhaseTimer();
6606
+
6607
+ // Simulate an async bailout/interruption by invoking lifecycle twice.
6608
+ if (debugRenderPhaseSideEffects) {
6609
+ instance.componentWillUpdate(newProps, newState, newContext);
6610
+ }
6564
6611
  }
6565
6612
  if (typeof instance.componentDidUpdate === 'function') {
6566
6613
  workInProgress.effectTag |= Update;
@@ -6598,23 +6645,28 @@ var ReactFiberClassComponent = function (scheduleWork, computeExpirationForFiber
6598
6645
  };
6599
6646
  };
6600
6647
 
6601
- // The Symbol used to tag the special React types. If there is no native Symbol
6648
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
6602
6649
  // nor polyfill, then a plain number is used for performance.
6603
- var REACT_PORTAL_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.portal') || 0xeaca;
6650
+ var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
6604
6651
 
6605
- function createPortal$1(children, containerInfo,
6606
- // TODO: figure out the API for cross-renderer implementation.
6607
- implementation) {
6608
- var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
6652
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
6653
+ var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
6654
+ var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
6655
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
6656
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
6609
6657
 
6610
- return {
6611
- // This tag allow us to uniquely identify this as a React Portal
6612
- $$typeof: REACT_PORTAL_TYPE,
6613
- key: key == null ? null : '' + key,
6614
- children: children,
6615
- containerInfo: containerInfo,
6616
- implementation: implementation
6617
- };
6658
+ var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
6659
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
6660
+
6661
+ function getIteratorFn(maybeIterable) {
6662
+ if (maybeIterable === null || typeof maybeIterable === 'undefined') {
6663
+ return null;
6664
+ }
6665
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
6666
+ if (typeof maybeIterator === 'function') {
6667
+ return maybeIterator;
6668
+ }
6669
+ return null;
6618
6670
  }
6619
6671
 
6620
6672
  var getCurrentFiberStackAddendum$1 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
@@ -6652,38 +6704,6 @@ var getCurrentFiberStackAddendum$1 = ReactDebugCurrentFiber.getCurrentFiberStack
6652
6704
 
6653
6705
  var isArray$1 = Array.isArray;
6654
6706
 
6655
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
6656
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
6657
-
6658
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
6659
- // nor polyfill, then a plain number is used for performance.
6660
- var REACT_ELEMENT_TYPE;
6661
- var REACT_CALL_TYPE;
6662
- var REACT_RETURN_TYPE;
6663
- var REACT_FRAGMENT_TYPE;
6664
- if (typeof Symbol === 'function' && Symbol['for']) {
6665
- REACT_ELEMENT_TYPE = Symbol['for']('react.element');
6666
- REACT_CALL_TYPE = Symbol['for']('react.call');
6667
- REACT_RETURN_TYPE = Symbol['for']('react.return');
6668
- REACT_FRAGMENT_TYPE = Symbol['for']('react.fragment');
6669
- } else {
6670
- REACT_ELEMENT_TYPE = 0xeac7;
6671
- REACT_CALL_TYPE = 0xeac8;
6672
- REACT_RETURN_TYPE = 0xeac9;
6673
- REACT_FRAGMENT_TYPE = 0xeacb;
6674
- }
6675
-
6676
- function getIteratorFn(maybeIterable) {
6677
- if (maybeIterable === null || typeof maybeIterable === 'undefined') {
6678
- return null;
6679
- }
6680
- var iteratorFn = ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
6681
- if (typeof iteratorFn === 'function') {
6682
- return iteratorFn;
6683
- }
6684
- return null;
6685
- }
6686
-
6687
6707
  function coerceRef(current, element) {
6688
6708
  var mixedRef = element.ref;
6689
6709
  if (mixedRef !== null && typeof mixedRef !== 'function') {
@@ -6744,21 +6764,12 @@ function warnOnFunctionType() {
6744
6764
  // to be able to optimize each path individually by branching early. This needs
6745
6765
  // a compiler or we can do it manually. Helpers that don't need this branching
6746
6766
  // live outside of this function.
6747
- function ChildReconciler(shouldClone, shouldTrackSideEffects) {
6767
+ function ChildReconciler(shouldTrackSideEffects) {
6748
6768
  function deleteChild(returnFiber, childToDelete) {
6749
6769
  if (!shouldTrackSideEffects) {
6750
6770
  // Noop.
6751
6771
  return;
6752
6772
  }
6753
- if (!shouldClone) {
6754
- // When we're reconciling in place we have a work in progress copy. We
6755
- // actually want the current copy. If there is no current copy, then we
6756
- // don't need to track deletion side-effects.
6757
- if (childToDelete.alternate === null) {
6758
- return;
6759
- }
6760
- childToDelete = childToDelete.alternate;
6761
- }
6762
6773
  // Deletions are added in reversed order so we add it to the front.
6763
6774
  // At this point, the return fiber's effect list is empty except for
6764
6775
  // deletions, so we can just append the deletion to the list. The remaining
@@ -6811,22 +6822,10 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
6811
6822
  function useFiber(fiber, pendingProps, expirationTime) {
6812
6823
  // We currently set sibling to null and index to 0 here because it is easy
6813
6824
  // to forget to do before returning it. E.g. for the single child case.
6814
- if (shouldClone) {
6815
- var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
6816
- clone.index = 0;
6817
- clone.sibling = null;
6818
- return clone;
6819
- } else {
6820
- // We override the expiration time even if it is earlier, because if
6821
- // we're reconciling at a later time that means that this was
6822
- // down-prioritized.
6823
- fiber.expirationTime = expirationTime;
6824
- fiber.effectTag = NoEffect;
6825
- fiber.index = 0;
6826
- fiber.sibling = null;
6827
- fiber.pendingProps = pendingProps;
6828
- return fiber;
6829
- }
6825
+ var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
6826
+ clone.index = 0;
6827
+ clone.sibling = null;
6828
+ return clone;
6830
6829
  }
6831
6830
 
6832
6831
  function placeChild(newFiber, lastPlacedIndex, newIndex) {
@@ -7623,7 +7622,7 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
7623
7622
  // Handle top level unkeyed fragments as if they were arrays.
7624
7623
  // This leads to an ambiguity between <>{[...]}</> and <>...</>.
7625
7624
  // We treat the ambiguous cases above the same.
7626
- if (enableReactFragment && typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
7625
+ if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
7627
7626
  newChild = newChild.props.children;
7628
7627
  }
7629
7628
 
@@ -7698,11 +7697,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
7698
7697
  return reconcileChildFibers;
7699
7698
  }
7700
7699
 
7701
- var reconcileChildFibers = ChildReconciler(true, true);
7702
-
7703
- var reconcileChildFibersInPlace = ChildReconciler(false, true);
7704
-
7705
- var mountChildFibersInPlace = ChildReconciler(false, false);
7700
+ var reconcileChildFibers = ChildReconciler(true);
7701
+ var mountChildFibers = ChildReconciler(false);
7706
7702
 
7707
7703
  function cloneChildFibers(current, workInProgress) {
7708
7704
  !(current === null || workInProgress.child === current.child) ? invariant(false, 'Resuming work not yet implemented.') : void 0;
@@ -7757,20 +7753,15 @@ var ReactFiberBeginWork = function (config, hostContext, hydrationContext, sched
7757
7753
  // won't update its child set by applying minimal side-effects. Instead,
7758
7754
  // we will add them all to the child before it gets rendered. That means
7759
7755
  // we can optimize this reconciliation pass by not tracking side-effects.
7760
- workInProgress.child = mountChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, renderExpirationTime);
7761
- } else if (current.child === workInProgress.child) {
7756
+ workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7757
+ } else {
7762
7758
  // If the current child is the same as the work in progress, it means that
7763
7759
  // we haven't yet started any work on these children. Therefore, we use
7764
7760
  // the clone algorithm to create a copy of all the current children.
7765
7761
 
7766
7762
  // If we had any progressed work already, that is invalid at this point so
7767
7763
  // let's throw it out.
7768
- workInProgress.child = reconcileChildFibers(workInProgress, workInProgress.child, nextChildren, renderExpirationTime);
7769
- } else {
7770
- // If, on the other hand, it is already using a clone, that means we've
7771
- // already begun some work on this tree and we can continue where we left
7772
- // off by reconciling against the existing children.
7773
- workInProgress.child = reconcileChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, renderExpirationTime);
7764
+ workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderExpirationTime);
7774
7765
  }
7775
7766
  }
7776
7767
 
@@ -7880,6 +7871,9 @@ var ReactFiberBeginWork = function (config, hostContext, hydrationContext, sched
7880
7871
  {
7881
7872
  ReactDebugCurrentFiber.setCurrentPhase('render');
7882
7873
  nextChildren = instance.render();
7874
+ if (debugRenderPhaseSideEffects) {
7875
+ instance.render();
7876
+ }
7883
7877
  ReactDebugCurrentFiber.setCurrentPhase(null);
7884
7878
  }
7885
7879
  // React DevTools reads this flag.
@@ -7938,7 +7932,7 @@ var ReactFiberBeginWork = function (config, hostContext, hydrationContext, sched
7938
7932
  // Ensure that children mount into this root without tracking
7939
7933
  // side-effects. This ensures that we don't store Placement effects on
7940
7934
  // nodes that will be hydrated.
7941
- workInProgress.child = mountChildFibersInPlace(workInProgress, workInProgress.child, element, renderExpirationTime);
7935
+ workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
7942
7936
  } else {
7943
7937
  // Otherwise reset hydration state in case we aborted and resumed another
7944
7938
  // root.
@@ -8105,11 +8099,9 @@ var ReactFiberBeginWork = function (config, hostContext, hydrationContext, sched
8105
8099
  // The following is a fork of reconcileChildrenAtExpirationTime but using
8106
8100
  // stateNode to store the child.
8107
8101
  if (current === null) {
8108
- workInProgress.stateNode = mountChildFibersInPlace(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
8109
- } else if (current.child === workInProgress.child) {
8110
- workInProgress.stateNode = reconcileChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
8102
+ workInProgress.stateNode = mountChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
8111
8103
  } else {
8112
- workInProgress.stateNode = reconcileChildFibersInPlace(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
8104
+ workInProgress.stateNode = reconcileChildFibers(workInProgress, workInProgress.stateNode, nextChildren, renderExpirationTime);
8113
8105
  }
8114
8106
 
8115
8107
  memoizeProps(workInProgress, nextCall);
@@ -8138,7 +8130,7 @@ var ReactFiberBeginWork = function (config, hostContext, hydrationContext, sched
8138
8130
  // flow doesn't do during mount. This doesn't happen at the root because
8139
8131
  // the root always starts with a "current" with a null child.
8140
8132
  // TODO: Consider unifying this with how the root works.
8141
- workInProgress.child = reconcileChildFibersInPlace(workInProgress, workInProgress.child, nextChildren, renderExpirationTime);
8133
+ workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8142
8134
  memoizeProps(workInProgress, nextChildren);
8143
8135
  } else {
8144
8136
  reconcileChildren(current, workInProgress, nextChildren);
@@ -9528,18 +9520,28 @@ var ReactFiberHydrationContext = function (config) {
9528
9520
  }
9529
9521
  }
9530
9522
 
9531
- function canHydrate(fiber, nextInstance) {
9523
+ function tryHydrate(fiber, nextInstance) {
9532
9524
  switch (fiber.tag) {
9533
9525
  case HostComponent:
9534
9526
  {
9535
9527
  var type = fiber.type;
9536
9528
  var props = fiber.pendingProps;
9537
- return canHydrateInstance(nextInstance, type, props);
9529
+ var instance = canHydrateInstance(nextInstance, type, props);
9530
+ if (instance !== null) {
9531
+ fiber.stateNode = instance;
9532
+ return true;
9533
+ }
9534
+ return false;
9538
9535
  }
9539
9536
  case HostText:
9540
9537
  {
9541
9538
  var text = fiber.pendingProps;
9542
- return canHydrateTextInstance(nextInstance, text);
9539
+ var textInstance = canHydrateTextInstance(nextInstance, text);
9540
+ if (textInstance !== null) {
9541
+ fiber.stateNode = textInstance;
9542
+ return true;
9543
+ }
9544
+ return false;
9543
9545
  }
9544
9546
  default:
9545
9547
  return false;
@@ -9558,12 +9560,12 @@ var ReactFiberHydrationContext = function (config) {
9558
9560
  hydrationParentFiber = fiber;
9559
9561
  return;
9560
9562
  }
9561
- if (!canHydrate(fiber, nextInstance)) {
9563
+ if (!tryHydrate(fiber, nextInstance)) {
9562
9564
  // If we can't hydrate this instance let's try the next one.
9563
9565
  // We use this as a heuristic. It's based on intuition and not data so it
9564
9566
  // might be flawed or unnecessary.
9565
9567
  nextInstance = getNextHydratableSibling(nextInstance);
9566
- if (!nextInstance || !canHydrate(fiber, nextInstance)) {
9568
+ if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
9567
9569
  // Nothing to hydrate. Make it an insertion.
9568
9570
  insertNonHydratedInstance(hydrationParentFiber, fiber);
9569
9571
  isHydrating = false;
@@ -9576,7 +9578,6 @@ var ReactFiberHydrationContext = function (config) {
9576
9578
  // fiber associated with it.
9577
9579
  deleteHydratableInstance(hydrationParentFiber, nextHydratableInstance);
9578
9580
  }
9579
- fiber.stateNode = nextInstance;
9580
9581
  hydrationParentFiber = fiber;
9581
9582
  nextHydratableInstance = getFirstHydratableChild(nextInstance);
9582
9583
  }
@@ -9710,6 +9711,12 @@ function logCapturedError(capturedError) {
9710
9711
  return;
9711
9712
  }
9712
9713
 
9714
+ var error = capturedError.error;
9715
+ var suppressLogging = error && error.suppressReactErrorLogging;
9716
+ if (suppressLogging) {
9717
+ return;
9718
+ }
9719
+
9713
9720
  {
9714
9721
  var componentName = capturedError.componentName,
9715
9722
  componentStack = capturedError.componentStack,
@@ -9805,6 +9812,7 @@ var ReactFiberScheduler = function (config) {
9805
9812
 
9806
9813
  var now = config.now,
9807
9814
  scheduleDeferredCallback = config.scheduleDeferredCallback,
9815
+ cancelDeferredCallback = config.cancelDeferredCallback,
9808
9816
  useSyncScheduling = config.useSyncScheduling,
9809
9817
  prepareForCommit = config.prepareForCommit,
9810
9818
  resetAfterCommit = config.resetAfterCommit;
@@ -10212,6 +10220,7 @@ var ReactFiberScheduler = function (config) {
10212
10220
  {
10213
10221
  ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
10214
10222
  }
10223
+
10215
10224
  var next = beginWork(current, workInProgress, nextRenderExpirationTime);
10216
10225
  {
10217
10226
  ReactDebugCurrentFiber.resetCurrentFiber();
@@ -10532,7 +10541,10 @@ var ReactFiberScheduler = function (config) {
10532
10541
  } catch (e) {
10533
10542
  // Prevent cycle if logCapturedError() throws.
10534
10543
  // A cycle may still occur if logCapturedError renders a component that throws.
10535
- console.error(e);
10544
+ var suppressLogging = e && e.suppressReactErrorLogging;
10545
+ if (!suppressLogging) {
10546
+ console.error(e);
10547
+ }
10536
10548
  }
10537
10549
 
10538
10550
  // If we're in the commit phase, defer scheduling an update on the
@@ -10677,6 +10689,19 @@ var ReactFiberScheduler = function (config) {
10677
10689
  return scheduleWorkImpl(fiber, expirationTime, false);
10678
10690
  }
10679
10691
 
10692
+ function checkRootNeedsClearing(root, fiber, expirationTime) {
10693
+ if (!isWorking && root === nextRoot && expirationTime < nextRenderExpirationTime) {
10694
+ // Restart the root from the top.
10695
+ if (nextUnitOfWork !== null) {
10696
+ // This is an interruption. (Used for performance tracking.)
10697
+ interruptedBy = fiber;
10698
+ }
10699
+ nextRoot = null;
10700
+ nextUnitOfWork = null;
10701
+ nextRenderExpirationTime = NoWork;
10702
+ }
10703
+ }
10704
+
10680
10705
  function scheduleWorkImpl(fiber, expirationTime, isErrorRecovery) {
10681
10706
  recordScheduleUpdate();
10682
10707
 
@@ -10702,17 +10727,10 @@ var ReactFiberScheduler = function (config) {
10702
10727
  if (node['return'] === null) {
10703
10728
  if (node.tag === HostRoot) {
10704
10729
  var root = node.stateNode;
10705
- if (!isWorking && root === nextRoot && expirationTime <= nextRenderExpirationTime) {
10706
- // Restart the root from the top.
10707
- if (nextUnitOfWork !== null) {
10708
- // This is an interruption. (Used for performance tracking.)
10709
- interruptedBy = fiber;
10710
- }
10711
- nextRoot = null;
10712
- nextUnitOfWork = null;
10713
- nextRenderExpirationTime = NoWork;
10714
- }
10730
+
10731
+ checkRootNeedsClearing(root, fiber, expirationTime);
10715
10732
  requestWork(root, expirationTime);
10733
+ checkRootNeedsClearing(root, fiber, expirationTime);
10716
10734
  } else {
10717
10735
  {
10718
10736
  if (!isErrorRecovery && fiber.tag === ClassComponent) {
@@ -10764,7 +10782,8 @@ var ReactFiberScheduler = function (config) {
10764
10782
  var firstScheduledRoot = null;
10765
10783
  var lastScheduledRoot = null;
10766
10784
 
10767
- var isCallbackScheduled = false;
10785
+ var callbackExpirationTime = NoWork;
10786
+ var callbackID = -1;
10768
10787
  var isRendering = false;
10769
10788
  var nextFlushedRoot = null;
10770
10789
  var nextFlushedExpirationTime = NoWork;
@@ -10782,6 +10801,31 @@ var ReactFiberScheduler = function (config) {
10782
10801
 
10783
10802
  var timeHeuristicForUnitOfWork = 1;
10784
10803
 
10804
+ function scheduleCallbackWithExpiration(expirationTime) {
10805
+ if (callbackExpirationTime !== NoWork) {
10806
+ // A callback is already scheduled. Check its expiration time (timeout).
10807
+ if (expirationTime > callbackExpirationTime) {
10808
+ // Existing callback has sufficient timeout. Exit.
10809
+ return;
10810
+ } else {
10811
+ // Existing callback has insufficient timeout. Cancel and schedule a
10812
+ // new one.
10813
+ cancelDeferredCallback(callbackID);
10814
+ }
10815
+ // The request callback timer is already running. Don't start a new one.
10816
+ } else {
10817
+ startRequestCallbackTimer();
10818
+ }
10819
+
10820
+ // Compute a timeout for the given expiration time.
10821
+ var currentMs = now() - startTime;
10822
+ var expirationMs = expirationTimeToMs(expirationTime);
10823
+ var timeout = expirationMs - currentMs;
10824
+
10825
+ callbackExpirationTime = expirationTime;
10826
+ callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
10827
+ }
10828
+
10785
10829
  // requestWork is called by the scheduler whenever a root receives an update.
10786
10830
  // It's up to the renderer to call renderRoot at some point in the future.
10787
10831
  function requestWork(root, expirationTime) {
@@ -10822,7 +10866,9 @@ var ReactFiberScheduler = function (config) {
10822
10866
  if (isUnbatchingUpdates) {
10823
10867
  // ...unless we're inside unbatchedUpdates, in which case we should
10824
10868
  // flush it now.
10825
- performWorkOnRoot(root, Sync);
10869
+ nextFlushedRoot = root;
10870
+ nextFlushedExpirationTime = Sync;
10871
+ performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime);
10826
10872
  }
10827
10873
  return;
10828
10874
  }
@@ -10830,9 +10876,8 @@ var ReactFiberScheduler = function (config) {
10830
10876
  // TODO: Get rid of Sync and use current time?
10831
10877
  if (expirationTime === Sync) {
10832
10878
  performWork(Sync, null);
10833
- } else if (!isCallbackScheduled) {
10834
- isCallbackScheduled = true;
10835
- scheduleDeferredCallback(performAsyncWork);
10879
+ } else {
10880
+ scheduleCallbackWithExpiration(expirationTime);
10836
10881
  }
10837
10882
  }
10838
10883
 
@@ -10910,8 +10955,14 @@ var ReactFiberScheduler = function (config) {
10910
10955
  deadline = dl;
10911
10956
 
10912
10957
  // Keep working on roots until there's no more work, or until the we reach
10913
- // the deadlne.
10958
+ // the deadline.
10914
10959
  findHighestPriorityRoot();
10960
+
10961
+ if (enableUserTimingAPI && deadline !== null) {
10962
+ var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
10963
+ stopRequestCallbackTimer(didExpire);
10964
+ }
10965
+
10915
10966
  while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || nextFlushedExpirationTime <= minExpirationTime) && !deadlineDidExpire) {
10916
10967
  performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime);
10917
10968
  // Find the next highest priority work.
@@ -10923,12 +10974,12 @@ var ReactFiberScheduler = function (config) {
10923
10974
 
10924
10975
  // If we're inside a callback, set this to false since we just completed it.
10925
10976
  if (deadline !== null) {
10926
- isCallbackScheduled = false;
10977
+ callbackExpirationTime = NoWork;
10978
+ callbackID = -1;
10927
10979
  }
10928
10980
  // If there's work left over, schedule a new callback.
10929
- if (nextFlushedRoot !== null && !isCallbackScheduled) {
10930
- isCallbackScheduled = true;
10931
- scheduleDeferredCallback(performAsyncWork);
10981
+ if (nextFlushedExpirationTime !== NoWork) {
10982
+ scheduleCallbackWithExpiration(nextFlushedExpirationTime);
10932
10983
  }
10933
10984
 
10934
10985
  // Clean-up.
@@ -11001,6 +11052,8 @@ var ReactFiberScheduler = function (config) {
11001
11052
  return false;
11002
11053
  }
11003
11054
  if (deadline.timeRemaining() > timeHeuristicForUnitOfWork) {
11055
+ // Disregard deadline.didTimeout. Only expired work should be flushed
11056
+ // during a timeout. This path is only hit for non-expired work.
11004
11057
  return false;
11005
11058
  }
11006
11059
  deadlineDidExpire = true;
@@ -11243,9 +11296,24 @@ var ReactFiberReconciler$3 = ( ReactFiberReconciler$2 && ReactFiberReconciler$1
11243
11296
  // This is hacky but makes it work with both Rollup and Jest.
11244
11297
  var reactReconciler = ReactFiberReconciler$3['default'] ? ReactFiberReconciler$3['default'] : ReactFiberReconciler$3;
11245
11298
 
11299
+ function createPortal$1(children, containerInfo,
11300
+ // TODO: figure out the API for cross-renderer implementation.
11301
+ implementation) {
11302
+ var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
11303
+
11304
+ return {
11305
+ // This tag allow us to uniquely identify this as a React Portal
11306
+ $$typeof: REACT_PORTAL_TYPE,
11307
+ key: key == null ? null : '' + key,
11308
+ children: children,
11309
+ containerInfo: containerInfo,
11310
+ implementation: implementation
11311
+ };
11312
+ }
11313
+
11246
11314
  // TODO: this is special because it gets imported during build.
11247
11315
 
11248
- var ReactVersion = '16.1.0';
11316
+ var ReactVersion = '16.2.1';
11249
11317
 
11250
11318
  // a requestAnimationFrame, storing the time for the start of the frame, then
11251
11319
  // scheduling a postMessage which gets scheduled after paint. Within the
@@ -11275,24 +11343,28 @@ if (hasNativePerformanceNow) {
11275
11343
 
11276
11344
  // TODO: There's no way to cancel, because Fiber doesn't atm.
11277
11345
  var rIC = void 0;
11346
+ var cIC = void 0;
11278
11347
 
11279
11348
  if (!ExecutionEnvironment.canUseDOM) {
11280
11349
  rIC = function (frameCallback) {
11281
- setTimeout(function () {
11350
+ return setTimeout(function () {
11282
11351
  frameCallback({
11283
11352
  timeRemaining: function () {
11284
11353
  return Infinity;
11285
11354
  }
11286
11355
  });
11287
11356
  });
11288
- return 0;
11289
11357
  };
11290
- } else if (typeof requestIdleCallback !== 'function') {
11291
- // Polyfill requestIdleCallback.
11358
+ cIC = function (timeoutID) {
11359
+ clearTimeout(timeoutID);
11360
+ };
11361
+ } else if (typeof requestIdleCallback !== 'function' || typeof cancelIdleCallback !== 'function') {
11362
+ // Polyfill requestIdleCallback and cancelIdleCallback
11292
11363
 
11293
11364
  var scheduledRICCallback = null;
11294
-
11295
11365
  var isIdleScheduled = false;
11366
+ var timeoutTime = -1;
11367
+
11296
11368
  var isAnimationFrameScheduled = false;
11297
11369
 
11298
11370
  var frameDeadline = 0;
@@ -11305,17 +11377,21 @@ if (!ExecutionEnvironment.canUseDOM) {
11305
11377
  var frameDeadlineObject;
11306
11378
  if (hasNativePerformanceNow) {
11307
11379
  frameDeadlineObject = {
11380
+ didTimeout: false,
11308
11381
  timeRemaining: function () {
11309
11382
  // We assume that if we have a performance timer that the rAF callback
11310
11383
  // gets a performance timer value. Not sure if this is always true.
11311
- return frameDeadline - performance.now();
11384
+ var remaining = frameDeadline - performance.now();
11385
+ return remaining > 0 ? remaining : 0;
11312
11386
  }
11313
11387
  };
11314
11388
  } else {
11315
11389
  frameDeadlineObject = {
11390
+ didTimeout: false,
11316
11391
  timeRemaining: function () {
11317
11392
  // Fallback to Date.now()
11318
- return frameDeadline - Date.now();
11393
+ var remaining = frameDeadline - Date.now();
11394
+ return remaining > 0 ? remaining : 0;
11319
11395
  }
11320
11396
  };
11321
11397
  }
@@ -11326,7 +11402,33 @@ if (!ExecutionEnvironment.canUseDOM) {
11326
11402
  if (event.source !== window || event.data !== messageKey) {
11327
11403
  return;
11328
11404
  }
11405
+
11329
11406
  isIdleScheduled = false;
11407
+
11408
+ var currentTime = now();
11409
+ if (frameDeadline - currentTime <= 0) {
11410
+ // There's no time left in this idle period. Check if the callback has
11411
+ // a timeout and whether it's been exceeded.
11412
+ if (timeoutTime !== -1 && timeoutTime <= currentTime) {
11413
+ // Exceeded the timeout. Invoke the callback even though there's no
11414
+ // time left.
11415
+ frameDeadlineObject.didTimeout = true;
11416
+ } else {
11417
+ // No timeout.
11418
+ if (!isAnimationFrameScheduled) {
11419
+ // Schedule another animation callback so we retry later.
11420
+ isAnimationFrameScheduled = true;
11421
+ requestAnimationFrame(animationTick);
11422
+ }
11423
+ // Exit without invoking the callback.
11424
+ return;
11425
+ }
11426
+ } else {
11427
+ // There's still time left in this idle period.
11428
+ frameDeadlineObject.didTimeout = false;
11429
+ }
11430
+
11431
+ timeoutTime = -1;
11330
11432
  var callback = scheduledRICCallback;
11331
11433
  scheduledRICCallback = null;
11332
11434
  if (callback !== null) {
@@ -11364,10 +11466,13 @@ if (!ExecutionEnvironment.canUseDOM) {
11364
11466
  }
11365
11467
  };
11366
11468
 
11367
- rIC = function (callback) {
11469
+ rIC = function (callback, options) {
11368
11470
  // This assumes that we only schedule one callback at a time because that's
11369
11471
  // how Fiber uses it.
11370
11472
  scheduledRICCallback = callback;
11473
+ if (options != null && typeof options.timeout === 'number') {
11474
+ timeoutTime = now() + options.timeout;
11475
+ }
11371
11476
  if (!isAnimationFrameScheduled) {
11372
11477
  // If rAF didn't already schedule one, we need to schedule a frame.
11373
11478
  // TODO: If this rAF doesn't materialize because the browser throttles, we
@@ -11378,8 +11483,15 @@ if (!ExecutionEnvironment.canUseDOM) {
11378
11483
  }
11379
11484
  return 0;
11380
11485
  };
11486
+
11487
+ cIC = function () {
11488
+ scheduledRICCallback = null;
11489
+ isIdleScheduled = false;
11490
+ timeoutTime = -1;
11491
+ };
11381
11492
  } else {
11382
- rIC = requestIdleCallback;
11493
+ rIC = window.requestIdleCallback;
11494
+ cIC = window.cancelIdleCallback;
11383
11495
  }
11384
11496
 
11385
11497
  /**
@@ -11769,6 +11881,14 @@ function initWrapperState(element, props) {
11769
11881
  };
11770
11882
  }
11771
11883
 
11884
+ function updateChecked(element, props) {
11885
+ var node = element;
11886
+ var checked = props.checked;
11887
+ if (checked != null) {
11888
+ setValueForProperty(node, 'checked', checked);
11889
+ }
11890
+ }
11891
+
11772
11892
  function updateWrapper(element, props) {
11773
11893
  var node = element;
11774
11894
  {
@@ -11784,10 +11904,7 @@ function updateWrapper(element, props) {
11784
11904
  }
11785
11905
  }
11786
11906
 
11787
- var checked = props.checked;
11788
- if (checked != null) {
11789
- setValueForProperty(node, 'checked', checked || false);
11790
- }
11907
+ updateChecked(element, props);
11791
11908
 
11792
11909
  var value = props.value;
11793
11910
  if (value != null) {
@@ -11913,6 +12030,11 @@ function updateNamedCousins(rootNode, props) {
11913
12030
  // mixing React radio buttons with non-React ones.
11914
12031
  var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
11915
12032
  !otherProps ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : void 0;
12033
+
12034
+ // We need update the tracked value on the named cousin since the value
12035
+ // was changed but the input saw no event or value set
12036
+ updateValueIfChanged(otherNode);
12037
+
11916
12038
  // If this is a controlled radio button group, forcing the input that
11917
12039
  // was previously checked to update will cause it to be come re-checked
11918
12040
  // as appropriate.
@@ -11960,7 +12082,6 @@ function postMountWrapper$1(element, props) {
11960
12082
 
11961
12083
  function getHostProps$1(element, props) {
11962
12084
  var hostProps = _assign({ children: undefined }, props);
11963
-
11964
12085
  var content = flattenChildren(props.children);
11965
12086
 
11966
12087
  if (content) {
@@ -12186,11 +12307,10 @@ function initWrapperState$2(element, props) {
12186
12307
  }
12187
12308
  }
12188
12309
 
12189
- var value = props.value;
12190
- var initialValue = value;
12310
+ var initialValue = props.value;
12191
12311
 
12192
12312
  // Only bother fetching default value if we're going to use it
12193
- if (value == null) {
12313
+ if (initialValue == null) {
12194
12314
  var defaultValue = props.defaultValue;
12195
12315
  // TODO (yungsters): Remove support for children content in <textarea>.
12196
12316
  var children = props.children;
@@ -12340,89 +12460,6 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
12340
12460
  }
12341
12461
  });
12342
12462
 
12343
- // code copied and modified from escape-html
12344
- /**
12345
- * Module variables.
12346
- * @private
12347
- */
12348
-
12349
- var matchHtmlRegExp = /["'&<>]/;
12350
-
12351
- /**
12352
- * Escape special characters in the given string of html.
12353
- *
12354
- * @param {string} string The string to escape for inserting into HTML
12355
- * @return {string}
12356
- * @public
12357
- */
12358
-
12359
- function escapeHtml(string) {
12360
- var str = '' + string;
12361
- var match = matchHtmlRegExp.exec(str);
12362
-
12363
- if (!match) {
12364
- return str;
12365
- }
12366
-
12367
- var escape;
12368
- var html = '';
12369
- var index = 0;
12370
- var lastIndex = 0;
12371
-
12372
- for (index = match.index; index < str.length; index++) {
12373
- switch (str.charCodeAt(index)) {
12374
- case 34:
12375
- // "
12376
- escape = '&quot;';
12377
- break;
12378
- case 38:
12379
- // &
12380
- escape = '&amp;';
12381
- break;
12382
- case 39:
12383
- // '
12384
- escape = '&#x27;'; // modified from escape-html; used to be '&#39'
12385
- break;
12386
- case 60:
12387
- // <
12388
- escape = '&lt;';
12389
- break;
12390
- case 62:
12391
- // >
12392
- escape = '&gt;';
12393
- break;
12394
- default:
12395
- continue;
12396
- }
12397
-
12398
- if (lastIndex !== index) {
12399
- html += str.substring(lastIndex, index);
12400
- }
12401
-
12402
- lastIndex = index + 1;
12403
- html += escape;
12404
- }
12405
-
12406
- return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
12407
- }
12408
- // end code copied and modified from escape-html
12409
-
12410
- /**
12411
- * Escapes text to prevent scripting attacks.
12412
- *
12413
- * @param {*} text Text value to escape.
12414
- * @return {string} An escaped string.
12415
- */
12416
- function escapeTextContentForBrowser(text) {
12417
- if (typeof text === 'boolean' || typeof text === 'number') {
12418
- // this shortcircuit helps perf for types that we know will never have
12419
- // special characters, especially given that this function is used often
12420
- // for numeric dom ids.
12421
- return '' + text;
12422
- }
12423
- return escapeHtml(text);
12424
- }
12425
-
12426
12463
  /**
12427
12464
  * Set the textContent property of a node, ensuring that whitespace is preserved
12428
12465
  * even in IE8. innerText is a poor substitute for textContent and, among many
@@ -12445,20 +12482,6 @@ var setTextContent = function (node, text) {
12445
12482
  node.textContent = text;
12446
12483
  };
12447
12484
 
12448
- if (ExecutionEnvironment.canUseDOM) {
12449
- if (!('textContent' in document.documentElement)) {
12450
- setTextContent = function (node, text) {
12451
- if (node.nodeType === TEXT_NODE) {
12452
- node.nodeValue = text;
12453
- return;
12454
- }
12455
- setInnerHTML(node, escapeTextContentForBrowser(text));
12456
- };
12457
- }
12458
- }
12459
-
12460
- var setTextContent$1 = setTextContent;
12461
-
12462
12485
  /**
12463
12486
  * CSS properties which accept numbers but are not in units of "px".
12464
12487
  */
@@ -12564,7 +12587,7 @@ function dangerousStyleValue(name, value, isCustomProperty) {
12564
12587
  return ('' + value).trim();
12565
12588
  }
12566
12589
 
12567
- var warnValidStyle = emptyFunction$1;
12590
+ var warnValidStyle = emptyFunction;
12568
12591
 
12569
12592
  {
12570
12593
  // 'msTransform' is correct, but the other prefixes should be capitalized
@@ -13434,36 +13457,46 @@ function getStackAddendum$2() {
13434
13457
  {
13435
13458
  var warnedProperties$1 = {};
13436
13459
  var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
13437
- var EVENT_NAME_REGEX = /^on[A-Z]/;
13460
+ var EVENT_NAME_REGEX = /^on./;
13461
+ var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
13438
13462
  var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
13439
13463
  var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
13440
13464
 
13441
- var validateProperty$1 = function (tagName, name, value) {
13465
+ var validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
13442
13466
  if (hasOwnProperty$1.call(warnedProperties$1, name) && warnedProperties$1[name]) {
13443
13467
  return true;
13444
13468
  }
13445
13469
 
13446
- if (registrationNameModules.hasOwnProperty(name)) {
13447
- return true;
13448
- }
13449
-
13450
- if (plugins.length === 0 && EVENT_NAME_REGEX.test(name)) {
13451
- // If no event plugins have been injected, we might be in a server environment.
13452
- // Don't check events in this case.
13453
- return true;
13454
- }
13455
-
13456
13470
  var lowerCasedName = name.toLowerCase();
13457
- var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
13458
-
13459
- if (registrationName != null) {
13460
- warning(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2());
13471
+ if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
13472
+ warning(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
13461
13473
  warnedProperties$1[name] = true;
13462
13474
  return true;
13463
13475
  }
13464
13476
 
13465
- if (lowerCasedName.indexOf('on') === 0 && lowerCasedName.length > 2) {
13466
- warning(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$2());
13477
+ // We can't rely on the event system being injected on the server.
13478
+ if (canUseEventSystem) {
13479
+ if (registrationNameModules.hasOwnProperty(name)) {
13480
+ return true;
13481
+ }
13482
+ var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
13483
+ if (registrationName != null) {
13484
+ warning(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2());
13485
+ warnedProperties$1[name] = true;
13486
+ return true;
13487
+ }
13488
+ if (EVENT_NAME_REGEX.test(name)) {
13489
+ warning(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$2());
13490
+ warnedProperties$1[name] = true;
13491
+ return true;
13492
+ }
13493
+ } else if (EVENT_NAME_REGEX.test(name)) {
13494
+ // If no event plugins have been injected, we are in a server environment.
13495
+ // So we can't tell if the event name is correct for sure, but we can filter
13496
+ // out known bad ones like `onclick`. We can't suggest a specific replacement though.
13497
+ if (INVALID_EVENT_NAME_REGEX.test(name)) {
13498
+ warning(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.%s', name, getStackAddendum$2());
13499
+ }
13467
13500
  warnedProperties$1[name] = true;
13468
13501
  return true;
13469
13502
  }
@@ -13473,12 +13506,6 @@ function getStackAddendum$2() {
13473
13506
  return true;
13474
13507
  }
13475
13508
 
13476
- if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
13477
- warning(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
13478
- warnedProperties$1[name] = true;
13479
- return true;
13480
- }
13481
-
13482
13509
  if (lowerCasedName === 'innerhtml') {
13483
13510
  warning(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
13484
13511
  warnedProperties$1[name] = true;
@@ -13547,10 +13574,10 @@ function getStackAddendum$2() {
13547
13574
  };
13548
13575
  }
13549
13576
 
13550
- var warnUnknownProperties = function (type, props) {
13577
+ var warnUnknownProperties = function (type, props, canUseEventSystem) {
13551
13578
  var unknownProps = [];
13552
13579
  for (var key in props) {
13553
- var isValid = validateProperty$1(type, key, props[key]);
13580
+ var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
13554
13581
  if (!isValid) {
13555
13582
  unknownProps.push(key);
13556
13583
  }
@@ -13566,11 +13593,11 @@ var warnUnknownProperties = function (type, props) {
13566
13593
  }
13567
13594
  };
13568
13595
 
13569
- function validateProperties$2(type, props) {
13596
+ function validateProperties$2(type, props, canUseEventSystem) {
13570
13597
  if (isCustomComponent(type, props)) {
13571
13598
  return;
13572
13599
  }
13573
- warnUnknownProperties(type, props);
13600
+ warnUnknownProperties(type, props, canUseEventSystem);
13574
13601
  }
13575
13602
 
13576
13603
  // TODO: direct imports like some-package/src/* are bad. Fix me.
@@ -13591,7 +13618,7 @@ var HTML = '__html';
13591
13618
  var HTML_NAMESPACE = Namespaces.html;
13592
13619
 
13593
13620
 
13594
- var getStack = emptyFunction$1.thatReturns('');
13621
+ var getStack = emptyFunction.thatReturns('');
13595
13622
 
13596
13623
  {
13597
13624
  getStack = getCurrentFiberStackAddendum$2;
@@ -13609,7 +13636,7 @@ var getStack = emptyFunction$1.thatReturns('');
13609
13636
  var validatePropertiesInDevelopment = function (type, props) {
13610
13637
  validateProperties(type, props);
13611
13638
  validateProperties$1(type, props);
13612
- validateProperties$2(type, props);
13639
+ validateProperties$2(type, props, /* canUseEventSystem */true);
13613
13640
  };
13614
13641
 
13615
13642
  // HTML parsing normalizes CR and CRLF to LF.
@@ -13732,7 +13759,7 @@ function trapClickOnNonInteractiveElement(node) {
13732
13759
  // bookkeeping for it. Not sure if we need to clear it when the listener is
13733
13760
  // removed.
13734
13761
  // TODO: Only do this for the relevant Safaris maybe?
13735
- node.onclick = emptyFunction$1;
13762
+ node.onclick = emptyFunction;
13736
13763
  }
13737
13764
 
13738
13765
  function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
@@ -13764,10 +13791,10 @@ function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProp
13764
13791
  // https://github.com/facebook/react/issues/6731#issuecomment-254874553
13765
13792
  var canSetTextContent = tag !== 'textarea' || nextProp !== '';
13766
13793
  if (canSetTextContent) {
13767
- setTextContent$1(domElement, nextProp);
13794
+ setTextContent(domElement, nextProp);
13768
13795
  }
13769
13796
  } else if (typeof nextProp === 'number') {
13770
- setTextContent$1(domElement, '' + nextProp);
13797
+ setTextContent(domElement, '' + nextProp);
13771
13798
  }
13772
13799
  } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
13773
13800
  // Noop
@@ -13802,7 +13829,7 @@ function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, i
13802
13829
  } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
13803
13830
  setInnerHTML(domElement, propValue);
13804
13831
  } else if (propKey === CHILDREN) {
13805
- setTextContent$1(domElement, propValue);
13832
+ setTextContent(domElement, propValue);
13806
13833
  } else if (isCustomComponentTag) {
13807
13834
  if (propValue != null) {
13808
13835
  setValueForAttribute(domElement, propKey, propValue);
@@ -14151,6 +14178,13 @@ function diffProperties$1(domElement, tag, lastRawProps, nextRawProps, rootConta
14151
14178
 
14152
14179
  // Apply the diff.
14153
14180
  function updateProperties$1(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
14181
+ // Update checked *before* name.
14182
+ // In the middle of an update, it is possible to have multiple checked.
14183
+ // When a checked radio tries to change name, browser makes another radio's checked false.
14184
+ if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
14185
+ updateChecked(domElement, nextRawProps);
14186
+ }
14187
+
14154
14188
  var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
14155
14189
  var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
14156
14190
  // Apply the diff.
@@ -14164,10 +14198,6 @@ function updateProperties$1(domElement, updatePayload, tag, lastRawProps, nextRa
14164
14198
  // happen after `updateDOMProperties`. Otherwise HTML5 input validations
14165
14199
  // raise warnings and prevent the new value from being assigned.
14166
14200
  updateWrapper(domElement, nextRawProps);
14167
-
14168
- // We also check that we haven't missed a value update, such as a
14169
- // Radio group shifting the checked value to another named radio input.
14170
- updateValueIfChanged(domElement);
14171
14201
  break;
14172
14202
  case 'textarea':
14173
14203
  updateWrapper$1(domElement, nextRawProps);
@@ -14504,7 +14534,7 @@ var ReactDOMFiberComponent = Object.freeze({
14504
14534
  // TODO: direct imports like some-package/src/* are bad. Fix me.
14505
14535
  var getCurrentFiberStackAddendum$6 = ReactDebugCurrentFiber.getCurrentFiberStackAddendum;
14506
14536
 
14507
- var validateDOMNesting = emptyFunction$1;
14537
+ var validateDOMNesting = emptyFunction;
14508
14538
 
14509
14539
  {
14510
14540
  // This validation code was written based on the HTML5 parsing spec:
@@ -15040,14 +15070,19 @@ var DOMRenderer = reactReconciler({
15040
15070
 
15041
15071
  hydration: {
15042
15072
  canHydrateInstance: function (instance, type, props) {
15043
- return instance.nodeType === ELEMENT_NODE && type.toLowerCase() === instance.nodeName.toLowerCase();
15073
+ if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
15074
+ return null;
15075
+ }
15076
+ // This has now been refined to an element node.
15077
+ return instance;
15044
15078
  },
15045
15079
  canHydrateTextInstance: function (instance, text) {
15046
- if (text === '') {
15080
+ if (text === '' || instance.nodeType !== TEXT_NODE) {
15047
15081
  // Empty strings are not parsed by HTML so there won't be a correct match here.
15048
- return false;
15082
+ return null;
15049
15083
  }
15050
- return instance.nodeType === TEXT_NODE;
15084
+ // This has now been refined to a text node.
15085
+ return instance;
15051
15086
  },
15052
15087
  getNextHydratableSibling: function (instance) {
15053
15088
  var node = instance.nextSibling;
@@ -15132,6 +15167,7 @@ var DOMRenderer = reactReconciler({
15132
15167
  },
15133
15168
 
15134
15169
  scheduleDeferredCallback: rIC,
15170
+ cancelDeferredCallback: cIC,
15135
15171
 
15136
15172
  useSyncScheduling: !enableAsyncSchedulingByDefaultInReactDOM
15137
15173
  });