/** * @license React * react-dom-server.node.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; if (process.env.NODE_ENV !== "production") { (function() { 'use strict'; var React = require('react'); var util = require('util'); var async_hooks = require('async_hooks'); var ReactDOM = require('react-dom'); var ReactVersion = '18.3.0-next-3ba7add60-20221201'; var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // by calls to these methods by a Babel plugin. // // In PROD (or in packages without access to React internals), // they are left as they are instead. function warn(format) { { { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } printWarning('warn', format, args); } } } function error(format) { { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } printWarning('error', format, args); } } } function printWarning(level, format, args) { // When changing this logic, you might want to also // update consoleWithStackDev.www.js as well. { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ReactDebugCurrentFrame.getStackAddendum(); if (stack !== '') { format += '%s'; args = args.concat([stack]); } // eslint-disable-next-line react-internal/safe-string-coercion var argsWithFormat = args.map(function (item) { return String(item); }); // Careful: RN currently depends on this prefix argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it // breaks IE9: https://github.com/facebook/react/issues/13610 // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], console, argsWithFormat); } } function scheduleWork(callback) { setImmediate(callback); } function flushBuffered(destination) { // If we don't have any more data to send right now. // Flush whatever is in the buffer to the wire. if (typeof destination.flush === 'function') { // By convention the Zlib streams provide a flush function for this purpose. // For Express, compression middleware adds this method. destination.flush(); } } var requestStorage = new async_hooks.AsyncLocalStorage(); var VIEW_SIZE = 2048; var currentView = null; var writtenBytes = 0; var destinationHasCapacity = true; function beginWriting(destination) { currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; destinationHasCapacity = true; } function writeStringChunk(destination, stringChunk) { if (stringChunk.length === 0) { return; } // maximum possible view needed to encode entire string if (stringChunk.length * 3 > VIEW_SIZE) { if (writtenBytes > 0) { writeToDestination(destination, currentView.subarray(0, writtenBytes)); currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; } writeToDestination(destination, textEncoder.encode(stringChunk)); return; } var target = currentView; if (writtenBytes > 0) { target = currentView.subarray(writtenBytes); } var _textEncoder$encodeIn = textEncoder.encodeInto(stringChunk, target), read = _textEncoder$encodeIn.read, written = _textEncoder$encodeIn.written; writtenBytes += written; if (read < stringChunk.length) { writeToDestination(destination, currentView); currentView = new Uint8Array(VIEW_SIZE); // $FlowFixMe[incompatible-call] found when upgrading Flow writtenBytes = textEncoder.encodeInto(stringChunk.slice(read), currentView).written; } if (writtenBytes === VIEW_SIZE) { writeToDestination(destination, currentView); currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; } } function writeViewChunk(destination, chunk) { if (chunk.byteLength === 0) { return; } if (chunk.byteLength > VIEW_SIZE) { { if (precomputedChunkSet && precomputedChunkSet.has(chunk)) { error('A large precomputed chunk was passed to writeChunk without being copied.' + ' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' + ' Use "cloneChunk" to make a copy of this large precomputed chunk before writing it. This is a bug in React.'); } } // this chunk may overflow a single view which implies it was not // one that is cached by the streaming renderer. We will enqueu // it directly and expect it is not re-used if (writtenBytes > 0) { writeToDestination(destination, currentView.subarray(0, writtenBytes)); currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; } writeToDestination(destination, chunk); return; } var bytesToWrite = chunk; var allowableBytes = currentView.length - writtenBytes; if (allowableBytes < bytesToWrite.byteLength) { // this chunk would overflow the current view. We enqueue a full view // and start a new view with the remaining chunk if (allowableBytes === 0) { // the current view is already full, send it writeToDestination(destination, currentView); } else { // fill up the current view and apply the remaining chunk bytes // to a new view. currentView.set(bytesToWrite.subarray(0, allowableBytes), writtenBytes); writtenBytes += allowableBytes; writeToDestination(destination, currentView); bytesToWrite = bytesToWrite.subarray(allowableBytes); } currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; } currentView.set(bytesToWrite, writtenBytes); writtenBytes += bytesToWrite.byteLength; if (writtenBytes === VIEW_SIZE) { writeToDestination(destination, currentView); currentView = new Uint8Array(VIEW_SIZE); writtenBytes = 0; } } function writeChunk(destination, chunk) { if (typeof chunk === 'string') { writeStringChunk(destination, chunk); } else { writeViewChunk(destination, chunk); } } function writeToDestination(destination, view) { var currentHasCapacity = destination.write(view); destinationHasCapacity = destinationHasCapacity && currentHasCapacity; } function writeChunkAndReturn(destination, chunk) { writeChunk(destination, chunk); return destinationHasCapacity; } function completeWriting(destination) { if (currentView && writtenBytes > 0) { destination.write(currentView.subarray(0, writtenBytes)); } currentView = null; writtenBytes = 0; destinationHasCapacity = true; } function close(destination) { destination.end(); } var textEncoder = new util.TextEncoder(); function stringToChunk(content) { return content; } var precomputedChunkSet = new Set() ; function stringToPrecomputedChunk(content) { var precomputedChunk = textEncoder.encode(content); { if (precomputedChunkSet) { precomputedChunkSet.add(precomputedChunk); } } return precomputedChunk; } function clonePrecomputedChunk(precomputedChunk) { return precomputedChunk.length > VIEW_SIZE ? precomputedChunk.slice() : precomputedChunk; } function closeWithError(destination, error) { // $FlowFixMe: This is an Error object or the destination accepts other types. destination.destroy(error); } /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol * and Temporal.* types. See https://github.com/facebook/react/pull/22064. * * The functions in this module will throw an easier-to-understand, * easier-to-debug exception with a clear errors message message explaining the * problem. (Instead of a confusing exception thrown inside the implementation * of the `value` object). */ // $FlowFixMe only called in DEV, so void return is not possible. function typeName(value) { { // toStringTag is needed for namespaced types like Temporal.Instant var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag; var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object'; // $FlowFixMe return type; } } // $FlowFixMe only called in DEV, so void return is not possible. function willCoercionThrow(value) { { try { testStringCoercion(value); return false; } catch (e) { return true; } } } function testStringCoercion(value) { // If you ended up here by following an exception call stack, here's what's // happened: you supplied an object or symbol value to React (as a prop, key, // DOM attribute, CSS property, string ref, etc.) and when React tried to // coerce it to a string using `'' + value`, an exception was thrown. // // The most common types that will cause this exception are `Symbol` instances // and Temporal objects like `Temporal.Instant`. But any object that has a // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this // exception. (Library authors do this to prevent users from using built-in // numeric operators like `+` or comparison operators like `>=` because custom // methods are needed to perform accurate arithmetic or comparison.) // // To fix the problem, coerce this object or symbol value to a string before // passing it to React. The most reliable way is usually `String(value)`. // // To find which value is throwing, check the browser or debugger console. // Before this exception was thrown, there should be `console.error` output // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the // problem and how that type was used: key, atrribute, input value prop, etc. // In most cases, this console output also shows the component and its // ancestor components where the exception happened. // // eslint-disable-next-line react-internal/safe-string-coercion return '' + value; } function checkAttributeStringCoercion(value, attributeName) { { if (willCoercionThrow(value)) { error('The provided `%s` attribute is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', attributeName, typeName(value)); return testStringCoercion(value); // throw (to help callers find troubleshooting comments) } } } function checkCSSPropertyStringCoercion(value, propName) { { if (willCoercionThrow(value)) { error('The provided `%s` CSS property is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value)); return testStringCoercion(value); // throw (to help callers find troubleshooting comments) } } } function checkHtmlStringCoercion(value) { { if (willCoercionThrow(value)) { error('The provided HTML markup uses a value of unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value)); return testStringCoercion(value); // throw (to help callers find troubleshooting comments) } } } // ----------------------------------------------------------------------------- var enableFloat = true; // When a node is unmounted, recurse into the Fiber subtree and clean out // $FlowFixMe[method-unbinding] var hasOwnProperty = Object.prototype.hasOwnProperty; // A reserved attribute. // It is handled by React separately and shouldn't be written to the DOM. var RESERVED = 0; // A simple string attribute. // Attributes that aren't in the filter are presumed to have this type. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called // "enumerated" attributes with "true" and "false" as possible values. // When true, it should be set to a "true" string. // When false, it should be set to a "false" string. var BOOLEANISH_STRING = 2; // A real boolean attribute. // When true, it should be present (set either to an empty string or its name). // When false, it should be omitted. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value. // When true, it should be present (set either to an empty string or its name). // When false, it should be omitted. // For any other value, should be present with that value. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric. // When falsy, it should be removed. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric. // When falsy, it should be removed. var POSITIVE_NUMERIC = 6; /* eslint-disable max-len */ var 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"; /* eslint-enable max-len */ var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040"; var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$'); var illegalAttributeNameCache = {}; var validatedAttributeNameCache = {}; function isAttributeNameSafe(attributeName) { if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) { return true; } if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) { return false; } if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { validatedAttributeNameCache[attributeName] = true; return true; } illegalAttributeNameCache[attributeName] = true; { error('Invalid attribute name: `%s`', attributeName); } return false; } function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) { if (propertyInfo !== null && propertyInfo.type === RESERVED) { return false; } switch (typeof value) { case 'function': case 'symbol': // eslint-disable-line return true; case 'boolean': { if (isCustomComponentTag) { return false; } if (propertyInfo !== null) { return !propertyInfo.acceptsBooleans; } else { var prefix = name.toLowerCase().slice(0, 5); return prefix !== 'data-' && prefix !== 'aria-'; } } default: return false; } } function getPropertyInfo(name) { return properties.hasOwnProperty(name) ? properties[name] : null; } function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) { this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN; this.attributeName = attributeName; this.attributeNamespace = attributeNamespace; this.mustUseProperty = mustUseProperty; this.propertyName = name; this.type = type; this.sanitizeURL = sanitizeURL; this.removeEmptyString = removeEmptyString; } // When adding attributes to this list, be sure to also add them to // the `possibleStandardNames` module to ensure casing and incorrect // name warnings. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM. var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular // elements (not just inputs). Now that ReactDOMInput assigns to the // defaultValue property -- do we need this? 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style']; reservedProps.forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty name, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // A few React string attributes have a different name. // This is a mapping from React prop names to the attribute names. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) { var name = _ref[0], attributeName = _ref[1]; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty attributeName, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are "enumerated" HTML attributes that accept "true" and "false". // In React, we let users pass `true` and `false` even though technically // these aren't boolean attributes (they are coerced to strings). ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty name.toLowerCase(), // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are "enumerated" SVG attributes that accept "true" and "false". // In React, we let users pass `true` and `false` even though technically // these aren't boolean attributes (they are coerced to strings). // Since these are SVG attributes, their attribute names are case-sensitive. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty name, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are HTML boolean attributes. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM // on the client side because the browsers are inconsistent. Instead we call focus(). 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata 'itemScope'].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty name.toLowerCase(), // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are the few React props that we set as DOM properties // rather than attributes. These are all booleans. ['checked', // Note: `option.selected` is not updated if `select.multiple` is // disabled with `removeAttribute`. We have special logic for handling this. 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty name, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are HTML attributes that are "overloaded booleans": they behave like // booleans, but can also accept a string value. ['capture', 'download' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty name, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are HTML attributes that must be positive numbers. ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty name, // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These are HTML attributes that must be numbers. ['rowSpan', 'start'].forEach(function (name) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty name.toLowerCase(), // attributeName null, // attributeNamespace false, // sanitizeURL false); }); var CAMELIZE = /[\-\:]([a-z])/g; var capitalize = function (token) { return token[1].toUpperCase(); }; // This is a list of all SVG attributes that need special casing, namespacing, // or boolean value assignment. Regular attributes that just accept strings // and have the same names are omitted, just like in the HTML attribute filter. // Some of these attributes can be hard to find. This list was created by // scraping the MDN documentation. ['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' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (attributeName) { var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty attributeName, null, // attributeNamespace false, // sanitizeURL false); }); // String SVG attributes with the xlink namespace. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (attributeName) { var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL false); }); // String SVG attributes with the xml namespace. ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list, // you'll need to set attributeName to name.toLowerCase() // instead in the assignment below. ].forEach(function (attributeName) { var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL false); }); // These attribute exists both in HTML and SVG. // The attribute name is case-sensitive in SVG so we can't just use // the React name like we do for attributes that exist only in HTML. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty attributeName.toLowerCase(), // attributeName null, // attributeNamespace false, // sanitizeURL false); }); // These attributes accept URLs. These must not allow javascript: URLS. // These will also need to accept Trusted Types object in the future. var xlinkHref = 'xlinkHref'; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL false); ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) { // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty attributeName.toLowerCase(), // attributeName null, // attributeNamespace true, // sanitizeURL true); }); /** * CSS properties which accept numbers but are not in units of "px". */ var isUnitlessNumber = { animationIterationCount: true, aspectRatio: true, borderImageOutset: true, borderImageSlice: true, borderImageWidth: true, boxFlex: true, boxFlexGroup: true, boxOrdinalGroup: true, columnCount: true, columns: true, flex: true, flexGrow: true, flexPositive: true, flexShrink: true, flexNegative: true, flexOrder: true, gridArea: true, gridRow: true, gridRowEnd: true, gridRowSpan: true, gridRowStart: true, gridColumn: true, gridColumnEnd: true, gridColumnSpan: true, gridColumnStart: true, fontWeight: true, lineClamp: true, lineHeight: true, opacity: true, order: true, orphans: true, tabSize: true, widows: true, zIndex: true, zoom: true, // SVG-related properties fillOpacity: true, floodOpacity: true, stopOpacity: true, strokeDasharray: true, strokeDashoffset: true, strokeMiterlimit: true, strokeOpacity: true, strokeWidth: true }; /** * @param {string} prefix vendor-specific prefix, eg: Webkit * @param {string} key style name, eg: transitionDuration * @return {string} style name prefixed with `prefix`, properly camelCased, eg: * WebkitTransitionDuration */ function prefixKey(prefix, key) { return prefix + key.charAt(0).toUpperCase() + key.substring(1); } /** * Support style names that may come passed in prefixed by adding permutations * of vendor prefixes. */ var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an // infinite loop, because it iterates over the newly added props too. Object.keys(isUnitlessNumber).forEach(function (prop) { prefixes.forEach(function (prefix) { isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; }); }); var hasReadOnlyValue = { button: true, checkbox: true, image: true, hidden: true, radio: true, reset: true, submit: true }; function checkControlledValueProps(tagName, props) { { if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) { 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`.'); } if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) { 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`.'); } } } function isCustomComponent(tagName, props) { if (tagName.indexOf('-') === -1) { return typeof props.is === 'string'; } switch (tagName) { // These are reserved SVG and MathML elements. // We don't mind this list too much because we expect it to never grow. // The alternative is to track the namespace in a few places which is convoluted. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts case 'annotation-xml': case 'color-profile': case 'font-face': case 'font-face-src': case 'font-face-uri': case 'font-face-format': case 'font-face-name': case 'missing-glyph': return false; default: return true; } } var ariaProperties = { 'aria-current': 0, // state 'aria-description': 0, 'aria-details': 0, 'aria-disabled': 0, // state 'aria-hidden': 0, // state 'aria-invalid': 0, // state 'aria-keyshortcuts': 0, 'aria-label': 0, 'aria-roledescription': 0, // Widget Attributes 'aria-autocomplete': 0, 'aria-checked': 0, 'aria-expanded': 0, 'aria-haspopup': 0, 'aria-level': 0, 'aria-modal': 0, 'aria-multiline': 0, 'aria-multiselectable': 0, 'aria-orientation': 0, 'aria-placeholder': 0, 'aria-pressed': 0, 'aria-readonly': 0, 'aria-required': 0, 'aria-selected': 0, 'aria-sort': 0, 'aria-valuemax': 0, 'aria-valuemin': 0, 'aria-valuenow': 0, 'aria-valuetext': 0, // Live Region Attributes 'aria-atomic': 0, 'aria-busy': 0, 'aria-live': 0, 'aria-relevant': 0, // Drag-and-Drop Attributes 'aria-dropeffect': 0, 'aria-grabbed': 0, // Relationship Attributes 'aria-activedescendant': 0, 'aria-colcount': 0, 'aria-colindex': 0, 'aria-colspan': 0, 'aria-controls': 0, 'aria-describedby': 0, 'aria-errormessage': 0, 'aria-flowto': 0, 'aria-labelledby': 0, 'aria-owns': 0, 'aria-posinset': 0, 'aria-rowcount': 0, 'aria-rowindex': 0, 'aria-rowspan': 0, 'aria-setsize': 0 }; var warnedProperties = {}; var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); function validateProperty(tagName, name) { { if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) { return true; } if (rARIACamel.test(name)) { var ariaName = 'aria-' + name.slice(4).toLowerCase(); var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM // DOM properties, then it is an invalid aria-* attribute. if (correctName == null) { error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name); warnedProperties[name] = true; return true; } // aria-* attributes should be lowercase; suggest the lowercase version. if (name !== correctName) { error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName); warnedProperties[name] = true; return true; } } if (rARIA.test(name)) { var lowerCasedName = name.toLowerCase(); var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM // DOM properties, then it is an invalid aria-* attribute. if (standardName == null) { warnedProperties[name] = true; return false; } // aria-* attributes should be lowercase; suggest the lowercase version. if (name !== standardName) { error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName); warnedProperties[name] = true; return true; } } } return true; } function warnInvalidARIAProps(type, props) { { var invalidProps = []; for (var key in props) { var isValid = validateProperty(type, key); if (!isValid) { invalidProps.push(key); } } var unknownPropString = invalidProps.map(function (prop) { return '`' + prop + '`'; }).join(', '); if (invalidProps.length === 1) { error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); } else if (invalidProps.length > 1) { error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type); } } } function validateProperties(type, props) { if (isCustomComponent(type, props)) { return; } warnInvalidARIAProps(type, props); } var didWarnValueNull = false; function validateProperties$1(type, props) { { if (type !== 'input' && type !== 'textarea' && type !== 'select') { return; } if (props != null && props.value === null && !didWarnValueNull) { didWarnValueNull = true; if (type === 'select' && props.multiple) { error('`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); } else { error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type); } } } } // When adding attributes to the HTML or SVG allowed attribute list, be sure to // also add them to this module to ensure casing and incorrect name // warnings. var possibleStandardNames = { // HTML accept: 'accept', acceptcharset: 'acceptCharset', 'accept-charset': 'acceptCharset', accesskey: 'accessKey', action: 'action', allowfullscreen: 'allowFullScreen', alt: 'alt', as: 'as', async: 'async', autocapitalize: 'autoCapitalize', autocomplete: 'autoComplete', autocorrect: 'autoCorrect', autofocus: 'autoFocus', autoplay: 'autoPlay', autosave: 'autoSave', capture: 'capture', cellpadding: 'cellPadding', cellspacing: 'cellSpacing', challenge: 'challenge', charset: 'charSet', checked: 'checked', children: 'children', cite: 'cite', class: 'className', classid: 'classID', classname: 'className', cols: 'cols', colspan: 'colSpan', content: 'content', contenteditable: 'contentEditable', contextmenu: 'contextMenu', controls: 'controls', controlslist: 'controlsList', coords: 'coords', crossorigin: 'crossOrigin', dangerouslysetinnerhtml: 'dangerouslySetInnerHTML', data: 'data', datetime: 'dateTime', default: 'default', defaultchecked: 'defaultChecked', defaultvalue: 'defaultValue', defer: 'defer', dir: 'dir', disabled: 'disabled', disablepictureinpicture: 'disablePictureInPicture', disableremoteplayback: 'disableRemotePlayback', download: 'download', draggable: 'draggable', enctype: 'encType', enterkeyhint: 'enterKeyHint', for: 'htmlFor', form: 'form', formmethod: 'formMethod', formaction: 'formAction', formenctype: 'formEncType', formnovalidate: 'formNoValidate', formtarget: 'formTarget', frameborder: 'frameBorder', headers: 'headers', height: 'height', hidden: 'hidden', high: 'high', href: 'href', hreflang: 'hrefLang', htmlfor: 'htmlFor', httpequiv: 'httpEquiv', 'http-equiv': 'httpEquiv', icon: 'icon', id: 'id', imagesizes: 'imageSizes', imagesrcset: 'imageSrcSet', innerhtml: 'innerHTML', inputmode: 'inputMode', integrity: 'integrity', is: 'is', itemid: 'itemID', itemprop: 'itemProp', itemref: 'itemRef', itemscope: 'itemScope', itemtype: 'itemType', keyparams: 'keyParams', keytype: 'keyType', kind: 'kind', label: 'label', lang: 'lang', list: 'list', loop: 'loop', low: 'low', manifest: 'manifest', marginwidth: 'marginWidth', marginheight: 'marginHeight', max: 'max', maxlength: 'maxLength', media: 'media', mediagroup: 'mediaGroup', method: 'method', min: 'min', minlength: 'minLength', multiple: 'multiple', muted: 'muted', name: 'name', nomodule: 'noModule', nonce: 'nonce', novalidate: 'noValidate', open: 'open', optimum: 'optimum', pattern: 'pattern', placeholder: 'placeholder', playsinline: 'playsInline', poster: 'poster', preload: 'preload', profile: 'profile', radiogroup: 'radioGroup', readonly: 'readOnly', referrerpolicy: 'referrerPolicy', rel: 'rel', required: 'required', reversed: 'reversed', role: 'role', rows: 'rows', rowspan: 'rowSpan', sandbox: 'sandbox', scope: 'scope', scoped: 'scoped', scrolling: 'scrolling', seamless: 'seamless', selected: 'selected', shape: 'shape', size: 'size', sizes: 'sizes', span: 'span', spellcheck: 'spellCheck', src: 'src', srcdoc: 'srcDoc', srclang: 'srcLang', srcset: 'srcSet', start: 'start', step: 'step', style: 'style', summary: 'summary', tabindex: 'tabIndex', target: 'target', title: 'title', type: 'type', usemap: 'useMap', value: 'value', width: 'width', wmode: 'wmode', wrap: 'wrap', // SVG about: 'about', accentheight: 'accentHeight', 'accent-height': 'accentHeight', accumulate: 'accumulate', additive: 'additive', alignmentbaseline: 'alignmentBaseline', 'alignment-baseline': 'alignmentBaseline', allowreorder: 'allowReorder', alphabetic: 'alphabetic', amplitude: 'amplitude', arabicform: 'arabicForm', 'arabic-form': 'arabicForm', ascent: 'ascent', attributename: 'attributeName', attributetype: 'attributeType', autoreverse: 'autoReverse', azimuth: 'azimuth', basefrequency: 'baseFrequency', baselineshift: 'baselineShift', 'baseline-shift': 'baselineShift', baseprofile: 'baseProfile', bbox: 'bbox', begin: 'begin', bias: 'bias', by: 'by', calcmode: 'calcMode', capheight: 'capHeight', 'cap-height': 'capHeight', clip: 'clip', clippath: 'clipPath', 'clip-path': 'clipPath', clippathunits: 'clipPathUnits', cliprule: 'clipRule', 'clip-rule': 'clipRule', color: 'color', colorinterpolation: 'colorInterpolation', 'color-interpolation': 'colorInterpolation', colorinterpolationfilters: 'colorInterpolationFilters', 'color-interpolation-filters': 'colorInterpolationFilters', colorprofile: 'colorProfile', 'color-profile': 'colorProfile', colorrendering: 'colorRendering', 'color-rendering': 'colorRendering', contentscripttype: 'contentScriptType', contentstyletype: 'contentStyleType', cursor: 'cursor', cx: 'cx', cy: 'cy', d: 'd', datatype: 'datatype', decelerate: 'decelerate', descent: 'descent', diffuseconstant: 'diffuseConstant', direction: 'direction', display: 'display', divisor: 'divisor', dominantbaseline: 'dominantBaseline', 'dominant-baseline': 'dominantBaseline', dur: 'dur', dx: 'dx', dy: 'dy', edgemode: 'edgeMode', elevation: 'elevation', enablebackground: 'enableBackground', 'enable-background': 'enableBackground', end: 'end', exponent: 'exponent', externalresourcesrequired: 'externalResourcesRequired', fill: 'fill', fillopacity: 'fillOpacity', 'fill-opacity': 'fillOpacity', fillrule: 'fillRule', 'fill-rule': 'fillRule', filter: 'filter', filterres: 'filterRes', filterunits: 'filterUnits', floodopacity: 'floodOpacity', 'flood-opacity': 'floodOpacity', floodcolor: 'floodColor', 'flood-color': 'floodColor', focusable: 'focusable', fontfamily: 'fontFamily', 'font-family': 'fontFamily', fontsize: 'fontSize', 'font-size': 'fontSize', fontsizeadjust: 'fontSizeAdjust', 'font-size-adjust': 'fontSizeAdjust', fontstretch: 'fontStretch', 'font-stretch': 'fontStretch', fontstyle: 'fontStyle', 'font-style': 'fontStyle', fontvariant: 'fontVariant', 'font-variant': 'fontVariant', fontweight: 'fontWeight', 'font-weight': 'fontWeight', format: 'format', from: 'from', fx: 'fx', fy: 'fy', g1: 'g1', g2: 'g2', glyphname: 'glyphName', 'glyph-name': 'glyphName', glyphorientationhorizontal: 'glyphOrientationHorizontal', 'glyph-orientation-horizontal': 'glyphOrientationHorizontal', glyphorientationvertical: 'glyphOrientationVertical', 'glyph-orientation-vertical': 'glyphOrientationVertical', glyphref: 'glyphRef', gradienttransform: 'gradientTransform', gradientunits: 'gradientUnits', hanging: 'hanging', horizadvx: 'horizAdvX', 'horiz-adv-x': 'horizAdvX', horizoriginx: 'horizOriginX', 'horiz-origin-x': 'horizOriginX', ideographic: 'ideographic', imagerendering: 'imageRendering', 'image-rendering': 'imageRendering', in2: 'in2', in: 'in', inlist: 'inlist', intercept: 'intercept', k1: 'k1', k2: 'k2', k3: 'k3', k4: 'k4', k: 'k', kernelmatrix: 'kernelMatrix', kernelunitlength: 'kernelUnitLength', kerning: 'kerning', keypoints: 'keyPoints', keysplines: 'keySplines', keytimes: 'keyTimes', lengthadjust: 'lengthAdjust', letterspacing: 'letterSpacing', 'letter-spacing': 'letterSpacing', lightingcolor: 'lightingColor', 'lighting-color': 'lightingColor', limitingconeangle: 'limitingConeAngle', local: 'local', markerend: 'markerEnd', 'marker-end': 'markerEnd', markerheight: 'markerHeight', markermid: 'markerMid', 'marker-mid': 'markerMid', markerstart: 'markerStart', 'marker-start': 'markerStart', markerunits: 'markerUnits', markerwidth: 'markerWidth', mask: 'mask', maskcontentunits: 'maskContentUnits', maskunits: 'maskUnits', mathematical: 'mathematical', mode: 'mode', numoctaves: 'numOctaves', offset: 'offset', opacity: 'opacity', operator: 'operator', order: 'order', orient: 'orient', orientation: 'orientation', origin: 'origin', overflow: 'overflow', overlineposition: 'overlinePosition', 'overline-position': 'overlinePosition', overlinethickness: 'overlineThickness', 'overline-thickness': 'overlineThickness', paintorder: 'paintOrder', 'paint-order': 'paintOrder', panose1: 'panose1', 'panose-1': 'panose1', pathlength: 'pathLength', patterncontentunits: 'patternContentUnits', patterntransform: 'patternTransform', patternunits: 'patternUnits', pointerevents: 'pointerEvents', 'pointer-events': 'pointerEvents', points: 'points', pointsatx: 'pointsAtX', pointsaty: 'pointsAtY', pointsatz: 'pointsAtZ', prefix: 'prefix', preservealpha: 'preserveAlpha', preserveaspectratio: 'preserveAspectRatio', primitiveunits: 'primitiveUnits', property: 'property', r: 'r', radius: 'radius', refx: 'refX', refy: 'refY', renderingintent: 'renderingIntent', 'rendering-intent': 'renderingIntent', repeatcount: 'repeatCount', repeatdur: 'repeatDur', requiredextensions: 'requiredExtensions', requiredfeatures: 'requiredFeatures', resource: 'resource', restart: 'restart', result: 'result', results: 'results', rotate: 'rotate', rx: 'rx', ry: 'ry', scale: 'scale', security: 'security', seed: 'seed', shaperendering: 'shapeRendering', 'shape-rendering': 'shapeRendering', slope: 'slope', spacing: 'spacing', specularconstant: 'specularConstant', specularexponent: 'specularExponent', speed: 'speed', spreadmethod: 'spreadMethod', startoffset: 'startOffset', stddeviation: 'stdDeviation', stemh: 'stemh', stemv: 'stemv', stitchtiles: 'stitchTiles', stopcolor: 'stopColor', 'stop-color': 'stopColor', stopopacity: 'stopOpacity', 'stop-opacity': 'stopOpacity', strikethroughposition: 'strikethroughPosition', 'strikethrough-position': 'strikethroughPosition', strikethroughthickness: 'strikethroughThickness', 'strikethrough-thickness': 'strikethroughThickness', string: 'string', stroke: 'stroke', strokedasharray: 'strokeDasharray', 'stroke-dasharray': 'strokeDasharray', strokedashoffset: 'strokeDashoffset', 'stroke-dashoffset': 'strokeDashoffset', strokelinecap: 'strokeLinecap', 'stroke-linecap': 'strokeLinecap', strokelinejoin: 'strokeLinejoin', 'stroke-linejoin': 'strokeLinejoin', strokemiterlimit: 'strokeMiterlimit', 'stroke-miterlimit': 'strokeMiterlimit', strokewidth: 'strokeWidth', 'stroke-width': 'strokeWidth', strokeopacity: 'strokeOpacity', 'stroke-opacity': 'strokeOpacity', suppresscontenteditablewarning: 'suppressContentEditableWarning', suppresshydrationwarning: 'suppressHydrationWarning', surfacescale: 'surfaceScale', systemlanguage: 'systemLanguage', tablevalues: 'tableValues', targetx: 'targetX', targety: 'targetY', textanchor: 'textAnchor', 'text-anchor': 'textAnchor', textdecoration: 'textDecoration', 'text-decoration': 'textDecoration', textlength: 'textLength', textrendering: 'textRendering', 'text-rendering': 'textRendering', to: 'to', transform: 'transform', typeof: 'typeof', u1: 'u1', u2: 'u2', underlineposition: 'underlinePosition', 'underline-position': 'underlinePosition', underlinethickness: 'underlineThickness', 'underline-thickness': 'underlineThickness', unicode: 'unicode', unicodebidi: 'unicodeBidi', 'unicode-bidi': 'unicodeBidi', unicoderange: 'unicodeRange', 'unicode-range': 'unicodeRange', unitsperem: 'unitsPerEm', 'units-per-em': 'unitsPerEm', unselectable: 'unselectable', valphabetic: 'vAlphabetic', 'v-alphabetic': 'vAlphabetic', values: 'values', vectoreffect: 'vectorEffect', 'vector-effect': 'vectorEffect', version: 'version', vertadvy: 'vertAdvY', 'vert-adv-y': 'vertAdvY', vertoriginx: 'vertOriginX', 'vert-origin-x': 'vertOriginX', vertoriginy: 'vertOriginY', 'vert-origin-y': 'vertOriginY', vhanging: 'vHanging', 'v-hanging': 'vHanging', videographic: 'vIdeographic', 'v-ideographic': 'vIdeographic', viewbox: 'viewBox', viewtarget: 'viewTarget', visibility: 'visibility', vmathematical: 'vMathematical', 'v-mathematical': 'vMathematical', vocab: 'vocab', widths: 'widths', wordspacing: 'wordSpacing', 'word-spacing': 'wordSpacing', writingmode: 'writingMode', 'writing-mode': 'writingMode', x1: 'x1', x2: 'x2', x: 'x', xchannelselector: 'xChannelSelector', xheight: 'xHeight', 'x-height': 'xHeight', xlinkactuate: 'xlinkActuate', 'xlink:actuate': 'xlinkActuate', xlinkarcrole: 'xlinkArcrole', 'xlink:arcrole': 'xlinkArcrole', xlinkhref: 'xlinkHref', 'xlink:href': 'xlinkHref', xlinkrole: 'xlinkRole', 'xlink:role': 'xlinkRole', xlinkshow: 'xlinkShow', 'xlink:show': 'xlinkShow', xlinktitle: 'xlinkTitle', 'xlink:title': 'xlinkTitle', xlinktype: 'xlinkType', 'xlink:type': 'xlinkType', xmlbase: 'xmlBase', 'xml:base': 'xmlBase', xmllang: 'xmlLang', 'xml:lang': 'xmlLang', xmlns: 'xmlns', 'xml:space': 'xmlSpace', xmlnsxlink: 'xmlnsXlink', 'xmlns:xlink': 'xmlnsXlink', xmlspace: 'xmlSpace', y1: 'y1', y2: 'y2', y: 'y', ychannelselector: 'yChannelSelector', z: 'z', zoomandpan: 'zoomAndPan' }; var validateProperty$1 = function () {}; { var warnedProperties$1 = {}; var EVENT_NAME_REGEX = /^on./; var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/; var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$'); var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$'); validateProperty$1 = function (tagName, name, value, eventRegistry) { if (hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) { return true; } var lowerCasedName = name.toLowerCase(); if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') { error('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.'); warnedProperties$1[name] = true; return true; } // We can't rely on the event system being injected on the server. if (eventRegistry != null) { var registrationNameDependencies = eventRegistry.registrationNameDependencies, possibleRegistrationNames = eventRegistry.possibleRegistrationNames; if (registrationNameDependencies.hasOwnProperty(name)) { return true; } var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null; if (registrationName != null) { error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName); warnedProperties$1[name] = true; return true; } if (EVENT_NAME_REGEX.test(name)) { error('Unknown event handler property `%s`. It will be ignored.', name); warnedProperties$1[name] = true; return true; } } else if (EVENT_NAME_REGEX.test(name)) { // If no event plugins have been injected, we are in a server environment. // So we can't tell if the event name is correct for sure, but we can filter // out known bad ones like `onclick`. We can't suggest a specific replacement though. if (INVALID_EVENT_NAME_REGEX.test(name)) { error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name); } warnedProperties$1[name] = true; return true; } // Let the ARIA attribute hook validate ARIA attributes if (rARIA$1.test(name) || rARIACamel$1.test(name)) { return true; } if (lowerCasedName === 'innerhtml') { error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); warnedProperties$1[name] = true; return true; } if (lowerCasedName === 'aria') { error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.'); warnedProperties$1[name] = true; return true; } if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') { error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value); warnedProperties$1[name] = true; return true; } if (typeof value === 'number' && isNaN(value)) { error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name); warnedProperties$1[name] = true; return true; } var propertyInfo = getPropertyInfo(name); var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) { var standardName = possibleStandardNames[lowerCasedName]; if (standardName !== name) { error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName); warnedProperties$1[name] = true; return true; } } else if (!isReserved && name !== lowerCasedName) { // Unknown attributes should have lowercase casing since that's how they // will be cased anyway with server rendering. error('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); warnedProperties$1[name] = true; return true; } if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { if (value) { error('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); } else { error('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); } warnedProperties$1[name] = true; return true; } // Now that we've validated casing, do not validate // data types for reserved props if (isReserved) { return true; } // Warn when a known attribute is a bad type if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) { warnedProperties$1[name] = true; return false; } // Warn when passing the strings 'false' or 'true' into a boolean prop if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) { error('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); warnedProperties$1[name] = true; return true; } return true; }; } var warnUnknownProperties = function (type, props, eventRegistry) { { var unknownProps = []; for (var key in props) { var isValid = validateProperty$1(type, key, props[key], eventRegistry); if (!isValid) { unknownProps.push(key); } } var unknownPropString = unknownProps.map(function (prop) { return '`' + prop + '`'; }).join(', '); if (unknownProps.length === 1) { error('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://reactjs.org/link/attribute-behavior ', unknownPropString, type); } else if (unknownProps.length > 1) { error('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://reactjs.org/link/attribute-behavior ', unknownPropString, type); } } }; function validateProperties$2(type, props, eventRegistry) { if (isCustomComponent(type, props)) { return; } warnUnknownProperties(type, props, eventRegistry); } var warnValidStyle = function () {}; { // 'msTransform' is correct, but the other prefixes should be capitalized var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; var msPattern = /^-ms-/; var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon var badStyleValueWithSemicolonPattern = /;\s*$/; var warnedStyleNames = {}; var warnedStyleValues = {}; var warnedForNaNValue = false; var warnedForInfinityValue = false; var camelize = function (string) { return string.replace(hyphenPattern, function (_, character) { return character.toUpperCase(); }); }; var warnHyphenatedStyleName = function (name) { if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { return; } warnedStyleNames[name] = true; error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix // is converted to lowercase `ms`. camelize(name.replace(msPattern, 'ms-'))); }; var warnBadVendoredStyleName = function (name) { if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { return; } warnedStyleNames[name] = true; error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)); }; var warnStyleValueWithSemicolon = function (name, value) { if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { return; } warnedStyleValues[value] = true; error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')); }; var warnStyleValueIsNaN = function (name, value) { if (warnedForNaNValue) { return; } warnedForNaNValue = true; error('`NaN` is an invalid value for the `%s` css style property.', name); }; var warnStyleValueIsInfinity = function (name, value) { if (warnedForInfinityValue) { return; } warnedForInfinityValue = true; error('`Infinity` is an invalid value for the `%s` css style property.', name); }; warnValidStyle = function (name, value) { if (name.indexOf('-') > -1) { warnHyphenatedStyleName(name); } else if (badVendoredStyleNamePattern.test(name)) { warnBadVendoredStyleName(name); } else if (badStyleValueWithSemicolonPattern.test(value)) { warnStyleValueWithSemicolon(name, value); } if (typeof value === 'number') { if (isNaN(value)) { warnStyleValueIsNaN(name, value); } else if (!isFinite(value)) { warnStyleValueIsInfinity(name, value); } } }; } var warnValidStyle$1 = warnValidStyle; // code copied and modified from escape-html var matchHtmlRegExp = /["'&<>]/; /** * Escapes special characters and HTML entities in a given html string. * * @param {string} string HTML string to escape for later insertion * @return {string} * @public */ function escapeHtml(string) { { checkHtmlStringCoercion(string); } var str = '' + string; var match = matchHtmlRegExp.exec(str); if (!match) { return str; } var escape; var html = ''; var index; var lastIndex = 0; for (index = match.index; index < str.length; index++) { switch (str.charCodeAt(index)) { case 34: // " escape = '"'; break; case 38: // & escape = '&'; break; case 39: // ' escape = '''; // modified from escape-html; used to be ''' break; case 60: // < escape = '<'; break; case 62: // > escape = '>'; break; default: continue; } if (lastIndex !== index) { html += str.substring(lastIndex, index); } lastIndex = index + 1; html += escape; } return lastIndex !== index ? html + str.substring(lastIndex, index) : html; } // end code copied and modified from escape-html /** * Escapes text to prevent scripting attacks. * * @param {*} text Text value to escape. * @return {string} An escaped string. */ function escapeTextForBrowser(text) { if (typeof text === 'boolean' || typeof text === 'number') { // this shortcircuit helps perf for types that we know will never have // special characters, especially given that this function is used often // for numeric dom ids. return '' + text; } return escapeHtml(text); } var uppercasePattern = /([A-Z])/g; var msPattern$1 = /^ms-/; /** * Hyphenates a camelcased CSS property name, for example: * * > hyphenateStyleName('backgroundColor') * < "background-color" * > hyphenateStyleName('MozTransition') * < "-moz-transition" * > hyphenateStyleName('msTransition') * < "-ms-transition" * * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix * is converted to `-ms-`. */ function hyphenateStyleName(name) { return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern$1, '-ms-'); } // and any newline or tab are filtered out as if they're not part of the URL. // https://url.spec.whatwg.org/#url-parsing // Tab or newline are defined as \r\n\t: // https://infra.spec.whatwg.org/#ascii-tab-or-newline // A C0 control is a code point in the range \u0000 NULL to \u001F // INFORMATION SEPARATOR ONE, inclusive: // https://infra.spec.whatwg.org/#c0-control-or-space /* eslint-disable max-len */ var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i; var didWarn = false; function sanitizeURL(url) { { if (!didWarn && isJavaScriptProtocol.test(url)) { didWarn = true; error('A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url)); } } } var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare function isArray(a) { return isArrayImpl(a); } var assign = Object.assign; function validatePreloadResourceDifference(originalProps, originalImplicit, latestProps, latestImplicit) { { var href = originalProps.href; var originalWarningName = getResourceNameForWarning('preload', originalProps, originalImplicit); var latestWarningName = getResourceNameForWarning('preload', latestProps, latestImplicit); if (latestProps.as !== originalProps.as) { error('A %s is using the same href "%s" as a %s. This is always an error and React will only keep the first preload' + ' for any given href, discarding subsequent instances. To fix, find where you are using this href in link' + ' tags or in calls to ReactDOM.preload() or ReactDOM.preinit() and either make the Resource types agree or' + ' update the hrefs to be distinct for different Resource types.', latestWarningName, href, originalWarningName); } else { var missingProps = null; var extraProps = null; var differentProps = null; if (originalProps.media != null && latestProps.media == null) { missingProps = missingProps || {}; missingProps.media = originalProps.media; } for (var propName in latestProps) { var propValue = latestProps[propName]; var originalValue = originalProps[propName]; if (propValue != null && propValue !== originalValue) { if (originalValue == null) { extraProps = extraProps || {}; extraProps[propName] = propValue; } else { differentProps = differentProps || {}; differentProps[propName] = { original: originalValue, latest: propValue }; } } } if (missingProps || extraProps || differentProps) { warnDifferentProps(href, 'href', originalWarningName, latestWarningName, extraProps, missingProps, differentProps); } } } } function validateStyleResourceDifference(originalProps, latestProps) { { var href = originalProps.href; // eslint-disable-next-line no-labels var originalWarningName = getResourceNameForWarning('style', originalProps, false); var latestWarningName = getResourceNameForWarning('style', latestProps, false); var missingProps = null; var extraProps = null; var differentProps = null; if (originalProps.media != null && latestProps.media == null) { missingProps = missingProps || {}; missingProps.media = originalProps.media; } for (var propName in latestProps) { var propValue = latestProps[propName]; var originalValue = originalProps[propName]; if (propValue != null && propValue !== originalValue) { propName = propName === 'data-precedence' ? 'precedence' : propName; if (originalValue == null) { extraProps = extraProps || {}; extraProps[propName] = propValue; } else { differentProps = differentProps || {}; differentProps[propName] = { original: originalValue, latest: propValue }; } } } if (missingProps || extraProps || differentProps) { warnDifferentProps(href, 'href', originalWarningName, latestWarningName, extraProps, missingProps, differentProps); } } } function validateScriptResourceDifference(originalProps, latestProps) { { var src = originalProps.src; // eslint-disable-next-line no-labels var originalWarningName = getResourceNameForWarning('script', originalProps, false); var latestWarningName = getResourceNameForWarning('script', latestProps, false); var extraProps = null; var differentProps = null; for (var propName in latestProps) { var propValue = latestProps[propName]; var originalValue = originalProps[propName]; if (propValue != null && propValue !== originalValue) { if (originalValue == null) { extraProps = extraProps || {}; extraProps[propName] = propValue; } else { differentProps = differentProps || {}; differentProps[propName] = { original: originalValue, latest: propValue }; } } } if (extraProps || differentProps) { warnDifferentProps(src, 'src', originalWarningName, latestWarningName, extraProps, null, differentProps); } } } function validateStyleAndHintProps(preloadProps, styleProps, implicitPreload) { { var href = preloadProps.href; var originalWarningName = getResourceNameForWarning('preload', preloadProps, implicitPreload); var latestWarningName = getResourceNameForWarning('style', styleProps, false); if (preloadProps.as !== 'style') { error('While creating a %s for href "%s" a %s for this same href was found. When preloading a stylesheet the' + ' "as" prop must be of type "style". This most likely ocurred by rendering a preload link with an incorrect' + ' "as" prop or by calling ReactDOM.preload with an incorrect "as" option.', latestWarningName, href, originalWarningName); } var missingProps = null; var extraProps = null; var differentProps = null; for (var propName in styleProps) { var styleValue = styleProps[propName]; var preloadValue = preloadProps[propName]; switch (propName) { // Check for difference on specific props that cross over or influence // the relationship between the preload and stylesheet case 'crossOrigin': case 'referrerPolicy': case 'media': case 'title': { if (preloadValue !== styleValue && !(preloadValue == null && styleValue == null)) { if (styleValue == null) { missingProps = missingProps || {}; missingProps[propName] = preloadValue; } else if (preloadValue == null) { extraProps = extraProps || {}; extraProps[propName] = styleValue; } else { differentProps = differentProps || {}; differentProps[propName] = { original: preloadValue, latest: styleValue }; } } } } } if (missingProps || extraProps || differentProps) { warnDifferentProps(href, 'href', originalWarningName, latestWarningName, extraProps, missingProps, differentProps); } } } function validateScriptAndHintProps(preloadProps, scriptProps, implicitPreload) { { var href = preloadProps.href; var originalWarningName = getResourceNameForWarning('preload', preloadProps, implicitPreload); var latestWarningName = getResourceNameForWarning('script', scriptProps, false); if (preloadProps.as !== 'script') { error('While creating a %s for href "%s" a %s for this same url was found. When preloading a script the' + ' "as" prop must be of type "script". This most likely ocurred by rendering a preload link with an incorrect' + ' "as" prop or by calling ReactDOM.preload with an incorrect "as" option.', latestWarningName, href, originalWarningName); } var missingProps = null; var extraProps = null; var differentProps = null; for (var propName in scriptProps) { var scriptValue = scriptProps[propName]; var preloadValue = preloadProps[propName]; switch (propName) { // Check for difference on specific props that cross over or influence // the relationship between the preload and stylesheet case 'crossOrigin': case 'referrerPolicy': case 'integrity': { if (preloadValue !== scriptValue && !(preloadValue == null && scriptValue == null)) { if (scriptValue == null) { missingProps = missingProps || {}; missingProps[propName] = preloadValue; } else if (preloadValue == null) { extraProps = extraProps || {}; extraProps[propName] = scriptValue; } else { differentProps = differentProps || {}; differentProps[propName] = { original: preloadValue, latest: scriptValue }; } } } } } if (missingProps || extraProps || differentProps) { warnDifferentProps(href, 'href', originalWarningName, latestWarningName, extraProps, missingProps, differentProps); } } } function warnDifferentProps(url, urlPropKey, originalName, latestName, extraProps, missingProps, differentProps) { { var juxtaposedNameStatement = latestName === originalName ? 'an earlier instance of this Resource' : "a " + originalName + " with the same " + urlPropKey; var comparisonStatement = ''; if (missingProps !== null && typeof missingProps === 'object') { for (var propName in missingProps) { comparisonStatement += "\n " + propName + ": missing or null in latest props, \"" + missingProps[propName] + "\" in original props"; } } if (extraProps !== null && typeof extraProps === 'object') { for (var _propName in extraProps) { comparisonStatement += "\n " + _propName + ": \"" + extraProps[_propName] + "\" in latest props, missing or null in original props"; } } if (differentProps !== null && typeof differentProps === 'object') { for (var _propName2 in differentProps) { comparisonStatement += "\n " + _propName2 + ": \"" + differentProps[_propName2].latest + "\" in latest props, \"" + differentProps[_propName2].original + "\" in original props"; } } error('A %s with %s "%s" has props that disagree with those found on %s. Resources always use the props' + ' that were provided the first time they are encountered so any differences will be ignored. Please' + ' update Resources that share an %s to have props that agree. The differences are described below.%s', latestName, urlPropKey, url, juxtaposedNameStatement, urlPropKey, comparisonStatement); } } function getResourceNameForWarning(type, props, implicit) { { switch (type) { case 'style': { return 'style Resource'; } case 'script': { return 'script Resource'; } case 'preload': { if (implicit) { return "preload for a " + props.as + " Resource"; } return "preload Resource (as \"" + props.as + "\")"; } } } return 'Resource'; } function validateLinkPropsForStyleResource(props) { { // This should only be called when we know we are opting into Resource semantics (i.e. precedence is not null) var href = props.href, onLoad = props.onLoad, onError = props.onError, disabled = props.disabled; var allProps = ['onLoad', 'onError', 'disabled']; var includedProps = []; if (onLoad) includedProps.push('onLoad'); if (onError) includedProps.push('onError'); if (disabled != null) includedProps.push('disabled'); var allPropsUnionPhrase = propNamesListJoin(allProps, 'or'); var includedPropsPhrase = propNamesListJoin(includedProps, 'and'); includedPropsPhrase += includedProps.length === 1 ? ' prop' : ' props'; if (includedProps.length) { error('A link (rel="stylesheet") element with href "%s" has the precedence prop but also included the %s.' + ' When using %s React will opt out of Resource behavior. If you meant for this' + ' element to be treated as a Resource remove the %s. Otherwise remove the precedence prop.', href, includedPropsPhrase, allPropsUnionPhrase, includedPropsPhrase); return true; } } return false; } function propNamesListJoin(list, combinator) { switch (list.length) { case 0: return ''; case 1: return list[0]; case 2: return list[0] + ' ' + combinator + ' ' + list[1]; default: return list.slice(0, -1).join(', ') + ', ' + combinator + ' ' + list[list.length - 1]; } } function validateLinkPropsForPreloadResource(linkProps) { { var href = linkProps.href, as = linkProps.as; if (as === 'font') { var name = getResourceNameForWarning('preload', linkProps, false); if (!hasOwnProperty.call(linkProps, 'crossOrigin')) { error('A %s with href "%s" did not specify the crossOrigin prop. Font preloads must always use' + ' anonymouse CORS mode. To fix add an empty string, "anonymous", or any other string' + ' value except "use-credentials" for the crossOrigin prop of all font preloads.', name, href); } else if (linkProps.crossOrigin === 'use-credentials') { error('A %s with href "%s" specified a crossOrigin value of "use-credentials". Font preloads must always use' + ' anonymouse CORS mode. To fix use an empty string, "anonymous", or any other string' + ' value except "use-credentials" for the crossOrigin prop of all font preloads.', name, href); } } } } function validatePreloadArguments(href, options) { { if (!href || typeof href !== 'string') { var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); error('ReactDOM.preload() expected the first argument to be a string representing an href but found %s instead.', typeOfArg); } else if (typeof options !== 'object' || options === null) { var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); error('ReactDOM.preload() expected the second argument to be an options argument containing at least an "as" property' + ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', _typeOfArg, href); } else { var as = options.as; switch (as) { // Font specific validation of options case 'font': { if (options.crossOrigin === 'use-credentials') { error('ReactDOM.preload() was called with an "as" type of "font" and with a "crossOrigin" option of "use-credentials".' + ' Fonts preloading must use crossOrigin "anonymous" to be functional. Please update your font preload to omit' + ' the crossOrigin option or change it to any other value than "use-credentials" (Browsers default all other values' + ' to anonymous mode). The href for the preload call where this warning originated is "%s"', href); } break; } case 'script': case 'style': { break; } // We have an invalid as type and need to warn default: { var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); error('ReactDOM.preload() expected a valid "as" type in the options (second) argument but found %s instead.' + ' Please use one of the following valid values instead: %s. The href for the preload call where this' + ' warning originated is "%s".', typeOfAs, '"style", "font", or "script"', href); } } } } } function validatePreinitArguments(href, options) { { if (!href || typeof href !== 'string') { var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); error('ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.', typeOfArg); } else if (typeof options !== 'object' || options === null) { var _typeOfArg2 = getValueDescriptorExpectingObjectForWarning(options); error('ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', _typeOfArg2, href); } else { var as = options.as; switch (as) { case 'style': case 'script': { break; } // We have an invalid as type and need to warn default: { var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); error('ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + ' and "script". The href for the preinit call where this warning originated is "%s".', typeOfAs, href); } } } } } function getValueDescriptorExpectingObjectForWarning(thing) { return thing === null ? 'null' : thing === undefined ? 'undefined' : thing === '' ? 'an empty string' : "something with type \"" + typeof thing + "\""; } function getValueDescriptorExpectingEnumForWarning(thing) { return thing === null ? 'null' : thing === undefined ? 'undefined' : thing === '' ? 'an empty string' : typeof thing === 'string' ? JSON.stringify(thing) : "something with type \"" + typeof thing + "\""; } // @TODO add bootstrap script to implicit preloads function createResources() { return { // persistent preloadsMap: new Map(), stylesMap: new Map(), scriptsMap: new Map(), headsMap: new Map(), // cleared on flush charset: null, bases: new Set(), preconnects: new Set(), fontPreloads: new Set(), // usedImagePreloads: new Set(), precedences: new Map(), usedStylePreloads: new Set(), scripts: new Set(), usedScriptPreloads: new Set(), explicitStylePreloads: new Set(), // explicitImagePreloads: new Set(), explicitScriptPreloads: new Set(), headResources: new Set(), // cache for tracking structured meta tags structuredMetaKeys: new Map(), // like a module global for currently rendering boundary boundaryResources: null }; } function createBoundaryResources() { return new Set(); } var currentResources = null; var currentResourcesStack = []; function prepareToRenderResources(resources) { currentResourcesStack.push(currentResources); currentResources = resources; } function finishRenderingResources() { currentResources = currentResourcesStack.pop(); } function setCurrentlyRenderingBoundaryResourcesTarget(resources, boundaryResources) { resources.boundaryResources = boundaryResources; } var ReactDOMServerDispatcher = { preload: preload, preinit: preinit }; function preload(href, options) { if (!currentResources) { // While we expect that preload calls are primarily going to be observed // during render because effects and events don't run on the server it is // still possible that these get called in module scope. This is valid on // the client since there is still a document to interact with but on the // server we need a request to associate the call to. Because of this we // simply return and do not warn. return; } var resources = currentResources; { validatePreloadArguments(href, options); } if (typeof href === 'string' && href && typeof options === 'object' && options !== null) { var as = options.as; var resource = resources.preloadsMap.get(href); if (resource) { { var originallyImplicit = resource._dev_implicit_construction === true; var latestProps = preloadPropsFromPreloadOptions(href, as, options); validatePreloadResourceDifference(resource.props, originallyImplicit, latestProps, false); } } else { resource = createPreloadResource(resources, href, as, preloadPropsFromPreloadOptions(href, as, options)); } switch (as) { case 'font': { resources.fontPreloads.add(resource); break; } case 'style': { resources.explicitStylePreloads.add(resource); break; } case 'script': { resources.explicitScriptPreloads.add(resource); break; } } } } function preinit(href, options) { if (!currentResources) { // While we expect that preinit calls are primarily going to be observed // during render because effects and events don't run on the server it is // still possible that these get called in module scope. This is valid on // the client since there is still a document to interact with but on the // server we need a request to associate the call to. Because of this we // simply return and do not warn. return; } preinitImpl(currentResources, href, options); } // On the server, preinit may be called outside of render when sending an // external SSR runtime as part of the initial resources payload. Since this // is an internal React call, we do not need to use the resources stack. function preinitImpl(resources, href, options) { { validatePreinitArguments(href, options); } if (typeof href === 'string' && href && typeof options === 'object' && options !== null) { var as = options.as; switch (as) { case 'style': { var resource = resources.stylesMap.get(href); if (resource) { { var latestProps = stylePropsFromPreinitOptions(href, resource.precedence, options); validateStyleResourceDifference(resource.props, latestProps); } } else { var precedence = options.precedence || 'default'; var resourceProps = stylePropsFromPreinitOptions(href, precedence, options); resource = createStyleResource(resources, href, precedence, resourceProps); } resource.set.add(resource); resources.explicitStylePreloads.add(resource.hint); return; } case 'script': { var src = href; var _resource = resources.scriptsMap.get(src); if (_resource) { { var _latestProps = scriptPropsFromPreinitOptions(src, options); validateScriptResourceDifference(_resource.props, _latestProps); } } else { var scriptProps = scriptPropsFromPreinitOptions(src, options); _resource = createScriptResource(resources, src, scriptProps); resources.scripts.add(_resource); } return; } } } } function preloadPropsFromPreloadOptions(href, as, options) { return { href: href, rel: 'preload', as: as, crossOrigin: as === 'font' ? '' : options.crossOrigin, integrity: options.integrity }; } function preloadPropsFromRawProps(href, as, rawProps) { var props = assign({}, rawProps); props.href = href; props.rel = 'preload'; props.as = as; if (as === 'font') { // Font preloads always need CORS anonymous mode so we set it here // regardless of the props provided. This should warn elsewhere in // dev props.crossOrigin = ''; } return props; } function preloadAsStylePropsFromProps(href, props) { return { rel: 'preload', as: 'style', href: href, crossOrigin: props.crossOrigin, integrity: props.integrity, media: props.media, hrefLang: props.hrefLang, referrerPolicy: props.referrerPolicy }; } function preloadAsScriptPropsFromProps(href, props) { return { rel: 'preload', as: 'script', href: href, crossOrigin: props.crossOrigin, integrity: props.integrity, referrerPolicy: props.referrerPolicy }; } function createPreloadResource(resources, href, as, props) { var preloadsMap = resources.preloadsMap; { if (preloadsMap.has(href)) { error('createPreloadResource was called when a preload Resource matching the same href already exists. This is a bug in React.'); } } var resource = { type: 'preload', as: as, href: href, flushed: false, props: props }; preloadsMap.set(href, resource); return resource; } function stylePropsFromRawProps(href, precedence, rawProps) { var props = assign({}, rawProps); props.href = href; props.rel = 'stylesheet'; props['data-precedence'] = precedence; delete props.precedence; return props; } function stylePropsFromPreinitOptions(href, precedence, options) { return { rel: 'stylesheet', href: href, 'data-precedence': precedence, crossOrigin: options.crossOrigin }; } function createStyleResource(resources, href, precedence, props) { { if (resources.stylesMap.has(href)) { error('createStyleResource was called when a style Resource matching the same href already exists. This is a bug in React.'); } } var stylesMap = resources.stylesMap, preloadsMap = resources.preloadsMap, precedences = resources.precedences; // If this is the first time we've seen this precedence we encode it's position in our set even though // we don't add the resource to this set yet var precedenceSet = precedences.get(precedence); if (!precedenceSet) { precedenceSet = new Set(); precedences.set(precedence, precedenceSet); } var hint = preloadsMap.get(href); if (hint) { // If a preload for this style Resource already exists there are certain props we want to adopt // on the style Resource, primarily focussed on making sure the style network pathways utilize // the preload pathways. For instance if you have diffreent crossOrigin attributes for a preload // and a stylesheet the stylesheet will make a new request even if the preload had already loaded adoptPreloadPropsForStyleProps(props, hint.props); { validateStyleAndHintProps(hint.props, props, hint._dev_implicit_construction); } } else { var preloadResourceProps = preloadAsStylePropsFromProps(href, props); hint = createPreloadResource(resources, href, 'style', preloadResourceProps); { hint._dev_implicit_construction = true; } resources.explicitStylePreloads.add(hint); } var resource = { type: 'style', href: href, precedence: precedence, flushed: false, inShell: false, props: props, hint: hint, set: precedenceSet }; stylesMap.set(href, resource); return resource; } function adoptPreloadPropsForStyleProps(resourceProps, preloadProps) { if (resourceProps.crossOrigin == null) resourceProps.crossOrigin = preloadProps.crossOrigin; if (resourceProps.referrerPolicy == null) resourceProps.referrerPolicy = preloadProps.referrerPolicy; if (resourceProps.title == null) resourceProps.title = preloadProps.title; } function scriptPropsFromPreinitOptions(src, options) { return { src: src, async: true, crossOrigin: options.crossOrigin, integrity: options.integrity }; } function scriptPropsFromRawProps(src, rawProps) { var props = assign({}, rawProps); props.src = src; return props; } function createScriptResource(resources, src, props) { { if (resources.scriptsMap.has(src)) { error('createScriptResource was called when a script Resource matching the same src already exists. This is a bug in React.'); } } var scriptsMap = resources.scriptsMap, preloadsMap = resources.preloadsMap; var hint = preloadsMap.get(src); if (hint) { // If a preload for this style Resource already exists there are certain props we want to adopt // on the style Resource, primarily focussed on making sure the style network pathways utilize // the preload pathways. For instance if you have diffreent crossOrigin attributes for a preload // and a stylesheet the stylesheet will make a new request even if the preload had already loaded adoptPreloadPropsForScriptProps(props, hint.props); { validateScriptAndHintProps(hint.props, props, hint._dev_implicit_construction); } } else { var preloadResourceProps = preloadAsScriptPropsFromProps(src, props); hint = createPreloadResource(resources, src, 'script', preloadResourceProps); { hint._dev_implicit_construction = true; } resources.explicitScriptPreloads.add(hint); } var resource = { type: 'script', src: src, flushed: false, props: props, hint: hint }; scriptsMap.set(src, resource); return resource; } function adoptPreloadPropsForScriptProps(resourceProps, preloadProps) { if (resourceProps.crossOrigin == null) resourceProps.crossOrigin = preloadProps.crossOrigin; if (resourceProps.referrerPolicy == null) resourceProps.referrerPolicy = preloadProps.referrerPolicy; if (resourceProps.integrity == null) resourceProps.integrity = preloadProps.integrity; } function titlePropsFromRawProps(child, rawProps) { var props = assign({}, rawProps); props.children = child; return props; } function resourcesFromElement(type, props) { if (!currentResources) { throw new Error('"currentResources" was expected to exist. This is a bug in React.'); } var resources = currentResources; switch (type) { case 'title': { var child = props.children; if (Array.isArray(child) && child.length === 1) { child = child[0]; } if (typeof child === 'string' || typeof child === 'number') { var key = 'title::' + child; var resource = resources.headsMap.get(key); if (!resource) { resource = { type: 'title', props: titlePropsFromRawProps(child, props), flushed: false }; resources.headsMap.set(key, resource); resources.headResources.add(resource); } } return true; } case 'meta': { var _key, propertyPath; if (typeof props.charSet === 'string') { _key = 'charSet'; } else if (typeof props.content === 'string') { var contentKey = '::' + props.content; if (typeof props.httpEquiv === 'string') { _key = 'httpEquiv::' + props.httpEquiv + contentKey; } else if (typeof props.name === 'string') { _key = 'name::' + props.name + contentKey; } else if (typeof props.itemProp === 'string') { _key = 'itemProp::' + props.itemProp + contentKey; } else if (typeof props.property === 'string') { var property = props.property; _key = 'property::' + property + contentKey; propertyPath = property; var parentPath = property.split(':').slice(0, -1).join(':'); var parentResource = resources.structuredMetaKeys.get(parentPath); if (parentResource) { _key = parentResource.key + '::child::' + _key; } } } if (_key) { if (!resources.headsMap.has(_key)) { var _resource2 = { type: 'meta', key: _key, props: assign({}, props), flushed: false }; resources.headsMap.set(_key, _resource2); if (_key === 'charSet') { resources.charset = _resource2; } else { if (propertyPath) { resources.structuredMetaKeys.set(propertyPath, _resource2); } resources.headResources.add(_resource2); } } } return true; } case 'base': { var target = props.target, href = props.href; // We mirror the key construction on the client since we will likely unify // this code in the future to better guarantee key semantics are identical // in both environments var _key2 = 'base'; _key2 += typeof href === 'string' ? "[href=\"" + href + "\"]" : ':not([href])'; _key2 += typeof target === 'string' ? "[target=\"" + target + "\"]" : ':not([target])'; if (!resources.headsMap.has(_key2)) { var _resource3 = { type: 'base', props: assign({}, props), flushed: false }; resources.headsMap.set(_key2, _resource3); resources.bases.add(_resource3); } return true; } } return false; } // Construct a resource from link props. function resourcesFromLink(props) { if (!currentResources) { throw new Error('"currentResources" was expected to exist. This is a bug in React.'); } var resources = currentResources; var rel = props.rel, href = props.href; if (!href || typeof href !== 'string' || !rel || typeof rel !== 'string') { return false; } var key = ''; switch (rel) { case 'stylesheet': { var onLoad = props.onLoad, onError = props.onError, precedence = props.precedence, disabled = props.disabled; if (typeof precedence !== 'string' || onLoad || onError || disabled != null) { // This stylesheet is either not opted into Resource semantics or has conflicting properties which // disqualify it for such. We can still create a preload resource to help it load faster on the // client { validateLinkPropsForStyleResource(props); } // $FlowFixMe[incompatible-use] found when upgrading Flow var preloadResource = resources.preloadsMap.get(href); if (!preloadResource) { preloadResource = createPreloadResource( // $FlowFixMe[incompatible-call] found when upgrading Flow resources, href, 'style', preloadAsStylePropsFromProps(href, props)); { preloadResource._dev_implicit_construction = true; } resources.usedStylePreloads.add(preloadResource); } return false; } else { // We are able to convert this link element to a resource exclusively. We construct the relevant Resource // and return true indicating that this link was fully consumed. var _resource4 = resources.stylesMap.get(href); if (_resource4) { { var resourceProps = stylePropsFromRawProps(href, precedence, props); adoptPreloadPropsForStyleProps(resourceProps, _resource4.hint.props); validateStyleResourceDifference(_resource4.props, resourceProps); } } else { var _resourceProps = stylePropsFromRawProps(href, precedence, props); _resource4 = createStyleResource( // $FlowFixMe[incompatible-call] found when upgrading Flow currentResources, href, precedence, _resourceProps); resources.usedStylePreloads.add(_resource4.hint); } if (resources.boundaryResources) { resources.boundaryResources.add(_resource4); } else { _resource4.set.add(_resource4); } return true; } } case 'preload': { var as = props.as; switch (as) { case 'script': case 'style': case 'font': { { validateLinkPropsForPreloadResource(props); } var _resource5 = resources.preloadsMap.get(href); if (_resource5) { { var originallyImplicit = _resource5._dev_implicit_construction === true; var latestProps = preloadPropsFromRawProps(href, as, props); validatePreloadResourceDifference(_resource5.props, originallyImplicit, latestProps, false); } } else { _resource5 = createPreloadResource(resources, href, as, preloadPropsFromRawProps(href, as, props)); switch (as) { case 'script': { resources.explicitScriptPreloads.add(_resource5); break; } case 'style': { resources.explicitStylePreloads.add(_resource5); break; } case 'font': { resources.fontPreloads.add(_resource5); break; } } } return true; } } break; } } if (props.onLoad || props.onError) { // When a link has these props we can't treat it is a Resource but if we rendered it on the // server it would look like a Resource in the rendered html (the onLoad/onError aren't emitted) // Instead we expect the client to insert them rather than hydrate them which also guarantees // that the onLoad and onError won't fire before the event handlers are attached return true; } var sizes = typeof props.sizes === 'string' ? props.sizes : ''; var media = typeof props.media === 'string' ? props.media : ''; key = 'rel:' + rel + '::href:' + href + '::sizes:' + sizes + '::media:' + media; var resource = resources.headsMap.get(key); if (!resource) { resource = { type: 'link', props: assign({}, props), flushed: false }; resources.headsMap.set(key, resource); switch (rel) { case 'preconnect': case 'dns-prefetch': { resources.preconnects.add(resource); break; } default: { resources.headResources.add(resource); } } } return true; } // Construct a resource from link props. function resourcesFromScript(props) { if (!currentResources) { throw new Error('"currentResources" was expected to exist. This is a bug in React.'); } var resources = currentResources; var src = props.src, async = props.async, onLoad = props.onLoad, onError = props.onError; if (!src || typeof src !== 'string') { return false; } if (async) { if (onLoad || onError) { var preloadResource = resources.preloadsMap.get(src); if (!preloadResource) { preloadResource = createPreloadResource( // $FlowFixMe[incompatible-call] found when upgrading Flow resources, src, 'script', preloadAsScriptPropsFromProps(src, props)); { preloadResource._dev_implicit_construction = true; } resources.usedScriptPreloads.add(preloadResource); } } else { var resource = resources.scriptsMap.get(src); if (resource) { { var latestProps = scriptPropsFromRawProps(src, props); adoptPreloadPropsForScriptProps(latestProps, resource.hint.props); validateScriptResourceDifference(resource.props, latestProps); } } else { var resourceProps = scriptPropsFromRawProps(src, props); resource = createScriptResource(resources, src, resourceProps); resources.scripts.add(resource); } } return true; } return false; } function hoistResources(resources, source) { var currentBoundaryResources = resources.boundaryResources; if (currentBoundaryResources) { source.forEach(function (resource) { return currentBoundaryResources.add(resource); }); source.clear(); } } function hoistResourcesToRoot(resources, boundaryResources) { boundaryResources.forEach(function (resource) { return resource.set.add(resource); }); boundaryResources.clear(); } // The build script is at scripts/rollup/generate-inline-fizz-runtime.js. // Run `yarn generate-inline-fizz-runtime` to generate. var clientRenderBoundary = '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};'; var completeBoundary = '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};'; var completeBoundaryWithStyles = '$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};'; var completeSegment = '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};'; var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher; function prepareToRender(resources) { prepareToRenderResources(resources); var previousHostDispatcher = ReactDOMCurrentDispatcher.current; ReactDOMCurrentDispatcher.current = ReactDOMServerDispatcher; return previousHostDispatcher; } function cleanupAfterRender(previousDispatcher) { finishRenderingResources(); ReactDOMCurrentDispatcher.current = previousDispatcher; } // Used to distinguish these contexts from ones used in other renderers. var ScriptStreamingFormat = 0; var dataElementQuotedEnd = stringToPrecomputedChunk('">'); var startInlineScript = stringToPrecomputedChunk(''); var startScriptSrc = stringToPrecomputedChunk(''); /** * This escaping function is designed to work with bootstrapScriptContent only. * because we know we are escaping the entire script. We can avoid for instance * escaping html comment string sequences that are valid javascript as well because * if there are no sebsequent '); var completeSegmentData1 = stringToPrecomputedChunk('