UNPKG

95 kBJavaScriptView Raw
1/** @license React v16.4.0
2 * react-dom-server.node.development.js
3 *
4 * Copyright (c) 2013-present, Facebook, Inc.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var invariant = require('fbjs/lib/invariant');
20var React = require('react');
21var emptyFunction = require('fbjs/lib/emptyFunction');
22var emptyObject = require('fbjs/lib/emptyObject');
23var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');
24var memoizeStringOnly = require('fbjs/lib/memoizeStringOnly');
25var warning = require('fbjs/lib/warning');
26var checkPropTypes = require('prop-types/checkPropTypes');
27var camelizeStyleName = require('fbjs/lib/camelizeStyleName');
28var stream = require('stream');
29
30// TODO: this is special because it gets imported during build.
31
32var ReactVersion = '16.4.0';
33
34// Relying on the `invariant()` implementation lets us
35// have preserve the format and params in the www builds.
36
37/**
38 * Forked from fbjs/warning:
39 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
40 *
41 * Only change is we use console.warn instead of console.error,
42 * and do nothing when 'console' is not supported.
43 * This really simplifies the code.
44 * ---
45 * Similar to invariant but only logs a warning if the condition is not met.
46 * This can be used to log issues in development environments in critical
47 * paths. Removing the logging code for production environments will keep the
48 * same logic and follow the same code paths.
49 */
50
51var lowPriorityWarning = function () {};
52
53{
54 var printWarning = function (format) {
55 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
56 args[_key - 1] = arguments[_key];
57 }
58
59 var argIndex = 0;
60 var message = 'Warning: ' + format.replace(/%s/g, function () {
61 return args[argIndex++];
62 });
63 if (typeof console !== 'undefined') {
64 console.warn(message);
65 }
66 try {
67 // --- Welcome to debugging React ---
68 // This error was thrown as a convenience so that you can use this stack
69 // to find the callsite that caused this warning to fire.
70 throw new Error(message);
71 } catch (x) {}
72 };
73
74 lowPriorityWarning = function (condition, format) {
75 if (format === undefined) {
76 throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
77 }
78 if (!condition) {
79 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
80 args[_key2 - 2] = arguments[_key2];
81 }
82
83 printWarning.apply(undefined, [format].concat(args));
84 }
85 };
86}
87
88var lowPriorityWarning$1 = lowPriorityWarning;
89
90var describeComponentFrame = function (name, source, ownerName) {
91 return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
92};
93
94var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
95
96var ReactCurrentOwner = ReactInternals.ReactCurrentOwner;
97var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame;
98
99// Exports ReactDOM.createRoot
100
101
102// Experimental error-boundary API that can recover from errors within a single
103// render phase
104
105// Suspense
106
107// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
108
109
110// In some cases, StrictMode should also double-render lifecycles.
111// This can be confusing for tests though,
112// And it can be bad for performance in production.
113// This feature flag can be used to control the behavior:
114
115
116// To preserve the "Pause on caught exceptions" behavior of the debugger, we
117// replay the begin phase of a failed component inside invokeGuardedCallback.
118
119
120// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
121var warnAboutDeprecatedLifecycles = false;
122
123// Warn about legacy context API
124
125
126// Gather advanced timing metrics for Profiler subtrees.
127
128
129// Fires getDerivedStateFromProps for state *or* props changes
130
131
132// Only used in www builds.
133
134// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
135// nor polyfill, then a plain number is used for performance.
136var hasSymbol = typeof Symbol === 'function' && Symbol.for;
137
138
139var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
140var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
141var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
142var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
143var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
144var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
145var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
146var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
147
148// A reserved attribute.
149// It is handled by React separately and shouldn't be written to the DOM.
150var RESERVED = 0;
151
152// A simple string attribute.
153// Attributes that aren't in the whitelist are presumed to have this type.
154var STRING = 1;
155
156// A string attribute that accepts booleans in React. In HTML, these are called
157// "enumerated" attributes with "true" and "false" as possible values.
158// When true, it should be set to a "true" string.
159// When false, it should be set to a "false" string.
160var BOOLEANISH_STRING = 2;
161
162// A real boolean attribute.
163// When true, it should be present (set either to an empty string or its name).
164// When false, it should be omitted.
165var BOOLEAN = 3;
166
167// An attribute that can be used as a flag as well as with a value.
168// When true, it should be present (set either to an empty string or its name).
169// When false, it should be omitted.
170// For any other value, should be present with that value.
171var OVERLOADED_BOOLEAN = 4;
172
173// An attribute that must be numeric or parse as a numeric.
174// When falsy, it should be removed.
175var NUMERIC = 5;
176
177// An attribute that must be positive numeric or parse as a positive numeric.
178// When falsy, it should be removed.
179var POSITIVE_NUMERIC = 6;
180
181/* eslint-disable max-len */
182var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
183/* eslint-enable max-len */
184var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
185
186
187var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
188var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
189
190var illegalAttributeNameCache = {};
191var validatedAttributeNameCache = {};
192
193function isAttributeNameSafe(attributeName) {
194 if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
195 return true;
196 }
197 if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
198 return false;
199 }
200 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
201 validatedAttributeNameCache[attributeName] = true;
202 return true;
203 }
204 illegalAttributeNameCache[attributeName] = true;
205 {
206 warning(false, 'Invalid attribute name: `%s`', attributeName);
207 }
208 return false;
209}
210
211function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
212 if (propertyInfo !== null) {
213 return propertyInfo.type === RESERVED;
214 }
215 if (isCustomComponentTag) {
216 return false;
217 }
218 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
219 return true;
220 }
221 return false;
222}
223
224function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
225 if (propertyInfo !== null && propertyInfo.type === RESERVED) {
226 return false;
227 }
228 switch (typeof value) {
229 case 'function':
230 // $FlowIssue symbol is perfectly valid here
231 case 'symbol':
232 // eslint-disable-line
233 return true;
234 case 'boolean':
235 {
236 if (isCustomComponentTag) {
237 return false;
238 }
239 if (propertyInfo !== null) {
240 return !propertyInfo.acceptsBooleans;
241 } else {
242 var prefix = name.toLowerCase().slice(0, 5);
243 return prefix !== 'data-' && prefix !== 'aria-';
244 }
245 }
246 default:
247 return false;
248 }
249}
250
251function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
252 if (value === null || typeof value === 'undefined') {
253 return true;
254 }
255 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
256 return true;
257 }
258 if (isCustomComponentTag) {
259 return false;
260 }
261 if (propertyInfo !== null) {
262 switch (propertyInfo.type) {
263 case BOOLEAN:
264 return !value;
265 case OVERLOADED_BOOLEAN:
266 return value === false;
267 case NUMERIC:
268 return isNaN(value);
269 case POSITIVE_NUMERIC:
270 return isNaN(value) || value < 1;
271 }
272 }
273 return false;
274}
275
276function getPropertyInfo(name) {
277 return properties.hasOwnProperty(name) ? properties[name] : null;
278}
279
280function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace) {
281 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
282 this.attributeName = attributeName;
283 this.attributeNamespace = attributeNamespace;
284 this.mustUseProperty = mustUseProperty;
285 this.propertyName = name;
286 this.type = type;
287}
288
289// When adding attributes to this list, be sure to also add them to
290// the `possibleStandardNames` module to ensure casing and incorrect
291// name warnings.
292var properties = {};
293
294// These props are reserved by React. They shouldn't be written to the DOM.
295['children', 'dangerouslySetInnerHTML',
296// TODO: This prevents the assignment of defaultValue to regular
297// elements (not just inputs). Now that ReactDOMInput assigns to the
298// defaultValue property -- do we need this?
299'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
300 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
301 name, // attributeName
302 null);
303} // attributeNamespace
304);
305
306// A few React string attributes have a different name.
307// This is a mapping from React prop names to the attribute names.
308[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
309 var name = _ref[0],
310 attributeName = _ref[1];
311
312 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
313 attributeName, // attributeName
314 null);
315} // attributeNamespace
316);
317
318// These are "enumerated" HTML attributes that accept "true" and "false".
319// In React, we let users pass `true` and `false` even though technically
320// these aren't boolean attributes (they are coerced to strings).
321['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
322 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
323 name.toLowerCase(), // attributeName
324 null);
325} // attributeNamespace
326);
327
328// These are "enumerated" SVG attributes that accept "true" and "false".
329// In React, we let users pass `true` and `false` even though technically
330// these aren't boolean attributes (they are coerced to strings).
331// Since these are SVG attributes, their attribute names are case-sensitive.
332['autoReverse', 'externalResourcesRequired', 'preserveAlpha'].forEach(function (name) {
333 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
334 name, // attributeName
335 null);
336} // attributeNamespace
337);
338
339// These are HTML boolean attributes.
340['allowFullScreen', 'async',
341// Note: there is a special case that prevents it from being written to the DOM
342// on the client side because the browsers are inconsistent. Instead we call focus().
343'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
344// Microdata
345'itemScope'].forEach(function (name) {
346 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
347 name.toLowerCase(), // attributeName
348 null);
349} // attributeNamespace
350);
351
352// These are the few React props that we set as DOM properties
353// rather than attributes. These are all booleans.
354['checked',
355// Note: `option.selected` is not updated if `select.multiple` is
356// disabled with `removeAttribute`. We have special logic for handling this.
357'multiple', 'muted', 'selected'].forEach(function (name) {
358 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
359 name.toLowerCase(), // attributeName
360 null);
361} // attributeNamespace
362);
363
364// These are HTML attributes that are "overloaded booleans": they behave like
365// booleans, but can also accept a string value.
366['capture', 'download'].forEach(function (name) {
367 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
368 name.toLowerCase(), // attributeName
369 null);
370} // attributeNamespace
371);
372
373// These are HTML attributes that must be positive numbers.
374['cols', 'rows', 'size', 'span'].forEach(function (name) {
375 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
376 name.toLowerCase(), // attributeName
377 null);
378} // attributeNamespace
379);
380
381// These are HTML attributes that must be numbers.
382['rowSpan', 'start'].forEach(function (name) {
383 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
384 name.toLowerCase(), // attributeName
385 null);
386} // attributeNamespace
387);
388
389var CAMELIZE = /[\-\:]([a-z])/g;
390var capitalize = function (token) {
391 return token[1].toUpperCase();
392};
393
394// This is a list of all SVG attributes that need special casing, namespacing,
395// or boolean value assignment. Regular attributes that just accept strings
396// and have the same names are omitted, just like in the HTML whitelist.
397// Some of these attributes can be hard to find. This list was created by
398// scrapping the MDN documentation.
399['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) {
400 var name = attributeName.replace(CAMELIZE, capitalize);
401 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
402 attributeName, null);
403} // attributeNamespace
404);
405
406// String SVG attributes with the xlink namespace.
407['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
408 var name = attributeName.replace(CAMELIZE, capitalize);
409 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
410 attributeName, 'http://www.w3.org/1999/xlink');
411});
412
413// String SVG attributes with the xml namespace.
414['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
415 var name = attributeName.replace(CAMELIZE, capitalize);
416 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
417 attributeName, 'http://www.w3.org/XML/1998/namespace');
418});
419
420// Special case: this attribute exists both in HTML and SVG.
421// Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
422// its React `tabIndex` name, like we do for attributes that exist only in HTML.
423properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
424'tabindex', // attributeName
425null);
426
427// code copied and modified from escape-html
428/**
429 * Module variables.
430 * @private
431 */
432
433var matchHtmlRegExp = /["'&<>]/;
434
435/**
436 * Escapes special characters and HTML entities in a given html string.
437 *
438 * @param {string} string HTML string to escape for later insertion
439 * @return {string}
440 * @public
441 */
442
443function escapeHtml(string) {
444 var str = '' + string;
445 var match = matchHtmlRegExp.exec(str);
446
447 if (!match) {
448 return str;
449 }
450
451 var escape = void 0;
452 var html = '';
453 var index = 0;
454 var lastIndex = 0;
455
456 for (index = match.index; index < str.length; index++) {
457 switch (str.charCodeAt(index)) {
458 case 34:
459 // "
460 escape = '&quot;';
461 break;
462 case 38:
463 // &
464 escape = '&amp;';
465 break;
466 case 39:
467 // '
468 escape = '&#x27;'; // modified from escape-html; used to be '&#39'
469 break;
470 case 60:
471 // <
472 escape = '&lt;';
473 break;
474 case 62:
475 // >
476 escape = '&gt;';
477 break;
478 default:
479 continue;
480 }
481
482 if (lastIndex !== index) {
483 html += str.substring(lastIndex, index);
484 }
485
486 lastIndex = index + 1;
487 html += escape;
488 }
489
490 return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
491}
492// end code copied and modified from escape-html
493
494/**
495 * Escapes text to prevent scripting attacks.
496 *
497 * @param {*} text Text value to escape.
498 * @return {string} An escaped string.
499 */
500function escapeTextForBrowser(text) {
501 if (typeof text === 'boolean' || typeof text === 'number') {
502 // this shortcircuit helps perf for types that we know will never have
503 // special characters, especially given that this function is used often
504 // for numeric dom ids.
505 return '' + text;
506 }
507 return escapeHtml(text);
508}
509
510/**
511 * Escapes attribute value to prevent scripting attacks.
512 *
513 * @param {*} value Value to escape.
514 * @return {string} An escaped string.
515 */
516function quoteAttributeValueForBrowser(value) {
517 return '"' + escapeTextForBrowser(value) + '"';
518}
519
520/**
521 * Operations for dealing with DOM properties.
522 */
523
524/**
525 * Creates markup for the ID property.
526 *
527 * @param {string} id Unescaped ID.
528 * @return {string} Markup string.
529 */
530
531
532function createMarkupForRoot() {
533 return ROOT_ATTRIBUTE_NAME + '=""';
534}
535
536/**
537 * Creates markup for a property.
538 *
539 * @param {string} name
540 * @param {*} value
541 * @return {?string} Markup string, or null if the property was invalid.
542 */
543function createMarkupForProperty(name, value) {
544 var propertyInfo = getPropertyInfo(name);
545 if (name !== 'style' && shouldIgnoreAttribute(name, propertyInfo, false)) {
546 return '';
547 }
548 if (shouldRemoveAttribute(name, value, propertyInfo, false)) {
549 return '';
550 }
551 if (propertyInfo !== null) {
552 var attributeName = propertyInfo.attributeName;
553 var type = propertyInfo.type;
554
555 if (type === BOOLEAN || type === OVERLOADED_BOOLEAN && value === true) {
556 return attributeName + '=""';
557 } else {
558 return attributeName + '=' + quoteAttributeValueForBrowser(value);
559 }
560 } else {
561 return name + '=' + quoteAttributeValueForBrowser(value);
562 }
563}
564
565/**
566 * Creates markup for a custom property.
567 *
568 * @param {string} name
569 * @param {*} value
570 * @return {string} Markup string, or empty string if the property was invalid.
571 */
572function createMarkupForCustomAttribute(name, value) {
573 if (!isAttributeNameSafe(name) || value == null) {
574 return '';
575 }
576 return name + '=' + quoteAttributeValueForBrowser(value);
577}
578
579var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
580var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
581var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
582
583var Namespaces = {
584 html: HTML_NAMESPACE,
585 mathml: MATH_NAMESPACE,
586 svg: SVG_NAMESPACE
587};
588
589// Assumes there is no parent namespace.
590function getIntrinsicNamespace(type) {
591 switch (type) {
592 case 'svg':
593 return SVG_NAMESPACE;
594 case 'math':
595 return MATH_NAMESPACE;
596 default:
597 return HTML_NAMESPACE;
598 }
599}
600
601function getChildNamespace(parentNamespace, type) {
602 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
603 // No (or default) parent namespace: potential entry point.
604 return getIntrinsicNamespace(type);
605 }
606 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
607 // We're leaving SVG.
608 return HTML_NAMESPACE;
609 }
610 // By default, pass namespace below.
611 return parentNamespace;
612}
613
614var ReactControlledValuePropTypes = {
615 checkPropTypes: null
616};
617
618{
619 var hasReadOnlyValue = {
620 button: true,
621 checkbox: true,
622 image: true,
623 hidden: true,
624 radio: true,
625 reset: true,
626 submit: true
627 };
628
629 var propTypes = {
630 value: function (props, propName, componentName) {
631 if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
632 return null;
633 }
634 return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
635 },
636 checked: function (props, propName, componentName) {
637 if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
638 return null;
639 }
640 return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
641 }
642 };
643
644 /**
645 * Provide a linked `value` attribute for controlled forms. You should not use
646 * this outside of the ReactDOM controlled form components.
647 */
648 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props, getStack) {
649 checkPropTypes(propTypes, props, 'prop', tagName, getStack);
650 };
651}
652
653// For HTML, certain tags should omit their close tag. We keep a whitelist for
654// those special-case tags.
655
656var omittedCloseTags = {
657 area: true,
658 base: true,
659 br: true,
660 col: true,
661 embed: true,
662 hr: true,
663 img: true,
664 input: true,
665 keygen: true,
666 link: true,
667 meta: true,
668 param: true,
669 source: true,
670 track: true,
671 wbr: true
672 // NOTE: menuitem's close tag should be omitted, but that causes problems.
673};
674
675// For HTML, certain tags cannot have children. This has the same purpose as
676// `omittedCloseTags` except that `menuitem` should still have its closing tag.
677
678var voidElementTags = _assign({
679 menuitem: true
680}, omittedCloseTags);
681
682var HTML = '__html';
683
684function assertValidProps(tag, props, getStack) {
685 if (!props) {
686 return;
687 }
688 // Note the use of `==` which checks for null or undefined.
689 if (voidElementTags[tag]) {
690 !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, getStack()) : void 0;
691 }
692 if (props.dangerouslySetInnerHTML != null) {
693 !(props.children == null) ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0;
694 !(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;
695 }
696 {
697 !(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;
698 }
699 !(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;
700}
701
702/**
703 * CSS properties which accept numbers but are not in units of "px".
704 */
705var isUnitlessNumber = {
706 animationIterationCount: true,
707 borderImageOutset: true,
708 borderImageSlice: true,
709 borderImageWidth: true,
710 boxFlex: true,
711 boxFlexGroup: true,
712 boxOrdinalGroup: true,
713 columnCount: true,
714 columns: true,
715 flex: true,
716 flexGrow: true,
717 flexPositive: true,
718 flexShrink: true,
719 flexNegative: true,
720 flexOrder: true,
721 gridRow: true,
722 gridRowEnd: true,
723 gridRowSpan: true,
724 gridRowStart: true,
725 gridColumn: true,
726 gridColumnEnd: true,
727 gridColumnSpan: true,
728 gridColumnStart: true,
729 fontWeight: true,
730 lineClamp: true,
731 lineHeight: true,
732 opacity: true,
733 order: true,
734 orphans: true,
735 tabSize: true,
736 widows: true,
737 zIndex: true,
738 zoom: true,
739
740 // SVG-related properties
741 fillOpacity: true,
742 floodOpacity: true,
743 stopOpacity: true,
744 strokeDasharray: true,
745 strokeDashoffset: true,
746 strokeMiterlimit: true,
747 strokeOpacity: true,
748 strokeWidth: true
749};
750
751/**
752 * @param {string} prefix vendor-specific prefix, eg: Webkit
753 * @param {string} key style name, eg: transitionDuration
754 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
755 * WebkitTransitionDuration
756 */
757function prefixKey(prefix, key) {
758 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
759}
760
761/**
762 * Support style names that may come passed in prefixed by adding permutations
763 * of vendor prefixes.
764 */
765var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
766
767// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
768// infinite loop, because it iterates over the newly added props too.
769Object.keys(isUnitlessNumber).forEach(function (prop) {
770 prefixes.forEach(function (prefix) {
771 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
772 });
773});
774
775/**
776 * Convert a value into the proper css writable value. The style name `name`
777 * should be logical (no hyphens), as specified
778 * in `CSSProperty.isUnitlessNumber`.
779 *
780 * @param {string} name CSS property name such as `topMargin`.
781 * @param {*} value CSS property value such as `10px`.
782 * @return {string} Normalized style value with dimensions applied.
783 */
784function dangerousStyleValue(name, value, isCustomProperty) {
785 // Note that we've removed escapeTextForBrowser() calls here since the
786 // whole string will be escaped when the attribute is injected into
787 // the markup. If you provide unsafe user data here they can inject
788 // arbitrary CSS which may be problematic (I couldn't repro this):
789 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
790 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
791 // This is not an XSS hole but instead a potential CSS injection issue
792 // which has lead to a greater discussion about how we're going to
793 // trust URLs moving forward. See #2115901
794
795 var isEmpty = value == null || typeof value === 'boolean' || value === '';
796 if (isEmpty) {
797 return '';
798 }
799
800 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
801 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
802 }
803
804 return ('' + value).trim();
805}
806
807function isCustomComponent(tagName, props) {
808 if (tagName.indexOf('-') === -1) {
809 return typeof props.is === 'string';
810 }
811 switch (tagName) {
812 // These are reserved SVG and MathML elements.
813 // We don't mind this whitelist too much because we expect it to never grow.
814 // The alternative is to track the namespace in a few places which is convoluted.
815 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
816 case 'annotation-xml':
817 case 'color-profile':
818 case 'font-face':
819 case 'font-face-src':
820 case 'font-face-uri':
821 case 'font-face-format':
822 case 'font-face-name':
823 case 'missing-glyph':
824 return false;
825 default:
826 return true;
827 }
828}
829
830var warnValidStyle = emptyFunction;
831
832{
833 // 'msTransform' is correct, but the other prefixes should be capitalized
834 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
835
836 // style values shouldn't contain a semicolon
837 var badStyleValueWithSemicolonPattern = /;\s*$/;
838
839 var warnedStyleNames = {};
840 var warnedStyleValues = {};
841 var warnedForNaNValue = false;
842 var warnedForInfinityValue = false;
843
844 var warnHyphenatedStyleName = function (name, getStack) {
845 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
846 return;
847 }
848
849 warnedStyleNames[name] = true;
850 warning(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName(name), getStack());
851 };
852
853 var warnBadVendoredStyleName = function (name, getStack) {
854 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
855 return;
856 }
857
858 warnedStyleNames[name] = true;
859 warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), getStack());
860 };
861
862 var warnStyleValueWithSemicolon = function (name, value, getStack) {
863 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
864 return;
865 }
866
867 warnedStyleValues[value] = true;
868 warning(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.%s', name, value.replace(badStyleValueWithSemicolonPattern, ''), getStack());
869 };
870
871 var warnStyleValueIsNaN = function (name, value, getStack) {
872 if (warnedForNaNValue) {
873 return;
874 }
875
876 warnedForNaNValue = true;
877 warning(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, getStack());
878 };
879
880 var warnStyleValueIsInfinity = function (name, value, getStack) {
881 if (warnedForInfinityValue) {
882 return;
883 }
884
885 warnedForInfinityValue = true;
886 warning(false, '`Infinity` is an invalid value for the `%s` css style property.%s', name, getStack());
887 };
888
889 warnValidStyle = function (name, value, getStack) {
890 if (name.indexOf('-') > -1) {
891 warnHyphenatedStyleName(name, getStack);
892 } else if (badVendoredStyleNamePattern.test(name)) {
893 warnBadVendoredStyleName(name, getStack);
894 } else if (badStyleValueWithSemicolonPattern.test(value)) {
895 warnStyleValueWithSemicolon(name, value, getStack);
896 }
897
898 if (typeof value === 'number') {
899 if (isNaN(value)) {
900 warnStyleValueIsNaN(name, value, getStack);
901 } else if (!isFinite(value)) {
902 warnStyleValueIsInfinity(name, value, getStack);
903 }
904 }
905 };
906}
907
908var warnValidStyle$1 = warnValidStyle;
909
910var ariaProperties = {
911 'aria-current': 0, // state
912 'aria-details': 0,
913 'aria-disabled': 0, // state
914 'aria-hidden': 0, // state
915 'aria-invalid': 0, // state
916 'aria-keyshortcuts': 0,
917 'aria-label': 0,
918 'aria-roledescription': 0,
919 // Widget Attributes
920 'aria-autocomplete': 0,
921 'aria-checked': 0,
922 'aria-expanded': 0,
923 'aria-haspopup': 0,
924 'aria-level': 0,
925 'aria-modal': 0,
926 'aria-multiline': 0,
927 'aria-multiselectable': 0,
928 'aria-orientation': 0,
929 'aria-placeholder': 0,
930 'aria-pressed': 0,
931 'aria-readonly': 0,
932 'aria-required': 0,
933 'aria-selected': 0,
934 'aria-sort': 0,
935 'aria-valuemax': 0,
936 'aria-valuemin': 0,
937 'aria-valuenow': 0,
938 'aria-valuetext': 0,
939 // Live Region Attributes
940 'aria-atomic': 0,
941 'aria-busy': 0,
942 'aria-live': 0,
943 'aria-relevant': 0,
944 // Drag-and-Drop Attributes
945 'aria-dropeffect': 0,
946 'aria-grabbed': 0,
947 // Relationship Attributes
948 'aria-activedescendant': 0,
949 'aria-colcount': 0,
950 'aria-colindex': 0,
951 'aria-colspan': 0,
952 'aria-controls': 0,
953 'aria-describedby': 0,
954 'aria-errormessage': 0,
955 'aria-flowto': 0,
956 'aria-labelledby': 0,
957 'aria-owns': 0,
958 'aria-posinset': 0,
959 'aria-rowcount': 0,
960 'aria-rowindex': 0,
961 'aria-rowspan': 0,
962 'aria-setsize': 0
963};
964
965var warnedProperties = {};
966var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
967var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
968
969var hasOwnProperty = Object.prototype.hasOwnProperty;
970
971function getStackAddendum$1() {
972 var stack = ReactDebugCurrentFrame.getStackAddendum();
973 return stack != null ? stack : '';
974}
975
976function validateProperty(tagName, name) {
977 if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
978 return true;
979 }
980
981 if (rARIACamel.test(name)) {
982 var ariaName = 'aria-' + name.slice(4).toLowerCase();
983 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
984
985 // If this is an aria-* attribute, but is not listed in the known DOM
986 // DOM properties, then it is an invalid aria-* attribute.
987 if (correctName == null) {
988 warning(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.%s', name, getStackAddendum$1());
989 warnedProperties[name] = true;
990 return true;
991 }
992 // aria-* attributes should be lowercase; suggest the lowercase version.
993 if (name !== correctName) {
994 warning(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?%s', name, correctName, getStackAddendum$1());
995 warnedProperties[name] = true;
996 return true;
997 }
998 }
999
1000 if (rARIA.test(name)) {
1001 var lowerCasedName = name.toLowerCase();
1002 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
1003
1004 // If this is an aria-* attribute, but is not listed in the known DOM
1005 // DOM properties, then it is an invalid aria-* attribute.
1006 if (standardName == null) {
1007 warnedProperties[name] = true;
1008 return false;
1009 }
1010 // aria-* attributes should be lowercase; suggest the lowercase version.
1011 if (name !== standardName) {
1012 warning(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum$1());
1013 warnedProperties[name] = true;
1014 return true;
1015 }
1016 }
1017
1018 return true;
1019}
1020
1021function warnInvalidARIAProps(type, props) {
1022 var invalidProps = [];
1023
1024 for (var key in props) {
1025 var isValid = validateProperty(type, key);
1026 if (!isValid) {
1027 invalidProps.push(key);
1028 }
1029 }
1030
1031 var unknownPropString = invalidProps.map(function (prop) {
1032 return '`' + prop + '`';
1033 }).join(', ');
1034
1035 if (invalidProps.length === 1) {
1036 warning(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum$1());
1037 } else if (invalidProps.length > 1) {
1038 warning(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum$1());
1039 }
1040}
1041
1042function validateProperties(type, props) {
1043 if (isCustomComponent(type, props)) {
1044 return;
1045 }
1046 warnInvalidARIAProps(type, props);
1047}
1048
1049var didWarnValueNull = false;
1050
1051function getStackAddendum$2() {
1052 var stack = ReactDebugCurrentFrame.getStackAddendum();
1053 return stack != null ? stack : '';
1054}
1055
1056function validateProperties$1(type, props) {
1057 if (type !== 'input' && type !== 'textarea' && type !== 'select') {
1058 return;
1059 }
1060
1061 if (props != null && props.value === null && !didWarnValueNull) {
1062 didWarnValueNull = true;
1063 if (type === 'select' && props.multiple) {
1064 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.%s', type, getStackAddendum$2());
1065 } else {
1066 warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$2());
1067 }
1068 }
1069}
1070
1071/**
1072 * Registers plugins so that they can extract and dispatch events.
1073 *
1074 * @see {EventPluginHub}
1075 */
1076
1077/**
1078 * Ordered list of injected plugins.
1079 */
1080
1081
1082/**
1083 * Mapping from event name to dispatch config
1084 */
1085
1086
1087/**
1088 * Mapping from registration name to plugin module
1089 */
1090var registrationNameModules = {};
1091
1092/**
1093 * Mapping from registration name to event name
1094 */
1095
1096
1097/**
1098 * Mapping from lowercase registration names to the properly cased version,
1099 * used to warn in the case of missing event handlers. Available
1100 * only in true.
1101 * @type {Object}
1102 */
1103var possibleRegistrationNames = {};
1104// Trust the developer to only use possibleRegistrationNames in true
1105
1106/**
1107 * Injects an ordering of plugins (by plugin name). This allows the ordering
1108 * to be decoupled from injection of the actual plugins so that ordering is
1109 * always deterministic regardless of packaging, on-the-fly injection, etc.
1110 *
1111 * @param {array} InjectedEventPluginOrder
1112 * @internal
1113 * @see {EventPluginHub.injection.injectEventPluginOrder}
1114 */
1115
1116
1117/**
1118 * Injects plugins to be used by `EventPluginHub`. The plugin names must be
1119 * in the ordering injected by `injectEventPluginOrder`.
1120 *
1121 * Plugins can be injected as part of page initialization or on-the-fly.
1122 *
1123 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
1124 * @internal
1125 * @see {EventPluginHub.injection.injectEventPluginsByName}
1126 */
1127
1128// When adding attributes to the HTML or SVG whitelist, be sure to
1129// also add them to this module to ensure casing and incorrect name
1130// warnings.
1131var possibleStandardNames = {
1132 // HTML
1133 accept: 'accept',
1134 acceptcharset: 'acceptCharset',
1135 'accept-charset': 'acceptCharset',
1136 accesskey: 'accessKey',
1137 action: 'action',
1138 allowfullscreen: 'allowFullScreen',
1139 alt: 'alt',
1140 as: 'as',
1141 async: 'async',
1142 autocapitalize: 'autoCapitalize',
1143 autocomplete: 'autoComplete',
1144 autocorrect: 'autoCorrect',
1145 autofocus: 'autoFocus',
1146 autoplay: 'autoPlay',
1147 autosave: 'autoSave',
1148 capture: 'capture',
1149 cellpadding: 'cellPadding',
1150 cellspacing: 'cellSpacing',
1151 challenge: 'challenge',
1152 charset: 'charSet',
1153 checked: 'checked',
1154 children: 'children',
1155 cite: 'cite',
1156 class: 'className',
1157 classid: 'classID',
1158 classname: 'className',
1159 cols: 'cols',
1160 colspan: 'colSpan',
1161 content: 'content',
1162 contenteditable: 'contentEditable',
1163 contextmenu: 'contextMenu',
1164 controls: 'controls',
1165 controlslist: 'controlsList',
1166 coords: 'coords',
1167 crossorigin: 'crossOrigin',
1168 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
1169 data: 'data',
1170 datetime: 'dateTime',
1171 default: 'default',
1172 defaultchecked: 'defaultChecked',
1173 defaultvalue: 'defaultValue',
1174 defer: 'defer',
1175 dir: 'dir',
1176 disabled: 'disabled',
1177 download: 'download',
1178 draggable: 'draggable',
1179 enctype: 'encType',
1180 for: 'htmlFor',
1181 form: 'form',
1182 formmethod: 'formMethod',
1183 formaction: 'formAction',
1184 formenctype: 'formEncType',
1185 formnovalidate: 'formNoValidate',
1186 formtarget: 'formTarget',
1187 frameborder: 'frameBorder',
1188 headers: 'headers',
1189 height: 'height',
1190 hidden: 'hidden',
1191 high: 'high',
1192 href: 'href',
1193 hreflang: 'hrefLang',
1194 htmlfor: 'htmlFor',
1195 httpequiv: 'httpEquiv',
1196 'http-equiv': 'httpEquiv',
1197 icon: 'icon',
1198 id: 'id',
1199 innerhtml: 'innerHTML',
1200 inputmode: 'inputMode',
1201 integrity: 'integrity',
1202 is: 'is',
1203 itemid: 'itemID',
1204 itemprop: 'itemProp',
1205 itemref: 'itemRef',
1206 itemscope: 'itemScope',
1207 itemtype: 'itemType',
1208 keyparams: 'keyParams',
1209 keytype: 'keyType',
1210 kind: 'kind',
1211 label: 'label',
1212 lang: 'lang',
1213 list: 'list',
1214 loop: 'loop',
1215 low: 'low',
1216 manifest: 'manifest',
1217 marginwidth: 'marginWidth',
1218 marginheight: 'marginHeight',
1219 max: 'max',
1220 maxlength: 'maxLength',
1221 media: 'media',
1222 mediagroup: 'mediaGroup',
1223 method: 'method',
1224 min: 'min',
1225 minlength: 'minLength',
1226 multiple: 'multiple',
1227 muted: 'muted',
1228 name: 'name',
1229 nomodule: 'noModule',
1230 nonce: 'nonce',
1231 novalidate: 'noValidate',
1232 open: 'open',
1233 optimum: 'optimum',
1234 pattern: 'pattern',
1235 placeholder: 'placeholder',
1236 playsinline: 'playsInline',
1237 poster: 'poster',
1238 preload: 'preload',
1239 profile: 'profile',
1240 radiogroup: 'radioGroup',
1241 readonly: 'readOnly',
1242 referrerpolicy: 'referrerPolicy',
1243 rel: 'rel',
1244 required: 'required',
1245 reversed: 'reversed',
1246 role: 'role',
1247 rows: 'rows',
1248 rowspan: 'rowSpan',
1249 sandbox: 'sandbox',
1250 scope: 'scope',
1251 scoped: 'scoped',
1252 scrolling: 'scrolling',
1253 seamless: 'seamless',
1254 selected: 'selected',
1255 shape: 'shape',
1256 size: 'size',
1257 sizes: 'sizes',
1258 span: 'span',
1259 spellcheck: 'spellCheck',
1260 src: 'src',
1261 srcdoc: 'srcDoc',
1262 srclang: 'srcLang',
1263 srcset: 'srcSet',
1264 start: 'start',
1265 step: 'step',
1266 style: 'style',
1267 summary: 'summary',
1268 tabindex: 'tabIndex',
1269 target: 'target',
1270 title: 'title',
1271 type: 'type',
1272 usemap: 'useMap',
1273 value: 'value',
1274 width: 'width',
1275 wmode: 'wmode',
1276 wrap: 'wrap',
1277
1278 // SVG
1279 about: 'about',
1280 accentheight: 'accentHeight',
1281 'accent-height': 'accentHeight',
1282 accumulate: 'accumulate',
1283 additive: 'additive',
1284 alignmentbaseline: 'alignmentBaseline',
1285 'alignment-baseline': 'alignmentBaseline',
1286 allowreorder: 'allowReorder',
1287 alphabetic: 'alphabetic',
1288 amplitude: 'amplitude',
1289 arabicform: 'arabicForm',
1290 'arabic-form': 'arabicForm',
1291 ascent: 'ascent',
1292 attributename: 'attributeName',
1293 attributetype: 'attributeType',
1294 autoreverse: 'autoReverse',
1295 azimuth: 'azimuth',
1296 basefrequency: 'baseFrequency',
1297 baselineshift: 'baselineShift',
1298 'baseline-shift': 'baselineShift',
1299 baseprofile: 'baseProfile',
1300 bbox: 'bbox',
1301 begin: 'begin',
1302 bias: 'bias',
1303 by: 'by',
1304 calcmode: 'calcMode',
1305 capheight: 'capHeight',
1306 'cap-height': 'capHeight',
1307 clip: 'clip',
1308 clippath: 'clipPath',
1309 'clip-path': 'clipPath',
1310 clippathunits: 'clipPathUnits',
1311 cliprule: 'clipRule',
1312 'clip-rule': 'clipRule',
1313 color: 'color',
1314 colorinterpolation: 'colorInterpolation',
1315 'color-interpolation': 'colorInterpolation',
1316 colorinterpolationfilters: 'colorInterpolationFilters',
1317 'color-interpolation-filters': 'colorInterpolationFilters',
1318 colorprofile: 'colorProfile',
1319 'color-profile': 'colorProfile',
1320 colorrendering: 'colorRendering',
1321 'color-rendering': 'colorRendering',
1322 contentscripttype: 'contentScriptType',
1323 contentstyletype: 'contentStyleType',
1324 cursor: 'cursor',
1325 cx: 'cx',
1326 cy: 'cy',
1327 d: 'd',
1328 datatype: 'datatype',
1329 decelerate: 'decelerate',
1330 descent: 'descent',
1331 diffuseconstant: 'diffuseConstant',
1332 direction: 'direction',
1333 display: 'display',
1334 divisor: 'divisor',
1335 dominantbaseline: 'dominantBaseline',
1336 'dominant-baseline': 'dominantBaseline',
1337 dur: 'dur',
1338 dx: 'dx',
1339 dy: 'dy',
1340 edgemode: 'edgeMode',
1341 elevation: 'elevation',
1342 enablebackground: 'enableBackground',
1343 'enable-background': 'enableBackground',
1344 end: 'end',
1345 exponent: 'exponent',
1346 externalresourcesrequired: 'externalResourcesRequired',
1347 fill: 'fill',
1348 fillopacity: 'fillOpacity',
1349 'fill-opacity': 'fillOpacity',
1350 fillrule: 'fillRule',
1351 'fill-rule': 'fillRule',
1352 filter: 'filter',
1353 filterres: 'filterRes',
1354 filterunits: 'filterUnits',
1355 floodopacity: 'floodOpacity',
1356 'flood-opacity': 'floodOpacity',
1357 floodcolor: 'floodColor',
1358 'flood-color': 'floodColor',
1359 focusable: 'focusable',
1360 fontfamily: 'fontFamily',
1361 'font-family': 'fontFamily',
1362 fontsize: 'fontSize',
1363 'font-size': 'fontSize',
1364 fontsizeadjust: 'fontSizeAdjust',
1365 'font-size-adjust': 'fontSizeAdjust',
1366 fontstretch: 'fontStretch',
1367 'font-stretch': 'fontStretch',
1368 fontstyle: 'fontStyle',
1369 'font-style': 'fontStyle',
1370 fontvariant: 'fontVariant',
1371 'font-variant': 'fontVariant',
1372 fontweight: 'fontWeight',
1373 'font-weight': 'fontWeight',
1374 format: 'format',
1375 from: 'from',
1376 fx: 'fx',
1377 fy: 'fy',
1378 g1: 'g1',
1379 g2: 'g2',
1380 glyphname: 'glyphName',
1381 'glyph-name': 'glyphName',
1382 glyphorientationhorizontal: 'glyphOrientationHorizontal',
1383 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
1384 glyphorientationvertical: 'glyphOrientationVertical',
1385 'glyph-orientation-vertical': 'glyphOrientationVertical',
1386 glyphref: 'glyphRef',
1387 gradienttransform: 'gradientTransform',
1388 gradientunits: 'gradientUnits',
1389 hanging: 'hanging',
1390 horizadvx: 'horizAdvX',
1391 'horiz-adv-x': 'horizAdvX',
1392 horizoriginx: 'horizOriginX',
1393 'horiz-origin-x': 'horizOriginX',
1394 ideographic: 'ideographic',
1395 imagerendering: 'imageRendering',
1396 'image-rendering': 'imageRendering',
1397 in2: 'in2',
1398 in: 'in',
1399 inlist: 'inlist',
1400 intercept: 'intercept',
1401 k1: 'k1',
1402 k2: 'k2',
1403 k3: 'k3',
1404 k4: 'k4',
1405 k: 'k',
1406 kernelmatrix: 'kernelMatrix',
1407 kernelunitlength: 'kernelUnitLength',
1408 kerning: 'kerning',
1409 keypoints: 'keyPoints',
1410 keysplines: 'keySplines',
1411 keytimes: 'keyTimes',
1412 lengthadjust: 'lengthAdjust',
1413 letterspacing: 'letterSpacing',
1414 'letter-spacing': 'letterSpacing',
1415 lightingcolor: 'lightingColor',
1416 'lighting-color': 'lightingColor',
1417 limitingconeangle: 'limitingConeAngle',
1418 local: 'local',
1419 markerend: 'markerEnd',
1420 'marker-end': 'markerEnd',
1421 markerheight: 'markerHeight',
1422 markermid: 'markerMid',
1423 'marker-mid': 'markerMid',
1424 markerstart: 'markerStart',
1425 'marker-start': 'markerStart',
1426 markerunits: 'markerUnits',
1427 markerwidth: 'markerWidth',
1428 mask: 'mask',
1429 maskcontentunits: 'maskContentUnits',
1430 maskunits: 'maskUnits',
1431 mathematical: 'mathematical',
1432 mode: 'mode',
1433 numoctaves: 'numOctaves',
1434 offset: 'offset',
1435 opacity: 'opacity',
1436 operator: 'operator',
1437 order: 'order',
1438 orient: 'orient',
1439 orientation: 'orientation',
1440 origin: 'origin',
1441 overflow: 'overflow',
1442 overlineposition: 'overlinePosition',
1443 'overline-position': 'overlinePosition',
1444 overlinethickness: 'overlineThickness',
1445 'overline-thickness': 'overlineThickness',
1446 paintorder: 'paintOrder',
1447 'paint-order': 'paintOrder',
1448 panose1: 'panose1',
1449 'panose-1': 'panose1',
1450 pathlength: 'pathLength',
1451 patterncontentunits: 'patternContentUnits',
1452 patterntransform: 'patternTransform',
1453 patternunits: 'patternUnits',
1454 pointerevents: 'pointerEvents',
1455 'pointer-events': 'pointerEvents',
1456 points: 'points',
1457 pointsatx: 'pointsAtX',
1458 pointsaty: 'pointsAtY',
1459 pointsatz: 'pointsAtZ',
1460 prefix: 'prefix',
1461 preservealpha: 'preserveAlpha',
1462 preserveaspectratio: 'preserveAspectRatio',
1463 primitiveunits: 'primitiveUnits',
1464 property: 'property',
1465 r: 'r',
1466 radius: 'radius',
1467 refx: 'refX',
1468 refy: 'refY',
1469 renderingintent: 'renderingIntent',
1470 'rendering-intent': 'renderingIntent',
1471 repeatcount: 'repeatCount',
1472 repeatdur: 'repeatDur',
1473 requiredextensions: 'requiredExtensions',
1474 requiredfeatures: 'requiredFeatures',
1475 resource: 'resource',
1476 restart: 'restart',
1477 result: 'result',
1478 results: 'results',
1479 rotate: 'rotate',
1480 rx: 'rx',
1481 ry: 'ry',
1482 scale: 'scale',
1483 security: 'security',
1484 seed: 'seed',
1485 shaperendering: 'shapeRendering',
1486 'shape-rendering': 'shapeRendering',
1487 slope: 'slope',
1488 spacing: 'spacing',
1489 specularconstant: 'specularConstant',
1490 specularexponent: 'specularExponent',
1491 speed: 'speed',
1492 spreadmethod: 'spreadMethod',
1493 startoffset: 'startOffset',
1494 stddeviation: 'stdDeviation',
1495 stemh: 'stemh',
1496 stemv: 'stemv',
1497 stitchtiles: 'stitchTiles',
1498 stopcolor: 'stopColor',
1499 'stop-color': 'stopColor',
1500 stopopacity: 'stopOpacity',
1501 'stop-opacity': 'stopOpacity',
1502 strikethroughposition: 'strikethroughPosition',
1503 'strikethrough-position': 'strikethroughPosition',
1504 strikethroughthickness: 'strikethroughThickness',
1505 'strikethrough-thickness': 'strikethroughThickness',
1506 string: 'string',
1507 stroke: 'stroke',
1508 strokedasharray: 'strokeDasharray',
1509 'stroke-dasharray': 'strokeDasharray',
1510 strokedashoffset: 'strokeDashoffset',
1511 'stroke-dashoffset': 'strokeDashoffset',
1512 strokelinecap: 'strokeLinecap',
1513 'stroke-linecap': 'strokeLinecap',
1514 strokelinejoin: 'strokeLinejoin',
1515 'stroke-linejoin': 'strokeLinejoin',
1516 strokemiterlimit: 'strokeMiterlimit',
1517 'stroke-miterlimit': 'strokeMiterlimit',
1518 strokewidth: 'strokeWidth',
1519 'stroke-width': 'strokeWidth',
1520 strokeopacity: 'strokeOpacity',
1521 'stroke-opacity': 'strokeOpacity',
1522 suppresscontenteditablewarning: 'suppressContentEditableWarning',
1523 suppresshydrationwarning: 'suppressHydrationWarning',
1524 surfacescale: 'surfaceScale',
1525 systemlanguage: 'systemLanguage',
1526 tablevalues: 'tableValues',
1527 targetx: 'targetX',
1528 targety: 'targetY',
1529 textanchor: 'textAnchor',
1530 'text-anchor': 'textAnchor',
1531 textdecoration: 'textDecoration',
1532 'text-decoration': 'textDecoration',
1533 textlength: 'textLength',
1534 textrendering: 'textRendering',
1535 'text-rendering': 'textRendering',
1536 to: 'to',
1537 transform: 'transform',
1538 typeof: 'typeof',
1539 u1: 'u1',
1540 u2: 'u2',
1541 underlineposition: 'underlinePosition',
1542 'underline-position': 'underlinePosition',
1543 underlinethickness: 'underlineThickness',
1544 'underline-thickness': 'underlineThickness',
1545 unicode: 'unicode',
1546 unicodebidi: 'unicodeBidi',
1547 'unicode-bidi': 'unicodeBidi',
1548 unicoderange: 'unicodeRange',
1549 'unicode-range': 'unicodeRange',
1550 unitsperem: 'unitsPerEm',
1551 'units-per-em': 'unitsPerEm',
1552 unselectable: 'unselectable',
1553 valphabetic: 'vAlphabetic',
1554 'v-alphabetic': 'vAlphabetic',
1555 values: 'values',
1556 vectoreffect: 'vectorEffect',
1557 'vector-effect': 'vectorEffect',
1558 version: 'version',
1559 vertadvy: 'vertAdvY',
1560 'vert-adv-y': 'vertAdvY',
1561 vertoriginx: 'vertOriginX',
1562 'vert-origin-x': 'vertOriginX',
1563 vertoriginy: 'vertOriginY',
1564 'vert-origin-y': 'vertOriginY',
1565 vhanging: 'vHanging',
1566 'v-hanging': 'vHanging',
1567 videographic: 'vIdeographic',
1568 'v-ideographic': 'vIdeographic',
1569 viewbox: 'viewBox',
1570 viewtarget: 'viewTarget',
1571 visibility: 'visibility',
1572 vmathematical: 'vMathematical',
1573 'v-mathematical': 'vMathematical',
1574 vocab: 'vocab',
1575 widths: 'widths',
1576 wordspacing: 'wordSpacing',
1577 'word-spacing': 'wordSpacing',
1578 writingmode: 'writingMode',
1579 'writing-mode': 'writingMode',
1580 x1: 'x1',
1581 x2: 'x2',
1582 x: 'x',
1583 xchannelselector: 'xChannelSelector',
1584 xheight: 'xHeight',
1585 'x-height': 'xHeight',
1586 xlinkactuate: 'xlinkActuate',
1587 'xlink:actuate': 'xlinkActuate',
1588 xlinkarcrole: 'xlinkArcrole',
1589 'xlink:arcrole': 'xlinkArcrole',
1590 xlinkhref: 'xlinkHref',
1591 'xlink:href': 'xlinkHref',
1592 xlinkrole: 'xlinkRole',
1593 'xlink:role': 'xlinkRole',
1594 xlinkshow: 'xlinkShow',
1595 'xlink:show': 'xlinkShow',
1596 xlinktitle: 'xlinkTitle',
1597 'xlink:title': 'xlinkTitle',
1598 xlinktype: 'xlinkType',
1599 'xlink:type': 'xlinkType',
1600 xmlbase: 'xmlBase',
1601 'xml:base': 'xmlBase',
1602 xmllang: 'xmlLang',
1603 'xml:lang': 'xmlLang',
1604 xmlns: 'xmlns',
1605 'xml:space': 'xmlSpace',
1606 xmlnsxlink: 'xmlnsXlink',
1607 'xmlns:xlink': 'xmlnsXlink',
1608 xmlspace: 'xmlSpace',
1609 y1: 'y1',
1610 y2: 'y2',
1611 y: 'y',
1612 ychannelselector: 'yChannelSelector',
1613 z: 'z',
1614 zoomandpan: 'zoomAndPan'
1615};
1616
1617function getStackAddendum$3() {
1618 var stack = ReactDebugCurrentFrame.getStackAddendum();
1619 return stack != null ? stack : '';
1620}
1621
1622var validateProperty$1 = function () {};
1623
1624{
1625 var warnedProperties$1 = {};
1626 var _hasOwnProperty = Object.prototype.hasOwnProperty;
1627 var EVENT_NAME_REGEX = /^on./;
1628 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
1629 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
1630 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
1631
1632 validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
1633 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
1634 return true;
1635 }
1636
1637 var lowerCasedName = name.toLowerCase();
1638 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
1639 warning(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
1640 warnedProperties$1[name] = true;
1641 return true;
1642 }
1643
1644 // We can't rely on the event system being injected on the server.
1645 if (canUseEventSystem) {
1646 if (registrationNameModules.hasOwnProperty(name)) {
1647 return true;
1648 }
1649 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
1650 if (registrationName != null) {
1651 warning(false, 'Invalid event handler property `%s`. Did you mean `%s`?%s', name, registrationName, getStackAddendum$3());
1652 warnedProperties$1[name] = true;
1653 return true;
1654 }
1655 if (EVENT_NAME_REGEX.test(name)) {
1656 warning(false, 'Unknown event handler property `%s`. It will be ignored.%s', name, getStackAddendum$3());
1657 warnedProperties$1[name] = true;
1658 return true;
1659 }
1660 } else if (EVENT_NAME_REGEX.test(name)) {
1661 // If no event plugins have been injected, we are in a server environment.
1662 // So we can't tell if the event name is correct for sure, but we can filter
1663 // out known bad ones like `onclick`. We can't suggest a specific replacement though.
1664 if (INVALID_EVENT_NAME_REGEX.test(name)) {
1665 warning(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.%s', name, getStackAddendum$3());
1666 }
1667 warnedProperties$1[name] = true;
1668 return true;
1669 }
1670
1671 // Let the ARIA attribute hook validate ARIA attributes
1672 if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
1673 return true;
1674 }
1675
1676 if (lowerCasedName === 'innerhtml') {
1677 warning(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
1678 warnedProperties$1[name] = true;
1679 return true;
1680 }
1681
1682 if (lowerCasedName === 'aria') {
1683 warning(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
1684 warnedProperties$1[name] = true;
1685 return true;
1686 }
1687
1688 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
1689 warning(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.%s', typeof value, getStackAddendum$3());
1690 warnedProperties$1[name] = true;
1691 return true;
1692 }
1693
1694 if (typeof value === 'number' && isNaN(value)) {
1695 warning(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.%s', name, getStackAddendum$3());
1696 warnedProperties$1[name] = true;
1697 return true;
1698 }
1699
1700 var propertyInfo = getPropertyInfo(name);
1701 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
1702
1703 // Known attributes should match the casing specified in the property config.
1704 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
1705 var standardName = possibleStandardNames[lowerCasedName];
1706 if (standardName !== name) {
1707 warning(false, 'Invalid DOM property `%s`. Did you mean `%s`?%s', name, standardName, getStackAddendum$3());
1708 warnedProperties$1[name] = true;
1709 return true;
1710 }
1711 } else if (!isReserved && name !== lowerCasedName) {
1712 // Unknown attributes should have lowercase casing since that's how they
1713 // will be cased anyway with server rendering.
1714 warning(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.%s', name, lowerCasedName, getStackAddendum$3());
1715 warnedProperties$1[name] = true;
1716 return true;
1717 }
1718
1719 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
1720 if (value) {
1721 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.%s', value, name, name, value, name, getStackAddendum$3());
1722 } else {
1723 warning(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.%s', value, name, name, value, name, name, name, getStackAddendum$3());
1724 }
1725 warnedProperties$1[name] = true;
1726 return true;
1727 }
1728
1729 // Now that we've validated casing, do not validate
1730 // data types for reserved props
1731 if (isReserved) {
1732 return true;
1733 }
1734
1735 // Warn when a known attribute is a bad type
1736 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
1737 warnedProperties$1[name] = true;
1738 return false;
1739 }
1740
1741 return true;
1742 };
1743}
1744
1745var warnUnknownProperties = function (type, props, canUseEventSystem) {
1746 var unknownProps = [];
1747 for (var key in props) {
1748 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
1749 if (!isValid) {
1750 unknownProps.push(key);
1751 }
1752 }
1753
1754 var unknownPropString = unknownProps.map(function (prop) {
1755 return '`' + prop + '`';
1756 }).join(', ');
1757 if (unknownProps.length === 1) {
1758 warning(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$3());
1759 } else if (unknownProps.length > 1) {
1760 warning(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior%s', unknownPropString, type, getStackAddendum$3());
1761 }
1762};
1763
1764function validateProperties$2(type, props, canUseEventSystem) {
1765 if (isCustomComponent(type, props)) {
1766 return;
1767 }
1768 warnUnknownProperties(type, props, canUseEventSystem);
1769}
1770
1771function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1772
1773// Based on reading the React.Children implementation. TODO: type this somewhere?
1774
1775var toArray = React.Children.toArray;
1776
1777var currentDebugStack = void 0;
1778var currentDebugElementStack = void 0;
1779
1780var getStackAddendum = emptyFunction.thatReturns('');
1781var describeStackFrame = emptyFunction.thatReturns('');
1782
1783var validatePropertiesInDevelopment = function (type, props) {};
1784var setCurrentDebugStack = function (stack) {};
1785var pushElementToDebugStack = function (element) {};
1786var resetCurrentDebugStack = function () {};
1787
1788{
1789 validatePropertiesInDevelopment = function (type, props) {
1790 validateProperties(type, props);
1791 validateProperties$1(type, props);
1792 validateProperties$2(type, props, /* canUseEventSystem */false);
1793 };
1794
1795 describeStackFrame = function (element) {
1796 var source = element._source;
1797 var type = element.type;
1798 var name = getComponentName(type);
1799 var ownerName = null;
1800 return describeComponentFrame(name, source, ownerName);
1801 };
1802
1803 currentDebugStack = null;
1804 currentDebugElementStack = null;
1805 setCurrentDebugStack = function (stack) {
1806 var frame = stack[stack.length - 1];
1807 currentDebugElementStack = frame.debugElementStack;
1808 // We are about to enter a new composite stack, reset the array.
1809 currentDebugElementStack.length = 0;
1810 currentDebugStack = stack;
1811 ReactDebugCurrentFrame.getCurrentStack = getStackAddendum;
1812 };
1813 pushElementToDebugStack = function (element) {
1814 if (currentDebugElementStack !== null) {
1815 currentDebugElementStack.push(element);
1816 }
1817 };
1818 resetCurrentDebugStack = function () {
1819 currentDebugElementStack = null;
1820 currentDebugStack = null;
1821 ReactDebugCurrentFrame.getCurrentStack = null;
1822 };
1823 getStackAddendum = function () {
1824 if (currentDebugStack === null) {
1825 return '';
1826 }
1827 var stack = '';
1828 var debugStack = currentDebugStack;
1829 for (var i = debugStack.length - 1; i >= 0; i--) {
1830 var frame = debugStack[i];
1831 var _debugElementStack = frame.debugElementStack;
1832 for (var ii = _debugElementStack.length - 1; ii >= 0; ii--) {
1833 stack += describeStackFrame(_debugElementStack[ii]);
1834 }
1835 }
1836 return stack;
1837 };
1838}
1839
1840var didWarnDefaultInputValue = false;
1841var didWarnDefaultChecked = false;
1842var didWarnDefaultSelectValue = false;
1843var didWarnDefaultTextareaValue = false;
1844var didWarnInvalidOptionChildren = false;
1845var didWarnAboutNoopUpdateForComponent = {};
1846var didWarnAboutBadClass = {};
1847var didWarnAboutDeprecatedWillMount = {};
1848var didWarnAboutUndefinedDerivedState = {};
1849var didWarnAboutUninitializedState = {};
1850var valuePropNames = ['value', 'defaultValue'];
1851var newlineEatingTags = {
1852 listing: true,
1853 pre: true,
1854 textarea: true
1855};
1856
1857function getComponentName(type) {
1858 return typeof type === 'string' ? type : typeof type === 'function' ? type.displayName || type.name : null;
1859}
1860
1861// We accept any tag to be rendered but since this gets injected into arbitrary
1862// HTML, we want to make sure that it's a safe tag.
1863// http://www.w3.org/TR/REC-xml/#NT-Name
1864var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
1865var validatedTagCache = {};
1866function validateDangerousTag(tag) {
1867 if (!validatedTagCache.hasOwnProperty(tag)) {
1868 !VALID_TAG_REGEX.test(tag) ? invariant(false, 'Invalid tag: %s', tag) : void 0;
1869 validatedTagCache[tag] = true;
1870 }
1871}
1872
1873var processStyleName = memoizeStringOnly(function (styleName) {
1874 return hyphenateStyleName(styleName);
1875});
1876
1877function createMarkupForStyles(styles) {
1878 var serialized = '';
1879 var delimiter = '';
1880 for (var styleName in styles) {
1881 if (!styles.hasOwnProperty(styleName)) {
1882 continue;
1883 }
1884 var isCustomProperty = styleName.indexOf('--') === 0;
1885 var styleValue = styles[styleName];
1886 {
1887 if (!isCustomProperty) {
1888 warnValidStyle$1(styleName, styleValue, getStackAddendum);
1889 }
1890 }
1891 if (styleValue != null) {
1892 serialized += delimiter + processStyleName(styleName) + ':';
1893 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
1894
1895 delimiter = ';';
1896 }
1897 }
1898 return serialized || null;
1899}
1900
1901function warnNoop(publicInstance, callerName) {
1902 {
1903 var _constructor = publicInstance.constructor;
1904 var componentName = _constructor && getComponentName(_constructor) || 'ReactClass';
1905 var warningKey = componentName + '.' + callerName;
1906 if (didWarnAboutNoopUpdateForComponent[warningKey]) {
1907 return;
1908 }
1909
1910 warning(false, '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
1911 didWarnAboutNoopUpdateForComponent[warningKey] = true;
1912 }
1913}
1914
1915function shouldConstruct(Component) {
1916 return Component.prototype && Component.prototype.isReactComponent;
1917}
1918
1919function getNonChildrenInnerMarkup(props) {
1920 var innerHTML = props.dangerouslySetInnerHTML;
1921 if (innerHTML != null) {
1922 if (innerHTML.__html != null) {
1923 return innerHTML.__html;
1924 }
1925 } else {
1926 var content = props.children;
1927 if (typeof content === 'string' || typeof content === 'number') {
1928 return escapeTextForBrowser(content);
1929 }
1930 }
1931 return null;
1932}
1933
1934function flattenTopLevelChildren(children) {
1935 if (!React.isValidElement(children)) {
1936 return toArray(children);
1937 }
1938 var element = children;
1939 if (element.type !== REACT_FRAGMENT_TYPE) {
1940 return [element];
1941 }
1942 var fragmentChildren = element.props.children;
1943 if (!React.isValidElement(fragmentChildren)) {
1944 return toArray(fragmentChildren);
1945 }
1946 var fragmentChildElement = fragmentChildren;
1947 return [fragmentChildElement];
1948}
1949
1950function flattenOptionChildren(children) {
1951 var content = '';
1952 // Flatten children and warn if they aren't strings or numbers;
1953 // invalid types are ignored.
1954 React.Children.forEach(children, function (child) {
1955 if (child == null) {
1956 return;
1957 }
1958 if (typeof child === 'string' || typeof child === 'number') {
1959 content += child;
1960 } else {
1961 {
1962 if (!didWarnInvalidOptionChildren) {
1963 didWarnInvalidOptionChildren = true;
1964 warning(false, 'Only strings and numbers are supported as <option> children.');
1965 }
1966 }
1967 }
1968 });
1969 return content;
1970}
1971
1972function maskContext(type, context) {
1973 var contextTypes = type.contextTypes;
1974 if (!contextTypes) {
1975 return emptyObject;
1976 }
1977 var maskedContext = {};
1978 for (var contextName in contextTypes) {
1979 maskedContext[contextName] = context[contextName];
1980 }
1981 return maskedContext;
1982}
1983
1984function checkContextTypes(typeSpecs, values, location) {
1985 {
1986 checkPropTypes(typeSpecs, values, location, 'Component', getStackAddendum);
1987 }
1988}
1989
1990function processContext(type, context) {
1991 var maskedContext = maskContext(type, context);
1992 {
1993 if (type.contextTypes) {
1994 checkContextTypes(type.contextTypes, maskedContext, 'context');
1995 }
1996 }
1997 return maskedContext;
1998}
1999
2000var STYLE = 'style';
2001var RESERVED_PROPS = {
2002 children: null,
2003 dangerouslySetInnerHTML: null,
2004 suppressContentEditableWarning: null,
2005 suppressHydrationWarning: null
2006};
2007
2008function createOpenTagMarkup(tagVerbatim, tagLowercase, props, namespace, makeStaticMarkup, isRootElement) {
2009 var ret = '<' + tagVerbatim;
2010
2011 for (var propKey in props) {
2012 if (!props.hasOwnProperty(propKey)) {
2013 continue;
2014 }
2015 var propValue = props[propKey];
2016 if (propValue == null) {
2017 continue;
2018 }
2019 if (propKey === STYLE) {
2020 propValue = createMarkupForStyles(propValue);
2021 }
2022 var markup = null;
2023 if (isCustomComponent(tagLowercase, props)) {
2024 if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
2025 markup = createMarkupForCustomAttribute(propKey, propValue);
2026 }
2027 } else {
2028 markup = createMarkupForProperty(propKey, propValue);
2029 }
2030 if (markup) {
2031 ret += ' ' + markup;
2032 }
2033 }
2034
2035 // For static pages, no need to put React ID and checksum. Saves lots of
2036 // bytes.
2037 if (makeStaticMarkup) {
2038 return ret;
2039 }
2040
2041 if (isRootElement) {
2042 ret += ' ' + createMarkupForRoot();
2043 }
2044 return ret;
2045}
2046
2047function validateRenderResult(child, type) {
2048 if (child === undefined) {
2049 invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', getComponentName(type) || 'Component');
2050 }
2051}
2052
2053function resolve(child, context) {
2054 while (React.isValidElement(child)) {
2055 // Safe because we just checked it's an element.
2056 var element = child;
2057 var Component = element.type;
2058 {
2059 pushElementToDebugStack(element);
2060 }
2061 if (typeof Component !== 'function') {
2062 break;
2063 }
2064 processChild(element, Component);
2065 }
2066
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 = {
2074 isMounted: function (publicInstance) {
2075 return false;
2076 },
2077 enqueueForceUpdate: function (publicInstance) {
2078 if (queue === null) {
2079 warnNoop(publicInstance, 'forceUpdate');
2080 return null;
2081 }
2082 },
2083 enqueueReplaceState: function (publicInstance, completeState) {
2084 replace = true;
2085 queue = [completeState];
2086 },
2087 enqueueSetState: function (publicInstance, currentPartialState) {
2088 if (queue === null) {
2089 warnNoop(publicInstance, 'setState');
2090 return null;
2091 }
2092 queue.push(currentPartialState);
2093 }
2094 };
2095
2096 var inst = void 0;
2097 if (shouldConstruct(Component)) {
2098 inst = new Component(element.props, publicContext, updater);
2099
2100 if (typeof Component.getDerivedStateFromProps === 'function') {
2101 {
2102 if (inst.state === null || inst.state === undefined) {
2103 var componentName = getComponentName(Component) || 'Unknown';
2104 if (!didWarnAboutUninitializedState[componentName]) {
2105 warning(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, inst.state === null ? 'null' : 'undefined');
2106 didWarnAboutUninitializedState[componentName] = true;
2107 }
2108 }
2109 }
2110
2111 var partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
2112
2113 {
2114 if (partialState === undefined) {
2115 var _componentName = getComponentName(Component) || 'Unknown';
2116 if (!didWarnAboutUndefinedDerivedState[_componentName]) {
2117 warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', _componentName);
2118 didWarnAboutUndefinedDerivedState[_componentName] = true;
2119 }
2120 }
2121 }
2122
2123 if (partialState != null) {
2124 inst.state = _assign({}, inst.state, partialState);
2125 }
2126 }
2127 } else {
2128 {
2129 if (Component.prototype && typeof Component.prototype.render === 'function') {
2130 var _componentName2 = getComponentName(Component) || 'Unknown';
2131
2132 if (!didWarnAboutBadClass[_componentName2]) {
2133 warning(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', _componentName2, _componentName2);
2134 didWarnAboutBadClass[_componentName2] = true;
2135 }
2136 }
2137 }
2138 inst = Component(element.props, publicContext, updater);
2139 if (inst == null || inst.render == null) {
2140 child = inst;
2141 validateRenderResult(child, Component);
2142 return;
2143 }
2144 }
2145
2146 inst.props = element.props;
2147 inst.context = publicContext;
2148 inst.updater = updater;
2149
2150 var initialState = inst.state;
2151 if (initialState === undefined) {
2152 inst.state = initialState = null;
2153 }
2154 if (typeof inst.UNSAFE_componentWillMount === 'function' || typeof inst.componentWillMount === 'function') {
2155 if (typeof inst.componentWillMount === 'function') {
2156 {
2157 if (warnAboutDeprecatedLifecycles && inst.componentWillMount.__suppressDeprecationWarning !== true) {
2158 var _componentName3 = getComponentName(Component) || 'Unknown';
2159
2160 if (!didWarnAboutDeprecatedWillMount[_componentName3]) {
2161 lowPriorityWarning$1(false, '%s: componentWillMount() is deprecated and will be ' + 'removed in the next major version. Read about the motivations ' + 'behind this change: ' + 'https://fb.me/react-async-component-lifecycle-hooks' + '\n\n' + 'As a temporary workaround, you can rename to ' + 'UNSAFE_componentWillMount instead.', _componentName3);
2162 didWarnAboutDeprecatedWillMount[_componentName3] = true;
2163 }
2164 }
2165 }
2166
2167 // In order to support react-lifecycles-compat polyfilled components,
2168 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
2169 if (typeof Component.getDerivedStateFromProps !== 'function') {
2170 inst.componentWillMount();
2171 }
2172 }
2173 if (typeof inst.UNSAFE_componentWillMount === 'function' && typeof Component.getDerivedStateFromProps !== 'function') {
2174 // In order to support react-lifecycles-compat polyfilled components,
2175 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
2176 inst.UNSAFE_componentWillMount();
2177 }
2178 if (queue.length) {
2179 var oldQueue = queue;
2180 var oldReplace = replace;
2181 queue = null;
2182 replace = false;
2183
2184 if (oldReplace && oldQueue.length === 1) {
2185 inst.state = oldQueue[0];
2186 } else {
2187 var nextState = oldReplace ? oldQueue[0] : inst.state;
2188 var dontMutate = true;
2189 for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
2190 var partial = oldQueue[i];
2191 var _partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
2192 if (_partialState != null) {
2193 if (dontMutate) {
2194 dontMutate = false;
2195 nextState = _assign({}, nextState, _partialState);
2196 } else {
2197 _assign(nextState, _partialState);
2198 }
2199 }
2200 }
2201 inst.state = nextState;
2202 }
2203 } else {
2204 queue = null;
2205 }
2206 }
2207 child = inst.render();
2208
2209 {
2210 if (child === undefined && inst.render._isMockFunction) {
2211 // This is probably bad practice. Consider warning here and
2212 // deprecating this convenience.
2213 child = null;
2214 }
2215 }
2216 validateRenderResult(child, Component);
2217
2218 var childContext = void 0;
2219 if (typeof inst.getChildContext === 'function') {
2220 var childContextTypes = Component.childContextTypes;
2221 if (typeof childContextTypes === 'object') {
2222 childContext = inst.getChildContext();
2223 for (var contextKey in childContext) {
2224 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(Component) || 'Unknown', contextKey) : void 0;
2225 }
2226 } else {
2227 warning(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(Component) || 'Unknown');
2228 }
2229 }
2230 if (childContext) {
2231 context = _assign({}, context, childContext);
2232 }
2233 }
2234 return { child: child, context: context };
2235}
2236
2237var ReactDOMServerRenderer = function () {
2238 function ReactDOMServerRenderer(children, makeStaticMarkup) {
2239 _classCallCheck(this, ReactDOMServerRenderer);
2240
2241 var flatChildren = flattenTopLevelChildren(children);
2242
2243 var topFrame = {
2244 type: null,
2245 // Assume all trees start in the HTML namespace (not totally true, but
2246 // this is what we did historically)
2247 domNamespace: Namespaces.html,
2248 children: flatChildren,
2249 childIndex: 0,
2250 context: emptyObject,
2251 footer: ''
2252 };
2253 {
2254 topFrame.debugElementStack = [];
2255 }
2256 this.stack = [topFrame];
2257 this.exhausted = false;
2258 this.currentSelectValue = null;
2259 this.previousWasTextNode = false;
2260 this.makeStaticMarkup = makeStaticMarkup;
2261
2262 // Context (new API)
2263 this.providerStack = []; // Stack of provider objects
2264 this.providerIndex = -1;
2265 }
2266 // TODO: type this more strictly:
2267
2268
2269 ReactDOMServerRenderer.prototype.pushProvider = function pushProvider(provider) {
2270 this.providerIndex += 1;
2271 this.providerStack[this.providerIndex] = provider;
2272 var context = provider.type._context;
2273 context._currentValue = provider.props.value;
2274 };
2275
2276 ReactDOMServerRenderer.prototype.popProvider = function popProvider(provider) {
2277 {
2278 !(this.providerIndex > -1 && provider === this.providerStack[this.providerIndex]) ? warning(false, 'Unexpected pop.') : void 0;
2279 }
2280 this.providerStack[this.providerIndex] = null;
2281 this.providerIndex -= 1;
2282 var context = provider.type._context;
2283 if (this.providerIndex < 0) {
2284 context._currentValue = context._defaultValue;
2285 } else {
2286 // We assume this type is correct because of the index check above.
2287 var previousProvider = this.providerStack[this.providerIndex];
2288 context._currentValue = previousProvider.props.value;
2289 }
2290 };
2291
2292 ReactDOMServerRenderer.prototype.read = function read(bytes) {
2293 if (this.exhausted) {
2294 return null;
2295 }
2296
2297 var out = '';
2298 while (out.length < bytes) {
2299 if (this.stack.length === 0) {
2300 this.exhausted = true;
2301 break;
2302 }
2303 var frame = this.stack[this.stack.length - 1];
2304 if (frame.childIndex >= frame.children.length) {
2305 var _footer = frame.footer;
2306 out += _footer;
2307 if (_footer !== '') {
2308 this.previousWasTextNode = false;
2309 }
2310 this.stack.pop();
2311 if (frame.type === 'select') {
2312 this.currentSelectValue = null;
2313 } else if (frame.type != null && frame.type.type != null && frame.type.type.$$typeof === REACT_PROVIDER_TYPE) {
2314 var provider = frame.type;
2315 this.popProvider(provider);
2316 }
2317 continue;
2318 }
2319 var child = frame.children[frame.childIndex++];
2320 {
2321 setCurrentDebugStack(this.stack);
2322 }
2323 out += this.render(child, frame.context, frame.domNamespace);
2324 {
2325 // TODO: Handle reentrant server render calls. This doesn't.
2326 resetCurrentDebugStack();
2327 }
2328 }
2329 return out;
2330 };
2331
2332 ReactDOMServerRenderer.prototype.render = function render(child, context, parentNamespace) {
2333 if (typeof child === 'string' || typeof child === 'number') {
2334 var text = '' + child;
2335 if (text === '') {
2336 return '';
2337 }
2338 if (this.makeStaticMarkup) {
2339 return escapeTextForBrowser(text);
2340 }
2341 if (this.previousWasTextNode) {
2342 return '<!-- -->' + escapeTextForBrowser(text);
2343 }
2344 this.previousWasTextNode = true;
2345 return escapeTextForBrowser(text);
2346 } else {
2347 var nextChild = void 0;
2348
2349 var _resolve = resolve(child, context);
2350
2351 nextChild = _resolve.child;
2352 context = _resolve.context;
2353
2354 if (nextChild === null || nextChild === false) {
2355 return '';
2356 } else if (!React.isValidElement(nextChild)) {
2357 if (nextChild != null && nextChild.$$typeof != null) {
2358 // Catch unexpected special types early.
2359 var $$typeof = nextChild.$$typeof;
2360 !($$typeof !== REACT_PORTAL_TYPE) ? invariant(false, 'Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.') : void 0;
2361 // Catch-all to prevent an infinite loop if React.Children.toArray() supports some new type.
2362 invariant(false, 'Unknown element-like object type: %s. This is likely a bug in React. Please file an issue.', $$typeof.toString());
2363 }
2364 var nextChildren = toArray(nextChild);
2365 var frame = {
2366 type: null,
2367 domNamespace: parentNamespace,
2368 children: nextChildren,
2369 childIndex: 0,
2370 context: context,
2371 footer: ''
2372 };
2373 {
2374 frame.debugElementStack = [];
2375 }
2376 this.stack.push(frame);
2377 return '';
2378 }
2379 // Safe because we just checked it's an element.
2380 var nextElement = nextChild;
2381 var elementType = nextElement.type;
2382
2383 if (typeof elementType === 'string') {
2384 return this.renderDOM(nextElement, context, parentNamespace);
2385 }
2386
2387 switch (elementType) {
2388 case REACT_STRICT_MODE_TYPE:
2389 case REACT_ASYNC_MODE_TYPE:
2390 case REACT_PROFILER_TYPE:
2391 case REACT_FRAGMENT_TYPE:
2392 {
2393 var _nextChildren = toArray(nextChild.props.children);
2394 var _frame = {
2395 type: null,
2396 domNamespace: parentNamespace,
2397 children: _nextChildren,
2398 childIndex: 0,
2399 context: context,
2400 footer: ''
2401 };
2402 {
2403 _frame.debugElementStack = [];
2404 }
2405 this.stack.push(_frame);
2406 return '';
2407 }
2408 // eslint-disable-next-line-no-fallthrough
2409 default:
2410 break;
2411 }
2412 if (typeof elementType === 'object' && elementType !== null) {
2413 switch (elementType.$$typeof) {
2414 case REACT_FORWARD_REF_TYPE:
2415 {
2416 var element = nextChild;
2417 var _nextChildren2 = toArray(elementType.render(element.props, element.ref));
2418 var _frame2 = {
2419 type: null,
2420 domNamespace: parentNamespace,
2421 children: _nextChildren2,
2422 childIndex: 0,
2423 context: context,
2424 footer: ''
2425 };
2426 {
2427 _frame2.debugElementStack = [];
2428 }
2429 this.stack.push(_frame2);
2430 return '';
2431 }
2432 case REACT_PROVIDER_TYPE:
2433 {
2434 var provider = nextChild;
2435 var nextProps = provider.props;
2436 var _nextChildren3 = toArray(nextProps.children);
2437 var _frame3 = {
2438 type: provider,
2439 domNamespace: parentNamespace,
2440 children: _nextChildren3,
2441 childIndex: 0,
2442 context: context,
2443 footer: ''
2444 };
2445 {
2446 _frame3.debugElementStack = [];
2447 }
2448
2449 this.pushProvider(provider);
2450
2451 this.stack.push(_frame3);
2452 return '';
2453 }
2454 case REACT_CONTEXT_TYPE:
2455 {
2456 var consumer = nextChild;
2457 var _nextProps = consumer.props;
2458 var nextValue = consumer.type._currentValue;
2459
2460 var _nextChildren4 = toArray(_nextProps.children(nextValue));
2461 var _frame4 = {
2462 type: nextChild,
2463 domNamespace: parentNamespace,
2464 children: _nextChildren4,
2465 childIndex: 0,
2466 context: context,
2467 footer: ''
2468 };
2469 {
2470 _frame4.debugElementStack = [];
2471 }
2472 this.stack.push(_frame4);
2473 return '';
2474 }
2475 default:
2476 break;
2477 }
2478 }
2479
2480 var info = '';
2481 {
2482 var owner = nextElement._owner;
2483 if (elementType === undefined || typeof elementType === 'object' && elementType !== null && Object.keys(elementType).length === 0) {
2484 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
2485 }
2486 var ownerName = owner ? getComponentName(owner) : null;
2487 if (ownerName) {
2488 info += '\n\nCheck the render method of `' + ownerName + '`.';
2489 }
2490 }
2491 invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', elementType == null ? elementType : typeof elementType, info);
2492 }
2493 };
2494
2495 ReactDOMServerRenderer.prototype.renderDOM = function renderDOM(element, context, parentNamespace) {
2496 var tag = element.type.toLowerCase();
2497
2498 var namespace = parentNamespace;
2499 if (parentNamespace === Namespaces.html) {
2500 namespace = getIntrinsicNamespace(tag);
2501 }
2502
2503 {
2504 if (namespace === Namespaces.html) {
2505 // Should this check be gated by parent namespace? Not sure we want to
2506 // allow <SVG> or <mATH>.
2507 !(tag === element.type) ? warning(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', element.type) : void 0;
2508 }
2509 }
2510
2511 validateDangerousTag(tag);
2512
2513 var props = element.props;
2514 if (tag === 'input') {
2515 {
2516 ReactControlledValuePropTypes.checkPropTypes('input', props, getStackAddendum);
2517
2518 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnDefaultChecked) {
2519 warning(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', 'A component', props.type);
2520 didWarnDefaultChecked = true;
2521 }
2522 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultInputValue) {
2523 warning(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', 'A component', props.type);
2524 didWarnDefaultInputValue = true;
2525 }
2526 }
2527
2528 props = _assign({
2529 type: undefined
2530 }, props, {
2531 defaultChecked: undefined,
2532 defaultValue: undefined,
2533 value: props.value != null ? props.value : props.defaultValue,
2534 checked: props.checked != null ? props.checked : props.defaultChecked
2535 });
2536 } else if (tag === 'textarea') {
2537 {
2538 ReactControlledValuePropTypes.checkPropTypes('textarea', props, getStackAddendum);
2539 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultTextareaValue) {
2540 warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
2541 didWarnDefaultTextareaValue = true;
2542 }
2543 }
2544
2545 var initialValue = props.value;
2546 if (initialValue == null) {
2547 var defaultValue = props.defaultValue;
2548 // TODO (yungsters): Remove support for children content in <textarea>.
2549 var textareaChildren = props.children;
2550 if (textareaChildren != null) {
2551 {
2552 warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
2553 }
2554 !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0;
2555 if (Array.isArray(textareaChildren)) {
2556 !(textareaChildren.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0;
2557 textareaChildren = textareaChildren[0];
2558 }
2559
2560 defaultValue = '' + textareaChildren;
2561 }
2562 if (defaultValue == null) {
2563 defaultValue = '';
2564 }
2565 initialValue = defaultValue;
2566 }
2567
2568 props = _assign({}, props, {
2569 value: undefined,
2570 children: '' + initialValue
2571 });
2572 } else if (tag === 'select') {
2573 {
2574 ReactControlledValuePropTypes.checkPropTypes('select', props, getStackAddendum);
2575
2576 for (var i = 0; i < valuePropNames.length; i++) {
2577 var propName = valuePropNames[i];
2578 if (props[propName] == null) {
2579 continue;
2580 }
2581 var isArray = Array.isArray(props[propName]);
2582 if (props.multiple && !isArray) {
2583 warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, '' // getDeclarationErrorAddendum(),
2584 );
2585 } else if (!props.multiple && isArray) {
2586 warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, '' // getDeclarationErrorAddendum(),
2587 );
2588 }
2589 }
2590
2591 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultSelectValue) {
2592 warning(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
2593 didWarnDefaultSelectValue = true;
2594 }
2595 }
2596 this.currentSelectValue = props.value != null ? props.value : props.defaultValue;
2597 props = _assign({}, props, {
2598 value: undefined
2599 });
2600 } else if (tag === 'option') {
2601 var selected = null;
2602 var selectValue = this.currentSelectValue;
2603 var optionChildren = flattenOptionChildren(props.children);
2604 if (selectValue != null) {
2605 var value = void 0;
2606 if (props.value != null) {
2607 value = props.value + '';
2608 } else {
2609 value = optionChildren;
2610 }
2611 selected = false;
2612 if (Array.isArray(selectValue)) {
2613 // multiple
2614 for (var j = 0; j < selectValue.length; j++) {
2615 if ('' + selectValue[j] === value) {
2616 selected = true;
2617 break;
2618 }
2619 }
2620 } else {
2621 selected = '' + selectValue === value;
2622 }
2623
2624 props = _assign({
2625 selected: undefined,
2626 children: undefined
2627 }, props, {
2628 selected: selected,
2629 children: optionChildren
2630 });
2631 }
2632 }
2633
2634 {
2635 validatePropertiesInDevelopment(tag, props);
2636 }
2637
2638 assertValidProps(tag, props, getStackAddendum);
2639
2640 var out = createOpenTagMarkup(element.type, tag, props, namespace, this.makeStaticMarkup, this.stack.length === 1);
2641 var footer = '';
2642 if (omittedCloseTags.hasOwnProperty(tag)) {
2643 out += '/>';
2644 } else {
2645 out += '>';
2646 footer = '</' + element.type + '>';
2647 }
2648 var children = void 0;
2649 var innerMarkup = getNonChildrenInnerMarkup(props);
2650 if (innerMarkup != null) {
2651 children = [];
2652 if (newlineEatingTags[tag] && innerMarkup.charAt(0) === '\n') {
2653 // text/html ignores the first character in these tags if it's a newline
2654 // Prefer to break application/xml over text/html (for now) by adding
2655 // a newline specifically to get eaten by the parser. (Alternately for
2656 // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
2657 // \r is normalized out by HTMLTextAreaElement#value.)
2658 // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
2659 // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
2660 // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
2661 // See: Parsing of "textarea" "listing" and "pre" elements
2662 // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
2663 out += '\n';
2664 }
2665 out += innerMarkup;
2666 } else {
2667 children = toArray(props.children);
2668 }
2669 var frame = {
2670 domNamespace: getChildNamespace(parentNamespace, element.type),
2671 type: tag,
2672 children: children,
2673 childIndex: 0,
2674 context: context,
2675 footer: footer
2676 };
2677 {
2678 frame.debugElementStack = [];
2679 }
2680 this.stack.push(frame);
2681 this.previousWasTextNode = false;
2682 return out;
2683 };
2684
2685 return ReactDOMServerRenderer;
2686}();
2687
2688/**
2689 * Render a ReactElement to its initial HTML. This should only be used on the
2690 * server.
2691 * See https://reactjs.org/docs/react-dom-server.html#rendertostring
2692 */
2693function renderToString(element) {
2694 var renderer = new ReactDOMServerRenderer(element, false);
2695 var markup = renderer.read(Infinity);
2696 return markup;
2697}
2698
2699/**
2700 * Similar to renderToString, except this doesn't create extra DOM attributes
2701 * such as data-react-id that React uses internally.
2702 * See https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup
2703 */
2704function renderToStaticMarkup(element) {
2705 var renderer = new ReactDOMServerRenderer(element, true);
2706 var markup = renderer.read(Infinity);
2707 return markup;
2708}
2709
2710function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2711
2712function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2713
2714function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2715
2716// This is a Readable Node.js stream which wraps the ReactDOMPartialRenderer.
2717
2718var ReactMarkupReadableStream = function (_Readable) {
2719 _inherits(ReactMarkupReadableStream, _Readable);
2720
2721 function ReactMarkupReadableStream(element, makeStaticMarkup) {
2722 _classCallCheck$1(this, ReactMarkupReadableStream);
2723
2724 var _this = _possibleConstructorReturn(this, _Readable.call(this, {}));
2725 // Calls the stream.Readable(options) constructor. Consider exposing built-in
2726 // features like highWaterMark in the future.
2727
2728
2729 _this.partialRenderer = new ReactDOMServerRenderer(element, makeStaticMarkup);
2730 return _this;
2731 }
2732
2733 ReactMarkupReadableStream.prototype._read = function _read(size) {
2734 try {
2735 this.push(this.partialRenderer.read(size));
2736 } catch (err) {
2737 this.emit('error', err);
2738 }
2739 };
2740
2741 return ReactMarkupReadableStream;
2742}(stream.Readable);
2743/**
2744 * Render a ReactElement to its initial HTML. This should only be used on the
2745 * server.
2746 * See https://reactjs.org/docs/react-dom-stream.html#rendertonodestream
2747 */
2748
2749
2750function renderToNodeStream(element) {
2751 return new ReactMarkupReadableStream(element, false);
2752}
2753
2754/**
2755 * Similar to renderToNodeStream, except this doesn't create extra DOM attributes
2756 * such as data-react-id that React uses internally.
2757 * See https://reactjs.org/docs/react-dom-stream.html#rendertostaticnodestream
2758 */
2759function renderToStaticNodeStream(element) {
2760 return new ReactMarkupReadableStream(element, true);
2761}
2762
2763// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
2764var ReactDOMServerNode = {
2765 renderToString: renderToString,
2766 renderToStaticMarkup: renderToStaticMarkup,
2767 renderToNodeStream: renderToNodeStream,
2768 renderToStaticNodeStream: renderToStaticNodeStream,
2769 version: ReactVersion
2770};
2771
2772var ReactDOMServerNode$1 = Object.freeze({
2773 default: ReactDOMServerNode
2774});
2775
2776var ReactDOMServer = ( ReactDOMServerNode$1 && ReactDOMServerNode ) || ReactDOMServerNode$1;
2777
2778// TODO: decide on the top-level export form.
2779// This is hacky but makes it work with both Rollup and Jest
2780var server_node = ReactDOMServer.default ? ReactDOMServer.default : ReactDOMServer;
2781
2782module.exports = server_node;
2783 })();
2784}