UNPKG

128 kBJavaScriptView Raw
1/** @license React v16.8.2
2 * react-dom-server.node.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
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 React = require('react');
20var checkPropTypes = require('prop-types/checkPropTypes');
21var stream = require('stream');
22
23// TODO: this is special because it gets imported during build.
24
25var ReactVersion = '16.8.2';
26
27/**
28 * Use invariant() to assert state which your program assumes to be true.
29 *
30 * Provide sprintf-style format (only %s is supported) and arguments
31 * to provide information about what broke and what you were
32 * expecting.
33 *
34 * The invariant message will be stripped in production, but the invariant
35 * will remain to ensure logic does not differ in production.
36 */
37
38var validateFormat = function () {};
39
40{
41 validateFormat = function (format) {
42 if (format === undefined) {
43 throw new Error('invariant requires an error message argument');
44 }
45 };
46}
47
48function invariant(condition, format, a, b, c, d, e, f) {
49 validateFormat(format);
50
51 if (!condition) {
52 var error = void 0;
53 if (format === undefined) {
54 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
55 } else {
56 var args = [a, b, c, d, e, f];
57 var argIndex = 0;
58 error = new Error(format.replace(/%s/g, function () {
59 return args[argIndex++];
60 }));
61 error.name = 'Invariant Violation';
62 }
63
64 error.framesToPop = 1; // we don't care about invariant's own frame
65 throw error;
66 }
67}
68
69// Relying on the `invariant()` implementation lets us
70// preserve the format and params in the www builds.
71
72/**
73 * Similar to invariant but only logs a warning if the condition is not met.
74 * This can be used to log issues in development environments in critical
75 * paths. Removing the logging code for production environments will keep the
76 * same logic and follow the same code paths.
77 */
78
79var warningWithoutStack = function () {};
80
81{
82 warningWithoutStack = function (condition, format) {
83 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
84 args[_key - 2] = arguments[_key];
85 }
86
87 if (format === undefined) {
88 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
89 }
90 if (args.length > 8) {
91 // Check before the condition to catch violations early.
92 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
93 }
94 if (condition) {
95 return;
96 }
97 if (typeof console !== 'undefined') {
98 var argsWithFormat = args.map(function (item) {
99 return '' + item;
100 });
101 argsWithFormat.unshift('Warning: ' + format);
102
103 // We intentionally don't use spread (or .apply) directly because it
104 // breaks IE9: https://github.com/facebook/react/issues/13610
105 Function.prototype.apply.call(console.error, console, argsWithFormat);
106 }
107 try {
108 // --- Welcome to debugging React ---
109 // This error was thrown as a convenience so that you can use this stack
110 // to find the callsite that caused this warning to fire.
111 var argIndex = 0;
112 var message = 'Warning: ' + format.replace(/%s/g, function () {
113 return args[argIndex++];
114 });
115 throw new Error(message);
116 } catch (x) {}
117 };
118}
119
120var warningWithoutStack$1 = warningWithoutStack;
121
122// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
123// nor polyfill, then a plain number is used for performance.
124var hasSymbol = typeof Symbol === 'function' && Symbol.for;
125
126
127var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
128var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
129var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
130var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
131var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
132var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
133
134var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
135var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
136var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
137var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
138var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
139
140var Resolved = 1;
141
142
143function refineResolvedLazyComponent(lazyComponent) {
144 return lazyComponent._status === Resolved ? lazyComponent._result : null;
145}
146
147function getWrappedName(outerType, innerType, wrapperName) {
148 var functionName = innerType.displayName || innerType.name || '';
149 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
150}
151
152function getComponentName(type) {
153 if (type == null) {
154 // Host root, text node or just invalid type.
155 return null;
156 }
157 {
158 if (typeof type.tag === 'number') {
159 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
160 }
161 }
162 if (typeof type === 'function') {
163 return type.displayName || type.name || null;
164 }
165 if (typeof type === 'string') {
166 return type;
167 }
168 switch (type) {
169 case REACT_CONCURRENT_MODE_TYPE:
170 return 'ConcurrentMode';
171 case REACT_FRAGMENT_TYPE:
172 return 'Fragment';
173 case REACT_PORTAL_TYPE:
174 return 'Portal';
175 case REACT_PROFILER_TYPE:
176 return 'Profiler';
177 case REACT_STRICT_MODE_TYPE:
178 return 'StrictMode';
179 case REACT_SUSPENSE_TYPE:
180 return 'Suspense';
181 }
182 if (typeof type === 'object') {
183 switch (type.$$typeof) {
184 case REACT_CONTEXT_TYPE:
185 return 'Context.Consumer';
186 case REACT_PROVIDER_TYPE:
187 return 'Context.Provider';
188 case REACT_FORWARD_REF_TYPE:
189 return getWrappedName(type, type.render, 'ForwardRef');
190 case REACT_MEMO_TYPE:
191 return getComponentName(type.type);
192 case REACT_LAZY_TYPE:
193 {
194 var thenable = type;
195 var resolvedThenable = refineResolvedLazyComponent(thenable);
196 if (resolvedThenable) {
197 return getComponentName(resolvedThenable);
198 }
199 }
200 }
201 }
202 return null;
203}
204
205/**
206 * Forked from fbjs/warning:
207 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
208 *
209 * Only change is we use console.warn instead of console.error,
210 * and do nothing when 'console' is not supported.
211 * This really simplifies the code.
212 * ---
213 * Similar to invariant but only logs a warning if the condition is not met.
214 * This can be used to log issues in development environments in critical
215 * paths. Removing the logging code for production environments will keep the
216 * same logic and follow the same code paths.
217 */
218
219var lowPriorityWarning = function () {};
220
221{
222 var printWarning = function (format) {
223 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
224 args[_key - 1] = arguments[_key];
225 }
226
227 var argIndex = 0;
228 var message = 'Warning: ' + format.replace(/%s/g, function () {
229 return args[argIndex++];
230 });
231 if (typeof console !== 'undefined') {
232 console.warn(message);
233 }
234 try {
235 // --- Welcome to debugging React ---
236 // This error was thrown as a convenience so that you can use this stack
237 // to find the callsite that caused this warning to fire.
238 throw new Error(message);
239 } catch (x) {}
240 };
241
242 lowPriorityWarning = function (condition, format) {
243 if (format === undefined) {
244 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
245 }
246 if (!condition) {
247 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
248 args[_key2 - 2] = arguments[_key2];
249 }
250
251 printWarning.apply(undefined, [format].concat(args));
252 }
253 };
254}
255
256var lowPriorityWarning$1 = lowPriorityWarning;
257
258var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
259
260// Prevent newer renderers from RTE when used with older react package versions.
261// Current owner and dispatcher used to share the same ref,
262// but PR #14548 split them out to better support the react-debug-tools package.
263if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
264 ReactSharedInternals.ReactCurrentDispatcher = {
265 current: null
266 };
267}
268
269/**
270 * Similar to invariant but only logs a warning if the condition is not met.
271 * This can be used to log issues in development environments in critical
272 * paths. Removing the logging code for production environments will keep the
273 * same logic and follow the same code paths.
274 */
275
276var warning = warningWithoutStack$1;
277
278{
279 warning = function (condition, format) {
280 if (condition) {
281 return;
282 }
283 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
284 var stack = ReactDebugCurrentFrame.getStackAddendum();
285 // eslint-disable-next-line react-internal/warning-and-invariant-args
286
287 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
288 args[_key - 2] = arguments[_key];
289 }
290
291 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
292 };
293}
294
295var warning$1 = warning;
296
297var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
298
299var describeComponentFrame = function (name, source, ownerName) {
300 var sourceInfo = '';
301 if (source) {
302 var path = source.fileName;
303 var fileName = path.replace(BEFORE_SLASH_RE, '');
304 {
305 // In DEV, include code for a common special case:
306 // prefer "folder/index.js" instead of just "index.js".
307 if (/^index\./.test(fileName)) {
308 var match = path.match(BEFORE_SLASH_RE);
309 if (match) {
310 var pathBeforeSlash = match[1];
311 if (pathBeforeSlash) {
312 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
313 fileName = folderName + '/' + fileName;
314 }
315 }
316 }
317 }
318 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
319 } else if (ownerName) {
320 sourceInfo = ' (created by ' + ownerName + ')';
321 }
322 return '\n in ' + (name || 'Unknown') + sourceInfo;
323};
324
325// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
326
327
328// In some cases, StrictMode should also double-render lifecycles.
329// This can be confusing for tests though,
330// And it can be bad for performance in production.
331// This feature flag can be used to control the behavior:
332
333
334// To preserve the "Pause on caught exceptions" behavior of the debugger, we
335// replay the begin phase of a failed component inside invokeGuardedCallback.
336
337
338// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
339var warnAboutDeprecatedLifecycles = false;
340
341// Gather advanced timing metrics for Profiler subtrees.
342
343
344// Trace which interactions trigger each commit.
345
346
347// Only used in www builds.
348var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
349
350// Only used in www builds.
351
352
353// Only used in www builds.
354
355
356// React Fire: prevent the value and checked attributes from syncing
357// with their related DOM properties
358
359
360// These APIs will no longer be "unstable" in the upcoming 16.7 release,
361// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
362
363var ReactDebugCurrentFrame$1 = void 0;
364{
365 ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
366}
367
368var didWarnAboutInvalidateContextType = {};
369
370var emptyObject = {};
371{
372 Object.freeze(emptyObject);
373}
374
375function maskContext(type, context) {
376 var contextTypes = type.contextTypes;
377 if (!contextTypes) {
378 return emptyObject;
379 }
380 var maskedContext = {};
381 for (var contextName in contextTypes) {
382 maskedContext[contextName] = context[contextName];
383 }
384 return maskedContext;
385}
386
387function checkContextTypes(typeSpecs, values, location) {
388 {
389 checkPropTypes(typeSpecs, values, location, 'Component', ReactDebugCurrentFrame$1.getCurrentStack);
390 }
391}
392
393function validateContextBounds(context, threadID) {
394 // If we don't have enough slots in this context to store this threadID,
395 // fill it in without leaving any holes to ensure that the VM optimizes
396 // this as non-holey index properties.
397 // (Note: If `react` package is < 16.6, _threadCount is undefined.)
398 for (var i = context._threadCount | 0; i <= threadID; i++) {
399 // We assume that this is the same as the defaultValue which might not be
400 // true if we're rendering inside a secondary renderer but they are
401 // secondary because these use cases are very rare.
402 context[i] = context._currentValue2;
403 context._threadCount = i + 1;
404 }
405}
406
407function processContext(type, context, threadID) {
408 var contextType = type.contextType;
409 if (typeof contextType === 'object' && contextType !== null) {
410 {
411 if (contextType.$$typeof !== REACT_CONTEXT_TYPE) {
412 var name = getComponentName(type) || 'Component';
413 if (!didWarnAboutInvalidateContextType[name]) {
414 didWarnAboutInvalidateContextType[name] = true;
415 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext(). ' + 'Did you accidentally pass the Context.Provider instead?', name);
416 }
417 }
418 }
419 validateContextBounds(contextType, threadID);
420 return contextType[threadID];
421 } else {
422 var maskedContext = maskContext(type, context);
423 {
424 if (type.contextTypes) {
425 checkContextTypes(type.contextTypes, maskedContext, 'context');
426 }
427 }
428 return maskedContext;
429 }
430}
431
432// Allocates a new index for each request. Tries to stay as compact as possible so that these
433// indices can be used to reference a tightly packaged array. As opposed to being used in a Map.
434// The first allocated index is 1.
435
436var nextAvailableThreadIDs = new Uint16Array(16);
437for (var i = 0; i < 15; i++) {
438 nextAvailableThreadIDs[i] = i + 1;
439}
440nextAvailableThreadIDs[15] = 0;
441
442function growThreadCountAndReturnNextAvailable() {
443 var oldArray = nextAvailableThreadIDs;
444 var oldSize = oldArray.length;
445 var newSize = oldSize * 2;
446 !(newSize <= 0x10000) ? invariant(false, 'Maximum number of concurrent React renderers exceeded. This can happen if you are not properly destroying the Readable provided by React. Ensure that you call .destroy() on it if you no longer want to read from it, and did not read to the end. If you use .pipe() this should be automatic.') : void 0;
447 var newArray = new Uint16Array(newSize);
448 newArray.set(oldArray);
449 nextAvailableThreadIDs = newArray;
450 nextAvailableThreadIDs[0] = oldSize + 1;
451 for (var _i = oldSize; _i < newSize - 1; _i++) {
452 nextAvailableThreadIDs[_i] = _i + 1;
453 }
454 nextAvailableThreadIDs[newSize - 1] = 0;
455 return oldSize;
456}
457
458function allocThreadID() {
459 var nextID = nextAvailableThreadIDs[0];
460 if (nextID === 0) {
461 return growThreadCountAndReturnNextAvailable();
462 }
463 nextAvailableThreadIDs[0] = nextAvailableThreadIDs[nextID];
464 return nextID;
465}
466
467function freeThreadID(id) {
468 nextAvailableThreadIDs[id] = nextAvailableThreadIDs[0];
469 nextAvailableThreadIDs[0] = id;
470}
471
472// A reserved attribute.
473// It is handled by React separately and shouldn't be written to the DOM.
474var RESERVED = 0;
475
476// A simple string attribute.
477// Attributes that aren't in the whitelist are presumed to have this type.
478var STRING = 1;
479
480// A string attribute that accepts booleans in React. In HTML, these are called
481// "enumerated" attributes with "true" and "false" as possible values.
482// When true, it should be set to a "true" string.
483// When false, it should be set to a "false" string.
484var BOOLEANISH_STRING = 2;
485
486// A real boolean attribute.
487// When true, it should be present (set either to an empty string or its name).
488// When false, it should be omitted.
489var BOOLEAN = 3;
490
491// An attribute that can be used as a flag as well as with a value.
492// When true, it should be present (set either to an empty string or its name).
493// When false, it should be omitted.
494// For any other value, should be present with that value.
495var OVERLOADED_BOOLEAN = 4;
496
497// An attribute that must be numeric or parse as a numeric.
498// When falsy, it should be removed.
499var NUMERIC = 5;
500
501// An attribute that must be positive numeric or parse as a positive numeric.
502// When falsy, it should be removed.
503var POSITIVE_NUMERIC = 6;
504
505/* eslint-disable max-len */
506var 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';
507/* eslint-enable max-len */
508var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
509
510
511var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
512var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
513
514var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
515var illegalAttributeNameCache = {};
516var validatedAttributeNameCache = {};
517
518function isAttributeNameSafe(attributeName) {
519 if (hasOwnProperty$1.call(validatedAttributeNameCache, attributeName)) {
520 return true;
521 }
522 if (hasOwnProperty$1.call(illegalAttributeNameCache, attributeName)) {
523 return false;
524 }
525 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
526 validatedAttributeNameCache[attributeName] = true;
527 return true;
528 }
529 illegalAttributeNameCache[attributeName] = true;
530 {
531 warning$1(false, 'Invalid attribute name: `%s`', attributeName);
532 }
533 return false;
534}
535
536function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
537 if (propertyInfo !== null) {
538 return propertyInfo.type === RESERVED;
539 }
540 if (isCustomComponentTag) {
541 return false;
542 }
543 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
544 return true;
545 }
546 return false;
547}
548
549function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
550 if (propertyInfo !== null && propertyInfo.type === RESERVED) {
551 return false;
552 }
553 switch (typeof value) {
554 case 'function':
555 // $FlowIssue symbol is perfectly valid here
556 case 'symbol':
557 // eslint-disable-line
558 return true;
559 case 'boolean':
560 {
561 if (isCustomComponentTag) {
562 return false;
563 }
564 if (propertyInfo !== null) {
565 return !propertyInfo.acceptsBooleans;
566 } else {
567 var prefix = name.toLowerCase().slice(0, 5);
568 return prefix !== 'data-' && prefix !== 'aria-';
569 }
570 }
571 default:
572 return false;
573 }
574}
575
576function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
577 if (value === null || typeof value === 'undefined') {
578 return true;
579 }
580 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
581 return true;
582 }
583 if (isCustomComponentTag) {
584 return false;
585 }
586 if (propertyInfo !== null) {
587 switch (propertyInfo.type) {
588 case BOOLEAN:
589 return !value;
590 case OVERLOADED_BOOLEAN:
591 return value === false;
592 case NUMERIC:
593 return isNaN(value);
594 case POSITIVE_NUMERIC:
595 return isNaN(value) || value < 1;
596 }
597 }
598 return false;
599}
600
601function getPropertyInfo(name) {
602 return properties.hasOwnProperty(name) ? properties[name] : null;
603}
604
605function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace) {
606 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
607 this.attributeName = attributeName;
608 this.attributeNamespace = attributeNamespace;
609 this.mustUseProperty = mustUseProperty;
610 this.propertyName = name;
611 this.type = type;
612}
613
614// When adding attributes to this list, be sure to also add them to
615// the `possibleStandardNames` module to ensure casing and incorrect
616// name warnings.
617var properties = {};
618
619// These props are reserved by React. They shouldn't be written to the DOM.
620['children', 'dangerouslySetInnerHTML',
621// TODO: This prevents the assignment of defaultValue to regular
622// elements (not just inputs). Now that ReactDOMInput assigns to the
623// defaultValue property -- do we need this?
624'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
625 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
626 name, // attributeName
627 null);
628} // attributeNamespace
629);
630
631// A few React string attributes have a different name.
632// This is a mapping from React prop names to the attribute names.
633[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
634 var name = _ref[0],
635 attributeName = _ref[1];
636
637 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
638 attributeName, // attributeName
639 null);
640} // attributeNamespace
641);
642
643// These are "enumerated" HTML attributes that accept "true" and "false".
644// In React, we let users pass `true` and `false` even though technically
645// these aren't boolean attributes (they are coerced to strings).
646['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
647 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
648 name.toLowerCase(), // attributeName
649 null);
650} // attributeNamespace
651);
652
653// These are "enumerated" SVG attributes that accept "true" and "false".
654// In React, we let users pass `true` and `false` even though technically
655// these aren't boolean attributes (they are coerced to strings).
656// Since these are SVG attributes, their attribute names are case-sensitive.
657['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
658 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
659 name, // attributeName
660 null);
661} // attributeNamespace
662);
663
664// These are HTML boolean attributes.
665['allowFullScreen', 'async',
666// Note: there is a special case that prevents it from being written to the DOM
667// on the client side because the browsers are inconsistent. Instead we call focus().
668'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
669// Microdata
670'itemScope'].forEach(function (name) {
671 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
672 name.toLowerCase(), // attributeName
673 null);
674} // attributeNamespace
675);
676
677// These are the few React props that we set as DOM properties
678// rather than attributes. These are all booleans.
679['checked',
680// Note: `option.selected` is not updated if `select.multiple` is
681// disabled with `removeAttribute`. We have special logic for handling this.
682'multiple', 'muted', 'selected'].forEach(function (name) {
683 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
684 name, // attributeName
685 null);
686} // attributeNamespace
687);
688
689// These are HTML attributes that are "overloaded booleans": they behave like
690// booleans, but can also accept a string value.
691['capture', 'download'].forEach(function (name) {
692 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
693 name, // attributeName
694 null);
695} // attributeNamespace
696);
697
698// These are HTML attributes that must be positive numbers.
699['cols', 'rows', 'size', 'span'].forEach(function (name) {
700 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
701 name, // attributeName
702 null);
703} // attributeNamespace
704);
705
706// These are HTML attributes that must be numbers.
707['rowSpan', 'start'].forEach(function (name) {
708 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
709 name.toLowerCase(), // attributeName
710 null);
711} // attributeNamespace
712);
713
714var CAMELIZE = /[\-\:]([a-z])/g;
715var capitalize = function (token) {
716 return token[1].toUpperCase();
717};
718
719// This is a list of all SVG attributes that need special casing, namespacing,
720// or boolean value assignment. Regular attributes that just accept strings
721// and have the same names are omitted, just like in the HTML whitelist.
722// Some of these attributes can be hard to find. This list was created by
723// scrapping the MDN documentation.
724['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) {
725 var name = attributeName.replace(CAMELIZE, capitalize);
726 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
727 attributeName, null);
728} // attributeNamespace
729);
730
731// String SVG attributes with the xlink namespace.
732['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
733 var name = attributeName.replace(CAMELIZE, capitalize);
734 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
735 attributeName, 'http://www.w3.org/1999/xlink');
736});
737
738// String SVG attributes with the xml namespace.
739['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
740 var name = attributeName.replace(CAMELIZE, capitalize);
741 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
742 attributeName, 'http://www.w3.org/XML/1998/namespace');
743});
744
745// These attribute exists both in HTML and SVG.
746// The attribute name is case-sensitive in SVG so we can't just use
747// the React name like we do for attributes that exist only in HTML.
748['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
749 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
750 attributeName.toLowerCase(), // attributeName
751 null);
752} // attributeNamespace
753);
754
755// code copied and modified from escape-html
756/**
757 * Module variables.
758 * @private
759 */
760
761var matchHtmlRegExp = /["'&<>]/;
762
763/**
764 * Escapes special characters and HTML entities in a given html string.
765 *
766 * @param {string} string HTML string to escape for later insertion
767 * @return {string}
768 * @public
769 */
770
771function escapeHtml(string) {
772 var str = '' + string;
773 var match = matchHtmlRegExp.exec(str);
774
775 if (!match) {
776 return str;
777 }
778
779 var escape = void 0;
780 var html = '';
781 var index = void 0;
782 var lastIndex = 0;
783
784 for (index = match.index; index < str.length; index++) {
785 switch (str.charCodeAt(index)) {
786 case 34:
787 // "
788 escape = '&quot;';
789 break;
790 case 38:
791 // &
792 escape = '&amp;';
793 break;
794 case 39:
795 // '
796 escape = '&#x27;'; // modified from escape-html; used to be '&#39'
797 break;
798 case 60:
799 // <
800 escape = '&lt;';
801 break;
802 case 62:
803 // >
804 escape = '&gt;';
805 break;
806 default:
807 continue;
808 }
809
810 if (lastIndex !== index) {
811 html += str.substring(lastIndex, index);
812 }
813
814 lastIndex = index + 1;
815 html += escape;
816 }
817
818 return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
819}
820// end code copied and modified from escape-html
821
822/**
823 * Escapes text to prevent scripting attacks.
824 *
825 * @param {*} text Text value to escape.
826 * @return {string} An escaped string.
827 */
828function escapeTextForBrowser(text) {
829 if (typeof text === 'boolean' || typeof text === 'number') {
830 // this shortcircuit helps perf for types that we know will never have
831 // special characters, especially given that this function is used often
832 // for numeric dom ids.
833 return '' + text;
834 }
835 return escapeHtml(text);
836}
837
838/**
839 * Escapes attribute value to prevent scripting attacks.
840 *
841 * @param {*} value Value to escape.
842 * @return {string} An escaped string.
843 */
844function quoteAttributeValueForBrowser(value) {
845 return '"' + escapeTextForBrowser(value) + '"';
846}
847
848/**
849 * Operations for dealing with DOM properties.
850 */
851
852/**
853 * Creates markup for the ID property.
854 *
855 * @param {string} id Unescaped ID.
856 * @return {string} Markup string.
857 */
858
859
860function createMarkupForRoot() {
861 return ROOT_ATTRIBUTE_NAME + '=""';
862}
863
864/**
865 * Creates markup for a property.
866 *
867 * @param {string} name
868 * @param {*} value
869 * @return {?string} Markup string, or null if the property was invalid.
870 */
871function createMarkupForProperty(name, value) {
872 var propertyInfo = getPropertyInfo(name);
873 if (name !== 'style' && shouldIgnoreAttribute(name, propertyInfo, false)) {
874 return '';
875 }
876 if (shouldRemoveAttribute(name, value, propertyInfo, false)) {
877 return '';
878 }
879 if (propertyInfo !== null) {
880 var attributeName = propertyInfo.attributeName;
881 var type = propertyInfo.type;
882
883 if (type === BOOLEAN || type === OVERLOADED_BOOLEAN && value === true) {
884 return attributeName + '=""';
885 } else {
886 return attributeName + '=' + quoteAttributeValueForBrowser(value);
887 }
888 } else if (isAttributeNameSafe(name)) {
889 return name + '=' + quoteAttributeValueForBrowser(value);
890 }
891 return '';
892}
893
894/**
895 * Creates markup for a custom property.
896 *
897 * @param {string} name
898 * @param {*} value
899 * @return {string} Markup string, or empty string if the property was invalid.
900 */
901function createMarkupForCustomAttribute(name, value) {
902 if (!isAttributeNameSafe(name) || value == null) {
903 return '';
904 }
905 return name + '=' + quoteAttributeValueForBrowser(value);
906}
907
908/**
909 * inlined Object.is polyfill to avoid requiring consumers ship their own
910 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
911 */
912function is(x, y) {
913 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
914 ;
915}
916
917var currentlyRenderingComponent = null;
918var firstWorkInProgressHook = null;
919var workInProgressHook = null;
920// Whether the work-in-progress hook is a re-rendered hook
921var isReRender = false;
922// Whether an update was scheduled during the currently executing render pass.
923var didScheduleRenderPhaseUpdate = false;
924// Lazily created map of render-phase updates
925var renderPhaseUpdates = null;
926// Counter to prevent infinite loops.
927var numberOfReRenders = 0;
928var RE_RENDER_LIMIT = 25;
929
930var isInHookUserCodeInDev = false;
931
932// In DEV, this is the name of the currently executing primitive hook
933var currentHookNameInDev = void 0;
934
935function resolveCurrentlyRenderingComponent() {
936 !(currentlyRenderingComponent !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)') : void 0;
937 {
938 !!isInHookUserCodeInDev ? warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks') : void 0;
939 }
940 return currentlyRenderingComponent;
941}
942
943function areHookInputsEqual(nextDeps, prevDeps) {
944 if (prevDeps === null) {
945 {
946 warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
947 }
948 return false;
949 }
950
951 {
952 // Don't bother comparing lengths in prod because these arrays should be
953 // passed inline.
954 if (nextDeps.length !== prevDeps.length) {
955 warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, '[' + nextDeps.join(', ') + ']', '[' + prevDeps.join(', ') + ']');
956 }
957 }
958 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
959 if (is(nextDeps[i], prevDeps[i])) {
960 continue;
961 }
962 return false;
963 }
964 return true;
965}
966
967function createHook() {
968 if (numberOfReRenders > 0) {
969 invariant(false, 'Rendered more hooks than during the previous render');
970 }
971 return {
972 memoizedState: null,
973 queue: null,
974 next: null
975 };
976}
977
978function createWorkInProgressHook() {
979 if (workInProgressHook === null) {
980 // This is the first hook in the list
981 if (firstWorkInProgressHook === null) {
982 isReRender = false;
983 firstWorkInProgressHook = workInProgressHook = createHook();
984 } else {
985 // There's already a work-in-progress. Reuse it.
986 isReRender = true;
987 workInProgressHook = firstWorkInProgressHook;
988 }
989 } else {
990 if (workInProgressHook.next === null) {
991 isReRender = false;
992 // Append to the end of the list
993 workInProgressHook = workInProgressHook.next = createHook();
994 } else {
995 // There's already a work-in-progress. Reuse it.
996 isReRender = true;
997 workInProgressHook = workInProgressHook.next;
998 }
999 }
1000 return workInProgressHook;
1001}
1002
1003function prepareToUseHooks(componentIdentity) {
1004 currentlyRenderingComponent = componentIdentity;
1005 {
1006 isInHookUserCodeInDev = false;
1007 }
1008
1009 // The following should have already been reset
1010 // didScheduleRenderPhaseUpdate = false;
1011 // firstWorkInProgressHook = null;
1012 // numberOfReRenders = 0;
1013 // renderPhaseUpdates = null;
1014 // workInProgressHook = null;
1015}
1016
1017function finishHooks(Component, props, children, refOrContext) {
1018 // This must be called after every function component to prevent hooks from
1019 // being used in classes.
1020
1021 while (didScheduleRenderPhaseUpdate) {
1022 // Updates were scheduled during the render phase. They are stored in
1023 // the `renderPhaseUpdates` map. Call the component again, reusing the
1024 // work-in-progress hooks and applying the additional updates on top. Keep
1025 // restarting until no more updates are scheduled.
1026 didScheduleRenderPhaseUpdate = false;
1027 numberOfReRenders += 1;
1028
1029 // Start over from the beginning of the list
1030 workInProgressHook = null;
1031
1032 children = Component(props, refOrContext);
1033 }
1034 currentlyRenderingComponent = null;
1035 firstWorkInProgressHook = null;
1036 numberOfReRenders = 0;
1037 renderPhaseUpdates = null;
1038 workInProgressHook = null;
1039 {
1040 isInHookUserCodeInDev = false;
1041 }
1042
1043 // These were reset above
1044 // currentlyRenderingComponent = null;
1045 // didScheduleRenderPhaseUpdate = false;
1046 // firstWorkInProgressHook = null;
1047 // numberOfReRenders = 0;
1048 // renderPhaseUpdates = null;
1049 // workInProgressHook = null;
1050
1051 return children;
1052}
1053
1054function readContext(context, observedBits) {
1055 var threadID = currentThreadID;
1056 validateContextBounds(context, threadID);
1057 {
1058 !!isInHookUserCodeInDev ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
1059 }
1060 return context[threadID];
1061}
1062
1063function useContext(context, observedBits) {
1064 {
1065 currentHookNameInDev = 'useContext';
1066 }
1067 resolveCurrentlyRenderingComponent();
1068 var threadID = currentThreadID;
1069 validateContextBounds(context, threadID);
1070 return context[threadID];
1071}
1072
1073function basicStateReducer(state, action) {
1074 return typeof action === 'function' ? action(state) : action;
1075}
1076
1077function useState(initialState) {
1078 {
1079 currentHookNameInDev = 'useState';
1080 }
1081 return useReducer(basicStateReducer,
1082 // useReducer has a special case to support lazy useState initializers
1083 initialState);
1084}
1085
1086function useReducer(reducer, initialArg, init) {
1087 {
1088 if (reducer !== basicStateReducer) {
1089 currentHookNameInDev = 'useReducer';
1090 }
1091 }
1092 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1093 workInProgressHook = createWorkInProgressHook();
1094 if (isReRender) {
1095 // This is a re-render. Apply the new render phase updates to the previous
1096 var _queue = workInProgressHook.queue;
1097 var _dispatch = _queue.dispatch;
1098 if (renderPhaseUpdates !== null) {
1099 // Render phase updates are stored in a map of queue -> linked list
1100 var firstRenderPhaseUpdate = renderPhaseUpdates.get(_queue);
1101 if (firstRenderPhaseUpdate !== undefined) {
1102 renderPhaseUpdates.delete(_queue);
1103 var newState = workInProgressHook.memoizedState;
1104 var update = firstRenderPhaseUpdate;
1105 do {
1106 // Process this render phase update. We don't have to check the
1107 // priority because it will always be the same as the current
1108 // render's.
1109 var _action = update.action;
1110 {
1111 isInHookUserCodeInDev = true;
1112 }
1113 newState = reducer(newState, _action);
1114 {
1115 isInHookUserCodeInDev = false;
1116 }
1117 update = update.next;
1118 } while (update !== null);
1119
1120 workInProgressHook.memoizedState = newState;
1121
1122 return [newState, _dispatch];
1123 }
1124 }
1125 return [workInProgressHook.memoizedState, _dispatch];
1126 } else {
1127 {
1128 isInHookUserCodeInDev = true;
1129 }
1130 var initialState = void 0;
1131 if (reducer === basicStateReducer) {
1132 // Special case for `useState`.
1133 initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
1134 } else {
1135 initialState = init !== undefined ? init(initialArg) : initialArg;
1136 }
1137 {
1138 isInHookUserCodeInDev = false;
1139 }
1140 workInProgressHook.memoizedState = initialState;
1141 var _queue2 = workInProgressHook.queue = {
1142 last: null,
1143 dispatch: null
1144 };
1145 var _dispatch2 = _queue2.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue2);
1146 return [workInProgressHook.memoizedState, _dispatch2];
1147 }
1148}
1149
1150function useMemo(nextCreate, deps) {
1151 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1152 workInProgressHook = createWorkInProgressHook();
1153
1154 var nextDeps = deps === undefined ? null : deps;
1155
1156 if (workInProgressHook !== null) {
1157 var prevState = workInProgressHook.memoizedState;
1158 if (prevState !== null) {
1159 if (nextDeps !== null) {
1160 var prevDeps = prevState[1];
1161 if (areHookInputsEqual(nextDeps, prevDeps)) {
1162 return prevState[0];
1163 }
1164 }
1165 }
1166 }
1167
1168 {
1169 isInHookUserCodeInDev = true;
1170 }
1171 var nextValue = nextCreate();
1172 {
1173 isInHookUserCodeInDev = false;
1174 }
1175 workInProgressHook.memoizedState = [nextValue, nextDeps];
1176 return nextValue;
1177}
1178
1179function useRef(initialValue) {
1180 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1181 workInProgressHook = createWorkInProgressHook();
1182 var previousRef = workInProgressHook.memoizedState;
1183 if (previousRef === null) {
1184 var ref = { current: initialValue };
1185 {
1186 Object.seal(ref);
1187 }
1188 workInProgressHook.memoizedState = ref;
1189 return ref;
1190 } else {
1191 return previousRef;
1192 }
1193}
1194
1195function useLayoutEffect(create, inputs) {
1196 {
1197 currentHookNameInDev = 'useLayoutEffect';
1198 }
1199 warning$1(false, 'useLayoutEffect does nothing on the server, because its effect cannot ' + "be encoded into the server renderer's output format. This will lead " + 'to a mismatch between the initial, non-hydrated UI and the intended ' + 'UI. To avoid this, useLayoutEffect should only be used in ' + 'components that render exclusively on the client.');
1200}
1201
1202function dispatchAction(componentIdentity, queue, action) {
1203 !(numberOfReRenders < RE_RENDER_LIMIT) ? invariant(false, 'Too many re-renders. React limits the number of renders to prevent an infinite loop.') : void 0;
1204
1205 if (componentIdentity === currentlyRenderingComponent) {
1206 // This is a render phase update. Stash it in a lazily-created map of
1207 // queue -> linked list of updates. After this render pass, we'll restart
1208 // and apply the stashed updates on top of the work-in-progress hook.
1209 didScheduleRenderPhaseUpdate = true;
1210 var update = {
1211 action: action,
1212 next: null
1213 };
1214 if (renderPhaseUpdates === null) {
1215 renderPhaseUpdates = new Map();
1216 }
1217 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
1218 if (firstRenderPhaseUpdate === undefined) {
1219 renderPhaseUpdates.set(queue, update);
1220 } else {
1221 // Append the update to the end of the list.
1222 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
1223 while (lastRenderPhaseUpdate.next !== null) {
1224 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
1225 }
1226 lastRenderPhaseUpdate.next = update;
1227 }
1228 } else {
1229 // This means an update has happened after the function component has
1230 // returned. On the server this is a no-op. In React Fiber, the update
1231 // would be scheduled for a future render.
1232 }
1233}
1234
1235function useCallback(callback, deps) {
1236 // Callbacks are passed as they are in the server environment.
1237 return callback;
1238}
1239
1240function noop() {}
1241
1242var currentThreadID = 0;
1243
1244function setCurrentThreadID(threadID) {
1245 currentThreadID = threadID;
1246}
1247
1248var Dispatcher = {
1249 readContext: readContext,
1250 useContext: useContext,
1251 useMemo: useMemo,
1252 useReducer: useReducer,
1253 useRef: useRef,
1254 useState: useState,
1255 useLayoutEffect: useLayoutEffect,
1256 useCallback: useCallback,
1257 // useImperativeHandle is not run in the server environment
1258 useImperativeHandle: noop,
1259 // Effects are not run in the server environment.
1260 useEffect: noop,
1261 // Debugging effect
1262 useDebugValue: noop
1263};
1264
1265var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1266var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1267var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1268
1269var Namespaces = {
1270 html: HTML_NAMESPACE,
1271 mathml: MATH_NAMESPACE,
1272 svg: SVG_NAMESPACE
1273};
1274
1275// Assumes there is no parent namespace.
1276function getIntrinsicNamespace(type) {
1277 switch (type) {
1278 case 'svg':
1279 return SVG_NAMESPACE;
1280 case 'math':
1281 return MATH_NAMESPACE;
1282 default:
1283 return HTML_NAMESPACE;
1284 }
1285}
1286
1287function getChildNamespace(parentNamespace, type) {
1288 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
1289 // No (or default) parent namespace: potential entry point.
1290 return getIntrinsicNamespace(type);
1291 }
1292 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
1293 // We're leaving SVG.
1294 return HTML_NAMESPACE;
1295 }
1296 // By default, pass namespace below.
1297 return parentNamespace;
1298}
1299
1300var ReactDebugCurrentFrame$2 = null;
1301
1302var ReactControlledValuePropTypes = {
1303 checkPropTypes: null
1304};
1305
1306{
1307 ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
1308
1309 var hasReadOnlyValue = {
1310 button: true,
1311 checkbox: true,
1312 image: true,
1313 hidden: true,
1314 radio: true,
1315 reset: true,
1316 submit: true
1317 };
1318
1319 var propTypes = {
1320 value: function (props, propName, componentName) {
1321 if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null) {
1322 return null;
1323 }
1324 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`.');
1325 },
1326 checked: function (props, propName, componentName) {
1327 if (props.onChange || props.readOnly || props.disabled || props[propName] == null) {
1328 return null;
1329 }
1330 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`.');
1331 }
1332 };
1333
1334 /**
1335 * Provide a linked `value` attribute for controlled forms. You should not use
1336 * this outside of the ReactDOM controlled form components.
1337 */
1338 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
1339 checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum);
1340 };
1341}
1342
1343// For HTML, certain tags should omit their close tag. We keep a whitelist for
1344// those special-case tags.
1345
1346var omittedCloseTags = {
1347 area: true,
1348 base: true,
1349 br: true,
1350 col: true,
1351 embed: true,
1352 hr: true,
1353 img: true,
1354 input: true,
1355 keygen: true,
1356 link: true,
1357 meta: true,
1358 param: true,
1359 source: true,
1360 track: true,
1361 wbr: true
1362 // NOTE: menuitem's close tag should be omitted, but that causes problems.
1363};
1364
1365// For HTML, certain tags cannot have children. This has the same purpose as
1366// `omittedCloseTags` except that `menuitem` should still have its closing tag.
1367
1368var voidElementTags = _assign({
1369 menuitem: true
1370}, omittedCloseTags);
1371
1372// TODO: We can remove this if we add invariantWithStack()
1373// or add stack by default to invariants where possible.
1374var HTML = '__html';
1375
1376var ReactDebugCurrentFrame$3 = null;
1377{
1378 ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
1379}
1380
1381function assertValidProps(tag, props) {
1382 if (!props) {
1383 return;
1384 }
1385 // Note the use of `==` which checks for null or undefined.
1386 if (voidElementTags[tag]) {
1387 !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, ReactDebugCurrentFrame$3.getStackAddendum()) : void 0;
1388 }
1389 if (props.dangerouslySetInnerHTML != null) {
1390 !(props.children == null) ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0;
1391 !(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;
1392 }
1393 {
1394 !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning$1(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.') : void 0;
1395 }
1396 !(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', ReactDebugCurrentFrame$3.getStackAddendum()) : void 0;
1397}
1398
1399/**
1400 * CSS properties which accept numbers but are not in units of "px".
1401 */
1402var isUnitlessNumber = {
1403 animationIterationCount: true,
1404 borderImageOutset: true,
1405 borderImageSlice: true,
1406 borderImageWidth: true,
1407 boxFlex: true,
1408 boxFlexGroup: true,
1409 boxOrdinalGroup: true,
1410 columnCount: true,
1411 columns: true,
1412 flex: true,
1413 flexGrow: true,
1414 flexPositive: true,
1415 flexShrink: true,
1416 flexNegative: true,
1417 flexOrder: true,
1418 gridArea: true,
1419 gridRow: true,
1420 gridRowEnd: true,
1421 gridRowSpan: true,
1422 gridRowStart: true,
1423 gridColumn: true,
1424 gridColumnEnd: true,
1425 gridColumnSpan: true,
1426 gridColumnStart: true,
1427 fontWeight: true,
1428 lineClamp: true,
1429 lineHeight: true,
1430 opacity: true,
1431 order: true,
1432 orphans: true,
1433 tabSize: true,
1434 widows: true,
1435 zIndex: true,
1436 zoom: true,
1437
1438 // SVG-related properties
1439 fillOpacity: true,
1440 floodOpacity: true,
1441 stopOpacity: true,
1442 strokeDasharray: true,
1443 strokeDashoffset: true,
1444 strokeMiterlimit: true,
1445 strokeOpacity: true,
1446 strokeWidth: true
1447};
1448
1449/**
1450 * @param {string} prefix vendor-specific prefix, eg: Webkit
1451 * @param {string} key style name, eg: transitionDuration
1452 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
1453 * WebkitTransitionDuration
1454 */
1455function prefixKey(prefix, key) {
1456 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
1457}
1458
1459/**
1460 * Support style names that may come passed in prefixed by adding permutations
1461 * of vendor prefixes.
1462 */
1463var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
1464
1465// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
1466// infinite loop, because it iterates over the newly added props too.
1467Object.keys(isUnitlessNumber).forEach(function (prop) {
1468 prefixes.forEach(function (prefix) {
1469 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
1470 });
1471});
1472
1473/**
1474 * Convert a value into the proper css writable value. The style name `name`
1475 * should be logical (no hyphens), as specified
1476 * in `CSSProperty.isUnitlessNumber`.
1477 *
1478 * @param {string} name CSS property name such as `topMargin`.
1479 * @param {*} value CSS property value such as `10px`.
1480 * @return {string} Normalized style value with dimensions applied.
1481 */
1482function dangerousStyleValue(name, value, isCustomProperty) {
1483 // Note that we've removed escapeTextForBrowser() calls here since the
1484 // whole string will be escaped when the attribute is injected into
1485 // the markup. If you provide unsafe user data here they can inject
1486 // arbitrary CSS which may be problematic (I couldn't repro this):
1487 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
1488 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
1489 // This is not an XSS hole but instead a potential CSS injection issue
1490 // which has lead to a greater discussion about how we're going to
1491 // trust URLs moving forward. See #2115901
1492
1493 var isEmpty = value == null || typeof value === 'boolean' || value === '';
1494 if (isEmpty) {
1495 return '';
1496 }
1497
1498 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
1499 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
1500 }
1501
1502 return ('' + value).trim();
1503}
1504
1505var uppercasePattern = /([A-Z])/g;
1506var msPattern = /^ms-/;
1507
1508/**
1509 * Hyphenates a camelcased CSS property name, for example:
1510 *
1511 * > hyphenateStyleName('backgroundColor')
1512 * < "background-color"
1513 * > hyphenateStyleName('MozTransition')
1514 * < "-moz-transition"
1515 * > hyphenateStyleName('msTransition')
1516 * < "-ms-transition"
1517 *
1518 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
1519 * is converted to `-ms-`.
1520 */
1521function hyphenateStyleName(name) {
1522 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
1523}
1524
1525function isCustomComponent(tagName, props) {
1526 if (tagName.indexOf('-') === -1) {
1527 return typeof props.is === 'string';
1528 }
1529 switch (tagName) {
1530 // These are reserved SVG and MathML elements.
1531 // We don't mind this whitelist too much because we expect it to never grow.
1532 // The alternative is to track the namespace in a few places which is convoluted.
1533 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
1534 case 'annotation-xml':
1535 case 'color-profile':
1536 case 'font-face':
1537 case 'font-face-src':
1538 case 'font-face-uri':
1539 case 'font-face-format':
1540 case 'font-face-name':
1541 case 'missing-glyph':
1542 return false;
1543 default:
1544 return true;
1545 }
1546}
1547
1548var warnValidStyle = function () {};
1549
1550{
1551 // 'msTransform' is correct, but the other prefixes should be capitalized
1552 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
1553 var msPattern$1 = /^-ms-/;
1554 var hyphenPattern = /-(.)/g;
1555
1556 // style values shouldn't contain a semicolon
1557 var badStyleValueWithSemicolonPattern = /;\s*$/;
1558
1559 var warnedStyleNames = {};
1560 var warnedStyleValues = {};
1561 var warnedForNaNValue = false;
1562 var warnedForInfinityValue = false;
1563
1564 var camelize = function (string) {
1565 return string.replace(hyphenPattern, function (_, character) {
1566 return character.toUpperCase();
1567 });
1568 };
1569
1570 var warnHyphenatedStyleName = function (name) {
1571 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
1572 return;
1573 }
1574
1575 warnedStyleNames[name] = true;
1576 warning$1(false, 'Unsupported style property %s. Did you mean %s?', name,
1577 // As Andi Smith suggests
1578 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
1579 // is converted to lowercase `ms`.
1580 camelize(name.replace(msPattern$1, 'ms-')));
1581 };
1582
1583 var warnBadVendoredStyleName = function (name) {
1584 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
1585 return;
1586 }
1587
1588 warnedStyleNames[name] = true;
1589 warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
1590 };
1591
1592 var warnStyleValueWithSemicolon = function (name, value) {
1593 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
1594 return;
1595 }
1596
1597 warnedStyleValues[value] = true;
1598 warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
1599 };
1600
1601 var warnStyleValueIsNaN = function (name, value) {
1602 if (warnedForNaNValue) {
1603 return;
1604 }
1605
1606 warnedForNaNValue = true;
1607 warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
1608 };
1609
1610 var warnStyleValueIsInfinity = function (name, value) {
1611 if (warnedForInfinityValue) {
1612 return;
1613 }
1614
1615 warnedForInfinityValue = true;
1616 warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
1617 };
1618
1619 warnValidStyle = function (name, value) {
1620 if (name.indexOf('-') > -1) {
1621 warnHyphenatedStyleName(name);
1622 } else if (badVendoredStyleNamePattern.test(name)) {
1623 warnBadVendoredStyleName(name);
1624 } else if (badStyleValueWithSemicolonPattern.test(value)) {
1625 warnStyleValueWithSemicolon(name, value);
1626 }
1627
1628 if (typeof value === 'number') {
1629 if (isNaN(value)) {
1630 warnStyleValueIsNaN(name, value);
1631 } else if (!isFinite(value)) {
1632 warnStyleValueIsInfinity(name, value);
1633 }
1634 }
1635 };
1636}
1637
1638var warnValidStyle$1 = warnValidStyle;
1639
1640var ariaProperties = {
1641 'aria-current': 0, // state
1642 'aria-details': 0,
1643 'aria-disabled': 0, // state
1644 'aria-hidden': 0, // state
1645 'aria-invalid': 0, // state
1646 'aria-keyshortcuts': 0,
1647 'aria-label': 0,
1648 'aria-roledescription': 0,
1649 // Widget Attributes
1650 'aria-autocomplete': 0,
1651 'aria-checked': 0,
1652 'aria-expanded': 0,
1653 'aria-haspopup': 0,
1654 'aria-level': 0,
1655 'aria-modal': 0,
1656 'aria-multiline': 0,
1657 'aria-multiselectable': 0,
1658 'aria-orientation': 0,
1659 'aria-placeholder': 0,
1660 'aria-pressed': 0,
1661 'aria-readonly': 0,
1662 'aria-required': 0,
1663 'aria-selected': 0,
1664 'aria-sort': 0,
1665 'aria-valuemax': 0,
1666 'aria-valuemin': 0,
1667 'aria-valuenow': 0,
1668 'aria-valuetext': 0,
1669 // Live Region Attributes
1670 'aria-atomic': 0,
1671 'aria-busy': 0,
1672 'aria-live': 0,
1673 'aria-relevant': 0,
1674 // Drag-and-Drop Attributes
1675 'aria-dropeffect': 0,
1676 'aria-grabbed': 0,
1677 // Relationship Attributes
1678 'aria-activedescendant': 0,
1679 'aria-colcount': 0,
1680 'aria-colindex': 0,
1681 'aria-colspan': 0,
1682 'aria-controls': 0,
1683 'aria-describedby': 0,
1684 'aria-errormessage': 0,
1685 'aria-flowto': 0,
1686 'aria-labelledby': 0,
1687 'aria-owns': 0,
1688 'aria-posinset': 0,
1689 'aria-rowcount': 0,
1690 'aria-rowindex': 0,
1691 'aria-rowspan': 0,
1692 'aria-setsize': 0
1693};
1694
1695var warnedProperties = {};
1696var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
1697var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
1698
1699var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1700
1701function validateProperty(tagName, name) {
1702 if (hasOwnProperty$2.call(warnedProperties, name) && warnedProperties[name]) {
1703 return true;
1704 }
1705
1706 if (rARIACamel.test(name)) {
1707 var ariaName = 'aria-' + name.slice(4).toLowerCase();
1708 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
1709
1710 // If this is an aria-* attribute, but is not listed in the known DOM
1711 // DOM properties, then it is an invalid aria-* attribute.
1712 if (correctName == null) {
1713 warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
1714 warnedProperties[name] = true;
1715 return true;
1716 }
1717 // aria-* attributes should be lowercase; suggest the lowercase version.
1718 if (name !== correctName) {
1719 warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
1720 warnedProperties[name] = true;
1721 return true;
1722 }
1723 }
1724
1725 if (rARIA.test(name)) {
1726 var lowerCasedName = name.toLowerCase();
1727 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
1728
1729 // If this is an aria-* attribute, but is not listed in the known DOM
1730 // DOM properties, then it is an invalid aria-* attribute.
1731 if (standardName == null) {
1732 warnedProperties[name] = true;
1733 return false;
1734 }
1735 // aria-* attributes should be lowercase; suggest the lowercase version.
1736 if (name !== standardName) {
1737 warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
1738 warnedProperties[name] = true;
1739 return true;
1740 }
1741 }
1742
1743 return true;
1744}
1745
1746function warnInvalidARIAProps(type, props) {
1747 var invalidProps = [];
1748
1749 for (var key in props) {
1750 var isValid = validateProperty(type, key);
1751 if (!isValid) {
1752 invalidProps.push(key);
1753 }
1754 }
1755
1756 var unknownPropString = invalidProps.map(function (prop) {
1757 return '`' + prop + '`';
1758 }).join(', ');
1759
1760 if (invalidProps.length === 1) {
1761 warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
1762 } else if (invalidProps.length > 1) {
1763 warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
1764 }
1765}
1766
1767function validateProperties(type, props) {
1768 if (isCustomComponent(type, props)) {
1769 return;
1770 }
1771 warnInvalidARIAProps(type, props);
1772}
1773
1774var didWarnValueNull = false;
1775
1776function validateProperties$1(type, props) {
1777 if (type !== 'input' && type !== 'textarea' && type !== 'select') {
1778 return;
1779 }
1780
1781 if (props != null && props.value === null && !didWarnValueNull) {
1782 didWarnValueNull = true;
1783 if (type === 'select' && props.multiple) {
1784 warning$1(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.', type);
1785 } else {
1786 warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
1787 }
1788 }
1789}
1790
1791/**
1792 * Registers plugins so that they can extract and dispatch events.
1793 *
1794 * @see {EventPluginHub}
1795 */
1796
1797/**
1798 * Ordered list of injected plugins.
1799 */
1800
1801
1802/**
1803 * Mapping from event name to dispatch config
1804 */
1805
1806
1807/**
1808 * Mapping from registration name to plugin module
1809 */
1810var registrationNameModules = {};
1811
1812/**
1813 * Mapping from registration name to event name
1814 */
1815
1816
1817/**
1818 * Mapping from lowercase registration names to the properly cased version,
1819 * used to warn in the case of missing event handlers. Available
1820 * only in true.
1821 * @type {Object}
1822 */
1823var possibleRegistrationNames = {};
1824// Trust the developer to only use possibleRegistrationNames in true
1825
1826/**
1827 * Injects an ordering of plugins (by plugin name). This allows the ordering
1828 * to be decoupled from injection of the actual plugins so that ordering is
1829 * always deterministic regardless of packaging, on-the-fly injection, etc.
1830 *
1831 * @param {array} InjectedEventPluginOrder
1832 * @internal
1833 * @see {EventPluginHub.injection.injectEventPluginOrder}
1834 */
1835
1836
1837/**
1838 * Injects plugins to be used by `EventPluginHub`. The plugin names must be
1839 * in the ordering injected by `injectEventPluginOrder`.
1840 *
1841 * Plugins can be injected as part of page initialization or on-the-fly.
1842 *
1843 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
1844 * @internal
1845 * @see {EventPluginHub.injection.injectEventPluginsByName}
1846 */
1847
1848// When adding attributes to the HTML or SVG whitelist, be sure to
1849// also add them to this module to ensure casing and incorrect name
1850// warnings.
1851var possibleStandardNames = {
1852 // HTML
1853 accept: 'accept',
1854 acceptcharset: 'acceptCharset',
1855 'accept-charset': 'acceptCharset',
1856 accesskey: 'accessKey',
1857 action: 'action',
1858 allowfullscreen: 'allowFullScreen',
1859 alt: 'alt',
1860 as: 'as',
1861 async: 'async',
1862 autocapitalize: 'autoCapitalize',
1863 autocomplete: 'autoComplete',
1864 autocorrect: 'autoCorrect',
1865 autofocus: 'autoFocus',
1866 autoplay: 'autoPlay',
1867 autosave: 'autoSave',
1868 capture: 'capture',
1869 cellpadding: 'cellPadding',
1870 cellspacing: 'cellSpacing',
1871 challenge: 'challenge',
1872 charset: 'charSet',
1873 checked: 'checked',
1874 children: 'children',
1875 cite: 'cite',
1876 class: 'className',
1877 classid: 'classID',
1878 classname: 'className',
1879 cols: 'cols',
1880 colspan: 'colSpan',
1881 content: 'content',
1882 contenteditable: 'contentEditable',
1883 contextmenu: 'contextMenu',
1884 controls: 'controls',
1885 controlslist: 'controlsList',
1886 coords: 'coords',
1887 crossorigin: 'crossOrigin',
1888 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
1889 data: 'data',
1890 datetime: 'dateTime',
1891 default: 'default',
1892 defaultchecked: 'defaultChecked',
1893 defaultvalue: 'defaultValue',
1894 defer: 'defer',
1895 dir: 'dir',
1896 disabled: 'disabled',
1897 download: 'download',
1898 draggable: 'draggable',
1899 enctype: 'encType',
1900 for: 'htmlFor',
1901 form: 'form',
1902 formmethod: 'formMethod',
1903 formaction: 'formAction',
1904 formenctype: 'formEncType',
1905 formnovalidate: 'formNoValidate',
1906 formtarget: 'formTarget',
1907 frameborder: 'frameBorder',
1908 headers: 'headers',
1909 height: 'height',
1910 hidden: 'hidden',
1911 high: 'high',
1912 href: 'href',
1913 hreflang: 'hrefLang',
1914 htmlfor: 'htmlFor',
1915 httpequiv: 'httpEquiv',
1916 'http-equiv': 'httpEquiv',
1917 icon: 'icon',
1918 id: 'id',
1919 innerhtml: 'innerHTML',
1920 inputmode: 'inputMode',
1921 integrity: 'integrity',
1922 is: 'is',
1923 itemid: 'itemID',
1924 itemprop: 'itemProp',
1925 itemref: 'itemRef',
1926 itemscope: 'itemScope',
1927 itemtype: 'itemType',
1928 keyparams: 'keyParams',
1929 keytype: 'keyType',
1930 kind: 'kind',
1931 label: 'label',
1932 lang: 'lang',
1933 list: 'list',
1934 loop: 'loop',
1935 low: 'low',
1936 manifest: 'manifest',
1937 marginwidth: 'marginWidth',
1938 marginheight: 'marginHeight',
1939 max: 'max',
1940 maxlength: 'maxLength',
1941 media: 'media',
1942 mediagroup: 'mediaGroup',
1943 method: 'method',
1944 min: 'min',
1945 minlength: 'minLength',
1946 multiple: 'multiple',
1947 muted: 'muted',
1948 name: 'name',
1949 nomodule: 'noModule',
1950 nonce: 'nonce',
1951 novalidate: 'noValidate',
1952 open: 'open',
1953 optimum: 'optimum',
1954 pattern: 'pattern',
1955 placeholder: 'placeholder',
1956 playsinline: 'playsInline',
1957 poster: 'poster',
1958 preload: 'preload',
1959 profile: 'profile',
1960 radiogroup: 'radioGroup',
1961 readonly: 'readOnly',
1962 referrerpolicy: 'referrerPolicy',
1963 rel: 'rel',
1964 required: 'required',
1965 reversed: 'reversed',
1966 role: 'role',
1967 rows: 'rows',
1968 rowspan: 'rowSpan',
1969 sandbox: 'sandbox',
1970 scope: 'scope',
1971 scoped: 'scoped',
1972 scrolling: 'scrolling',
1973 seamless: 'seamless',
1974 selected: 'selected',
1975 shape: 'shape',
1976 size: 'size',
1977 sizes: 'sizes',
1978 span: 'span',
1979 spellcheck: 'spellCheck',
1980 src: 'src',
1981 srcdoc: 'srcDoc',
1982 srclang: 'srcLang',
1983 srcset: 'srcSet',
1984 start: 'start',
1985 step: 'step',
1986 style: 'style',
1987 summary: 'summary',
1988 tabindex: 'tabIndex',
1989 target: 'target',
1990 title: 'title',
1991 type: 'type',
1992 usemap: 'useMap',
1993 value: 'value',
1994 width: 'width',
1995 wmode: 'wmode',
1996 wrap: 'wrap',
1997
1998 // SVG
1999 about: 'about',
2000 accentheight: 'accentHeight',
2001 'accent-height': 'accentHeight',
2002 accumulate: 'accumulate',
2003 additive: 'additive',
2004 alignmentbaseline: 'alignmentBaseline',
2005 'alignment-baseline': 'alignmentBaseline',
2006 allowreorder: 'allowReorder',
2007 alphabetic: 'alphabetic',
2008 amplitude: 'amplitude',
2009 arabicform: 'arabicForm',
2010 'arabic-form': 'arabicForm',
2011 ascent: 'ascent',
2012 attributename: 'attributeName',
2013 attributetype: 'attributeType',
2014 autoreverse: 'autoReverse',
2015 azimuth: 'azimuth',
2016 basefrequency: 'baseFrequency',
2017 baselineshift: 'baselineShift',
2018 'baseline-shift': 'baselineShift',
2019 baseprofile: 'baseProfile',
2020 bbox: 'bbox',
2021 begin: 'begin',
2022 bias: 'bias',
2023 by: 'by',
2024 calcmode: 'calcMode',
2025 capheight: 'capHeight',
2026 'cap-height': 'capHeight',
2027 clip: 'clip',
2028 clippath: 'clipPath',
2029 'clip-path': 'clipPath',
2030 clippathunits: 'clipPathUnits',
2031 cliprule: 'clipRule',
2032 'clip-rule': 'clipRule',
2033 color: 'color',
2034 colorinterpolation: 'colorInterpolation',
2035 'color-interpolation': 'colorInterpolation',
2036 colorinterpolationfilters: 'colorInterpolationFilters',
2037 'color-interpolation-filters': 'colorInterpolationFilters',
2038 colorprofile: 'colorProfile',
2039 'color-profile': 'colorProfile',
2040 colorrendering: 'colorRendering',
2041 'color-rendering': 'colorRendering',
2042 contentscripttype: 'contentScriptType',
2043 contentstyletype: 'contentStyleType',
2044 cursor: 'cursor',
2045 cx: 'cx',
2046 cy: 'cy',
2047 d: 'd',
2048 datatype: 'datatype',
2049 decelerate: 'decelerate',
2050 descent: 'descent',
2051 diffuseconstant: 'diffuseConstant',
2052 direction: 'direction',
2053 display: 'display',
2054 divisor: 'divisor',
2055 dominantbaseline: 'dominantBaseline',
2056 'dominant-baseline': 'dominantBaseline',
2057 dur: 'dur',
2058 dx: 'dx',
2059 dy: 'dy',
2060 edgemode: 'edgeMode',
2061 elevation: 'elevation',
2062 enablebackground: 'enableBackground',
2063 'enable-background': 'enableBackground',
2064 end: 'end',
2065 exponent: 'exponent',
2066 externalresourcesrequired: 'externalResourcesRequired',
2067 fill: 'fill',
2068 fillopacity: 'fillOpacity',
2069 'fill-opacity': 'fillOpacity',
2070 fillrule: 'fillRule',
2071 'fill-rule': 'fillRule',
2072 filter: 'filter',
2073 filterres: 'filterRes',
2074 filterunits: 'filterUnits',
2075 floodopacity: 'floodOpacity',
2076 'flood-opacity': 'floodOpacity',
2077 floodcolor: 'floodColor',
2078 'flood-color': 'floodColor',
2079 focusable: 'focusable',
2080 fontfamily: 'fontFamily',
2081 'font-family': 'fontFamily',
2082 fontsize: 'fontSize',
2083 'font-size': 'fontSize',
2084 fontsizeadjust: 'fontSizeAdjust',
2085 'font-size-adjust': 'fontSizeAdjust',
2086 fontstretch: 'fontStretch',
2087 'font-stretch': 'fontStretch',
2088 fontstyle: 'fontStyle',
2089 'font-style': 'fontStyle',
2090 fontvariant: 'fontVariant',
2091 'font-variant': 'fontVariant',
2092 fontweight: 'fontWeight',
2093 'font-weight': 'fontWeight',
2094 format: 'format',
2095 from: 'from',
2096 fx: 'fx',
2097 fy: 'fy',
2098 g1: 'g1',
2099 g2: 'g2',
2100 glyphname: 'glyphName',
2101 'glyph-name': 'glyphName',
2102 glyphorientationhorizontal: 'glyphOrientationHorizontal',
2103 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
2104 glyphorientationvertical: 'glyphOrientationVertical',
2105 'glyph-orientation-vertical': 'glyphOrientationVertical',
2106 glyphref: 'glyphRef',
2107 gradienttransform: 'gradientTransform',
2108 gradientunits: 'gradientUnits',
2109 hanging: 'hanging',
2110 horizadvx: 'horizAdvX',
2111 'horiz-adv-x': 'horizAdvX',
2112 horizoriginx: 'horizOriginX',
2113 'horiz-origin-x': 'horizOriginX',
2114 ideographic: 'ideographic',
2115 imagerendering: 'imageRendering',
2116 'image-rendering': 'imageRendering',
2117 in2: 'in2',
2118 in: 'in',
2119 inlist: 'inlist',
2120 intercept: 'intercept',
2121 k1: 'k1',
2122 k2: 'k2',
2123 k3: 'k3',
2124 k4: 'k4',
2125 k: 'k',
2126 kernelmatrix: 'kernelMatrix',
2127 kernelunitlength: 'kernelUnitLength',
2128 kerning: 'kerning',
2129 keypoints: 'keyPoints',
2130 keysplines: 'keySplines',
2131 keytimes: 'keyTimes',
2132 lengthadjust: 'lengthAdjust',
2133 letterspacing: 'letterSpacing',
2134 'letter-spacing': 'letterSpacing',
2135 lightingcolor: 'lightingColor',
2136 'lighting-color': 'lightingColor',
2137 limitingconeangle: 'limitingConeAngle',
2138 local: 'local',
2139 markerend: 'markerEnd',
2140 'marker-end': 'markerEnd',
2141 markerheight: 'markerHeight',
2142 markermid: 'markerMid',
2143 'marker-mid': 'markerMid',
2144 markerstart: 'markerStart',
2145 'marker-start': 'markerStart',
2146 markerunits: 'markerUnits',
2147 markerwidth: 'markerWidth',
2148 mask: 'mask',
2149 maskcontentunits: 'maskContentUnits',
2150 maskunits: 'maskUnits',
2151 mathematical: 'mathematical',
2152 mode: 'mode',
2153 numoctaves: 'numOctaves',
2154 offset: 'offset',
2155 opacity: 'opacity',
2156 operator: 'operator',
2157 order: 'order',
2158 orient: 'orient',
2159 orientation: 'orientation',
2160 origin: 'origin',
2161 overflow: 'overflow',
2162 overlineposition: 'overlinePosition',
2163 'overline-position': 'overlinePosition',
2164 overlinethickness: 'overlineThickness',
2165 'overline-thickness': 'overlineThickness',
2166 paintorder: 'paintOrder',
2167 'paint-order': 'paintOrder',
2168 panose1: 'panose1',
2169 'panose-1': 'panose1',
2170 pathlength: 'pathLength',
2171 patterncontentunits: 'patternContentUnits',
2172 patterntransform: 'patternTransform',
2173 patternunits: 'patternUnits',
2174 pointerevents: 'pointerEvents',
2175 'pointer-events': 'pointerEvents',
2176 points: 'points',
2177 pointsatx: 'pointsAtX',
2178 pointsaty: 'pointsAtY',
2179 pointsatz: 'pointsAtZ',
2180 prefix: 'prefix',
2181 preservealpha: 'preserveAlpha',
2182 preserveaspectratio: 'preserveAspectRatio',
2183 primitiveunits: 'primitiveUnits',
2184 property: 'property',
2185 r: 'r',
2186 radius: 'radius',
2187 refx: 'refX',
2188 refy: 'refY',
2189 renderingintent: 'renderingIntent',
2190 'rendering-intent': 'renderingIntent',
2191 repeatcount: 'repeatCount',
2192 repeatdur: 'repeatDur',
2193 requiredextensions: 'requiredExtensions',
2194 requiredfeatures: 'requiredFeatures',
2195 resource: 'resource',
2196 restart: 'restart',
2197 result: 'result',
2198 results: 'results',
2199 rotate: 'rotate',
2200 rx: 'rx',
2201 ry: 'ry',
2202 scale: 'scale',
2203 security: 'security',
2204 seed: 'seed',
2205 shaperendering: 'shapeRendering',
2206 'shape-rendering': 'shapeRendering',
2207 slope: 'slope',
2208 spacing: 'spacing',
2209 specularconstant: 'specularConstant',
2210 specularexponent: 'specularExponent',
2211 speed: 'speed',
2212 spreadmethod: 'spreadMethod',
2213 startoffset: 'startOffset',
2214 stddeviation: 'stdDeviation',
2215 stemh: 'stemh',
2216 stemv: 'stemv',
2217 stitchtiles: 'stitchTiles',
2218 stopcolor: 'stopColor',
2219 'stop-color': 'stopColor',
2220 stopopacity: 'stopOpacity',
2221 'stop-opacity': 'stopOpacity',
2222 strikethroughposition: 'strikethroughPosition',
2223 'strikethrough-position': 'strikethroughPosition',
2224 strikethroughthickness: 'strikethroughThickness',
2225 'strikethrough-thickness': 'strikethroughThickness',
2226 string: 'string',
2227 stroke: 'stroke',
2228 strokedasharray: 'strokeDasharray',
2229 'stroke-dasharray': 'strokeDasharray',
2230 strokedashoffset: 'strokeDashoffset',
2231 'stroke-dashoffset': 'strokeDashoffset',
2232 strokelinecap: 'strokeLinecap',
2233 'stroke-linecap': 'strokeLinecap',
2234 strokelinejoin: 'strokeLinejoin',
2235 'stroke-linejoin': 'strokeLinejoin',
2236 strokemiterlimit: 'strokeMiterlimit',
2237 'stroke-miterlimit': 'strokeMiterlimit',
2238 strokewidth: 'strokeWidth',
2239 'stroke-width': 'strokeWidth',
2240 strokeopacity: 'strokeOpacity',
2241 'stroke-opacity': 'strokeOpacity',
2242 suppresscontenteditablewarning: 'suppressContentEditableWarning',
2243 suppresshydrationwarning: 'suppressHydrationWarning',
2244 surfacescale: 'surfaceScale',
2245 systemlanguage: 'systemLanguage',
2246 tablevalues: 'tableValues',
2247 targetx: 'targetX',
2248 targety: 'targetY',
2249 textanchor: 'textAnchor',
2250 'text-anchor': 'textAnchor',
2251 textdecoration: 'textDecoration',
2252 'text-decoration': 'textDecoration',
2253 textlength: 'textLength',
2254 textrendering: 'textRendering',
2255 'text-rendering': 'textRendering',
2256 to: 'to',
2257 transform: 'transform',
2258 typeof: 'typeof',
2259 u1: 'u1',
2260 u2: 'u2',
2261 underlineposition: 'underlinePosition',
2262 'underline-position': 'underlinePosition',
2263 underlinethickness: 'underlineThickness',
2264 'underline-thickness': 'underlineThickness',
2265 unicode: 'unicode',
2266 unicodebidi: 'unicodeBidi',
2267 'unicode-bidi': 'unicodeBidi',
2268 unicoderange: 'unicodeRange',
2269 'unicode-range': 'unicodeRange',
2270 unitsperem: 'unitsPerEm',
2271 'units-per-em': 'unitsPerEm',
2272 unselectable: 'unselectable',
2273 valphabetic: 'vAlphabetic',
2274 'v-alphabetic': 'vAlphabetic',
2275 values: 'values',
2276 vectoreffect: 'vectorEffect',
2277 'vector-effect': 'vectorEffect',
2278 version: 'version',
2279 vertadvy: 'vertAdvY',
2280 'vert-adv-y': 'vertAdvY',
2281 vertoriginx: 'vertOriginX',
2282 'vert-origin-x': 'vertOriginX',
2283 vertoriginy: 'vertOriginY',
2284 'vert-origin-y': 'vertOriginY',
2285 vhanging: 'vHanging',
2286 'v-hanging': 'vHanging',
2287 videographic: 'vIdeographic',
2288 'v-ideographic': 'vIdeographic',
2289 viewbox: 'viewBox',
2290 viewtarget: 'viewTarget',
2291 visibility: 'visibility',
2292 vmathematical: 'vMathematical',
2293 'v-mathematical': 'vMathematical',
2294 vocab: 'vocab',
2295 widths: 'widths',
2296 wordspacing: 'wordSpacing',
2297 'word-spacing': 'wordSpacing',
2298 writingmode: 'writingMode',
2299 'writing-mode': 'writingMode',
2300 x1: 'x1',
2301 x2: 'x2',
2302 x: 'x',
2303 xchannelselector: 'xChannelSelector',
2304 xheight: 'xHeight',
2305 'x-height': 'xHeight',
2306 xlinkactuate: 'xlinkActuate',
2307 'xlink:actuate': 'xlinkActuate',
2308 xlinkarcrole: 'xlinkArcrole',
2309 'xlink:arcrole': 'xlinkArcrole',
2310 xlinkhref: 'xlinkHref',
2311 'xlink:href': 'xlinkHref',
2312 xlinkrole: 'xlinkRole',
2313 'xlink:role': 'xlinkRole',
2314 xlinkshow: 'xlinkShow',
2315 'xlink:show': 'xlinkShow',
2316 xlinktitle: 'xlinkTitle',
2317 'xlink:title': 'xlinkTitle',
2318 xlinktype: 'xlinkType',
2319 'xlink:type': 'xlinkType',
2320 xmlbase: 'xmlBase',
2321 'xml:base': 'xmlBase',
2322 xmllang: 'xmlLang',
2323 'xml:lang': 'xmlLang',
2324 xmlns: 'xmlns',
2325 'xml:space': 'xmlSpace',
2326 xmlnsxlink: 'xmlnsXlink',
2327 'xmlns:xlink': 'xmlnsXlink',
2328 xmlspace: 'xmlSpace',
2329 y1: 'y1',
2330 y2: 'y2',
2331 y: 'y',
2332 ychannelselector: 'yChannelSelector',
2333 z: 'z',
2334 zoomandpan: 'zoomAndPan'
2335};
2336
2337var validateProperty$1 = function () {};
2338
2339{
2340 var warnedProperties$1 = {};
2341 var _hasOwnProperty = Object.prototype.hasOwnProperty;
2342 var EVENT_NAME_REGEX = /^on./;
2343 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
2344 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
2345 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
2346
2347 validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
2348 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
2349 return true;
2350 }
2351
2352 var lowerCasedName = name.toLowerCase();
2353 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
2354 warning$1(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.');
2355 warnedProperties$1[name] = true;
2356 return true;
2357 }
2358
2359 // We can't rely on the event system being injected on the server.
2360 if (canUseEventSystem) {
2361 if (registrationNameModules.hasOwnProperty(name)) {
2362 return true;
2363 }
2364 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
2365 if (registrationName != null) {
2366 warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
2367 warnedProperties$1[name] = true;
2368 return true;
2369 }
2370 if (EVENT_NAME_REGEX.test(name)) {
2371 warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
2372 warnedProperties$1[name] = true;
2373 return true;
2374 }
2375 } else if (EVENT_NAME_REGEX.test(name)) {
2376 // If no event plugins have been injected, we are in a server environment.
2377 // So we can't tell if the event name is correct for sure, but we can filter
2378 // out known bad ones like `onclick`. We can't suggest a specific replacement though.
2379 if (INVALID_EVENT_NAME_REGEX.test(name)) {
2380 warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
2381 }
2382 warnedProperties$1[name] = true;
2383 return true;
2384 }
2385
2386 // Let the ARIA attribute hook validate ARIA attributes
2387 if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
2388 return true;
2389 }
2390
2391 if (lowerCasedName === 'innerhtml') {
2392 warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
2393 warnedProperties$1[name] = true;
2394 return true;
2395 }
2396
2397 if (lowerCasedName === 'aria') {
2398 warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
2399 warnedProperties$1[name] = true;
2400 return true;
2401 }
2402
2403 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
2404 warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
2405 warnedProperties$1[name] = true;
2406 return true;
2407 }
2408
2409 if (typeof value === 'number' && isNaN(value)) {
2410 warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
2411 warnedProperties$1[name] = true;
2412 return true;
2413 }
2414
2415 var propertyInfo = getPropertyInfo(name);
2416 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
2417
2418 // Known attributes should match the casing specified in the property config.
2419 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
2420 var standardName = possibleStandardNames[lowerCasedName];
2421 if (standardName !== name) {
2422 warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
2423 warnedProperties$1[name] = true;
2424 return true;
2425 }
2426 } else if (!isReserved && name !== lowerCasedName) {
2427 // Unknown attributes should have lowercase casing since that's how they
2428 // will be cased anyway with server rendering.
2429 warning$1(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.', name, lowerCasedName);
2430 warnedProperties$1[name] = true;
2431 return true;
2432 }
2433
2434 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
2435 if (value) {
2436 warning$1(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()}.', value, name, name, value, name);
2437 } else {
2438 warning$1(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.', value, name, name, value, name, name, name);
2439 }
2440 warnedProperties$1[name] = true;
2441 return true;
2442 }
2443
2444 // Now that we've validated casing, do not validate
2445 // data types for reserved props
2446 if (isReserved) {
2447 return true;
2448 }
2449
2450 // Warn when a known attribute is a bad type
2451 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
2452 warnedProperties$1[name] = true;
2453 return false;
2454 }
2455
2456 // Warn when passing the strings 'false' or 'true' into a boolean prop
2457 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
2458 warning$1(false, 'Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
2459 warnedProperties$1[name] = true;
2460 return true;
2461 }
2462
2463 return true;
2464 };
2465}
2466
2467var warnUnknownProperties = function (type, props, canUseEventSystem) {
2468 var unknownProps = [];
2469 for (var key in props) {
2470 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
2471 if (!isValid) {
2472 unknownProps.push(key);
2473 }
2474 }
2475
2476 var unknownPropString = unknownProps.map(function (prop) {
2477 return '`' + prop + '`';
2478 }).join(', ');
2479 if (unknownProps.length === 1) {
2480 warning$1(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', unknownPropString, type);
2481 } else if (unknownProps.length > 1) {
2482 warning$1(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', unknownPropString, type);
2483 }
2484};
2485
2486function validateProperties$2(type, props, canUseEventSystem) {
2487 if (isCustomComponent(type, props)) {
2488 return;
2489 }
2490 warnUnknownProperties(type, props, canUseEventSystem);
2491}
2492
2493function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2494
2495// Based on reading the React.Children implementation. TODO: type this somewhere?
2496
2497var toArray = React.Children.toArray;
2498
2499// This is only used in DEV.
2500// Each entry is `this.stack` from a currently executing renderer instance.
2501// (There may be more than one because ReactDOMServer is reentrant).
2502// Each stack is an array of frames which may contain nested stacks of elements.
2503var currentDebugStacks = [];
2504
2505var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
2506var ReactDebugCurrentFrame = void 0;
2507var prevGetCurrentStackImpl = null;
2508var getCurrentServerStackImpl = function () {
2509 return '';
2510};
2511var describeStackFrame = function (element) {
2512 return '';
2513};
2514
2515var validatePropertiesInDevelopment = function (type, props) {};
2516var pushCurrentDebugStack = function (stack) {};
2517var pushElementToDebugStack = function (element) {};
2518var popCurrentDebugStack = function () {};
2519var hasWarnedAboutUsingContextAsConsumer = false;
2520
2521{
2522 ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
2523
2524 validatePropertiesInDevelopment = function (type, props) {
2525 validateProperties(type, props);
2526 validateProperties$1(type, props);
2527 validateProperties$2(type, props, /* canUseEventSystem */false);
2528 };
2529
2530 describeStackFrame = function (element) {
2531 var source = element._source;
2532 var type = element.type;
2533 var name = getComponentName(type);
2534 var ownerName = null;
2535 return describeComponentFrame(name, source, ownerName);
2536 };
2537
2538 pushCurrentDebugStack = function (stack) {
2539 currentDebugStacks.push(stack);
2540
2541 if (currentDebugStacks.length === 1) {
2542 // We are entering a server renderer.
2543 // Remember the previous (e.g. client) global stack implementation.
2544 prevGetCurrentStackImpl = ReactDebugCurrentFrame.getCurrentStack;
2545 ReactDebugCurrentFrame.getCurrentStack = getCurrentServerStackImpl;
2546 }
2547 };
2548
2549 pushElementToDebugStack = function (element) {
2550 // For the innermost executing ReactDOMServer call,
2551 var stack = currentDebugStacks[currentDebugStacks.length - 1];
2552 // Take the innermost executing frame (e.g. <Foo>),
2553 var frame = stack[stack.length - 1];
2554 // and record that it has one more element associated with it.
2555 frame.debugElementStack.push(element);
2556 // We only need this because we tail-optimize single-element
2557 // children and directly handle them in an inner loop instead of
2558 // creating separate frames for them.
2559 };
2560
2561 popCurrentDebugStack = function () {
2562 currentDebugStacks.pop();
2563
2564 if (currentDebugStacks.length === 0) {
2565 // We are exiting the server renderer.
2566 // Restore the previous (e.g. client) global stack implementation.
2567 ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
2568 prevGetCurrentStackImpl = null;
2569 }
2570 };
2571
2572 getCurrentServerStackImpl = function () {
2573 if (currentDebugStacks.length === 0) {
2574 // Nothing is currently rendering.
2575 return '';
2576 }
2577 // ReactDOMServer is reentrant so there may be multiple calls at the same time.
2578 // Take the frames from the innermost call which is the last in the array.
2579 var frames = currentDebugStacks[currentDebugStacks.length - 1];
2580 var stack = '';
2581 // Go through every frame in the stack from the innermost one.
2582 for (var i = frames.length - 1; i >= 0; i--) {
2583 var frame = frames[i];
2584 // Every frame might have more than one debug element stack entry associated with it.
2585 // This is because single-child nesting doesn't create materialized frames.
2586 // Instead it would push them through `pushElementToDebugStack()`.
2587 var _debugElementStack = frame.debugElementStack;
2588 for (var ii = _debugElementStack.length - 1; ii >= 0; ii--) {
2589 stack += describeStackFrame(_debugElementStack[ii]);
2590 }
2591 }
2592 return stack;
2593 };
2594}
2595
2596var didWarnDefaultInputValue = false;
2597var didWarnDefaultChecked = false;
2598var didWarnDefaultSelectValue = false;
2599var didWarnDefaultTextareaValue = false;
2600var didWarnInvalidOptionChildren = false;
2601var didWarnAboutNoopUpdateForComponent = {};
2602var didWarnAboutBadClass = {};
2603var didWarnAboutDeprecatedWillMount = {};
2604var didWarnAboutUndefinedDerivedState = {};
2605var didWarnAboutUninitializedState = {};
2606var valuePropNames = ['value', 'defaultValue'];
2607var newlineEatingTags = {
2608 listing: true,
2609 pre: true,
2610 textarea: true
2611};
2612
2613// We accept any tag to be rendered but since this gets injected into arbitrary
2614// HTML, we want to make sure that it's a safe tag.
2615// http://www.w3.org/TR/REC-xml/#NT-Name
2616var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
2617var validatedTagCache = {};
2618function validateDangerousTag(tag) {
2619 if (!validatedTagCache.hasOwnProperty(tag)) {
2620 !VALID_TAG_REGEX.test(tag) ? invariant(false, 'Invalid tag: %s', tag) : void 0;
2621 validatedTagCache[tag] = true;
2622 }
2623}
2624
2625var styleNameCache = {};
2626var processStyleName = function (styleName) {
2627 if (styleNameCache.hasOwnProperty(styleName)) {
2628 return styleNameCache[styleName];
2629 }
2630 var result = hyphenateStyleName(styleName);
2631 styleNameCache[styleName] = result;
2632 return result;
2633};
2634
2635function createMarkupForStyles(styles) {
2636 var serialized = '';
2637 var delimiter = '';
2638 for (var styleName in styles) {
2639 if (!styles.hasOwnProperty(styleName)) {
2640 continue;
2641 }
2642 var isCustomProperty = styleName.indexOf('--') === 0;
2643 var styleValue = styles[styleName];
2644 {
2645 if (!isCustomProperty) {
2646 warnValidStyle$1(styleName, styleValue);
2647 }
2648 }
2649 if (styleValue != null) {
2650 serialized += delimiter + processStyleName(styleName) + ':';
2651 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
2652
2653 delimiter = ';';
2654 }
2655 }
2656 return serialized || null;
2657}
2658
2659function warnNoop(publicInstance, callerName) {
2660 {
2661 var _constructor = publicInstance.constructor;
2662 var componentName = _constructor && getComponentName(_constructor) || 'ReactClass';
2663 var warningKey = componentName + '.' + callerName;
2664 if (didWarnAboutNoopUpdateForComponent[warningKey]) {
2665 return;
2666 }
2667
2668 warningWithoutStack$1(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);
2669 didWarnAboutNoopUpdateForComponent[warningKey] = true;
2670 }
2671}
2672
2673function shouldConstruct(Component) {
2674 return Component.prototype && Component.prototype.isReactComponent;
2675}
2676
2677function getNonChildrenInnerMarkup(props) {
2678 var innerHTML = props.dangerouslySetInnerHTML;
2679 if (innerHTML != null) {
2680 if (innerHTML.__html != null) {
2681 return innerHTML.__html;
2682 }
2683 } else {
2684 var content = props.children;
2685 if (typeof content === 'string' || typeof content === 'number') {
2686 return escapeTextForBrowser(content);
2687 }
2688 }
2689 return null;
2690}
2691
2692function flattenTopLevelChildren(children) {
2693 if (!React.isValidElement(children)) {
2694 return toArray(children);
2695 }
2696 var element = children;
2697 if (element.type !== REACT_FRAGMENT_TYPE) {
2698 return [element];
2699 }
2700 var fragmentChildren = element.props.children;
2701 if (!React.isValidElement(fragmentChildren)) {
2702 return toArray(fragmentChildren);
2703 }
2704 var fragmentChildElement = fragmentChildren;
2705 return [fragmentChildElement];
2706}
2707
2708function flattenOptionChildren(children) {
2709 if (children === undefined || children === null) {
2710 return children;
2711 }
2712 var content = '';
2713 // Flatten children and warn if they aren't strings or numbers;
2714 // invalid types are ignored.
2715 React.Children.forEach(children, function (child) {
2716 if (child == null) {
2717 return;
2718 }
2719 content += child;
2720 {
2721 if (!didWarnInvalidOptionChildren && typeof child !== 'string' && typeof child !== 'number') {
2722 didWarnInvalidOptionChildren = true;
2723 warning$1(false, 'Only strings and numbers are supported as <option> children.');
2724 }
2725 }
2726 });
2727 return content;
2728}
2729
2730var hasOwnProperty = Object.prototype.hasOwnProperty;
2731var STYLE = 'style';
2732var RESERVED_PROPS = {
2733 children: null,
2734 dangerouslySetInnerHTML: null,
2735 suppressContentEditableWarning: null,
2736 suppressHydrationWarning: null
2737};
2738
2739function createOpenTagMarkup(tagVerbatim, tagLowercase, props, namespace, makeStaticMarkup, isRootElement) {
2740 var ret = '<' + tagVerbatim;
2741
2742 for (var propKey in props) {
2743 if (!hasOwnProperty.call(props, propKey)) {
2744 continue;
2745 }
2746 var propValue = props[propKey];
2747 if (propValue == null) {
2748 continue;
2749 }
2750 if (propKey === STYLE) {
2751 propValue = createMarkupForStyles(propValue);
2752 }
2753 var markup = null;
2754 if (isCustomComponent(tagLowercase, props)) {
2755 if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
2756 markup = createMarkupForCustomAttribute(propKey, propValue);
2757 }
2758 } else {
2759 markup = createMarkupForProperty(propKey, propValue);
2760 }
2761 if (markup) {
2762 ret += ' ' + markup;
2763 }
2764 }
2765
2766 // For static pages, no need to put React ID and checksum. Saves lots of
2767 // bytes.
2768 if (makeStaticMarkup) {
2769 return ret;
2770 }
2771
2772 if (isRootElement) {
2773 ret += ' ' + createMarkupForRoot();
2774 }
2775 return ret;
2776}
2777
2778function validateRenderResult(child, type) {
2779 if (child === undefined) {
2780 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');
2781 }
2782}
2783
2784function resolve(child, context, threadID) {
2785 while (React.isValidElement(child)) {
2786 // Safe because we just checked it's an element.
2787 var element = child;
2788 var Component = element.type;
2789 {
2790 pushElementToDebugStack(element);
2791 }
2792 if (typeof Component !== 'function') {
2793 break;
2794 }
2795 processChild(element, Component);
2796 }
2797
2798 // Extra closure so queue and replace can be captured properly
2799 function processChild(element, Component) {
2800 var publicContext = processContext(Component, context, threadID);
2801
2802 var queue = [];
2803 var replace = false;
2804 var updater = {
2805 isMounted: function (publicInstance) {
2806 return false;
2807 },
2808 enqueueForceUpdate: function (publicInstance) {
2809 if (queue === null) {
2810 warnNoop(publicInstance, 'forceUpdate');
2811 return null;
2812 }
2813 },
2814 enqueueReplaceState: function (publicInstance, completeState) {
2815 replace = true;
2816 queue = [completeState];
2817 },
2818 enqueueSetState: function (publicInstance, currentPartialState) {
2819 if (queue === null) {
2820 warnNoop(publicInstance, 'setState');
2821 return null;
2822 }
2823 queue.push(currentPartialState);
2824 }
2825 };
2826
2827 var inst = void 0;
2828 if (shouldConstruct(Component)) {
2829 inst = new Component(element.props, publicContext, updater);
2830
2831 if (typeof Component.getDerivedStateFromProps === 'function') {
2832 {
2833 if (inst.state === null || inst.state === undefined) {
2834 var componentName = getComponentName(Component) || 'Unknown';
2835 if (!didWarnAboutUninitializedState[componentName]) {
2836 warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, inst.state === null ? 'null' : 'undefined', componentName);
2837 didWarnAboutUninitializedState[componentName] = true;
2838 }
2839 }
2840 }
2841
2842 var partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
2843
2844 {
2845 if (partialState === undefined) {
2846 var _componentName = getComponentName(Component) || 'Unknown';
2847 if (!didWarnAboutUndefinedDerivedState[_componentName]) {
2848 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', _componentName);
2849 didWarnAboutUndefinedDerivedState[_componentName] = true;
2850 }
2851 }
2852 }
2853
2854 if (partialState != null) {
2855 inst.state = _assign({}, inst.state, partialState);
2856 }
2857 }
2858 } else {
2859 {
2860 if (Component.prototype && typeof Component.prototype.render === 'function') {
2861 var _componentName2 = getComponentName(Component) || 'Unknown';
2862
2863 if (!didWarnAboutBadClass[_componentName2]) {
2864 warningWithoutStack$1(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);
2865 didWarnAboutBadClass[_componentName2] = true;
2866 }
2867 }
2868 }
2869 var componentIdentity = {};
2870 prepareToUseHooks(componentIdentity);
2871 inst = Component(element.props, publicContext, updater);
2872 inst = finishHooks(Component, element.props, inst, publicContext);
2873
2874 if (inst == null || inst.render == null) {
2875 child = inst;
2876 validateRenderResult(child, Component);
2877 return;
2878 }
2879 }
2880
2881 inst.props = element.props;
2882 inst.context = publicContext;
2883 inst.updater = updater;
2884
2885 var initialState = inst.state;
2886 if (initialState === undefined) {
2887 inst.state = initialState = null;
2888 }
2889 if (typeof inst.UNSAFE_componentWillMount === 'function' || typeof inst.componentWillMount === 'function') {
2890 if (typeof inst.componentWillMount === 'function') {
2891 {
2892 if (warnAboutDeprecatedLifecycles && inst.componentWillMount.__suppressDeprecationWarning !== true) {
2893 var _componentName3 = getComponentName(Component) || 'Unknown';
2894
2895 if (!didWarnAboutDeprecatedWillMount[_componentName3]) {
2896 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);
2897 didWarnAboutDeprecatedWillMount[_componentName3] = true;
2898 }
2899 }
2900 }
2901
2902 // In order to support react-lifecycles-compat polyfilled components,
2903 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
2904 if (typeof Component.getDerivedStateFromProps !== 'function') {
2905 inst.componentWillMount();
2906 }
2907 }
2908 if (typeof inst.UNSAFE_componentWillMount === 'function' && typeof Component.getDerivedStateFromProps !== 'function') {
2909 // In order to support react-lifecycles-compat polyfilled components,
2910 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
2911 inst.UNSAFE_componentWillMount();
2912 }
2913 if (queue.length) {
2914 var oldQueue = queue;
2915 var oldReplace = replace;
2916 queue = null;
2917 replace = false;
2918
2919 if (oldReplace && oldQueue.length === 1) {
2920 inst.state = oldQueue[0];
2921 } else {
2922 var nextState = oldReplace ? oldQueue[0] : inst.state;
2923 var dontMutate = true;
2924 for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
2925 var partial = oldQueue[i];
2926 var _partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
2927 if (_partialState != null) {
2928 if (dontMutate) {
2929 dontMutate = false;
2930 nextState = _assign({}, nextState, _partialState);
2931 } else {
2932 _assign(nextState, _partialState);
2933 }
2934 }
2935 }
2936 inst.state = nextState;
2937 }
2938 } else {
2939 queue = null;
2940 }
2941 }
2942 child = inst.render();
2943
2944 {
2945 if (child === undefined && inst.render._isMockFunction) {
2946 // This is probably bad practice. Consider warning here and
2947 // deprecating this convenience.
2948 child = null;
2949 }
2950 }
2951 validateRenderResult(child, Component);
2952
2953 var childContext = void 0;
2954 if (typeof inst.getChildContext === 'function') {
2955 var childContextTypes = Component.childContextTypes;
2956 if (typeof childContextTypes === 'object') {
2957 childContext = inst.getChildContext();
2958 for (var contextKey in childContext) {
2959 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(Component) || 'Unknown', contextKey) : void 0;
2960 }
2961 } else {
2962 warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(Component) || 'Unknown');
2963 }
2964 }
2965 if (childContext) {
2966 context = _assign({}, context, childContext);
2967 }
2968 }
2969 return { child: child, context: context };
2970}
2971
2972var ReactDOMServerRenderer = function () {
2973 // DEV-only
2974
2975 // TODO: type this more strictly:
2976 function ReactDOMServerRenderer(children, makeStaticMarkup) {
2977 _classCallCheck(this, ReactDOMServerRenderer);
2978
2979 var flatChildren = flattenTopLevelChildren(children);
2980
2981 var topFrame = {
2982 type: null,
2983 // Assume all trees start in the HTML namespace (not totally true, but
2984 // this is what we did historically)
2985 domNamespace: Namespaces.html,
2986 children: flatChildren,
2987 childIndex: 0,
2988 context: emptyObject,
2989 footer: ''
2990 };
2991 {
2992 topFrame.debugElementStack = [];
2993 }
2994 this.threadID = allocThreadID();
2995 this.stack = [topFrame];
2996 this.exhausted = false;
2997 this.currentSelectValue = null;
2998 this.previousWasTextNode = false;
2999 this.makeStaticMarkup = makeStaticMarkup;
3000 this.suspenseDepth = 0;
3001
3002 // Context (new API)
3003 this.contextIndex = -1;
3004 this.contextStack = [];
3005 this.contextValueStack = [];
3006 {
3007 this.contextProviderStack = [];
3008 }
3009 }
3010
3011 ReactDOMServerRenderer.prototype.destroy = function destroy() {
3012 if (!this.exhausted) {
3013 this.exhausted = true;
3014 freeThreadID(this.threadID);
3015 }
3016 };
3017
3018 /**
3019 * Note: We use just two stacks regardless of how many context providers you have.
3020 * Providers are always popped in the reverse order to how they were pushed
3021 * so we always know on the way down which provider you'll encounter next on the way up.
3022 * On the way down, we push the current provider, and its context value *before*
3023 * we mutated it, onto the stacks. Therefore, on the way up, we always know which
3024 * provider needs to be "restored" to which value.
3025 * https://github.com/facebook/react/pull/12985#issuecomment-396301248
3026 */
3027
3028 ReactDOMServerRenderer.prototype.pushProvider = function pushProvider(provider) {
3029 var index = ++this.contextIndex;
3030 var context = provider.type._context;
3031 var threadID = this.threadID;
3032 validateContextBounds(context, threadID);
3033 var previousValue = context[threadID];
3034
3035 // Remember which value to restore this context to on our way up.
3036 this.contextStack[index] = context;
3037 this.contextValueStack[index] = previousValue;
3038 {
3039 // Only used for push/pop mismatch warnings.
3040 this.contextProviderStack[index] = provider;
3041 }
3042
3043 // Mutate the current value.
3044 context[threadID] = provider.props.value;
3045 };
3046
3047 ReactDOMServerRenderer.prototype.popProvider = function popProvider(provider) {
3048 var index = this.contextIndex;
3049 {
3050 !(index > -1 && provider === this.contextProviderStack[index]) ? warningWithoutStack$1(false, 'Unexpected pop.') : void 0;
3051 }
3052
3053 var context = this.contextStack[index];
3054 var previousValue = this.contextValueStack[index];
3055
3056 // "Hide" these null assignments from Flow by using `any`
3057 // because conceptually they are deletions--as long as we
3058 // promise to never access values beyond `this.contextIndex`.
3059 this.contextStack[index] = null;
3060 this.contextValueStack[index] = null;
3061 {
3062 this.contextProviderStack[index] = null;
3063 }
3064 this.contextIndex--;
3065
3066 // Restore to the previous value we stored as we were walking down.
3067 // We've already verified that this context has been expanded to accommodate
3068 // this thread id, so we don't need to do it again.
3069 context[this.threadID] = previousValue;
3070 };
3071
3072 ReactDOMServerRenderer.prototype.read = function read(bytes) {
3073 if (this.exhausted) {
3074 return null;
3075 }
3076
3077 var prevThreadID = currentThreadID;
3078 setCurrentThreadID(this.threadID);
3079 var prevDispatcher = ReactCurrentDispatcher.current;
3080 ReactCurrentDispatcher.current = Dispatcher;
3081 try {
3082 // Markup generated within <Suspense> ends up buffered until we know
3083 // nothing in that boundary suspended
3084 var out = [''];
3085 var suspended = false;
3086 while (out[0].length < bytes) {
3087 if (this.stack.length === 0) {
3088 this.exhausted = true;
3089 freeThreadID(this.threadID);
3090 break;
3091 }
3092 var frame = this.stack[this.stack.length - 1];
3093 if (suspended || frame.childIndex >= frame.children.length) {
3094 var _footer = frame.footer;
3095 if (_footer !== '') {
3096 this.previousWasTextNode = false;
3097 }
3098 this.stack.pop();
3099 if (frame.type === 'select') {
3100 this.currentSelectValue = null;
3101 } else if (frame.type != null && frame.type.type != null && frame.type.type.$$typeof === REACT_PROVIDER_TYPE) {
3102 var provider = frame.type;
3103 this.popProvider(provider);
3104 } else if (frame.type === REACT_SUSPENSE_TYPE) {
3105 this.suspenseDepth--;
3106 var buffered = out.pop();
3107
3108 if (suspended) {
3109 suspended = false;
3110 // If rendering was suspended at this boundary, render the fallbackFrame
3111 var _fallbackFrame = frame.fallbackFrame;
3112 !_fallbackFrame ? invariant(false, 'suspense fallback not found, something is broken') : void 0;
3113 this.stack.push(_fallbackFrame);
3114 // Skip flushing output since we're switching to the fallback
3115 continue;
3116 } else {
3117 out[this.suspenseDepth] += buffered;
3118 }
3119 }
3120
3121 // Flush output
3122 out[this.suspenseDepth] += _footer;
3123 continue;
3124 }
3125 var child = frame.children[frame.childIndex++];
3126
3127 var outBuffer = '';
3128 {
3129 pushCurrentDebugStack(this.stack);
3130 // We're starting work on this frame, so reset its inner stack.
3131 frame.debugElementStack.length = 0;
3132 }
3133 try {
3134 outBuffer += this.render(child, frame.context, frame.domNamespace);
3135 } catch (err) {
3136 if (enableSuspenseServerRenderer && typeof err.then === 'function') {
3137 suspended = true;
3138 } else {
3139 throw err;
3140 }
3141 } finally {
3142 {
3143 popCurrentDebugStack();
3144 }
3145 }
3146 if (out.length <= this.suspenseDepth) {
3147 out.push('');
3148 }
3149 out[this.suspenseDepth] += outBuffer;
3150 }
3151 return out[0];
3152 } finally {
3153 ReactCurrentDispatcher.current = prevDispatcher;
3154 setCurrentThreadID(prevThreadID);
3155 }
3156 };
3157
3158 ReactDOMServerRenderer.prototype.render = function render(child, context, parentNamespace) {
3159 if (typeof child === 'string' || typeof child === 'number') {
3160 var text = '' + child;
3161 if (text === '') {
3162 return '';
3163 }
3164 if (this.makeStaticMarkup) {
3165 return escapeTextForBrowser(text);
3166 }
3167 if (this.previousWasTextNode) {
3168 return '<!-- -->' + escapeTextForBrowser(text);
3169 }
3170 this.previousWasTextNode = true;
3171 return escapeTextForBrowser(text);
3172 } else {
3173 var nextChild = void 0;
3174
3175 var _resolve = resolve(child, context, this.threadID);
3176
3177 nextChild = _resolve.child;
3178 context = _resolve.context;
3179
3180 if (nextChild === null || nextChild === false) {
3181 return '';
3182 } else if (!React.isValidElement(nextChild)) {
3183 if (nextChild != null && nextChild.$$typeof != null) {
3184 // Catch unexpected special types early.
3185 var $$typeof = nextChild.$$typeof;
3186 !($$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;
3187 // Catch-all to prevent an infinite loop if React.Children.toArray() supports some new type.
3188 invariant(false, 'Unknown element-like object type: %s. This is likely a bug in React. Please file an issue.', $$typeof.toString());
3189 }
3190 var nextChildren = toArray(nextChild);
3191 var frame = {
3192 type: null,
3193 domNamespace: parentNamespace,
3194 children: nextChildren,
3195 childIndex: 0,
3196 context: context,
3197 footer: ''
3198 };
3199 {
3200 frame.debugElementStack = [];
3201 }
3202 this.stack.push(frame);
3203 return '';
3204 }
3205 // Safe because we just checked it's an element.
3206 var nextElement = nextChild;
3207 var elementType = nextElement.type;
3208
3209 if (typeof elementType === 'string') {
3210 return this.renderDOM(nextElement, context, parentNamespace);
3211 }
3212
3213 switch (elementType) {
3214 case REACT_STRICT_MODE_TYPE:
3215 case REACT_CONCURRENT_MODE_TYPE:
3216 case REACT_PROFILER_TYPE:
3217 case REACT_FRAGMENT_TYPE:
3218 {
3219 var _nextChildren = toArray(nextChild.props.children);
3220 var _frame = {
3221 type: null,
3222 domNamespace: parentNamespace,
3223 children: _nextChildren,
3224 childIndex: 0,
3225 context: context,
3226 footer: ''
3227 };
3228 {
3229 _frame.debugElementStack = [];
3230 }
3231 this.stack.push(_frame);
3232 return '';
3233 }
3234 case REACT_SUSPENSE_TYPE:
3235 {
3236 if (enableSuspenseServerRenderer) {
3237 var fallback = nextChild.props.fallback;
3238 if (fallback === undefined) {
3239 // If there is no fallback, then this just behaves as a fragment.
3240 var _nextChildren3 = toArray(nextChild.props.children);
3241 var _frame3 = {
3242 type: null,
3243 domNamespace: parentNamespace,
3244 children: _nextChildren3,
3245 childIndex: 0,
3246 context: context,
3247 footer: ''
3248 };
3249 {
3250 _frame3.debugElementStack = [];
3251 }
3252 this.stack.push(_frame3);
3253 return '';
3254 }
3255 var fallbackChildren = toArray(fallback);
3256 var _nextChildren2 = toArray(nextChild.props.children);
3257 var _fallbackFrame2 = {
3258 type: null,
3259 domNamespace: parentNamespace,
3260 children: fallbackChildren,
3261 childIndex: 0,
3262 context: context,
3263 footer: '',
3264 out: ''
3265 };
3266 var _frame2 = {
3267 fallbackFrame: _fallbackFrame2,
3268 type: REACT_SUSPENSE_TYPE,
3269 domNamespace: parentNamespace,
3270 children: _nextChildren2,
3271 childIndex: 0,
3272 context: context,
3273 footer: '<!--/$-->'
3274 };
3275 {
3276 _frame2.debugElementStack = [];
3277 _fallbackFrame2.debugElementStack = [];
3278 }
3279 this.stack.push(_frame2);
3280 this.suspenseDepth++;
3281 return '<!--$-->';
3282 } else {
3283 invariant(false, 'ReactDOMServer does not yet support Suspense.');
3284 }
3285 }
3286 // eslint-disable-next-line-no-fallthrough
3287 default:
3288 break;
3289 }
3290 if (typeof elementType === 'object' && elementType !== null) {
3291 switch (elementType.$$typeof) {
3292 case REACT_FORWARD_REF_TYPE:
3293 {
3294 var element = nextChild;
3295 var _nextChildren4 = void 0;
3296 var componentIdentity = {};
3297 prepareToUseHooks(componentIdentity);
3298 _nextChildren4 = elementType.render(element.props, element.ref);
3299 _nextChildren4 = finishHooks(elementType.render, element.props, _nextChildren4, element.ref);
3300 _nextChildren4 = toArray(_nextChildren4);
3301 var _frame4 = {
3302 type: null,
3303 domNamespace: parentNamespace,
3304 children: _nextChildren4,
3305 childIndex: 0,
3306 context: context,
3307 footer: ''
3308 };
3309 {
3310 _frame4.debugElementStack = [];
3311 }
3312 this.stack.push(_frame4);
3313 return '';
3314 }
3315 case REACT_MEMO_TYPE:
3316 {
3317 var _element = nextChild;
3318 var _nextChildren5 = [React.createElement(elementType.type, _assign({ ref: _element.ref }, _element.props))];
3319 var _frame5 = {
3320 type: null,
3321 domNamespace: parentNamespace,
3322 children: _nextChildren5,
3323 childIndex: 0,
3324 context: context,
3325 footer: ''
3326 };
3327 {
3328 _frame5.debugElementStack = [];
3329 }
3330 this.stack.push(_frame5);
3331 return '';
3332 }
3333 case REACT_PROVIDER_TYPE:
3334 {
3335 var provider = nextChild;
3336 var nextProps = provider.props;
3337 var _nextChildren6 = toArray(nextProps.children);
3338 var _frame6 = {
3339 type: provider,
3340 domNamespace: parentNamespace,
3341 children: _nextChildren6,
3342 childIndex: 0,
3343 context: context,
3344 footer: ''
3345 };
3346 {
3347 _frame6.debugElementStack = [];
3348 }
3349
3350 this.pushProvider(provider);
3351
3352 this.stack.push(_frame6);
3353 return '';
3354 }
3355 case REACT_CONTEXT_TYPE:
3356 {
3357 var reactContext = nextChild.type;
3358 // The logic below for Context differs depending on PROD or DEV mode. In
3359 // DEV mode, we create a separate object for Context.Consumer that acts
3360 // like a proxy to Context. This proxy object adds unnecessary code in PROD
3361 // so we use the old behaviour (Context.Consumer references Context) to
3362 // reduce size and overhead. The separate object references context via
3363 // a property called "_context", which also gives us the ability to check
3364 // in DEV mode if this property exists or not and warn if it does not.
3365 {
3366 if (reactContext._context === undefined) {
3367 // This may be because it's a Context (rather than a Consumer).
3368 // Or it may be because it's older React where they're the same thing.
3369 // We only want to warn if we're sure it's a new React.
3370 if (reactContext !== reactContext.Consumer) {
3371 if (!hasWarnedAboutUsingContextAsConsumer) {
3372 hasWarnedAboutUsingContextAsConsumer = true;
3373 warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
3374 }
3375 }
3376 } else {
3377 reactContext = reactContext._context;
3378 }
3379 }
3380 var _nextProps = nextChild.props;
3381 var threadID = this.threadID;
3382 validateContextBounds(reactContext, threadID);
3383 var nextValue = reactContext[threadID];
3384
3385 var _nextChildren7 = toArray(_nextProps.children(nextValue));
3386 var _frame7 = {
3387 type: nextChild,
3388 domNamespace: parentNamespace,
3389 children: _nextChildren7,
3390 childIndex: 0,
3391 context: context,
3392 footer: ''
3393 };
3394 {
3395 _frame7.debugElementStack = [];
3396 }
3397 this.stack.push(_frame7);
3398 return '';
3399 }
3400 case REACT_LAZY_TYPE:
3401 invariant(false, 'ReactDOMServer does not yet support lazy-loaded components.');
3402 }
3403 }
3404
3405 var info = '';
3406 {
3407 var owner = nextElement._owner;
3408 if (elementType === undefined || typeof elementType === 'object' && elementType !== null && Object.keys(elementType).length === 0) {
3409 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.';
3410 }
3411 var ownerName = owner ? getComponentName(owner) : null;
3412 if (ownerName) {
3413 info += '\n\nCheck the render method of `' + ownerName + '`.';
3414 }
3415 }
3416 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);
3417 }
3418 };
3419
3420 ReactDOMServerRenderer.prototype.renderDOM = function renderDOM(element, context, parentNamespace) {
3421 var tag = element.type.toLowerCase();
3422
3423 var namespace = parentNamespace;
3424 if (parentNamespace === Namespaces.html) {
3425 namespace = getIntrinsicNamespace(tag);
3426 }
3427
3428 {
3429 if (namespace === Namespaces.html) {
3430 // Should this check be gated by parent namespace? Not sure we want to
3431 // allow <SVG> or <mATH>.
3432 !(tag === element.type) ? warning$1(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', element.type) : void 0;
3433 }
3434 }
3435
3436 validateDangerousTag(tag);
3437
3438 var props = element.props;
3439 if (tag === 'input') {
3440 {
3441 ReactControlledValuePropTypes.checkPropTypes('input', props);
3442
3443 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnDefaultChecked) {
3444 warning$1(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);
3445 didWarnDefaultChecked = true;
3446 }
3447 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultInputValue) {
3448 warning$1(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);
3449 didWarnDefaultInputValue = true;
3450 }
3451 }
3452
3453 props = _assign({
3454 type: undefined
3455 }, props, {
3456 defaultChecked: undefined,
3457 defaultValue: undefined,
3458 value: props.value != null ? props.value : props.defaultValue,
3459 checked: props.checked != null ? props.checked : props.defaultChecked
3460 });
3461 } else if (tag === 'textarea') {
3462 {
3463 ReactControlledValuePropTypes.checkPropTypes('textarea', props);
3464 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultTextareaValue) {
3465 warning$1(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');
3466 didWarnDefaultTextareaValue = true;
3467 }
3468 }
3469
3470 var initialValue = props.value;
3471 if (initialValue == null) {
3472 var defaultValue = props.defaultValue;
3473 // TODO (yungsters): Remove support for children content in <textarea>.
3474 var textareaChildren = props.children;
3475 if (textareaChildren != null) {
3476 {
3477 warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
3478 }
3479 !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0;
3480 if (Array.isArray(textareaChildren)) {
3481 !(textareaChildren.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0;
3482 textareaChildren = textareaChildren[0];
3483 }
3484
3485 defaultValue = '' + textareaChildren;
3486 }
3487 if (defaultValue == null) {
3488 defaultValue = '';
3489 }
3490 initialValue = defaultValue;
3491 }
3492
3493 props = _assign({}, props, {
3494 value: undefined,
3495 children: '' + initialValue
3496 });
3497 } else if (tag === 'select') {
3498 {
3499 ReactControlledValuePropTypes.checkPropTypes('select', props);
3500
3501 for (var i = 0; i < valuePropNames.length; i++) {
3502 var propName = valuePropNames[i];
3503 if (props[propName] == null) {
3504 continue;
3505 }
3506 var isArray = Array.isArray(props[propName]);
3507 if (props.multiple && !isArray) {
3508 warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.', propName);
3509 } else if (!props.multiple && isArray) {
3510 warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.', propName);
3511 }
3512 }
3513
3514 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultSelectValue) {
3515 warning$1(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');
3516 didWarnDefaultSelectValue = true;
3517 }
3518 }
3519 this.currentSelectValue = props.value != null ? props.value : props.defaultValue;
3520 props = _assign({}, props, {
3521 value: undefined
3522 });
3523 } else if (tag === 'option') {
3524 var selected = null;
3525 var selectValue = this.currentSelectValue;
3526 var optionChildren = flattenOptionChildren(props.children);
3527 if (selectValue != null) {
3528 var value = void 0;
3529 if (props.value != null) {
3530 value = props.value + '';
3531 } else {
3532 value = optionChildren;
3533 }
3534 selected = false;
3535 if (Array.isArray(selectValue)) {
3536 // multiple
3537 for (var j = 0; j < selectValue.length; j++) {
3538 if ('' + selectValue[j] === value) {
3539 selected = true;
3540 break;
3541 }
3542 }
3543 } else {
3544 selected = '' + selectValue === value;
3545 }
3546
3547 props = _assign({
3548 selected: undefined,
3549 children: undefined
3550 }, props, {
3551 selected: selected,
3552 children: optionChildren
3553 });
3554 }
3555 }
3556
3557 {
3558 validatePropertiesInDevelopment(tag, props);
3559 }
3560
3561 assertValidProps(tag, props);
3562
3563 var out = createOpenTagMarkup(element.type, tag, props, namespace, this.makeStaticMarkup, this.stack.length === 1);
3564 var footer = '';
3565 if (omittedCloseTags.hasOwnProperty(tag)) {
3566 out += '/>';
3567 } else {
3568 out += '>';
3569 footer = '</' + element.type + '>';
3570 }
3571 var children = void 0;
3572 var innerMarkup = getNonChildrenInnerMarkup(props);
3573 if (innerMarkup != null) {
3574 children = [];
3575 if (newlineEatingTags[tag] && innerMarkup.charAt(0) === '\n') {
3576 // text/html ignores the first character in these tags if it's a newline
3577 // Prefer to break application/xml over text/html (for now) by adding
3578 // a newline specifically to get eaten by the parser. (Alternately for
3579 // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
3580 // \r is normalized out by HTMLTextAreaElement#value.)
3581 // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
3582 // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
3583 // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
3584 // See: Parsing of "textarea" "listing" and "pre" elements
3585 // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
3586 out += '\n';
3587 }
3588 out += innerMarkup;
3589 } else {
3590 children = toArray(props.children);
3591 }
3592 var frame = {
3593 domNamespace: getChildNamespace(parentNamespace, element.type),
3594 type: tag,
3595 children: children,
3596 childIndex: 0,
3597 context: context,
3598 footer: footer
3599 };
3600 {
3601 frame.debugElementStack = [];
3602 }
3603 this.stack.push(frame);
3604 this.previousWasTextNode = false;
3605 return out;
3606 };
3607
3608 return ReactDOMServerRenderer;
3609}();
3610
3611/**
3612 * Render a ReactElement to its initial HTML. This should only be used on the
3613 * server.
3614 * See https://reactjs.org/docs/react-dom-server.html#rendertostring
3615 */
3616function renderToString(element) {
3617 var renderer = new ReactDOMServerRenderer(element, false);
3618 try {
3619 var markup = renderer.read(Infinity);
3620 return markup;
3621 } finally {
3622 renderer.destroy();
3623 }
3624}
3625
3626/**
3627 * Similar to renderToString, except this doesn't create extra DOM attributes
3628 * such as data-react-id that React uses internally.
3629 * See https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup
3630 */
3631function renderToStaticMarkup(element) {
3632 var renderer = new ReactDOMServerRenderer(element, true);
3633 try {
3634 var markup = renderer.read(Infinity);
3635 return markup;
3636 } finally {
3637 renderer.destroy();
3638 }
3639}
3640
3641function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3642
3643function _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; }
3644
3645function _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; }
3646
3647// This is a Readable Node.js stream which wraps the ReactDOMPartialRenderer.
3648
3649var ReactMarkupReadableStream = function (_Readable) {
3650 _inherits(ReactMarkupReadableStream, _Readable);
3651
3652 function ReactMarkupReadableStream(element, makeStaticMarkup) {
3653 _classCallCheck$1(this, ReactMarkupReadableStream);
3654
3655 var _this = _possibleConstructorReturn(this, _Readable.call(this, {}));
3656 // Calls the stream.Readable(options) constructor. Consider exposing built-in
3657 // features like highWaterMark in the future.
3658
3659
3660 _this.partialRenderer = new ReactDOMServerRenderer(element, makeStaticMarkup);
3661 return _this;
3662 }
3663
3664 ReactMarkupReadableStream.prototype._destroy = function _destroy(err, callback) {
3665 this.partialRenderer.destroy();
3666 callback(err);
3667 };
3668
3669 ReactMarkupReadableStream.prototype._read = function _read(size) {
3670 try {
3671 this.push(this.partialRenderer.read(size));
3672 } catch (err) {
3673 this.destroy(err);
3674 }
3675 };
3676
3677 return ReactMarkupReadableStream;
3678}(stream.Readable);
3679/**
3680 * Render a ReactElement to its initial HTML. This should only be used on the
3681 * server.
3682 * See https://reactjs.org/docs/react-dom-server.html#rendertonodestream
3683 */
3684
3685
3686function renderToNodeStream(element) {
3687 return new ReactMarkupReadableStream(element, false);
3688}
3689
3690/**
3691 * Similar to renderToNodeStream, except this doesn't create extra DOM attributes
3692 * such as data-react-id that React uses internally.
3693 * See https://reactjs.org/docs/react-dom-server.html#rendertostaticnodestream
3694 */
3695function renderToStaticNodeStream(element) {
3696 return new ReactMarkupReadableStream(element, true);
3697}
3698
3699// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
3700var ReactDOMServerNode = {
3701 renderToString: renderToString,
3702 renderToStaticMarkup: renderToStaticMarkup,
3703 renderToNodeStream: renderToNodeStream,
3704 renderToStaticNodeStream: renderToStaticNodeStream,
3705 version: ReactVersion
3706};
3707
3708var ReactDOMServerNode$1 = Object.freeze({
3709 default: ReactDOMServerNode
3710});
3711
3712var ReactDOMServer = ( ReactDOMServerNode$1 && ReactDOMServerNode ) || ReactDOMServerNode$1;
3713
3714// TODO: decide on the top-level export form.
3715// This is hacky but makes it work with both Rollup and Jest
3716var server_node = ReactDOMServer.default || ReactDOMServer;
3717
3718module.exports = server_node;
3719 })();
3720}