react-dom 16.4.0 → 16.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0
1
+ /** @license React v16.4.1
2
2
  * react-dom.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -2389,7 +2389,9 @@ var DOCUMENT_FRAGMENT_NODE = 11;
2389
2389
  * @return {DOMEventTarget} Target node.
2390
2390
  */
2391
2391
  function getEventTarget(nativeEvent) {
2392
- var target = nativeEvent.target || window;
2392
+ // Fallback to nativeEvent.srcElement for IE9
2393
+ // https://github.com/facebook/react/issues/12506
2394
+ var target = nativeEvent.target || nativeEvent.srcElement || window;
2393
2395
 
2394
2396
  // Normalize SVG <use> element events #4963
2395
2397
  if (target.correspondingUseElement) {
@@ -3359,20 +3361,28 @@ function updateWrapper(element, props) {
3359
3361
  }
3360
3362
  }
3361
3363
 
3362
- function postMountWrapper(element, props) {
3364
+ function postMountWrapper(element, props, isHydrating) {
3363
3365
  var node = element;
3364
3366
 
3365
3367
  if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
3368
+ var _initialValue = '' + node._wrapperState.initialValue;
3369
+ var currentValue = node.value;
3370
+
3366
3371
  // Do not assign value if it is already set. This prevents user text input
3367
3372
  // from being lost during SSR hydration.
3368
- if (node.value === '') {
3369
- node.value = '' + node._wrapperState.initialValue;
3373
+ if (!isHydrating) {
3374
+ // Do not re-assign the value property if there is no change. This
3375
+ // potentially avoids a DOM write and prevents Firefox (~60.0.1) from
3376
+ // prematurely marking required inputs as invalid
3377
+ if (_initialValue !== currentValue) {
3378
+ node.value = _initialValue;
3379
+ }
3370
3380
  }
3371
3381
 
3372
3382
  // value must be assigned before defaultValue. This fixes an issue where the
3373
3383
  // visually displayed value of date inputs disappears on mobile Safari and Chrome:
3374
3384
  // https://github.com/facebook/react/issues/7233
3375
- node.defaultValue = '' + node._wrapperState.initialValue;
3385
+ node.defaultValue = _initialValue;
3376
3386
  }
3377
3387
 
3378
3388
  // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
@@ -3645,14 +3655,8 @@ function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
3645
3655
  }
3646
3656
  }
3647
3657
 
3648
- function handleControlledInputBlur(inst, node) {
3649
- // TODO: In IE, inst is occasionally null. Why?
3650
- if (inst == null) {
3651
- return;
3652
- }
3653
-
3654
- // Fiber and ReactDOM keep wrapper state in separate places
3655
- var state = inst._wrapperState || node._wrapperState;
3658
+ function handleControlledInputBlur(node) {
3659
+ var state = node._wrapperState;
3656
3660
 
3657
3661
  if (!state || !state.controlled || node.type !== 'number') {
3658
3662
  return;
@@ -3709,7 +3713,7 @@ var ChangeEventPlugin = {
3709
3713
 
3710
3714
  // When blurring, set the value attribute for number inputs
3711
3715
  if (topLevelType === TOP_BLUR) {
3712
- handleControlledInputBlur(targetInst, targetNode);
3716
+ handleControlledInputBlur(targetNode);
3713
3717
  }
3714
3718
  }
3715
3719
  };
@@ -5379,9 +5383,14 @@ function isInDocument(node) {
5379
5383
  * Input selection module for React.
5380
5384
  */
5381
5385
 
5386
+ /**
5387
+ * @hasSelectionCapabilities: we get the element types that support selection
5388
+ * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
5389
+ * and `selectionEnd` rows.
5390
+ */
5382
5391
  function hasSelectionCapabilities(elem) {
5383
5392
  var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
5384
- return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
5393
+ return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
5385
5394
  }
5386
5395
 
5387
5396
  function getSelectionInformation() {
@@ -5402,7 +5411,7 @@ function restoreSelection(priorSelectionInformation) {
5402
5411
  var priorFocusedElem = priorSelectionInformation.focusedElem;
5403
5412
  var priorSelectionRange = priorSelectionInformation.selectionRange;
5404
5413
  if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
5405
- if (hasSelectionCapabilities(priorFocusedElem)) {
5414
+ if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
5406
5415
  setSelection(priorFocusedElem, priorSelectionRange);
5407
5416
  }
5408
5417
 
@@ -5419,7 +5428,9 @@ function restoreSelection(priorSelectionInformation) {
5419
5428
  }
5420
5429
  }
5421
5430
 
5422
- priorFocusedElem.focus();
5431
+ if (typeof priorFocusedElem.focus === 'function') {
5432
+ priorFocusedElem.focus();
5433
+ }
5423
5434
 
5424
5435
  for (var i = 0; i < ancestors.length; i++) {
5425
5436
  var info = ancestors[i];
@@ -5659,11 +5670,11 @@ var emptyObject = {};
5659
5670
 
5660
5671
  var emptyObject_1 = emptyObject;
5661
5672
 
5662
- {
5663
- if (ExecutionEnvironment_1.canUseDOM && typeof requestAnimationFrame !== 'function') {
5664
- warning_1(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
5665
- }
5666
- }
5673
+ // We capture a local reference to any global, in case it gets polyfilled after
5674
+ // this module is initially evaluated.
5675
+ // We want to be using a consistent implementation.
5676
+
5677
+ var localRequestAnimationFrame$1 = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
5667
5678
 
5668
5679
  /**
5669
5680
  * A scheduling library to allow scheduling work with more granular priority and
@@ -5686,32 +5697,42 @@ var emptyObject_1 = emptyObject;
5686
5697
  // layout, paint and other browser work is counted against the available time.
5687
5698
  // The frame rate is dynamically adjusted.
5688
5699
 
5700
+ // We capture a local reference to any global, in case it gets polyfilled after
5701
+ // this module is initially evaluated.
5702
+ // We want to be using a consistent implementation.
5703
+ var localDate = Date;
5704
+ var localSetTimeout = setTimeout;
5705
+ var localClearTimeout = clearTimeout;
5706
+
5689
5707
  var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
5690
5708
 
5691
5709
  var now$1 = void 0;
5692
5710
  if (hasNativePerformanceNow) {
5711
+ var Performance = performance;
5693
5712
  now$1 = function () {
5694
- return performance.now();
5713
+ return Performance.now();
5695
5714
  };
5696
5715
  } else {
5697
5716
  now$1 = function () {
5698
- return Date.now();
5717
+ return localDate.now();
5699
5718
  };
5700
5719
  }
5701
5720
 
5702
- // TODO: There's no way to cancel, because Fiber doesn't atm.
5703
5721
  var scheduleWork = void 0;
5704
5722
  var cancelScheduledWork = void 0;
5705
5723
 
5706
5724
  if (!ExecutionEnvironment_1.canUseDOM) {
5707
- var callbackIdCounter = 0;
5708
- // Timeouts are objects in Node.
5709
- // For consistency, we'll use numbers in the public API anyway.
5710
- var timeoutIds = {};
5725
+ var timeoutIds = new Map();
5711
5726
 
5712
5727
  scheduleWork = function (callback, options) {
5713
- var callbackId = callbackIdCounter++;
5714
- var timeoutId = setTimeout(function () {
5728
+ // keeping return type consistent
5729
+ var callbackConfig = {
5730
+ scheduledCallback: callback,
5731
+ timeoutTime: 0,
5732
+ next: null,
5733
+ prev: null
5734
+ };
5735
+ var timeoutId = localSetTimeout(function () {
5715
5736
  callback({
5716
5737
  timeRemaining: function () {
5717
5738
  return Infinity;
@@ -5720,33 +5741,28 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5720
5741
  didTimeout: false
5721
5742
  });
5722
5743
  });
5723
- timeoutIds[callbackId] = timeoutId;
5724
- return callbackId;
5744
+ timeoutIds.set(callback, timeoutId);
5745
+ return callbackConfig;
5725
5746
  };
5726
5747
  cancelScheduledWork = function (callbackId) {
5727
- var timeoutId = timeoutIds[callbackId];
5728
- delete timeoutIds[callbackId];
5729
- clearTimeout(timeoutId);
5748
+ var callback = callbackId.scheduledCallback;
5749
+ var timeoutId = timeoutIds.get(callback);
5750
+ timeoutIds.delete(callbackId);
5751
+ localClearTimeout(timeoutId);
5730
5752
  };
5731
5753
  } else {
5732
- // We keep callbacks in a queue.
5733
- // Calling scheduleWork will push in a new callback at the end of the queue.
5734
- // When we get idle time, callbacks are removed from the front of the queue
5735
- var pendingCallbacks = [];
5736
-
5737
- var _callbackIdCounter = 0;
5738
- var getCallbackId = function () {
5739
- _callbackIdCounter++;
5740
- return _callbackIdCounter;
5754
+ {
5755
+ if (typeof localRequestAnimationFrame$1 !== 'function') {
5756
+ warning_1(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
5757
+ }
5758
+ }
5759
+
5760
+ var localRequestAnimationFrame = typeof localRequestAnimationFrame$1 === 'function' ? localRequestAnimationFrame$1 : function (callback) {
5761
+ invariant_1(false, 'React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills');
5741
5762
  };
5742
5763
 
5743
- // When a callback is scheduled, we register it by adding it's id to this
5744
- // object.
5745
- // If the user calls 'cancelScheduledWork' with the id of that callback, it will be
5746
- // unregistered by removing the id from this object.
5747
- // Then we skip calling any callback which is not registered.
5748
- // This means cancelling is an O(1) time complexity instead of O(n).
5749
- var registeredCallbackIds = {};
5764
+ var headOfPendingCallbacksLinkedList = null;
5765
+ var tailOfPendingCallbacksLinkedList = null;
5750
5766
 
5751
5767
  // We track what the next soonest timeoutTime is, to be able to quickly tell
5752
5768
  // if none of the scheduled callbacks have timed out.
@@ -5770,17 +5786,27 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5770
5786
  }
5771
5787
  };
5772
5788
 
5773
- var safelyCallScheduledCallback = function (callback, callbackId) {
5774
- if (!registeredCallbackIds[callbackId]) {
5775
- // ignore cancelled callbacks
5776
- return;
5777
- }
5789
+ /**
5790
+ * Handles the case where a callback errors:
5791
+ * - don't catch the error, because this changes debugging behavior
5792
+ * - do start a new postMessage callback, to call any remaining callbacks,
5793
+ * - but only if there is an error, so there is not extra overhead.
5794
+ */
5795
+ var callUnsafely = function (callbackConfig, arg) {
5796
+ var callback = callbackConfig.scheduledCallback;
5797
+ var finishedCalling = false;
5778
5798
  try {
5779
- callback(frameDeadlineObject);
5780
- // Avoid using 'catch' to keep errors easy to debug
5799
+ callback(arg);
5800
+ finishedCalling = true;
5781
5801
  } finally {
5782
- // always clean up the callbackId, even if the callback throws
5783
- delete registeredCallbackIds[callbackId];
5802
+ // always remove it from linked list
5803
+ cancelScheduledWork(callbackConfig);
5804
+
5805
+ if (!finishedCalling) {
5806
+ // an error must have been thrown
5807
+ isIdleScheduled = true;
5808
+ window.postMessage(messageKey, '*');
5809
+ }
5784
5810
  }
5785
5811
  };
5786
5812
 
@@ -5790,7 +5816,7 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5790
5816
  * Keeps doing this until there are none which have currently timed out.
5791
5817
  */
5792
5818
  var callTimedOutCallbacks = function () {
5793
- if (pendingCallbacks.length === 0) {
5819
+ if (headOfPendingCallbacksLinkedList === null) {
5794
5820
  return;
5795
5821
  }
5796
5822
 
@@ -5807,24 +5833,38 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5807
5833
  // We know that none of them have timed out yet.
5808
5834
  return;
5809
5835
  }
5810
- nextSoonestTimeoutTime = -1; // we will reset it below
5836
+ // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until
5837
+ // after successfully calling any timed out callbacks.
5838
+ // If a timed out callback throws an error, we could get stuck in a state
5839
+ // where the nextSoonestTimeoutTime was set wrong.
5840
+ var updatedNextSoonestTimeoutTime = -1; // we will update nextSoonestTimeoutTime below
5841
+ var timedOutCallbacks = [];
5811
5842
 
5812
- // keep checking until we don't find any more timed out callbacks
5813
- frameDeadlineObject.didTimeout = true;
5814
- for (var i = 0, len = pendingCallbacks.length; i < len; i++) {
5815
- var currentCallbackConfig = pendingCallbacks[i];
5843
+ // iterate once to find timed out callbacks and find nextSoonestTimeoutTime
5844
+ var currentCallbackConfig = headOfPendingCallbacksLinkedList;
5845
+ while (currentCallbackConfig !== null) {
5816
5846
  var _timeoutTime = currentCallbackConfig.timeoutTime;
5817
5847
  if (_timeoutTime !== -1 && _timeoutTime <= currentTime) {
5818
5848
  // it has timed out!
5819
- // call it
5820
- var _callback = currentCallbackConfig.scheduledCallback;
5821
- safelyCallScheduledCallback(_callback, currentCallbackConfig.callbackId);
5849
+ timedOutCallbacks.push(currentCallbackConfig);
5822
5850
  } else {
5823
- if (_timeoutTime !== -1 && (nextSoonestTimeoutTime === -1 || _timeoutTime < nextSoonestTimeoutTime)) {
5824
- nextSoonestTimeoutTime = _timeoutTime;
5851
+ if (_timeoutTime !== -1 && (updatedNextSoonestTimeoutTime === -1 || _timeoutTime < updatedNextSoonestTimeoutTime)) {
5852
+ updatedNextSoonestTimeoutTime = _timeoutTime;
5825
5853
  }
5826
5854
  }
5855
+ currentCallbackConfig = currentCallbackConfig.next;
5827
5856
  }
5857
+
5858
+ if (timedOutCallbacks.length > 0) {
5859
+ frameDeadlineObject.didTimeout = true;
5860
+ for (var i = 0, len = timedOutCallbacks.length; i < len; i++) {
5861
+ callUnsafely(timedOutCallbacks[i], frameDeadlineObject);
5862
+ }
5863
+ }
5864
+
5865
+ // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until
5866
+ // after successfully calling any timed out callbacks.
5867
+ nextSoonestTimeoutTime = updatedNextSoonestTimeoutTime;
5828
5868
  };
5829
5869
 
5830
5870
  // We use the postMessage trick to defer idle work until after the repaint.
@@ -5835,7 +5875,7 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5835
5875
  }
5836
5876
  isIdleScheduled = false;
5837
5877
 
5838
- if (pendingCallbacks.length === 0) {
5878
+ if (headOfPendingCallbacksLinkedList === null) {
5839
5879
  return;
5840
5880
  }
5841
5881
 
@@ -5844,19 +5884,18 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5844
5884
 
5845
5885
  var currentTime = now$1();
5846
5886
  // Next, as long as we have idle time, try calling more callbacks.
5847
- while (frameDeadline - currentTime > 0 && pendingCallbacks.length > 0) {
5848
- var latestCallbackConfig = pendingCallbacks.shift();
5887
+ while (frameDeadline - currentTime > 0 && headOfPendingCallbacksLinkedList !== null) {
5888
+ var latestCallbackConfig = headOfPendingCallbacksLinkedList;
5849
5889
  frameDeadlineObject.didTimeout = false;
5850
- var latestCallback = latestCallbackConfig.scheduledCallback;
5851
- var newCallbackId = latestCallbackConfig.callbackId;
5852
- safelyCallScheduledCallback(latestCallback, newCallbackId);
5890
+ // callUnsafely will remove it from the head of the linked list
5891
+ callUnsafely(latestCallbackConfig, frameDeadlineObject);
5853
5892
  currentTime = now$1();
5854
5893
  }
5855
- if (pendingCallbacks.length > 0) {
5894
+ if (headOfPendingCallbacksLinkedList !== null) {
5856
5895
  if (!isAnimationFrameScheduled) {
5857
5896
  // Schedule another animation callback so we retry later.
5858
5897
  isAnimationFrameScheduled = true;
5859
- requestAnimationFrame(animationTick);
5898
+ localRequestAnimationFrame(animationTick);
5860
5899
  }
5861
5900
  }
5862
5901
  };
@@ -5891,7 +5930,7 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5891
5930
  }
5892
5931
  };
5893
5932
 
5894
- scheduleWork = function (callback, options) {
5933
+ scheduleWork = function (callback, options) /* CallbackConfigType */{
5895
5934
  var timeoutTime = -1;
5896
5935
  if (options != null && typeof options.timeout === 'number') {
5897
5936
  timeoutTime = now$1() + options.timeout;
@@ -5900,28 +5939,100 @@ if (!ExecutionEnvironment_1.canUseDOM) {
5900
5939
  nextSoonestTimeoutTime = timeoutTime;
5901
5940
  }
5902
5941
 
5903
- var newCallbackId = getCallbackId();
5904
5942
  var scheduledCallbackConfig = {
5905
5943
  scheduledCallback: callback,
5906
- callbackId: newCallbackId,
5907
- timeoutTime: timeoutTime
5944
+ timeoutTime: timeoutTime,
5945
+ prev: null,
5946
+ next: null
5908
5947
  };
5909
- pendingCallbacks.push(scheduledCallbackConfig);
5948
+ if (headOfPendingCallbacksLinkedList === null) {
5949
+ // Make this callback the head and tail of our list
5950
+ headOfPendingCallbacksLinkedList = scheduledCallbackConfig;
5951
+ tailOfPendingCallbacksLinkedList = scheduledCallbackConfig;
5952
+ } else {
5953
+ // Add latest callback as the new tail of the list
5954
+ scheduledCallbackConfig.prev = tailOfPendingCallbacksLinkedList;
5955
+ // renaming for clarity
5956
+ var oldTailOfPendingCallbacksLinkedList = tailOfPendingCallbacksLinkedList;
5957
+ if (oldTailOfPendingCallbacksLinkedList !== null) {
5958
+ oldTailOfPendingCallbacksLinkedList.next = scheduledCallbackConfig;
5959
+ }
5960
+ tailOfPendingCallbacksLinkedList = scheduledCallbackConfig;
5961
+ }
5910
5962
 
5911
- registeredCallbackIds[newCallbackId] = true;
5912
5963
  if (!isAnimationFrameScheduled) {
5913
5964
  // If rAF didn't already schedule one, we need to schedule a frame.
5914
5965
  // TODO: If this rAF doesn't materialize because the browser throttles, we
5915
5966
  // might want to still have setTimeout trigger scheduleWork as a backup to ensure
5916
5967
  // that we keep performing work.
5917
5968
  isAnimationFrameScheduled = true;
5918
- requestAnimationFrame(animationTick);
5969
+ localRequestAnimationFrame(animationTick);
5919
5970
  }
5920
- return newCallbackId;
5971
+ return scheduledCallbackConfig;
5921
5972
  };
5922
5973
 
5923
- cancelScheduledWork = function (callbackId) {
5924
- delete registeredCallbackIds[callbackId];
5974
+ cancelScheduledWork = function (callbackConfig /* CallbackConfigType */
5975
+ ) {
5976
+ if (callbackConfig.prev === null && headOfPendingCallbacksLinkedList !== callbackConfig) {
5977
+ // this callbackConfig has already been cancelled.
5978
+ // cancelScheduledWork should be idempotent, a no-op after first call.
5979
+ return;
5980
+ }
5981
+
5982
+ /**
5983
+ * There are four possible cases:
5984
+ * - Head/nodeToRemove/Tail -> null
5985
+ * In this case we set Head and Tail to null.
5986
+ * - Head -> ... middle nodes... -> Tail/nodeToRemove
5987
+ * In this case we point the middle.next to null and put middle as the new
5988
+ * Tail.
5989
+ * - Head/nodeToRemove -> ...middle nodes... -> Tail
5990
+ * In this case we point the middle.prev at null and move the Head to
5991
+ * middle.
5992
+ * - Head -> ... ?some nodes ... -> nodeToRemove -> ... ?some nodes ... -> Tail
5993
+ * In this case we point the Head.next to the Tail and the Tail.prev to
5994
+ * the Head.
5995
+ */
5996
+ var next = callbackConfig.next;
5997
+ var prev = callbackConfig.prev;
5998
+ callbackConfig.next = null;
5999
+ callbackConfig.prev = null;
6000
+ if (next !== null) {
6001
+ // we have a next
6002
+
6003
+ if (prev !== null) {
6004
+ // we have a prev
6005
+
6006
+ // callbackConfig is somewhere in the middle of a list of 3 or more nodes.
6007
+ prev.next = next;
6008
+ next.prev = prev;
6009
+ return;
6010
+ } else {
6011
+ // there is a next but not a previous one;
6012
+ // callbackConfig is the head of a list of 2 or more other nodes.
6013
+ next.prev = null;
6014
+ headOfPendingCallbacksLinkedList = next;
6015
+ return;
6016
+ }
6017
+ } else {
6018
+ // there is no next callback config; this must the tail of the list
6019
+
6020
+ if (prev !== null) {
6021
+ // we have a prev
6022
+
6023
+ // callbackConfig is the tail of a list of 2 or more other nodes.
6024
+ prev.next = null;
6025
+ tailOfPendingCallbacksLinkedList = prev;
6026
+ return;
6027
+ } else {
6028
+ // there is no previous callback config;
6029
+ // callbackConfig is the only thing in the linked list,
6030
+ // so both head and tail point to it.
6031
+ headOfPendingCallbacksLinkedList = null;
6032
+ tailOfPendingCallbacksLinkedList = null;
6033
+ return;
6034
+ }
6035
+ }
5925
6036
  };
5926
6037
  }
5927
6038
 
@@ -7983,7 +8094,7 @@ function setInitialProperties$1(domElement, tag, rawProps, rootContainerElement)
7983
8094
  // TODO: Make sure we check if this is still unmounted or do any clean
7984
8095
  // up necessary since we never stop tracking anymore.
7985
8096
  track(domElement);
7986
- postMountWrapper(domElement, rawProps);
8097
+ postMountWrapper(domElement, rawProps, false);
7987
8098
  break;
7988
8099
  case 'textarea':
7989
8100
  // TODO: Make sure we check if this is still unmounted or do any clean
@@ -8438,7 +8549,7 @@ function diffHydratedProperties$1(domElement, tag, rawProps, parentNamespace, ro
8438
8549
  // TODO: Make sure we check if this is still unmounted or do any clean
8439
8550
  // up necessary since we never stop tracking anymore.
8440
8551
  track(domElement);
8441
- postMountWrapper(domElement, rawProps);
8552
+ postMountWrapper(domElement, rawProps, true);
8442
8553
  break;
8443
8554
  case 'textarea':
8444
8555
  // TODO: Make sure we check if this is still unmounted or do any clean
@@ -9244,9 +9355,6 @@ var warnAboutLegacyContextAPI = false;
9244
9355
  // Gather advanced timing metrics for Profiler subtrees.
9245
9356
  var enableProfilerTimer = true;
9246
9357
 
9247
- // Fires getDerivedStateFromProps for state *or* props changes
9248
- var fireGetDerivedStateFromPropsOnStateUpdates = true;
9249
-
9250
9358
  // Only used in www builds.
9251
9359
 
9252
9360
  // Prefix measurements so that it's possible to filter them.
@@ -10048,6 +10156,8 @@ function FiberNode(tag, pendingProps, key, mode) {
10048
10156
  this.alternate = null;
10049
10157
 
10050
10158
  if (enableProfilerTimer) {
10159
+ this.actualDuration = 0;
10160
+ this.actualStartTime = 0;
10051
10161
  this.selfBaseTime = 0;
10052
10162
  this.treeBaseTime = 0;
10053
10163
  }
@@ -10118,6 +10228,15 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
10118
10228
  workInProgress.nextEffect = null;
10119
10229
  workInProgress.firstEffect = null;
10120
10230
  workInProgress.lastEffect = null;
10231
+
10232
+ if (enableProfilerTimer) {
10233
+ // We intentionally reset, rather than copy, actualDuration & actualStartTime.
10234
+ // This prevents time from endlessly accumulating in new commits.
10235
+ // This has the downside of resetting values for different priority renders,
10236
+ // But works for yielding (the common case) and should support resuming.
10237
+ workInProgress.actualDuration = 0;
10238
+ workInProgress.actualStartTime = 0;
10239
+ }
10121
10240
  }
10122
10241
 
10123
10242
  workInProgress.expirationTime = expirationTime;
@@ -10243,13 +10362,6 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
10243
10362
  var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
10244
10363
  fiber.type = REACT_PROFILER_TYPE;
10245
10364
  fiber.expirationTime = expirationTime;
10246
- if (enableProfilerTimer) {
10247
- fiber.stateNode = {
10248
- elapsedPauseTimeAtStart: 0,
10249
- duration: 0,
10250
- startTime: 0
10251
- };
10252
- }
10253
10365
 
10254
10366
  return fiber;
10255
10367
  }
@@ -10313,6 +10425,8 @@ function assignFiberPropertiesInDEV(target, source) {
10313
10425
  target.expirationTime = source.expirationTime;
10314
10426
  target.alternate = source.alternate;
10315
10427
  if (enableProfilerTimer) {
10428
+ target.actualDuration = source.actualDuration;
10429
+ target.actualStartTime = source.actualStartTime;
10316
10430
  target.selfBaseTime = source.selfBaseTime;
10317
10431
  target.treeBaseTime = source.treeBaseTime;
10318
10432
  }
@@ -11582,9 +11696,9 @@ function markActualRenderTimeStarted(fiber) {
11582
11696
  {
11583
11697
  fiberStack$1.push(fiber);
11584
11698
  }
11585
- var stateNode = fiber.stateNode;
11586
- stateNode.elapsedPauseTimeAtStart = totalElapsedPauseTime;
11587
- stateNode.startTime = now();
11699
+
11700
+ fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime;
11701
+ fiber.actualStartTime = now();
11588
11702
  }
11589
11703
 
11590
11704
  function pauseActualRenderTimerIfRunning() {
@@ -11601,10 +11715,10 @@ function recordElapsedActualRenderTime(fiber) {
11601
11715
  return;
11602
11716
  }
11603
11717
  {
11604
- !(fiber === fiberStack$1.pop()) ? warning_1(false, 'Unexpected Fiber popped.') : void 0;
11718
+ !(fiber === fiberStack$1.pop()) ? warning_1(false, 'Unexpected Fiber (%s) popped.', getComponentName(fiber)) : void 0;
11605
11719
  }
11606
- var stateNode = fiber.stateNode;
11607
- stateNode.duration += now() - (totalElapsedPauseTime - stateNode.elapsedPauseTimeAtStart) - stateNode.startTime;
11720
+
11721
+ fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration;
11608
11722
  }
11609
11723
 
11610
11724
  function resetActualRenderTimer() {
@@ -12211,10 +12325,8 @@ function updateClassInstance(current, workInProgress, renderExpirationTime) {
12211
12325
  }
12212
12326
 
12213
12327
  if (typeof getDerivedStateFromProps === 'function') {
12214
- if (fireGetDerivedStateFromPropsOnStateUpdates || oldProps !== newProps) {
12215
- applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
12216
- newState = workInProgress.memoizedState;
12217
- }
12328
+ applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
12329
+ newState = workInProgress.memoizedState;
12218
12330
  }
12219
12331
 
12220
12332
  var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
@@ -13096,7 +13208,8 @@ function ChildReconciler(shouldTrackSideEffects) {
13096
13208
  // Handle top level unkeyed fragments as if they were arrays.
13097
13209
  // This leads to an ambiguity between <>{[...]}</> and <>...</>.
13098
13210
  // We treat the ambiguous cases above the same.
13099
- if (typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null) {
13211
+ var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
13212
+ if (isUnkeyedTopLevelFragment) {
13100
13213
  newChild = newChild.props.children;
13101
13214
  }
13102
13215
 
@@ -13133,7 +13246,7 @@ function ChildReconciler(shouldTrackSideEffects) {
13133
13246
  warnOnFunctionType();
13134
13247
  }
13135
13248
  }
13136
- if (typeof newChild === 'undefined') {
13249
+ if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
13137
13250
  // If the new child is undefined, and the return fiber is a composite
13138
13251
  // component, throw an error. If Fiber return types are disabled,
13139
13252
  // we already threw above.
@@ -13545,11 +13658,6 @@ function updateMode(current, workInProgress) {
13545
13658
  function updateProfiler(current, workInProgress) {
13546
13659
  var nextProps = workInProgress.pendingProps;
13547
13660
  if (enableProfilerTimer) {
13548
- // Start render timer here and push start time onto queue
13549
- markActualRenderTimeStarted(workInProgress);
13550
-
13551
- // Let the "complete" phase know to stop the timer,
13552
- // And the scheduler to record the measured time.
13553
13661
  workInProgress.effectTag |= Update;
13554
13662
  }
13555
13663
  if (workInProgress.memoizedProps === nextProps) {
@@ -14257,11 +14365,6 @@ function bailoutOnLowPriority(current, workInProgress) {
14257
14365
  case ContextProvider:
14258
14366
  pushProvider(workInProgress);
14259
14367
  break;
14260
- case Profiler:
14261
- if (enableProfilerTimer) {
14262
- markActualRenderTimeStarted(workInProgress);
14263
- }
14264
- break;
14265
14368
  }
14266
14369
  // TODO: What if this is currently in progress?
14267
14370
  // How can that happen? How is this not being cloned?
@@ -14280,6 +14383,12 @@ function memoizeState(workInProgress, nextState) {
14280
14383
  }
14281
14384
 
14282
14385
  function beginWork(current, workInProgress, renderExpirationTime) {
14386
+ if (enableProfilerTimer) {
14387
+ if (workInProgress.mode & ProfileMode) {
14388
+ markActualRenderTimeStarted(workInProgress);
14389
+ }
14390
+ }
14391
+
14283
14392
  if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) {
14284
14393
  return bailoutOnLowPriority(current, workInProgress);
14285
14394
  }
@@ -14484,6 +14593,13 @@ if (supportsMutation) {
14484
14593
 
14485
14594
  function completeWork(current, workInProgress, renderExpirationTime) {
14486
14595
  var newProps = workInProgress.pendingProps;
14596
+
14597
+ if (enableProfilerTimer) {
14598
+ if (workInProgress.mode & ProfileMode) {
14599
+ recordElapsedActualRenderTime(workInProgress);
14600
+ }
14601
+ }
14602
+
14487
14603
  switch (workInProgress.tag) {
14488
14604
  case FunctionalComponent:
14489
14605
  return null;
@@ -14616,9 +14732,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
14616
14732
  case Mode:
14617
14733
  return null;
14618
14734
  case Profiler:
14619
- if (enableProfilerTimer) {
14620
- recordElapsedActualRenderTime(workInProgress);
14621
- }
14622
14735
  return null;
14623
14736
  case HostPortal:
14624
14737
  popHostContainer(workInProgress);
@@ -15348,11 +15461,7 @@ function commitWork(current, finishedWork) {
15348
15461
  {
15349
15462
  if (enableProfilerTimer) {
15350
15463
  var onRender = finishedWork.memoizedProps.onRender;
15351
- onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.stateNode.duration, finishedWork.treeBaseTime, finishedWork.stateNode.startTime, getCommitTime());
15352
-
15353
- // Reset actualTime after successful commit.
15354
- // By default, we append to this time to account for errors and pauses.
15355
- finishedWork.stateNode.duration = 0;
15464
+ onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseTime, finishedWork.actualStartTime, getCommitTime());
15356
15465
  }
15357
15466
  return;
15358
15467
  }
@@ -15559,6 +15668,12 @@ function throwException(root, returnFiber, sourceFiber, value, renderIsExpired,
15559
15668
  }
15560
15669
 
15561
15670
  function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
15671
+ if (enableProfilerTimer) {
15672
+ if (workInProgress.mode & ProfileMode) {
15673
+ recordElapsedActualRenderTime(workInProgress);
15674
+ }
15675
+ }
15676
+
15562
15677
  switch (workInProgress.tag) {
15563
15678
  case ClassComponent:
15564
15679
  {
@@ -15607,6 +15722,14 @@ function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
15607
15722
  }
15608
15723
 
15609
15724
  function unwindInterruptedWork(interruptedWork) {
15725
+ if (enableProfilerTimer) {
15726
+ if (interruptedWork.mode & ProfileMode) {
15727
+ // Resume in case we're picking up on work that was paused.
15728
+ resumeActualRenderTimerIfPaused();
15729
+ recordElapsedActualRenderTime(interruptedWork);
15730
+ }
15731
+ }
15732
+
15610
15733
  switch (interruptedWork.tag) {
15611
15734
  case ClassComponent:
15612
15735
  {
@@ -15630,13 +15753,6 @@ function unwindInterruptedWork(interruptedWork) {
15630
15753
  case ContextProvider:
15631
15754
  popProvider(interruptedWork);
15632
15755
  break;
15633
- case Profiler:
15634
- if (enableProfilerTimer) {
15635
- // Resume in case we're picking up on work that was paused.
15636
- resumeActualRenderTimerIfPaused();
15637
- recordElapsedActualRenderTime(interruptedWork);
15638
- }
15639
- break;
15640
15756
  default:
15641
15757
  break;
15642
15758
  }
@@ -15776,6 +15892,10 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
15776
15892
  clearCaughtError();
15777
15893
 
15778
15894
  if (enableProfilerTimer) {
15895
+ if (failedUnitOfWork.mode & ProfileMode) {
15896
+ recordElapsedActualRenderTime(failedUnitOfWork);
15897
+ }
15898
+
15779
15899
  // Stop "base" render timer again (after the re-thrown error).
15780
15900
  stopBaseRenderTimerIfRunning();
15781
15901
  }
@@ -16009,6 +16129,8 @@ function commitRoot(finishedWork) {
16009
16129
  stopCommitSnapshotEffectsTimer();
16010
16130
 
16011
16131
  if (enableProfilerTimer) {
16132
+ // Mark the current commit time to be shared by all Profilers in this batch.
16133
+ // This enables them to be grouped later.
16012
16134
  recordCommitTime();
16013
16135
  }
16014
16136
 
@@ -16537,7 +16659,7 @@ function captureCommitPhaseError(fiber, error) {
16537
16659
  function computeAsyncExpiration(currentTime) {
16538
16660
  // Given the current clock time, returns an expiration time. We use rounding
16539
16661
  // to batch like updates together.
16540
- // Should complete within ~1000ms. 1200ms max.
16662
+ // Should complete within ~5000ms. 5250ms max.
16541
16663
  var expirationMs = 5000;
16542
16664
  var bucketSizeMs = 250;
16543
16665
  return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
@@ -16724,7 +16846,7 @@ var firstScheduledRoot = null;
16724
16846
  var lastScheduledRoot = null;
16725
16847
 
16726
16848
  var callbackExpirationTime = NoWork;
16727
- var callbackID = -1;
16849
+ var callbackID = void 0;
16728
16850
  var isRendering = false;
16729
16851
  var nextFlushedRoot = null;
16730
16852
  var nextFlushedExpirationTime = NoWork;
@@ -16753,9 +16875,11 @@ function scheduleCallbackWithExpiration(expirationTime) {
16753
16875
  // Existing callback has sufficient timeout. Exit.
16754
16876
  return;
16755
16877
  } else {
16756
- // Existing callback has insufficient timeout. Cancel and schedule a
16757
- // new one.
16758
- cancelDeferredCallback(callbackID);
16878
+ if (callbackID !== null) {
16879
+ // Existing callback has insufficient timeout. Cancel and schedule a
16880
+ // new one.
16881
+ cancelDeferredCallback(callbackID);
16882
+ }
16759
16883
  }
16760
16884
  // The request callback timer is already running. Don't start a new one.
16761
16885
  } else {
@@ -16944,7 +17068,7 @@ function performWork(minExpirationTime, isAsync, dl) {
16944
17068
  // If we're inside a callback, set this to false since we just completed it.
16945
17069
  if (deadline !== null) {
16946
17070
  callbackExpirationTime = NoWork;
16947
- callbackID = -1;
17071
+ callbackID = null;
16948
17072
  }
16949
17073
  // If there's work left over, schedule a new callback.
16950
17074
  if (nextFlushedExpirationTime !== NoWork) {
@@ -17011,7 +17135,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
17011
17135
  // This root is already complete. We can commit it.
17012
17136
  completeRoot(root, finishedWork, expirationTime);
17013
17137
  } else {
17014
- root.finishedWork = null;
17015
17138
  finishedWork = renderRoot(root, expirationTime, false);
17016
17139
  if (finishedWork !== null) {
17017
17140
  // We've completed the root. Commit it.
@@ -17025,7 +17148,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
17025
17148
  // This root is already complete. We can commit it.
17026
17149
  completeRoot(root, _finishedWork, expirationTime);
17027
17150
  } else {
17028
- root.finishedWork = null;
17029
17151
  _finishedWork = renderRoot(root, expirationTime, true);
17030
17152
  if (_finishedWork !== null) {
17031
17153
  // We've completed the root. Check the deadline one more time
@@ -17380,7 +17502,7 @@ implementation) {
17380
17502
 
17381
17503
  // TODO: this is special because it gets imported during build.
17382
17504
 
17383
- var ReactVersion = '16.4.0';
17505
+ var ReactVersion = '16.4.1';
17384
17506
 
17385
17507
  // TODO: This type is shared between the reconciler and ReactDOM, but will
17386
17508
  // eventually be lifted out to the renderer.
@@ -17826,6 +17948,8 @@ var ReactDOM = {
17826
17948
 
17827
17949
  unstable_deferredUpdates: deferredUpdates,
17828
17950
 
17951
+ unstable_interactiveUpdates: interactiveUpdates$1,
17952
+
17829
17953
  flushSync: flushSync,
17830
17954
 
17831
17955
  unstable_flushControlled: flushControlled,