react-dom 16.4.0-alpha.3174632 → 16.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v16.4.0-alpha.3174632
1
+ /** @license React v16.4.2
2
2
  * react-dom-server.node.development.js
3
3
  *
4
4
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -16,11 +16,11 @@ if (process.env.NODE_ENV !== "production") {
16
16
  'use strict';
17
17
 
18
18
  var _assign = require('object-assign');
19
+ var invariant = require('fbjs/lib/invariant');
19
20
  var React = require('react');
20
21
  var emptyFunction = require('fbjs/lib/emptyFunction');
21
22
  var emptyObject = require('fbjs/lib/emptyObject');
22
23
  var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');
23
- var invariant = require('fbjs/lib/invariant');
24
24
  var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly');
25
25
  var warning = require('fbjs/lib/warning');
26
26
  var checkPropTypes = require('prop-types/checkPropTypes');
@@ -29,14 +29,10 @@ var stream = require('stream');
29
29
 
30
30
  // TODO: this is special because it gets imported during build.
31
31
 
32
- var ReactVersion = '16.4.0-alpha.3174632';
32
+ var ReactVersion = '16.4.2';
33
33
 
34
- /**
35
- * WARNING: DO NOT manually require this module.
36
- * This is a replacement for `invariant(...)` used by the error code system
37
- * and will _only_ be required by the corresponding babel pass.
38
- * It always throws.
39
- */
34
+ // Relying on the `invariant()` implementation lets us
35
+ // have preserve the format and params in the www builds.
40
36
 
41
37
  /**
42
38
  * Forked from fbjs/warning:
@@ -103,16 +99,11 @@ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
103
99
  // Exports ReactDOM.createRoot
104
100
 
105
101
 
106
-
107
- // Mutating mode (React DOM, React ART, React Native):
108
-
109
- // Experimental noop mode (currently unused):
110
-
111
- // Experimental persistent mode (Fabric):
112
-
113
102
  // Experimental error-boundary API that can recover from errors within a single
114
103
  // render phase
115
104
 
105
+ // Suspense
106
+
116
107
  // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
117
108
 
118
109
 
@@ -129,21 +120,27 @@ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
129
120
  // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
130
121
  var warnAboutDeprecatedLifecycles = false;
131
122
 
123
+ // Warn about legacy context API
124
+
125
+
126
+ // Gather advanced timing metrics for Profiler subtrees.
127
+
128
+
132
129
  // Only used in www builds.
133
130
 
134
131
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
135
132
  // nor polyfill, then a plain number is used for performance.
136
- var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
133
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
137
134
 
138
135
 
139
- var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
140
- var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
141
- var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
142
- var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
143
- var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol['for']('react.strict_mode') : 0xeacc;
144
- var REACT_PROVIDER_TYPE = hasSymbol ? Symbol['for']('react.provider') : 0xeacd;
145
- var REACT_CONTEXT_TYPE = hasSymbol ? Symbol['for']('react.context') : 0xeace;
146
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol['for']('react.async_mode') : 0xeacf;
136
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
137
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
138
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
139
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
140
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
141
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
142
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
143
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
147
144
 
148
145
  // A reserved attribute.
149
146
  // It is handled by React separately and shouldn't be written to the DOM.
@@ -187,14 +184,15 @@ var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u
187
184
  var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
188
185
  var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
189
186
 
187
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
190
188
  var illegalAttributeNameCache = {};
191
189
  var validatedAttributeNameCache = {};
192
190
 
193
191
  function isAttributeNameSafe(attributeName) {
194
- if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
192
+ if (hasOwnProperty$1.call(validatedAttributeNameCache, attributeName)) {
195
193
  return true;
196
194
  }
197
- if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
195
+ if (hasOwnProperty$1.call(illegalAttributeNameCache, attributeName)) {
198
196
  return false;
199
197
  }
200
198
  if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
@@ -255,6 +253,9 @@ function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)
255
253
  if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
256
254
  return true;
257
255
  }
256
+ if (isCustomComponentTag) {
257
+ return false;
258
+ }
258
259
  if (propertyInfo !== null) {
259
260
  switch (propertyInfo.type) {
260
261
  case BOOLEAN:
@@ -297,15 +298,20 @@ var properties = {};
297
298
  properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
298
299
  name, // attributeName
299
300
  null);
300
- });
301
+ } // attributeNamespace
302
+ );
301
303
 
302
304
  // A few React string attributes have a different name.
303
305
  // This is a mapping from React prop names to the attribute names.
304
- new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']]).forEach(function (attributeName, name) {
306
+ [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
307
+ var name = _ref[0],
308
+ attributeName = _ref[1];
309
+
305
310
  properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
306
311
  attributeName, // attributeName
307
312
  null);
308
- });
313
+ } // attributeNamespace
314
+ );
309
315
 
310
316
  // These are "enumerated" HTML attributes that accept "true" and "false".
311
317
  // In React, we let users pass `true` and `false` even though technically
@@ -314,7 +320,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
314
320
  properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
315
321
  name.toLowerCase(), // attributeName
316
322
  null);
317
- });
323
+ } // attributeNamespace
324
+ );
318
325
 
319
326
  // These are "enumerated" SVG attributes that accept "true" and "false".
320
327
  // In React, we let users pass `true` and `false` even though technically
@@ -324,7 +331,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
324
331
  properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
325
332
  name, // attributeName
326
333
  null);
327
- });
334
+ } // attributeNamespace
335
+ );
328
336
 
329
337
  // These are HTML boolean attributes.
330
338
  ['allowFullScreen', 'async',
@@ -336,7 +344,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
336
344
  properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
337
345
  name.toLowerCase(), // attributeName
338
346
  null);
339
- });
347
+ } // attributeNamespace
348
+ );
340
349
 
341
350
  // These are the few React props that we set as DOM properties
342
351
  // rather than attributes. These are all booleans.
@@ -347,7 +356,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
347
356
  properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
348
357
  name.toLowerCase(), // attributeName
349
358
  null);
350
- });
359
+ } // attributeNamespace
360
+ );
351
361
 
352
362
  // These are HTML attributes that are "overloaded booleans": they behave like
353
363
  // booleans, but can also accept a string value.
@@ -355,21 +365,24 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
355
365
  properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
356
366
  name.toLowerCase(), // attributeName
357
367
  null);
358
- });
368
+ } // attributeNamespace
369
+ );
359
370
 
360
371
  // These are HTML attributes that must be positive numbers.
361
372
  ['cols', 'rows', 'size', 'span'].forEach(function (name) {
362
373
  properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
363
374
  name.toLowerCase(), // attributeName
364
375
  null);
365
- });
376
+ } // attributeNamespace
377
+ );
366
378
 
367
379
  // These are HTML attributes that must be numbers.
368
380
  ['rowSpan', 'start'].forEach(function (name) {
369
381
  properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
370
382
  name.toLowerCase(), // attributeName
371
383
  null);
372
- });
384
+ } // attributeNamespace
385
+ );
373
386
 
374
387
  var CAMELIZE = /[\-\:]([a-z])/g;
375
388
  var capitalize = function (token) {
@@ -385,7 +398,8 @@ var capitalize = function (token) {
385
398
  var name = attributeName.replace(CAMELIZE, capitalize);
386
399
  properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
387
400
  attributeName, null);
388
- });
401
+ } // attributeNamespace
402
+ );
389
403
 
390
404
  // String SVG attributes with the xlink namespace.
391
405
  ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
@@ -541,9 +555,10 @@ function createMarkupForProperty(name, value) {
541
555
  } else {
542
556
  return attributeName + '=' + quoteAttributeValueForBrowser(value);
543
557
  }
544
- } else {
558
+ } else if (isAttributeNameSafe(name)) {
545
559
  return name + '=' + quoteAttributeValueForBrowser(value);
546
560
  }
561
+ return '';
547
562
  }
548
563
 
549
564
  /**
@@ -653,6 +668,7 @@ var omittedCloseTags = {
653
668
  source: true,
654
669
  track: true,
655
670
  wbr: true
671
+ // NOTE: menuitem's close tag should be omitted, but that causes problems.
656
672
  };
657
673
 
658
674
  // For HTML, certain tags cannot have children. This has the same purpose as
@@ -677,7 +693,7 @@ function assertValidProps(tag, props, getStack) {
677
693
  !(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML) ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0;
678
694
  }
679
695
  {
680
- warning(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack());
696
+ !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.%s', getStack()) : void 0;
681
697
  }
682
698
  !(props.style == null || typeof props.style === 'object') ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', getStack()) : void 0;
683
699
  }
@@ -949,7 +965,7 @@ var warnedProperties = {};
949
965
  var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
950
966
  var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
951
967
 
952
- var hasOwnProperty = Object.prototype.hasOwnProperty;
968
+ var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
953
969
 
954
970
  function getStackAddendum$1() {
955
971
  var stack = ReactDebugCurrentFrame.getStackAddendum();
@@ -957,7 +973,7 @@ function getStackAddendum$1() {
957
973
  }
958
974
 
959
975
  function validateProperty(tagName, name) {
960
- if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
976
+ if (hasOwnProperty$2.call(warnedProperties, name) && warnedProperties[name]) {
961
977
  return true;
962
978
  }
963
979
 
@@ -1136,7 +1152,7 @@ var possibleStandardNames = {
1136
1152
  checked: 'checked',
1137
1153
  children: 'children',
1138
1154
  cite: 'cite',
1139
- 'class': 'className',
1155
+ class: 'className',
1140
1156
  classid: 'classID',
1141
1157
  classname: 'className',
1142
1158
  cols: 'cols',
@@ -1151,7 +1167,7 @@ var possibleStandardNames = {
1151
1167
  dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
1152
1168
  data: 'data',
1153
1169
  datetime: 'dateTime',
1154
- 'default': 'default',
1170
+ default: 'default',
1155
1171
  defaultchecked: 'defaultChecked',
1156
1172
  defaultvalue: 'defaultValue',
1157
1173
  defer: 'defer',
@@ -1160,7 +1176,7 @@ var possibleStandardNames = {
1160
1176
  download: 'download',
1161
1177
  draggable: 'draggable',
1162
1178
  enctype: 'encType',
1163
- 'for': 'htmlFor',
1179
+ for: 'htmlFor',
1164
1180
  form: 'form',
1165
1181
  formmethod: 'formMethod',
1166
1182
  formaction: 'formAction',
@@ -1378,7 +1394,7 @@ var possibleStandardNames = {
1378
1394
  imagerendering: 'imageRendering',
1379
1395
  'image-rendering': 'imageRendering',
1380
1396
  in2: 'in2',
1381
- 'in': 'in',
1397
+ in: 'in',
1382
1398
  inlist: 'inlist',
1383
1399
  intercept: 'intercept',
1384
1400
  k1: 'k1',
@@ -1518,7 +1534,7 @@ var possibleStandardNames = {
1518
1534
  'text-rendering': 'textRendering',
1519
1535
  to: 'to',
1520
1536
  transform: 'transform',
1521
- 'typeof': 'typeof',
1537
+ typeof: 'typeof',
1522
1538
  u1: 'u1',
1523
1539
  u2: 'u2',
1524
1540
  underlineposition: 'underlinePosition',
@@ -1980,6 +1996,7 @@ function processContext(type, context) {
1980
1996
  return maskedContext;
1981
1997
  }
1982
1998
 
1999
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1983
2000
  var STYLE = 'style';
1984
2001
  var RESERVED_PROPS = {
1985
2002
  children: null,
@@ -1992,7 +2009,7 @@ function createOpenTagMarkup(tagVerbatim, tagLowercase, props, namespace, makeSt
1992
2009
  var ret = '<' + tagVerbatim;
1993
2010
 
1994
2011
  for (var propKey in props) {
1995
- if (!props.hasOwnProperty(propKey)) {
2012
+ if (!hasOwnProperty.call(props, propKey)) {
1996
2013
  continue;
1997
2014
  }
1998
2015
  var propValue = props[propKey];
@@ -2034,42 +2051,26 @@ function validateRenderResult(child, type) {
2034
2051
  }
2035
2052
 
2036
2053
  function resolve(child, context) {
2037
- var element = void 0;
2038
-
2039
- var Component = void 0;
2040
- var publicContext = void 0;
2041
- var inst = void 0,
2042
- queue = void 0,
2043
- replace = void 0;
2044
- var updater = void 0;
2045
-
2046
- var initialState = void 0;
2047
- var oldQueue = void 0,
2048
- oldReplace = void 0;
2049
- var nextState = void 0,
2050
- dontMutate = void 0;
2051
- var partial = void 0,
2052
- partialState = void 0;
2053
-
2054
- var childContext = void 0;
2055
- var childContextTypes = void 0,
2056
- contextKey = void 0;
2057
-
2058
2054
  while (React.isValidElement(child)) {
2059
2055
  // Safe because we just checked it's an element.
2060
- element = child;
2056
+ var element = child;
2057
+ var Component = element.type;
2061
2058
  {
2062
2059
  pushElementToDebugStack(element);
2063
2060
  }
2064
- Component = element.type;
2065
2061
  if (typeof Component !== 'function') {
2066
2062
  break;
2067
2063
  }
2068
- publicContext = processContext(Component, context);
2064
+ processChild(element, Component);
2065
+ }
2069
2066
 
2070
- queue = [];
2071
- replace = false;
2072
- updater = {
2067
+ // Extra closure so queue and replace can be captured properly
2068
+ function processChild(element, Component) {
2069
+ var publicContext = processContext(Component, context);
2070
+
2071
+ var queue = [];
2072
+ var replace = false;
2073
+ var updater = {
2073
2074
  isMounted: function (publicInstance) {
2074
2075
  return false;
2075
2076
  },
@@ -2092,6 +2093,7 @@ function resolve(child, context) {
2092
2093
  }
2093
2094
  };
2094
2095
 
2096
+ var inst = void 0;
2095
2097
  if (shouldConstruct(Component)) {
2096
2098
  inst = new Component(element.props, publicContext, updater);
2097
2099
 
@@ -2106,7 +2108,7 @@ function resolve(child, context) {
2106
2108
  }
2107
2109
  }
2108
2110
 
2109
- partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
2111
+ var partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
2110
2112
 
2111
2113
  {
2112
2114
  if (partialState === undefined) {
@@ -2137,7 +2139,7 @@ function resolve(child, context) {
2137
2139
  if (inst == null || inst.render == null) {
2138
2140
  child = inst;
2139
2141
  validateRenderResult(child, Component);
2140
- continue;
2142
+ return;
2141
2143
  }
2142
2144
  }
2143
2145
 
@@ -2145,7 +2147,7 @@ function resolve(child, context) {
2145
2147
  inst.context = publicContext;
2146
2148
  inst.updater = updater;
2147
2149
 
2148
- initialState = inst.state;
2150
+ var initialState = inst.state;
2149
2151
  if (initialState === undefined) {
2150
2152
  inst.state = initialState = null;
2151
2153
  }
@@ -2174,25 +2176,25 @@ function resolve(child, context) {
2174
2176
  inst.UNSAFE_componentWillMount();
2175
2177
  }
2176
2178
  if (queue.length) {
2177
- oldQueue = queue;
2178
- oldReplace = replace;
2179
+ var oldQueue = queue;
2180
+ var oldReplace = replace;
2179
2181
  queue = null;
2180
2182
  replace = false;
2181
2183
 
2182
2184
  if (oldReplace && oldQueue.length === 1) {
2183
2185
  inst.state = oldQueue[0];
2184
2186
  } else {
2185
- nextState = oldReplace ? oldQueue[0] : inst.state;
2186
- dontMutate = true;
2187
+ var nextState = oldReplace ? oldQueue[0] : inst.state;
2188
+ var dontMutate = true;
2187
2189
  for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
2188
- partial = oldQueue[i];
2189
- partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
2190
- if (partialState != null) {
2190
+ var partial = oldQueue[i];
2191
+ var _partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
2192
+ if (_partialState != null) {
2191
2193
  if (dontMutate) {
2192
2194
  dontMutate = false;
2193
- nextState = _assign({}, nextState, partialState);
2195
+ nextState = _assign({}, nextState, _partialState);
2194
2196
  } else {
2195
- _assign(nextState, partialState);
2197
+ _assign(nextState, _partialState);
2196
2198
  }
2197
2199
  }
2198
2200
  }
@@ -2213,11 +2215,12 @@ function resolve(child, context) {
2213
2215
  }
2214
2216
  validateRenderResult(child, Component);
2215
2217
 
2218
+ var childContext = void 0;
2216
2219
  if (typeof inst.getChildContext === 'function') {
2217
- childContextTypes = Component.childContextTypes;
2220
+ var childContextTypes = Component.childContextTypes;
2218
2221
  if (typeof childContextTypes === 'object') {
2219
2222
  childContext = inst.getChildContext();
2220
- for (contextKey in childContext) {
2223
+ for (var contextKey in childContext) {
2221
2224
  !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(Component) || 'Unknown', contextKey) : void 0;
2222
2225
  }
2223
2226
  } else {
@@ -2232,6 +2235,8 @@ function resolve(child, context) {
2232
2235
  }
2233
2236
 
2234
2237
  var ReactDOMServerRenderer = function () {
2238
+ // DEV-only
2239
+
2235
2240
  function ReactDOMServerRenderer(children, makeStaticMarkup) {
2236
2241
  _classCallCheck(this, ReactDOMServerRenderer);
2237
2242
 
@@ -2257,33 +2262,65 @@ var ReactDOMServerRenderer = function () {
2257
2262
  this.makeStaticMarkup = makeStaticMarkup;
2258
2263
 
2259
2264
  // Context (new API)
2260
- this.providerStack = []; // Stack of provider objects
2261
- this.providerIndex = -1;
2265
+ this.contextIndex = -1;
2266
+ this.contextStack = [];
2267
+ this.contextValueStack = [];
2268
+ {
2269
+ this.contextProviderStack = [];
2270
+ }
2262
2271
  }
2272
+
2273
+ /**
2274
+ * Note: We use just two stacks regardless of how many context providers you have.
2275
+ * Providers are always popped in the reverse order to how they were pushed
2276
+ * so we always know on the way down which provider you'll encounter next on the way up.
2277
+ * On the way down, we push the current provider, and its context value *before*
2278
+ * we mutated it, onto the stacks. Therefore, on the way up, we always know which
2279
+ * provider needs to be "restored" to which value.
2280
+ * https://github.com/facebook/react/pull/12985#issuecomment-396301248
2281
+ */
2282
+
2263
2283
  // TODO: type this more strictly:
2264
2284
 
2265
2285
 
2266
2286
  ReactDOMServerRenderer.prototype.pushProvider = function pushProvider(provider) {
2267
- this.providerIndex += 1;
2268
- this.providerStack[this.providerIndex] = provider;
2269
- var context = provider.type.context;
2270
- context.currentValue = provider.props.value;
2287
+ var index = ++this.contextIndex;
2288
+ var context = provider.type._context;
2289
+ var previousValue = context._currentValue;
2290
+
2291
+ // Remember which value to restore this context to on our way up.
2292
+ this.contextStack[index] = context;
2293
+ this.contextValueStack[index] = previousValue;
2294
+ {
2295
+ // Only used for push/pop mismatch warnings.
2296
+ this.contextProviderStack[index] = provider;
2297
+ }
2298
+
2299
+ // Mutate the current value.
2300
+ context._currentValue = provider.props.value;
2271
2301
  };
2272
2302
 
2273
2303
  ReactDOMServerRenderer.prototype.popProvider = function popProvider(provider) {
2304
+ var index = this.contextIndex;
2274
2305
  {
2275
- warning(this.providerIndex > -1 && provider === this.providerStack[this.providerIndex], 'Unexpected pop.');
2306
+ !(index > -1 && provider === this.contextProviderStack[index]) ? warning(false, 'Unexpected pop.') : void 0;
2276
2307
  }
2277
- this.providerStack[this.providerIndex] = null;
2278
- this.providerIndex -= 1;
2279
- var context = provider.type.context;
2280
- if (this.providerIndex < 0) {
2281
- context.currentValue = context.defaultValue;
2282
- } else {
2283
- // We assume this type is correct because of the index check above.
2284
- var previousProvider = this.providerStack[this.providerIndex];
2285
- context.currentValue = previousProvider.props.value;
2308
+
2309
+ var context = this.contextStack[index];
2310
+ var previousValue = this.contextValueStack[index];
2311
+
2312
+ // "Hide" these null assignments from Flow by using `any`
2313
+ // because conceptually they are deletions--as long as we
2314
+ // promise to never access values beyond `this.contextIndex`.
2315
+ this.contextStack[index] = null;
2316
+ this.contextValueStack[index] = null;
2317
+ {
2318
+ this.contextProviderStack[index] = null;
2286
2319
  }
2320
+ this.contextIndex--;
2321
+
2322
+ // Restore to the previous value we stored as we were walking down.
2323
+ context._currentValue = previousValue;
2287
2324
  };
2288
2325
 
2289
2326
  ReactDOMServerRenderer.prototype.read = function read(bytes) {
@@ -2384,6 +2421,7 @@ var ReactDOMServerRenderer = function () {
2384
2421
  switch (elementType) {
2385
2422
  case REACT_STRICT_MODE_TYPE:
2386
2423
  case REACT_ASYNC_MODE_TYPE:
2424
+ case REACT_PROFILER_TYPE:
2387
2425
  case REACT_FRAGMENT_TYPE:
2388
2426
  {
2389
2427
  var _nextChildren = toArray(nextChild.props.children);
@@ -2401,56 +2439,71 @@ var ReactDOMServerRenderer = function () {
2401
2439
  this.stack.push(_frame);
2402
2440
  return '';
2403
2441
  }
2404
- case REACT_CALL_TYPE:
2405
- case REACT_RETURN_TYPE:
2406
- invariant(false, 'The experimental Call and Return types are not currently supported by the server renderer.');
2407
2442
  // eslint-disable-next-line-no-fallthrough
2408
2443
  default:
2409
2444
  break;
2410
2445
  }
2411
2446
  if (typeof elementType === 'object' && elementType !== null) {
2412
2447
  switch (elementType.$$typeof) {
2448
+ case REACT_FORWARD_REF_TYPE:
2449
+ {
2450
+ var element = nextChild;
2451
+ var _nextChildren2 = toArray(elementType.render(element.props, element.ref));
2452
+ var _frame2 = {
2453
+ type: null,
2454
+ domNamespace: parentNamespace,
2455
+ children: _nextChildren2,
2456
+ childIndex: 0,
2457
+ context: context,
2458
+ footer: ''
2459
+ };
2460
+ {
2461
+ _frame2.debugElementStack = [];
2462
+ }
2463
+ this.stack.push(_frame2);
2464
+ return '';
2465
+ }
2413
2466
  case REACT_PROVIDER_TYPE:
2414
2467
  {
2415
2468
  var provider = nextChild;
2416
2469
  var nextProps = provider.props;
2417
- var _nextChildren2 = toArray(nextProps.children);
2418
- var _frame2 = {
2470
+ var _nextChildren3 = toArray(nextProps.children);
2471
+ var _frame3 = {
2419
2472
  type: provider,
2420
2473
  domNamespace: parentNamespace,
2421
- children: _nextChildren2,
2474
+ children: _nextChildren3,
2422
2475
  childIndex: 0,
2423
2476
  context: context,
2424
2477
  footer: ''
2425
2478
  };
2426
2479
  {
2427
- _frame2.debugElementStack = [];
2480
+ _frame3.debugElementStack = [];
2428
2481
  }
2429
2482
 
2430
2483
  this.pushProvider(provider);
2431
2484
 
2432
- this.stack.push(_frame2);
2485
+ this.stack.push(_frame3);
2433
2486
  return '';
2434
2487
  }
2435
2488
  case REACT_CONTEXT_TYPE:
2436
2489
  {
2437
2490
  var consumer = nextChild;
2438
2491
  var _nextProps = consumer.props;
2439
- var nextValue = consumer.type.currentValue;
2492
+ var nextValue = consumer.type._currentValue;
2440
2493
 
2441
- var _nextChildren3 = toArray(_nextProps.children(nextValue));
2442
- var _frame3 = {
2494
+ var _nextChildren4 = toArray(_nextProps.children(nextValue));
2495
+ var _frame4 = {
2443
2496
  type: nextChild,
2444
2497
  domNamespace: parentNamespace,
2445
- children: _nextChildren3,
2498
+ children: _nextChildren4,
2446
2499
  childIndex: 0,
2447
2500
  context: context,
2448
2501
  footer: ''
2449
2502
  };
2450
2503
  {
2451
- _frame3.debugElementStack = [];
2504
+ _frame4.debugElementStack = [];
2452
2505
  }
2453
- this.stack.push(_frame3);
2506
+ this.stack.push(_frame4);
2454
2507
  return '';
2455
2508
  }
2456
2509
  default:
@@ -2485,7 +2538,7 @@ var ReactDOMServerRenderer = function () {
2485
2538
  if (namespace === Namespaces.html) {
2486
2539
  // Should this check be gated by parent namespace? Not sure we want to
2487
2540
  // allow <SVG> or <mATH>.
2488
- warning(tag === element.type, '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', element.type);
2541
+ !(tag === element.type) ? warning(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', element.type) : void 0;
2489
2542
  }
2490
2543
  }
2491
2544
 
@@ -2561,9 +2614,11 @@ var ReactDOMServerRenderer = function () {
2561
2614
  }
2562
2615
  var isArray = Array.isArray(props[propName]);
2563
2616
  if (props.multiple && !isArray) {
2564
- warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, '');
2617
+ warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, '' // getDeclarationErrorAddendum(),
2618
+ );
2565
2619
  } else if (!props.multiple && isArray) {
2566
- warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, '');
2620
+ warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, '' // getDeclarationErrorAddendum(),
2621
+ );
2567
2622
  }
2568
2623
  }
2569
2624
 
@@ -2756,7 +2811,7 @@ var ReactDOMServer = ( ReactDOMServerNode$1 && ReactDOMServerNode ) || ReactDOMS
2756
2811
 
2757
2812
  // TODO: decide on the top-level export form.
2758
2813
  // This is hacky but makes it work with both Rollup and Jest
2759
- var server_node = ReactDOMServer['default'] ? ReactDOMServer['default'] : ReactDOMServer;
2814
+ var server_node = ReactDOMServer.default ? ReactDOMServer.default : ReactDOMServer;
2760
2815
 
2761
2816
  module.exports = server_node;
2762
2817
  })();