react-dom 16.4.0-alpha.0911da3 → 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.
- package/cjs/react-dom-server.browser.development.js +168 -116
- package/cjs/react-dom-server.browser.production.min.js +30 -30
- package/cjs/react-dom-server.node.development.js +169 -117
- package/cjs/react-dom-server.node.production.min.js +32 -32
- package/cjs/react-dom-test-utils.development.js +145 -136
- package/cjs/react-dom-test-utils.production.min.js +25 -26
- package/cjs/react-dom-unstable-native-dependencies.development.js +81 -61
- package/cjs/react-dom-unstable-native-dependencies.production.min.js +27 -28
- package/cjs/react-dom.development.js +11460 -10809
- package/cjs/react-dom.production.min.js +229 -240
- package/cjs/react-dom.profiling.min.js +242 -0
- package/package.json +2 -2
- package/umd/react-dom-server.browser.development.js +172 -120
- package/umd/react-dom-server.browser.production.min.js +29 -28
- package/umd/react-dom-test-utils.development.js +145 -136
- package/umd/react-dom-test-utils.production.min.js +20 -21
- package/umd/react-dom-unstable-native-dependencies.development.js +82 -62
- package/umd/react-dom-unstable-native-dependencies.production.min.js +23 -23
- package/umd/react-dom.development.js +11565 -10914
- package/umd/react-dom.production.min.js +188 -203
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.4.
|
|
1
|
+
/** @license React v16.4.1
|
|
2
2
|
* react-dom-server.browser.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -26,16 +26,12 @@ var warning = require('fbjs/lib/warning');
|
|
|
26
26
|
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
27
27
|
var camelizeStyleName = require('fbjs/lib/camelizeStyleName');
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* This is a replacement for `invariant(...)` used by the error code system
|
|
32
|
-
* and will _only_ be required by the corresponding babel pass.
|
|
33
|
-
* It always throws.
|
|
34
|
-
*/
|
|
29
|
+
// Relying on the `invariant()` implementation lets us
|
|
30
|
+
// have preserve the format and params in the www builds.
|
|
35
31
|
|
|
36
32
|
// TODO: this is special because it gets imported during build.
|
|
37
33
|
|
|
38
|
-
var ReactVersion = '16.4.
|
|
34
|
+
var ReactVersion = '16.4.1';
|
|
39
35
|
|
|
40
36
|
/**
|
|
41
37
|
* Forked from fbjs/warning:
|
|
@@ -102,16 +98,11 @@ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
|
|
|
102
98
|
// Exports ReactDOM.createRoot
|
|
103
99
|
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
// Mutating mode (React DOM, React ART, React Native):
|
|
107
|
-
|
|
108
|
-
// Experimental noop mode (currently unused):
|
|
109
|
-
|
|
110
|
-
// Experimental persistent mode (Fabric):
|
|
111
|
-
|
|
112
101
|
// Experimental error-boundary API that can recover from errors within a single
|
|
113
102
|
// render phase
|
|
114
103
|
|
|
104
|
+
// Suspense
|
|
105
|
+
|
|
115
106
|
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
116
107
|
|
|
117
108
|
|
|
@@ -128,21 +119,27 @@ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
|
|
|
128
119
|
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
129
120
|
var warnAboutDeprecatedLifecycles = false;
|
|
130
121
|
|
|
122
|
+
// Warn about legacy context API
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
// Gather advanced timing metrics for Profiler subtrees.
|
|
126
|
+
|
|
127
|
+
|
|
131
128
|
// Only used in www builds.
|
|
132
129
|
|
|
133
130
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
134
131
|
// nor polyfill, then a plain number is used for performance.
|
|
135
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol
|
|
132
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
136
133
|
|
|
137
134
|
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
145
|
-
var
|
|
135
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
136
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
137
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
138
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
139
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
140
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
141
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
142
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
146
143
|
|
|
147
144
|
// A reserved attribute.
|
|
148
145
|
// It is handled by React separately and shouldn't be written to the DOM.
|
|
@@ -254,6 +251,9 @@ function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)
|
|
|
254
251
|
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
|
|
255
252
|
return true;
|
|
256
253
|
}
|
|
254
|
+
if (isCustomComponentTag) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
257
|
if (propertyInfo !== null) {
|
|
258
258
|
switch (propertyInfo.type) {
|
|
259
259
|
case BOOLEAN:
|
|
@@ -296,15 +296,20 @@ var properties = {};
|
|
|
296
296
|
properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
|
|
297
297
|
name, // attributeName
|
|
298
298
|
null);
|
|
299
|
-
}
|
|
299
|
+
} // attributeNamespace
|
|
300
|
+
);
|
|
300
301
|
|
|
301
302
|
// A few React string attributes have a different name.
|
|
302
303
|
// This is a mapping from React prop names to the attribute names.
|
|
303
|
-
|
|
304
|
+
[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
|
|
305
|
+
var name = _ref[0],
|
|
306
|
+
attributeName = _ref[1];
|
|
307
|
+
|
|
304
308
|
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
305
309
|
attributeName, // attributeName
|
|
306
310
|
null);
|
|
307
|
-
}
|
|
311
|
+
} // attributeNamespace
|
|
312
|
+
);
|
|
308
313
|
|
|
309
314
|
// These are "enumerated" HTML attributes that accept "true" and "false".
|
|
310
315
|
// In React, we let users pass `true` and `false` even though technically
|
|
@@ -313,7 +318,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
|
|
|
313
318
|
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
314
319
|
name.toLowerCase(), // attributeName
|
|
315
320
|
null);
|
|
316
|
-
}
|
|
321
|
+
} // attributeNamespace
|
|
322
|
+
);
|
|
317
323
|
|
|
318
324
|
// These are "enumerated" SVG attributes that accept "true" and "false".
|
|
319
325
|
// In React, we let users pass `true` and `false` even though technically
|
|
@@ -323,7 +329,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
|
|
|
323
329
|
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
|
|
324
330
|
name, // attributeName
|
|
325
331
|
null);
|
|
326
|
-
}
|
|
332
|
+
} // attributeNamespace
|
|
333
|
+
);
|
|
327
334
|
|
|
328
335
|
// These are HTML boolean attributes.
|
|
329
336
|
['allowFullScreen', 'async',
|
|
@@ -335,7 +342,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
|
|
|
335
342
|
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
|
|
336
343
|
name.toLowerCase(), // attributeName
|
|
337
344
|
null);
|
|
338
|
-
}
|
|
345
|
+
} // attributeNamespace
|
|
346
|
+
);
|
|
339
347
|
|
|
340
348
|
// These are the few React props that we set as DOM properties
|
|
341
349
|
// rather than attributes. These are all booleans.
|
|
@@ -346,7 +354,8 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
|
|
|
346
354
|
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
|
|
347
355
|
name.toLowerCase(), // attributeName
|
|
348
356
|
null);
|
|
349
|
-
}
|
|
357
|
+
} // attributeNamespace
|
|
358
|
+
);
|
|
350
359
|
|
|
351
360
|
// These are HTML attributes that are "overloaded booleans": they behave like
|
|
352
361
|
// booleans, but can also accept a string value.
|
|
@@ -354,21 +363,24 @@ new Map([['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor'
|
|
|
354
363
|
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
|
|
355
364
|
name.toLowerCase(), // attributeName
|
|
356
365
|
null);
|
|
357
|
-
}
|
|
366
|
+
} // attributeNamespace
|
|
367
|
+
);
|
|
358
368
|
|
|
359
369
|
// These are HTML attributes that must be positive numbers.
|
|
360
370
|
['cols', 'rows', 'size', 'span'].forEach(function (name) {
|
|
361
371
|
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
|
|
362
372
|
name.toLowerCase(), // attributeName
|
|
363
373
|
null);
|
|
364
|
-
}
|
|
374
|
+
} // attributeNamespace
|
|
375
|
+
);
|
|
365
376
|
|
|
366
377
|
// These are HTML attributes that must be numbers.
|
|
367
378
|
['rowSpan', 'start'].forEach(function (name) {
|
|
368
379
|
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
|
|
369
380
|
name.toLowerCase(), // attributeName
|
|
370
381
|
null);
|
|
371
|
-
}
|
|
382
|
+
} // attributeNamespace
|
|
383
|
+
);
|
|
372
384
|
|
|
373
385
|
var CAMELIZE = /[\-\:]([a-z])/g;
|
|
374
386
|
var capitalize = function (token) {
|
|
@@ -384,7 +396,8 @@ var capitalize = function (token) {
|
|
|
384
396
|
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
385
397
|
properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
|
|
386
398
|
attributeName, null);
|
|
387
|
-
}
|
|
399
|
+
} // attributeNamespace
|
|
400
|
+
);
|
|
388
401
|
|
|
389
402
|
// String SVG attributes with the xlink namespace.
|
|
390
403
|
['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
|
|
@@ -652,6 +665,7 @@ var omittedCloseTags = {
|
|
|
652
665
|
source: true,
|
|
653
666
|
track: true,
|
|
654
667
|
wbr: true
|
|
668
|
+
// NOTE: menuitem's close tag should be omitted, but that causes problems.
|
|
655
669
|
};
|
|
656
670
|
|
|
657
671
|
// For HTML, certain tags cannot have children. This has the same purpose as
|
|
@@ -676,7 +690,7 @@ function assertValidProps(tag, props, getStack) {
|
|
|
676
690
|
!(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;
|
|
677
691
|
}
|
|
678
692
|
{
|
|
679
|
-
|
|
693
|
+
!(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;
|
|
680
694
|
}
|
|
681
695
|
!(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;
|
|
682
696
|
}
|
|
@@ -1135,7 +1149,7 @@ var possibleStandardNames = {
|
|
|
1135
1149
|
checked: 'checked',
|
|
1136
1150
|
children: 'children',
|
|
1137
1151
|
cite: 'cite',
|
|
1138
|
-
|
|
1152
|
+
class: 'className',
|
|
1139
1153
|
classid: 'classID',
|
|
1140
1154
|
classname: 'className',
|
|
1141
1155
|
cols: 'cols',
|
|
@@ -1150,7 +1164,7 @@ var possibleStandardNames = {
|
|
|
1150
1164
|
dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
|
|
1151
1165
|
data: 'data',
|
|
1152
1166
|
datetime: 'dateTime',
|
|
1153
|
-
|
|
1167
|
+
default: 'default',
|
|
1154
1168
|
defaultchecked: 'defaultChecked',
|
|
1155
1169
|
defaultvalue: 'defaultValue',
|
|
1156
1170
|
defer: 'defer',
|
|
@@ -1159,7 +1173,7 @@ var possibleStandardNames = {
|
|
|
1159
1173
|
download: 'download',
|
|
1160
1174
|
draggable: 'draggable',
|
|
1161
1175
|
enctype: 'encType',
|
|
1162
|
-
|
|
1176
|
+
for: 'htmlFor',
|
|
1163
1177
|
form: 'form',
|
|
1164
1178
|
formmethod: 'formMethod',
|
|
1165
1179
|
formaction: 'formAction',
|
|
@@ -1377,7 +1391,7 @@ var possibleStandardNames = {
|
|
|
1377
1391
|
imagerendering: 'imageRendering',
|
|
1378
1392
|
'image-rendering': 'imageRendering',
|
|
1379
1393
|
in2: 'in2',
|
|
1380
|
-
|
|
1394
|
+
in: 'in',
|
|
1381
1395
|
inlist: 'inlist',
|
|
1382
1396
|
intercept: 'intercept',
|
|
1383
1397
|
k1: 'k1',
|
|
@@ -1517,7 +1531,7 @@ var possibleStandardNames = {
|
|
|
1517
1531
|
'text-rendering': 'textRendering',
|
|
1518
1532
|
to: 'to',
|
|
1519
1533
|
transform: 'transform',
|
|
1520
|
-
|
|
1534
|
+
typeof: 'typeof',
|
|
1521
1535
|
u1: 'u1',
|
|
1522
1536
|
u2: 'u2',
|
|
1523
1537
|
underlineposition: 'underlinePosition',
|
|
@@ -2033,42 +2047,26 @@ function validateRenderResult(child, type) {
|
|
|
2033
2047
|
}
|
|
2034
2048
|
|
|
2035
2049
|
function resolve(child, context) {
|
|
2036
|
-
var element = void 0;
|
|
2037
|
-
|
|
2038
|
-
var Component = void 0;
|
|
2039
|
-
var publicContext = void 0;
|
|
2040
|
-
var inst = void 0,
|
|
2041
|
-
queue = void 0,
|
|
2042
|
-
replace = void 0;
|
|
2043
|
-
var updater = void 0;
|
|
2044
|
-
|
|
2045
|
-
var initialState = void 0;
|
|
2046
|
-
var oldQueue = void 0,
|
|
2047
|
-
oldReplace = void 0;
|
|
2048
|
-
var nextState = void 0,
|
|
2049
|
-
dontMutate = void 0;
|
|
2050
|
-
var partial = void 0,
|
|
2051
|
-
partialState = void 0;
|
|
2052
|
-
|
|
2053
|
-
var childContext = void 0;
|
|
2054
|
-
var childContextTypes = void 0,
|
|
2055
|
-
contextKey = void 0;
|
|
2056
|
-
|
|
2057
2050
|
while (React.isValidElement(child)) {
|
|
2058
2051
|
// Safe because we just checked it's an element.
|
|
2059
|
-
element = child;
|
|
2052
|
+
var element = child;
|
|
2053
|
+
var Component = element.type;
|
|
2060
2054
|
{
|
|
2061
2055
|
pushElementToDebugStack(element);
|
|
2062
2056
|
}
|
|
2063
|
-
Component = element.type;
|
|
2064
2057
|
if (typeof Component !== 'function') {
|
|
2065
2058
|
break;
|
|
2066
2059
|
}
|
|
2067
|
-
|
|
2060
|
+
processChild(element, Component);
|
|
2061
|
+
}
|
|
2068
2062
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2063
|
+
// Extra closure so queue and replace can be captured properly
|
|
2064
|
+
function processChild(element, Component) {
|
|
2065
|
+
var publicContext = processContext(Component, context);
|
|
2066
|
+
|
|
2067
|
+
var queue = [];
|
|
2068
|
+
var replace = false;
|
|
2069
|
+
var updater = {
|
|
2072
2070
|
isMounted: function (publicInstance) {
|
|
2073
2071
|
return false;
|
|
2074
2072
|
},
|
|
@@ -2091,6 +2089,7 @@ function resolve(child, context) {
|
|
|
2091
2089
|
}
|
|
2092
2090
|
};
|
|
2093
2091
|
|
|
2092
|
+
var inst = void 0;
|
|
2094
2093
|
if (shouldConstruct(Component)) {
|
|
2095
2094
|
inst = new Component(element.props, publicContext, updater);
|
|
2096
2095
|
|
|
@@ -2105,7 +2104,7 @@ function resolve(child, context) {
|
|
|
2105
2104
|
}
|
|
2106
2105
|
}
|
|
2107
2106
|
|
|
2108
|
-
partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
|
|
2107
|
+
var partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
|
|
2109
2108
|
|
|
2110
2109
|
{
|
|
2111
2110
|
if (partialState === undefined) {
|
|
@@ -2136,7 +2135,7 @@ function resolve(child, context) {
|
|
|
2136
2135
|
if (inst == null || inst.render == null) {
|
|
2137
2136
|
child = inst;
|
|
2138
2137
|
validateRenderResult(child, Component);
|
|
2139
|
-
|
|
2138
|
+
return;
|
|
2140
2139
|
}
|
|
2141
2140
|
}
|
|
2142
2141
|
|
|
@@ -2144,7 +2143,7 @@ function resolve(child, context) {
|
|
|
2144
2143
|
inst.context = publicContext;
|
|
2145
2144
|
inst.updater = updater;
|
|
2146
2145
|
|
|
2147
|
-
initialState = inst.state;
|
|
2146
|
+
var initialState = inst.state;
|
|
2148
2147
|
if (initialState === undefined) {
|
|
2149
2148
|
inst.state = initialState = null;
|
|
2150
2149
|
}
|
|
@@ -2173,25 +2172,25 @@ function resolve(child, context) {
|
|
|
2173
2172
|
inst.UNSAFE_componentWillMount();
|
|
2174
2173
|
}
|
|
2175
2174
|
if (queue.length) {
|
|
2176
|
-
oldQueue = queue;
|
|
2177
|
-
oldReplace = replace;
|
|
2175
|
+
var oldQueue = queue;
|
|
2176
|
+
var oldReplace = replace;
|
|
2178
2177
|
queue = null;
|
|
2179
2178
|
replace = false;
|
|
2180
2179
|
|
|
2181
2180
|
if (oldReplace && oldQueue.length === 1) {
|
|
2182
2181
|
inst.state = oldQueue[0];
|
|
2183
2182
|
} else {
|
|
2184
|
-
nextState = oldReplace ? oldQueue[0] : inst.state;
|
|
2185
|
-
dontMutate = true;
|
|
2183
|
+
var nextState = oldReplace ? oldQueue[0] : inst.state;
|
|
2184
|
+
var dontMutate = true;
|
|
2186
2185
|
for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
|
|
2187
|
-
partial = oldQueue[i];
|
|
2188
|
-
|
|
2189
|
-
if (
|
|
2186
|
+
var partial = oldQueue[i];
|
|
2187
|
+
var _partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
|
|
2188
|
+
if (_partialState != null) {
|
|
2190
2189
|
if (dontMutate) {
|
|
2191
2190
|
dontMutate = false;
|
|
2192
|
-
nextState = _assign({}, nextState,
|
|
2191
|
+
nextState = _assign({}, nextState, _partialState);
|
|
2193
2192
|
} else {
|
|
2194
|
-
_assign(nextState,
|
|
2193
|
+
_assign(nextState, _partialState);
|
|
2195
2194
|
}
|
|
2196
2195
|
}
|
|
2197
2196
|
}
|
|
@@ -2212,11 +2211,12 @@ function resolve(child, context) {
|
|
|
2212
2211
|
}
|
|
2213
2212
|
validateRenderResult(child, Component);
|
|
2214
2213
|
|
|
2214
|
+
var childContext = void 0;
|
|
2215
2215
|
if (typeof inst.getChildContext === 'function') {
|
|
2216
|
-
childContextTypes = Component.childContextTypes;
|
|
2216
|
+
var childContextTypes = Component.childContextTypes;
|
|
2217
2217
|
if (typeof childContextTypes === 'object') {
|
|
2218
2218
|
childContext = inst.getChildContext();
|
|
2219
|
-
for (contextKey in childContext) {
|
|
2219
|
+
for (var contextKey in childContext) {
|
|
2220
2220
|
!(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(Component) || 'Unknown', contextKey) : void 0;
|
|
2221
2221
|
}
|
|
2222
2222
|
} else {
|
|
@@ -2231,6 +2231,8 @@ function resolve(child, context) {
|
|
|
2231
2231
|
}
|
|
2232
2232
|
|
|
2233
2233
|
var ReactDOMServerRenderer = function () {
|
|
2234
|
+
// DEV-only
|
|
2235
|
+
|
|
2234
2236
|
function ReactDOMServerRenderer(children, makeStaticMarkup) {
|
|
2235
2237
|
_classCallCheck(this, ReactDOMServerRenderer);
|
|
2236
2238
|
|
|
@@ -2256,33 +2258,65 @@ var ReactDOMServerRenderer = function () {
|
|
|
2256
2258
|
this.makeStaticMarkup = makeStaticMarkup;
|
|
2257
2259
|
|
|
2258
2260
|
// Context (new API)
|
|
2259
|
-
this.
|
|
2260
|
-
this.
|
|
2261
|
+
this.contextIndex = -1;
|
|
2262
|
+
this.contextStack = [];
|
|
2263
|
+
this.contextValueStack = [];
|
|
2264
|
+
{
|
|
2265
|
+
this.contextProviderStack = [];
|
|
2266
|
+
}
|
|
2261
2267
|
}
|
|
2268
|
+
|
|
2269
|
+
/**
|
|
2270
|
+
* Note: We use just two stacks regardless of how many context providers you have.
|
|
2271
|
+
* Providers are always popped in the reverse order to how they were pushed
|
|
2272
|
+
* so we always know on the way down which provider you'll encounter next on the way up.
|
|
2273
|
+
* On the way down, we push the current provider, and its context value *before*
|
|
2274
|
+
* we mutated it, onto the stacks. Therefore, on the way up, we always know which
|
|
2275
|
+
* provider needs to be "restored" to which value.
|
|
2276
|
+
* https://github.com/facebook/react/pull/12985#issuecomment-396301248
|
|
2277
|
+
*/
|
|
2278
|
+
|
|
2262
2279
|
// TODO: type this more strictly:
|
|
2263
2280
|
|
|
2264
2281
|
|
|
2265
2282
|
ReactDOMServerRenderer.prototype.pushProvider = function pushProvider(provider) {
|
|
2266
|
-
this.
|
|
2267
|
-
|
|
2268
|
-
var
|
|
2269
|
-
|
|
2283
|
+
var index = ++this.contextIndex;
|
|
2284
|
+
var context = provider.type._context;
|
|
2285
|
+
var previousValue = context._currentValue;
|
|
2286
|
+
|
|
2287
|
+
// Remember which value to restore this context to on our way up.
|
|
2288
|
+
this.contextStack[index] = context;
|
|
2289
|
+
this.contextValueStack[index] = previousValue;
|
|
2290
|
+
{
|
|
2291
|
+
// Only used for push/pop mismatch warnings.
|
|
2292
|
+
this.contextProviderStack[index] = provider;
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
// Mutate the current value.
|
|
2296
|
+
context._currentValue = provider.props.value;
|
|
2270
2297
|
};
|
|
2271
2298
|
|
|
2272
2299
|
ReactDOMServerRenderer.prototype.popProvider = function popProvider(provider) {
|
|
2300
|
+
var index = this.contextIndex;
|
|
2273
2301
|
{
|
|
2274
|
-
|
|
2302
|
+
!(index > -1 && provider === this.contextProviderStack[index]) ? warning(false, 'Unexpected pop.') : void 0;
|
|
2275
2303
|
}
|
|
2276
|
-
|
|
2277
|
-
this.
|
|
2278
|
-
var
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2304
|
+
|
|
2305
|
+
var context = this.contextStack[index];
|
|
2306
|
+
var previousValue = this.contextValueStack[index];
|
|
2307
|
+
|
|
2308
|
+
// "Hide" these null assignments from Flow by using `any`
|
|
2309
|
+
// because conceptually they are deletions--as long as we
|
|
2310
|
+
// promise to never access values beyond `this.contextIndex`.
|
|
2311
|
+
this.contextStack[index] = null;
|
|
2312
|
+
this.contextValueStack[index] = null;
|
|
2313
|
+
{
|
|
2314
|
+
this.contextProviderStack[index] = null;
|
|
2285
2315
|
}
|
|
2316
|
+
this.contextIndex--;
|
|
2317
|
+
|
|
2318
|
+
// Restore to the previous value we stored as we were walking down.
|
|
2319
|
+
context._currentValue = previousValue;
|
|
2286
2320
|
};
|
|
2287
2321
|
|
|
2288
2322
|
ReactDOMServerRenderer.prototype.read = function read(bytes) {
|
|
@@ -2383,6 +2417,7 @@ var ReactDOMServerRenderer = function () {
|
|
|
2383
2417
|
switch (elementType) {
|
|
2384
2418
|
case REACT_STRICT_MODE_TYPE:
|
|
2385
2419
|
case REACT_ASYNC_MODE_TYPE:
|
|
2420
|
+
case REACT_PROFILER_TYPE:
|
|
2386
2421
|
case REACT_FRAGMENT_TYPE:
|
|
2387
2422
|
{
|
|
2388
2423
|
var _nextChildren = toArray(nextChild.props.children);
|
|
@@ -2400,56 +2435,71 @@ var ReactDOMServerRenderer = function () {
|
|
|
2400
2435
|
this.stack.push(_frame);
|
|
2401
2436
|
return '';
|
|
2402
2437
|
}
|
|
2403
|
-
case REACT_CALL_TYPE:
|
|
2404
|
-
case REACT_RETURN_TYPE:
|
|
2405
|
-
invariant(false, 'The experimental Call and Return types are not currently supported by the server renderer.');
|
|
2406
2438
|
// eslint-disable-next-line-no-fallthrough
|
|
2407
2439
|
default:
|
|
2408
2440
|
break;
|
|
2409
2441
|
}
|
|
2410
2442
|
if (typeof elementType === 'object' && elementType !== null) {
|
|
2411
2443
|
switch (elementType.$$typeof) {
|
|
2444
|
+
case REACT_FORWARD_REF_TYPE:
|
|
2445
|
+
{
|
|
2446
|
+
var element = nextChild;
|
|
2447
|
+
var _nextChildren2 = toArray(elementType.render(element.props, element.ref));
|
|
2448
|
+
var _frame2 = {
|
|
2449
|
+
type: null,
|
|
2450
|
+
domNamespace: parentNamespace,
|
|
2451
|
+
children: _nextChildren2,
|
|
2452
|
+
childIndex: 0,
|
|
2453
|
+
context: context,
|
|
2454
|
+
footer: ''
|
|
2455
|
+
};
|
|
2456
|
+
{
|
|
2457
|
+
_frame2.debugElementStack = [];
|
|
2458
|
+
}
|
|
2459
|
+
this.stack.push(_frame2);
|
|
2460
|
+
return '';
|
|
2461
|
+
}
|
|
2412
2462
|
case REACT_PROVIDER_TYPE:
|
|
2413
2463
|
{
|
|
2414
2464
|
var provider = nextChild;
|
|
2415
2465
|
var nextProps = provider.props;
|
|
2416
|
-
var
|
|
2417
|
-
var
|
|
2466
|
+
var _nextChildren3 = toArray(nextProps.children);
|
|
2467
|
+
var _frame3 = {
|
|
2418
2468
|
type: provider,
|
|
2419
2469
|
domNamespace: parentNamespace,
|
|
2420
|
-
children:
|
|
2470
|
+
children: _nextChildren3,
|
|
2421
2471
|
childIndex: 0,
|
|
2422
2472
|
context: context,
|
|
2423
2473
|
footer: ''
|
|
2424
2474
|
};
|
|
2425
2475
|
{
|
|
2426
|
-
|
|
2476
|
+
_frame3.debugElementStack = [];
|
|
2427
2477
|
}
|
|
2428
2478
|
|
|
2429
2479
|
this.pushProvider(provider);
|
|
2430
2480
|
|
|
2431
|
-
this.stack.push(
|
|
2481
|
+
this.stack.push(_frame3);
|
|
2432
2482
|
return '';
|
|
2433
2483
|
}
|
|
2434
2484
|
case REACT_CONTEXT_TYPE:
|
|
2435
2485
|
{
|
|
2436
2486
|
var consumer = nextChild;
|
|
2437
2487
|
var _nextProps = consumer.props;
|
|
2438
|
-
var nextValue = consumer.type.
|
|
2488
|
+
var nextValue = consumer.type._currentValue;
|
|
2439
2489
|
|
|
2440
|
-
var
|
|
2441
|
-
var
|
|
2490
|
+
var _nextChildren4 = toArray(_nextProps.children(nextValue));
|
|
2491
|
+
var _frame4 = {
|
|
2442
2492
|
type: nextChild,
|
|
2443
2493
|
domNamespace: parentNamespace,
|
|
2444
|
-
children:
|
|
2494
|
+
children: _nextChildren4,
|
|
2445
2495
|
childIndex: 0,
|
|
2446
2496
|
context: context,
|
|
2447
2497
|
footer: ''
|
|
2448
2498
|
};
|
|
2449
2499
|
{
|
|
2450
|
-
|
|
2500
|
+
_frame4.debugElementStack = [];
|
|
2451
2501
|
}
|
|
2452
|
-
this.stack.push(
|
|
2502
|
+
this.stack.push(_frame4);
|
|
2453
2503
|
return '';
|
|
2454
2504
|
}
|
|
2455
2505
|
default:
|
|
@@ -2484,7 +2534,7 @@ var ReactDOMServerRenderer = function () {
|
|
|
2484
2534
|
if (namespace === Namespaces.html) {
|
|
2485
2535
|
// Should this check be gated by parent namespace? Not sure we want to
|
|
2486
2536
|
// allow <SVG> or <mATH>.
|
|
2487
|
-
|
|
2537
|
+
!(tag === element.type) ? warning(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', element.type) : void 0;
|
|
2488
2538
|
}
|
|
2489
2539
|
}
|
|
2490
2540
|
|
|
@@ -2560,9 +2610,11 @@ var ReactDOMServerRenderer = function () {
|
|
|
2560
2610
|
}
|
|
2561
2611
|
var isArray = Array.isArray(props[propName]);
|
|
2562
2612
|
if (props.multiple && !isArray) {
|
|
2563
|
-
warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, '')
|
|
2613
|
+
warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, '' // getDeclarationErrorAddendum(),
|
|
2614
|
+
);
|
|
2564
2615
|
} else if (!props.multiple && isArray) {
|
|
2565
|
-
warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, '')
|
|
2616
|
+
warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, '' // getDeclarationErrorAddendum(),
|
|
2617
|
+
);
|
|
2566
2618
|
}
|
|
2567
2619
|
}
|
|
2568
2620
|
|
|
@@ -2710,7 +2762,7 @@ var ReactDOMServer = ( ReactDOMServerBrowser$1 && ReactDOMServerBrowser ) || Rea
|
|
|
2710
2762
|
|
|
2711
2763
|
// TODO: decide on the top-level export form.
|
|
2712
2764
|
// This is hacky but makes it work with both Rollup and Jest
|
|
2713
|
-
var server_browser = ReactDOMServer
|
|
2765
|
+
var server_browser = ReactDOMServer.default ? ReactDOMServer.default : ReactDOMServer;
|
|
2714
2766
|
|
|
2715
2767
|
module.exports = server_browser;
|
|
2716
2768
|
})();
|