2018-09-20 02:56:13 +02:00
/ * * @ l i c e n s e R e a c t v 1 6 . 5 . 2
2017-10-14 18:40:54 +02:00
* react - dom - server . browser . development . js
*
2018-09-20 02:56:13 +02:00
* Copyright ( c ) Facebook , Inc . and its affiliates .
2017-10-14 18:40:54 +02:00
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree .
* /
2017-12-10 21:51:33 +01:00
2017-10-14 18:40:54 +02:00
'use strict' ;
2017-12-10 21:51:33 +01:00
if ( process . env . NODE _ENV !== "production" ) {
( function ( ) {
2017-10-14 18:40:54 +02:00
'use strict' ;
2017-12-10 21:51:33 +01:00
var _assign = require ( 'object-assign' ) ;
var React = require ( 'react' ) ;
2017-10-14 18:40:54 +02:00
var checkPropTypes = require ( 'prop-types/checkPropTypes' ) ;
/ * *
2018-09-20 02:56:13 +02:00
* Use invariant ( ) to assert state which your program assumes to be true .
*
* Provide sprintf - style format ( only % s is supported ) and arguments
* to provide information about what broke and what you were
* expecting .
*
* The invariant message will be stripped in production , but the invariant
* will remain to ensure logic does not differ in production .
2017-10-14 18:40:54 +02:00
* /
2018-09-20 02:56:13 +02:00
var validateFormat = function ( ) { } ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
{
validateFormat = function ( format ) {
if ( format === undefined ) {
throw new Error ( 'invariant requires an error message argument' ) ;
}
} ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
function invariant ( condition , format , a , b , c , d , e , f ) {
validateFormat ( format ) ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
if ( ! condition ) {
var error = void 0 ;
if ( format === undefined ) {
error = new Error ( 'Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.' ) ;
} else {
var args = [ a , b , c , d , e , f ] ;
var argIndex = 0 ;
error = new Error ( format . replace ( /%s/g , function ( ) {
return args [ argIndex ++ ] ;
} ) ) ;
error . name = 'Invariant Violation' ;
}
error . framesToPop = 1 ; // we don't care about invariant's own frame
throw error ;
}
}
// Relying on the `invariant()` implementation lets us
// preserve the format and params in the www builds.
// TODO: this is special because it gets imported during build.
var ReactVersion = '16.5.2' ;
/ * *
* Similar to invariant but only logs a warning if the condition is not met .
* This can be used to log issues in development environments in critical
* paths . Removing the logging code for production environments will keep the
* same logic and follow the same code paths .
* /
var warningWithoutStack = function ( ) { } ;
{
warningWithoutStack = function ( condition , format ) {
for ( var _len = arguments . length , args = Array ( _len > 2 ? _len - 2 : 0 ) , _key = 2 ; _key < _len ; _key ++ ) {
args [ _key - 2 ] = arguments [ _key ] ;
}
if ( format === undefined ) {
throw new Error ( '`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument' ) ;
}
if ( args . length > 8 ) {
// Check before the condition to catch violations early.
throw new Error ( 'warningWithoutStack() currently supports at most 8 arguments.' ) ;
}
if ( condition ) {
return ;
}
if ( typeof console !== 'undefined' ) {
var _args$map = args . map ( function ( item ) {
return '' + item ;
} ) ,
a = _args$map [ 0 ] ,
b = _args$map [ 1 ] ,
c = _args$map [ 2 ] ,
d = _args$map [ 3 ] ,
e = _args$map [ 4 ] ,
f = _args$map [ 5 ] ,
g = _args$map [ 6 ] ,
h = _args$map [ 7 ] ;
var message = 'Warning: ' + format ;
// We intentionally don't use spread (or .apply) because it breaks IE9:
// https://github.com/facebook/react/issues/13610
switch ( args . length ) {
case 0 :
console . error ( message ) ;
break ;
case 1 :
console . error ( message , a ) ;
break ;
case 2 :
console . error ( message , a , b ) ;
break ;
case 3 :
console . error ( message , a , b , c ) ;
break ;
case 4 :
console . error ( message , a , b , c , d ) ;
break ;
case 5 :
console . error ( message , a , b , c , d , e ) ;
break ;
case 6 :
console . error ( message , a , b , c , d , e , f ) ;
break ;
case 7 :
console . error ( message , a , b , c , d , e , f , g ) ;
break ;
case 8 :
console . error ( message , a , b , c , d , e , f , g , h ) ;
break ;
default :
throw new Error ( 'warningWithoutStack() currently supports at most 8 arguments.' ) ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
var argIndex = 0 ;
var _message = 'Warning: ' + format . replace ( /%s/g , function ( ) {
return args [ argIndex ++ ] ;
} ) ;
throw new Error ( _message ) ;
} catch ( x ) { }
} ;
}
var warningWithoutStack$1 = warningWithoutStack ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var hasSymbol = typeof Symbol === 'function' && Symbol . for ;
var REACT _PORTAL _TYPE = hasSymbol ? Symbol . for ( 'react.portal' ) : 0xeaca ;
var REACT _FRAGMENT _TYPE = hasSymbol ? Symbol . for ( 'react.fragment' ) : 0xeacb ;
var REACT _STRICT _MODE _TYPE = hasSymbol ? Symbol . for ( 'react.strict_mode' ) : 0xeacc ;
var REACT _PROFILER _TYPE = hasSymbol ? Symbol . for ( 'react.profiler' ) : 0xead2 ;
var REACT _PROVIDER _TYPE = hasSymbol ? Symbol . for ( 'react.provider' ) : 0xeacd ;
var REACT _CONTEXT _TYPE = hasSymbol ? Symbol . for ( 'react.context' ) : 0xeace ;
var REACT _ASYNC _MODE _TYPE = hasSymbol ? Symbol . for ( 'react.async_mode' ) : 0xeacf ;
var REACT _FORWARD _REF _TYPE = hasSymbol ? Symbol . for ( 'react.forward_ref' ) : 0xead0 ;
var REACT _PLACEHOLDER _TYPE = hasSymbol ? Symbol . for ( 'react.placeholder' ) : 0xead1 ;
var Resolved = 1 ;
function refineResolvedThenable ( thenable ) {
return thenable . _reactStatus === Resolved ? thenable . _reactResult : null ;
}
function getComponentName ( type ) {
if ( type == null ) {
// Host root, text node or just invalid type.
return null ;
}
{
if ( typeof type . tag === 'number' ) {
warningWithoutStack$1 ( false , 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.' ) ;
}
}
if ( typeof type === 'function' ) {
return type . displayName || type . name || null ;
}
if ( typeof type === 'string' ) {
return type ;
}
switch ( type ) {
case REACT _ASYNC _MODE _TYPE :
return 'AsyncMode' ;
case REACT _FRAGMENT _TYPE :
return 'Fragment' ;
case REACT _PORTAL _TYPE :
return 'Portal' ;
case REACT _PROFILER _TYPE :
return 'Profiler' ;
case REACT _STRICT _MODE _TYPE :
return 'StrictMode' ;
case REACT _PLACEHOLDER _TYPE :
return 'Placeholder' ;
}
if ( typeof type === 'object' ) {
switch ( type . $$typeof ) {
case REACT _CONTEXT _TYPE :
return 'Context.Consumer' ;
case REACT _PROVIDER _TYPE :
return 'Context.Provider' ;
case REACT _FORWARD _REF _TYPE :
var renderFn = type . render ;
var functionName = renderFn . displayName || renderFn . name || '' ;
return type . displayName || ( functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef' ) ;
}
if ( typeof type . then === 'function' ) {
var thenable = type ;
var resolvedThenable = refineResolvedThenable ( thenable ) ;
if ( resolvedThenable ) {
return getComponentName ( resolvedThenable ) ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
}
}
return null ;
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
/ * *
* Forked from fbjs / warning :
* https : //github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
*
* Only change is we use console . warn instead of console . error ,
* and do nothing when 'console' is not supported .
* This really simplifies the code .
* -- -
* Similar to invariant but only logs a warning if the condition is not met .
* This can be used to log issues in development environments in critical
* paths . Removing the logging code for production environments will keep the
* same logic and follow the same code paths .
* /
var lowPriorityWarning = function ( ) { } ;
{
var printWarning = function ( format ) {
for ( var _len = arguments . length , args = Array ( _len > 1 ? _len - 1 : 0 ) , _key = 1 ; _key < _len ; _key ++ ) {
args [ _key - 1 ] = arguments [ _key ] ;
}
var argIndex = 0 ;
var message = 'Warning: ' + format . replace ( /%s/g , function ( ) {
return args [ argIndex ++ ] ;
} ) ;
if ( typeof console !== 'undefined' ) {
console . warn ( message ) ;
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error ( message ) ;
} catch ( x ) { }
} ;
lowPriorityWarning = function ( condition , format ) {
if ( format === undefined ) {
throw new Error ( '`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument' ) ;
}
if ( ! condition ) {
for ( var _len2 = arguments . length , args = Array ( _len2 > 2 ? _len2 - 2 : 0 ) , _key2 = 2 ; _key2 < _len2 ; _key2 ++ ) {
args [ _key2 - 2 ] = arguments [ _key2 ] ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
printWarning . apply ( undefined , [ format ] . concat ( args ) ) ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
} ;
}
var lowPriorityWarning$1 = lowPriorityWarning ;
var ReactSharedInternals = React . _ _SECRET _INTERNALS _DO _NOT _USE _OR _YOU _WILL _BE _FIRED ;
/ * *
* Similar to invariant but only logs a warning if the condition is not met .
* This can be used to log issues in development environments in critical
* paths . Removing the logging code for production environments will keep the
* same logic and follow the same code paths .
* /
var warning = warningWithoutStack$1 ;
{
warning = function ( condition , format ) {
if ( condition ) {
return ;
}
var ReactDebugCurrentFrame = ReactSharedInternals . ReactDebugCurrentFrame ;
var stack = ReactDebugCurrentFrame . getStackAddendum ( ) ;
// eslint-disable-next-line react-internal/warning-and-invariant-args
for ( var _len = arguments . length , args = Array ( _len > 2 ? _len - 2 : 0 ) , _key = 2 ; _key < _len ; _key ++ ) {
args [ _key - 2 ] = arguments [ _key ] ;
}
warningWithoutStack$1 . apply ( undefined , [ false , format + '%s' ] . concat ( args , [ stack ] ) ) ;
} ;
}
var warning$1 = warning ;
var BEFORE _SLASH _RE = /^(.*)[\\\/]/ ;
var describeComponentFrame = function ( name , source , ownerName ) {
var sourceInfo = '' ;
if ( source ) {
var path = source . fileName ;
var fileName = path . replace ( BEFORE _SLASH _RE , '' ) ;
{
// In DEV, include code for a common special case:
// prefer "folder/index.js" instead of just "index.js".
if ( /^index\./ . test ( fileName ) ) {
var match = path . match ( BEFORE _SLASH _RE ) ;
if ( match ) {
var pathBeforeSlash = match [ 1 ] ;
if ( pathBeforeSlash ) {
var folderName = pathBeforeSlash . replace ( BEFORE _SLASH _RE , '' ) ;
fileName = folderName + '/' + fileName ;
}
}
}
}
sourceInfo = ' (at ' + fileName + ':' + source . lineNumber + ')' ;
} else if ( ownerName ) {
sourceInfo = ' (created by ' + ownerName + ')' ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
return '\n in ' + ( name || 'Unknown' ) + sourceInfo ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
// Exports ReactDOM.createRoot
// Experimental error-boundary API that can recover from errors within a single
// render phase
// Suspense
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
// In some cases, StrictMode should also double-render lifecycles.
// This can be confusing for tests though,
// And it can be bad for performance in production.
// This feature flag can be used to control the behavior:
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
// replay the begin phase of a failed component inside invokeGuardedCallback.
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
var warnAboutDeprecatedLifecycles = false ;
// Warn about legacy context API
// Gather advanced timing metrics for Profiler subtrees.
// Trace which interactions trigger each commit.
// Only used in www builds.
var enableSuspenseServerRenderer = false ;
// Only used in www builds.
// React Fire: prevent the value and checked attributes from syncing
// with their related DOM properties
// 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 whitelist 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 ;
2017-10-14 18:40:54 +02:00
/* eslint-disable max-len */
2018-09-20 02:56:13 +02:00
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' ;
2017-10-14 18:40:54 +02:00
/* eslint-enable max-len */
2018-09-20 02:56:13 +02:00
var ATTRIBUTE _NAME _CHAR = ATTRIBUTE _NAME _START _CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040' ;
2017-12-10 21:51:33 +01:00
var ROOT _ATTRIBUTE _NAME = 'data-reactroot' ;
2018-09-20 02:56:13 +02:00
var VALID _ATTRIBUTE _NAME _REGEX = new RegExp ( '^[' + ATTRIBUTE _NAME _START _CHAR + '][' + ATTRIBUTE _NAME _CHAR + ']*$' ) ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
var hasOwnProperty$1 = Object . prototype . hasOwnProperty ;
var illegalAttributeNameCache = { } ;
var validatedAttributeNameCache = { } ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
function isAttributeNameSafe ( attributeName ) {
if ( hasOwnProperty$1 . call ( validatedAttributeNameCache , attributeName ) ) {
return true ;
}
if ( hasOwnProperty$1 . call ( illegalAttributeNameCache , attributeName ) ) {
2017-12-10 21:51:33 +01:00
return false ;
}
2018-09-20 02:56:13 +02:00
if ( VALID _ATTRIBUTE _NAME _REGEX . test ( attributeName ) ) {
validatedAttributeNameCache [ attributeName ] = true ;
return true ;
}
illegalAttributeNameCache [ attributeName ] = true ;
{
warning$1 ( false , 'Invalid attribute name: `%s`' , attributeName ) ;
}
return false ;
}
function shouldIgnoreAttribute ( name , propertyInfo , isCustomComponentTag ) {
if ( propertyInfo !== null ) {
return propertyInfo . type === RESERVED ;
}
if ( isCustomComponentTag ) {
2017-12-10 21:51:33 +01:00
return false ;
}
2018-09-20 02:56:13 +02:00
if ( name . length > 2 && ( name [ 0 ] === 'o' || name [ 0 ] === 'O' ) && ( name [ 1 ] === 'n' || name [ 1 ] === 'N' ) ) {
2017-12-10 21:51:33 +01:00
return true ;
}
2018-09-20 02:56:13 +02:00
return false ;
}
function shouldRemoveAttributeWithWarning ( name , value , propertyInfo , isCustomComponentTag ) {
if ( propertyInfo !== null && propertyInfo . type === RESERVED ) {
return false ;
}
2017-12-10 21:51:33 +01:00
switch ( typeof value ) {
2018-09-20 02:56:13 +02:00
case 'function' :
// $FlowIssue symbol is perfectly valid here
case 'symbol' :
// eslint-disable-line
2017-12-10 21:51:33 +01:00
return true ;
2018-09-20 02:56:13 +02:00
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-' ;
}
}
2017-12-10 21:51:33 +01:00
default :
return false ;
}
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
function shouldRemoveAttribute ( name , value , propertyInfo , isCustomComponentTag ) {
if ( value === null || typeof value === 'undefined' ) {
2017-12-10 21:51:33 +01:00
return true ;
}
2018-09-20 02:56:13 +02:00
if ( shouldRemoveAttributeWithWarning ( name , value , propertyInfo , isCustomComponentTag ) ) {
return true ;
2017-12-10 21:51:33 +01:00
}
2018-09-20 02:56:13 +02:00
if ( isCustomComponentTag ) {
return false ;
}
if ( propertyInfo !== null ) {
switch ( propertyInfo . type ) {
case BOOLEAN :
return ! value ;
case OVERLOADED _BOOLEAN :
return value === false ;
case NUMERIC :
return isNaN ( value ) ;
case POSITIVE _NUMERIC :
return isNaN ( value ) || value < 1 ;
2017-12-10 21:51:33 +01:00
}
}
2018-09-20 02:56:13 +02:00
return false ;
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
function getPropertyInfo ( name ) {
return properties . hasOwnProperty ( name ) ? properties [ name ] : null ;
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
function PropertyInfoRecord ( name , type , mustUseProperty , attributeName , attributeNamespace ) {
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 ;
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
// 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 = { } ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
// These props are reserved by React. They shouldn't be written to the DOM.
[ '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' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , RESERVED , false , // mustUseProperty
name , // attributeName
null ) ;
} // attributeNamespace
) ;
// 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 ] ;
properties [ name ] = new PropertyInfoRecord ( name , STRING , false , // mustUseProperty
attributeName , // attributeName
null ) ;
} // attributeNamespace
) ;
// 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 ) {
properties [ name ] = new PropertyInfoRecord ( name , BOOLEANISH _STRING , false , // mustUseProperty
name . toLowerCase ( ) , // attributeName
null ) ;
} // attributeNamespace
) ;
// 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 ) {
properties [ name ] = new PropertyInfoRecord ( name , BOOLEANISH _STRING , false , // mustUseProperty
name , // attributeName
null ) ;
} // attributeNamespace
) ;
// 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' , 'formNoValidate' , 'hidden' , 'loop' , 'noModule' , 'noValidate' , 'open' , 'playsInline' , 'readOnly' , 'required' , 'reversed' , 'scoped' , 'seamless' ,
// Microdata
'itemScope' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , BOOLEAN , false , // mustUseProperty
name . toLowerCase ( ) , // attributeName
null ) ;
} // attributeNamespace
) ;
// 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' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , BOOLEAN , true , // mustUseProperty
name , // attributeName
null ) ;
} // attributeNamespace
) ;
// These are HTML attributes that are "overloaded booleans": they behave like
// booleans, but can also accept a string value.
[ 'capture' , 'download' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , OVERLOADED _BOOLEAN , false , // mustUseProperty
name , // attributeName
null ) ;
} // attributeNamespace
) ;
// These are HTML attributes that must be positive numbers.
[ 'cols' , 'rows' , 'size' , 'span' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , POSITIVE _NUMERIC , false , // mustUseProperty
name , // attributeName
null ) ;
} // attributeNamespace
) ;
// These are HTML attributes that must be numbers.
[ 'rowSpan' , 'start' ] . forEach ( function ( name ) {
properties [ name ] = new PropertyInfoRecord ( name , NUMERIC , false , // mustUseProperty
name . toLowerCase ( ) , // attributeName
null ) ;
} // attributeNamespace
) ;
2017-12-10 21:51:33 +01:00
var CAMELIZE = /[\-\:]([a-z])/g ;
var capitalize = function ( token ) {
return token [ 1 ] . toUpperCase ( ) ;
} ;
2018-09-20 02:56:13 +02:00
// 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 whitelist.
// Some of these attributes can be hard to find. This list was created by
// scrapping 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' ] . forEach ( function ( attributeName ) {
var name = attributeName . replace ( CAMELIZE , capitalize ) ;
properties [ name ] = new PropertyInfoRecord ( name , STRING , false , // mustUseProperty
attributeName , null ) ;
} // attributeNamespace
) ;
// String SVG attributes with the xlink namespace.
[ 'xlink:actuate' , 'xlink:arcrole' , 'xlink:href' , 'xlink:role' , 'xlink:show' , 'xlink:title' , 'xlink:type' ] . forEach ( function ( attributeName ) {
var name = attributeName . replace ( CAMELIZE , capitalize ) ;
properties [ name ] = new PropertyInfoRecord ( name , STRING , false , // mustUseProperty
attributeName , 'http://www.w3.org/1999/xlink' ) ;
2017-12-10 21:51:33 +01:00
} ) ;
2018-09-20 02:56:13 +02:00
// String SVG attributes with the xml namespace.
[ 'xml:base' , 'xml:lang' , 'xml:space' ] . forEach ( function ( attributeName ) {
var name = attributeName . replace ( CAMELIZE , capitalize ) ;
properties [ name ] = new PropertyInfoRecord ( name , STRING , false , // mustUseProperty
attributeName , 'http://www.w3.org/XML/1998/namespace' ) ;
} ) ;
2017-12-10 21:51:33 +01:00
2018-09-20 02:56:13 +02:00
// Special case: this attribute exists both in HTML and SVG.
// Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
// its React `tabIndex` name, like we do for attributes that exist only in HTML.
properties . tabIndex = new PropertyInfoRecord ( 'tabIndex' , STRING , false , // mustUseProperty
'tabindex' , // attributeName
null ) ;
2017-10-14 18:40:54 +02:00
// code copied and modified from escape-html
/ * *
* Module variables .
* @ private
* /
var matchHtmlRegExp = /["'&<>]/ ;
/ * *
2017-12-10 21:51:33 +01:00
* Escapes special characters and HTML entities in a given html string .
2017-10-14 18:40:54 +02:00
*
2017-12-10 21:51:33 +01:00
* @ param { string } string HTML string to escape for later insertion
2017-10-14 18:40:54 +02:00
* @ return { string }
* @ public
* /
function escapeHtml ( string ) {
var str = '' + string ;
var match = matchHtmlRegExp . exec ( str ) ;
if ( ! match ) {
return str ;
}
2018-09-20 02:56:13 +02:00
var escape = void 0 ;
2017-10-14 18:40:54 +02:00
var html = '' ;
var index = 0 ;
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 .
* /
2017-12-10 21:51:33 +01:00
function escapeTextForBrowser ( text ) {
2017-10-14 18:40:54 +02:00
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 ) ;
}
/ * *
* Escapes attribute value to prevent scripting attacks .
*
* @ param { * } value Value to escape .
* @ return { string } An escaped string .
* /
function quoteAttributeValueForBrowser ( value ) {
2017-12-10 21:51:33 +01:00
return '"' + escapeTextForBrowser ( value ) + '"' ;
2017-10-14 18:40:54 +02:00
}
/ * *
* Operations for dealing with DOM properties .
* /
2017-12-10 21:51:33 +01:00
/ * *
* Creates markup for the ID property .
*
* @ param { string } id Unescaped ID .
* @ return { string } Markup string .
* /
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
function createMarkupForRoot ( ) {
return ROOT _ATTRIBUTE _NAME + '=""' ;
}
/ * *
* Creates markup for a property .
*
* @ param { string } name
* @ param { * } value
* @ return { ? string } Markup string , or null if the property was invalid .
* /
function createMarkupForProperty ( name , value ) {
var propertyInfo = getPropertyInfo ( name ) ;
2018-09-20 02:56:13 +02:00
if ( name !== 'style' && shouldIgnoreAttribute ( name , propertyInfo , false ) ) {
return '' ;
}
if ( shouldRemoveAttribute ( name , value , propertyInfo , false ) ) {
return '' ;
}
if ( propertyInfo !== null ) {
2017-12-10 21:51:33 +01:00
var attributeName = propertyInfo . attributeName ;
2018-09-20 02:56:13 +02:00
var type = propertyInfo . type ;
if ( type === BOOLEAN || type === OVERLOADED _BOOLEAN && value === true ) {
2017-12-10 21:51:33 +01:00
return attributeName + '=""' ;
2018-09-20 02:56:13 +02:00
} else {
2017-12-10 21:51:33 +01:00
return attributeName + '=' + quoteAttributeValueForBrowser ( value ) ;
}
2018-09-20 02:56:13 +02:00
} else if ( isAttributeNameSafe ( name ) ) {
2017-12-10 21:51:33 +01:00
return name + '=' + quoteAttributeValueForBrowser ( value ) ;
}
2018-09-20 02:56:13 +02:00
return '' ;
2017-12-10 21:51:33 +01:00
}
/ * *
* Creates markup for a custom property .
*
* @ param { string } name
* @ param { * } value
* @ return { string } Markup string , or empty string if the property was invalid .
* /
function createMarkupForCustomAttribute ( name , value ) {
if ( ! isAttributeNameSafe ( name ) || value == null ) {
return '' ;
2017-10-14 18:40:54 +02:00
}
2017-12-10 21:51:33 +01:00
return name + '=' + quoteAttributeValueForBrowser ( value ) ;
}
var HTML _NAMESPACE = 'http://www.w3.org/1999/xhtml' ;
var MATH _NAMESPACE = 'http://www.w3.org/1998/Math/MathML' ;
var SVG _NAMESPACE = 'http://www.w3.org/2000/svg' ;
var Namespaces = {
html : HTML _NAMESPACE ,
mathml : MATH _NAMESPACE ,
svg : SVG _NAMESPACE
2017-10-14 18:40:54 +02:00
} ;
2017-12-10 21:51:33 +01:00
// Assumes there is no parent namespace.
function getIntrinsicNamespace ( type ) {
switch ( type ) {
case 'svg' :
return SVG _NAMESPACE ;
case 'math' :
return MATH _NAMESPACE ;
default :
return HTML _NAMESPACE ;
}
}
function getChildNamespace ( parentNamespace , type ) {
if ( parentNamespace == null || parentNamespace === HTML _NAMESPACE ) {
// No (or default) parent namespace: potential entry point.
return getIntrinsicNamespace ( type ) ;
}
if ( parentNamespace === SVG _NAMESPACE && type === 'foreignObject' ) {
// We're leaving SVG.
return HTML _NAMESPACE ;
}
// By default, pass namespace below.
return parentNamespace ;
}
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
var ReactDebugCurrentFrame$1 = null ;
2017-10-14 18:40:54 +02:00
var ReactControlledValuePropTypes = {
checkPropTypes : null
} ;
{
2018-09-20 02:56:13 +02:00
ReactDebugCurrentFrame$1 = ReactSharedInternals . ReactDebugCurrentFrame ;
2017-10-14 18:40:54 +02:00
var hasReadOnlyValue = {
button : true ,
checkbox : true ,
image : true ,
hidden : true ,
radio : true ,
reset : true ,
submit : true
} ;
2017-12-10 21:51:33 +01:00
var propTypes = {
2017-10-14 18:40:54 +02:00
value : function ( props , propName , componentName ) {
2018-09-20 02:56:13 +02:00
if ( hasReadOnlyValue [ props . type ] || props . onChange || props . readOnly || props . disabled || props [ propName ] == null ) {
2017-10-14 18:40:54 +02:00
return null ;
}
return new Error ( 'You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.' ) ;
} ,
checked : function ( props , propName , componentName ) {
2018-09-20 02:56:13 +02:00
if ( props . onChange || props . readOnly || props . disabled || props [ propName ] == null ) {
2017-10-14 18:40:54 +02:00
return null ;
}
return new Error ( 'You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.' ) ;
2017-12-10 21:51:33 +01:00
}
2017-10-14 18:40:54 +02:00
} ;
/ * *
* Provide a linked ` value ` attribute for controlled forms . You should not use
* this outside of the ReactDOM controlled form components .
* /
2018-09-20 02:56:13 +02:00
ReactControlledValuePropTypes . checkPropTypes = function ( tagName , props ) {
checkPropTypes ( propTypes , props , 'prop' , tagName , ReactDebugCurrentFrame$1 . getStackAddendum ) ;
2017-12-10 21:51:33 +01:00
} ;
}
2017-10-14 18:40:54 +02:00
// For HTML, certain tags should omit their close tag. We keep a whitelist for
// those special-case tags.
var omittedCloseTags = {
area : true ,
base : true ,
br : true ,
col : true ,
embed : true ,
hr : true ,
img : true ,
input : true ,
keygen : true ,
link : true ,
meta : true ,
param : true ,
source : true ,
track : true ,
wbr : true
2018-09-20 02:56:13 +02:00
// NOTE: menuitem's close tag should be omitted, but that causes problems.
2017-10-14 18:40:54 +02:00
} ;
// For HTML, certain tags cannot have children. This has the same purpose as
// `omittedCloseTags` except that `menuitem` should still have its closing tag.
2017-12-10 21:51:33 +01:00
var voidElementTags = _assign ( {
2017-10-14 18:40:54 +02:00
menuitem : true
2017-12-10 21:51:33 +01:00
} , omittedCloseTags ) ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
// TODO: We can remove this if we add invariantWithStack()
// or add stack by default to invariants where possible.
2017-10-14 18:40:54 +02:00
var HTML = '__html' ;
2018-09-20 02:56:13 +02:00
var ReactDebugCurrentFrame$2 = null ;
{
ReactDebugCurrentFrame$2 = ReactSharedInternals . ReactDebugCurrentFrame ;
}
function assertValidProps ( tag , props ) {
2017-10-14 18:40:54 +02:00
if ( ! props ) {
return ;
}
// Note the use of `==` which checks for null or undefined.
2017-12-10 21:51:33 +01:00
if ( voidElementTags [ tag ] ) {
2018-09-20 02:56:13 +02:00
! ( props . children == null && props . dangerouslySetInnerHTML == null ) ? invariant ( false , '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s' , tag , ReactDebugCurrentFrame$2 . getStackAddendum ( ) ) : void 0 ;
2017-10-14 18:40:54 +02:00
}
if ( props . dangerouslySetInnerHTML != null ) {
! ( props . children == null ) ? invariant ( false , 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.' ) : void 0 ;
! ( typeof props . dangerouslySetInnerHTML === 'object' && HTML in props . dangerouslySetInnerHTML ) ? invariant ( false , '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.' ) : void 0 ;
}
{
2018-09-20 02:56:13 +02:00
! ( props . suppressContentEditableWarning || ! props . contentEditable || props . children == null ) ? warning$1 ( false , 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.' ) : void 0 ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
! ( props . style == null || typeof props . style === 'object' ) ? invariant ( false , 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s' , ReactDebugCurrentFrame$2 . getStackAddendum ( ) ) : void 0 ;
2017-10-14 18:40:54 +02:00
}
/ * *
* CSS properties which accept numbers but are not in units of "px" .
* /
2017-12-10 21:51:33 +01:00
var isUnitlessNumber = {
2017-10-14 18:40:54 +02:00
animationIterationCount : 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 ,
2018-09-20 02:56:13 +02:00
gridArea : true ,
2017-10-14 18:40:54 +02:00
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.
2017-12-10 21:51:33 +01:00
Object . keys ( isUnitlessNumber ) . forEach ( function ( prop ) {
2017-10-14 18:40:54 +02:00
prefixes . forEach ( function ( prefix ) {
2017-12-10 21:51:33 +01:00
isUnitlessNumber [ prefixKey ( prefix , prop ) ] = isUnitlessNumber [ prop ] ;
2017-10-14 18:40:54 +02:00
} ) ;
} ) ;
/ * *
* Convert a value into the proper css writable value . The style name ` name `
* should be logical ( no hyphens ) , as specified
* in ` CSSProperty.isUnitlessNumber ` .
*
* @ param { string } name CSS property name such as ` topMargin ` .
* @ param { * } value CSS property value such as ` 10px ` .
* @ return { string } Normalized style value with dimensions applied .
* /
function dangerousStyleValue ( name , value , isCustomProperty ) {
// Note that we've removed escapeTextForBrowser() calls here since the
// whole string will be escaped when the attribute is injected into
// the markup. If you provide unsafe user data here they can inject
// arbitrary CSS which may be problematic (I couldn't repro this):
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
// This is not an XSS hole but instead a potential CSS injection issue
// which has lead to a greater discussion about how we're going to
// trust URLs moving forward. See #2115901
var isEmpty = value == null || typeof value === 'boolean' || value === '' ;
if ( isEmpty ) {
return '' ;
}
if ( ! isCustomProperty && typeof value === 'number' && value !== 0 && ! ( isUnitlessNumber . hasOwnProperty ( name ) && isUnitlessNumber [ name ] ) ) {
return value + 'px' ; // Presumes implicit 'px' suffix for unitless numbers
}
return ( '' + value ) . trim ( ) ;
}
2018-09-20 02:56:13 +02:00
var uppercasePattern = /([A-Z])/g ;
var msPattern = /^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 , '-ms-' ) ;
}
2017-10-14 18:40:54 +02:00
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 whitelist 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 ;
}
}
2018-09-20 02:56:13 +02:00
var warnValidStyle = function ( ) { } ;
2017-10-14 18:40:54 +02:00
{
// 'msTransform' is correct, but the other prefixes should be capitalized
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/ ;
2018-09-20 02:56:13 +02:00
var msPattern$1 = /^-ms-/ ;
var hyphenPattern = /-(.)/g ;
2017-10-14 18:40:54 +02:00
// style values shouldn't contain a semicolon
var badStyleValueWithSemicolonPattern = /;\s*$/ ;
var warnedStyleNames = { } ;
var warnedStyleValues = { } ;
var warnedForNaNValue = false ;
var warnedForInfinityValue = false ;
2018-09-20 02:56:13 +02:00
var camelize = function ( string ) {
return string . replace ( hyphenPattern , function ( _ , character ) {
return character . toUpperCase ( ) ;
} ) ;
} ;
var warnHyphenatedStyleName = function ( name ) {
2017-10-14 18:40:54 +02:00
if ( warnedStyleNames . hasOwnProperty ( name ) && warnedStyleNames [ name ] ) {
return ;
}
warnedStyleNames [ name ] = true ;
2018-09-20 02:56:13 +02:00
warning$1 ( false , '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$1 , 'ms-' ) ) ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
var warnBadVendoredStyleName = function ( name ) {
2017-10-14 18:40:54 +02:00
if ( warnedStyleNames . hasOwnProperty ( name ) && warnedStyleNames [ name ] ) {
return ;
}
warnedStyleNames [ name ] = true ;
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Unsupported vendor-prefixed style property %s. Did you mean %s?' , name , name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
var warnStyleValueWithSemicolon = function ( name , value ) {
2017-10-14 18:40:54 +02:00
if ( warnedStyleValues . hasOwnProperty ( value ) && warnedStyleValues [ value ] ) {
return ;
}
warnedStyleValues [ value ] = true ;
2018-09-20 02:56:13 +02:00
warning$1 ( false , "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.' , name , value . replace ( badStyleValueWithSemicolonPattern , '' ) ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
var warnStyleValueIsNaN = function ( name , value ) {
2017-10-14 18:40:54 +02:00
if ( warnedForNaNValue ) {
return ;
}
warnedForNaNValue = true ;
2018-09-20 02:56:13 +02:00
warning$1 ( false , '`NaN` is an invalid value for the `%s` css style property.' , name ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
var warnStyleValueIsInfinity = function ( name , value ) {
2017-10-14 18:40:54 +02:00
if ( warnedForInfinityValue ) {
return ;
}
warnedForInfinityValue = true ;
2018-09-20 02:56:13 +02:00
warning$1 ( false , '`Infinity` is an invalid value for the `%s` css style property.' , name ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
warnValidStyle = function ( name , value ) {
2017-10-14 18:40:54 +02:00
if ( name . indexOf ( '-' ) > - 1 ) {
2018-09-20 02:56:13 +02:00
warnHyphenatedStyleName ( name ) ;
2017-10-14 18:40:54 +02:00
} else if ( badVendoredStyleNamePattern . test ( name ) ) {
2018-09-20 02:56:13 +02:00
warnBadVendoredStyleName ( name ) ;
2017-10-14 18:40:54 +02:00
} else if ( badStyleValueWithSemicolonPattern . test ( value ) ) {
2018-09-20 02:56:13 +02:00
warnStyleValueWithSemicolon ( name , value ) ;
2017-10-14 18:40:54 +02:00
}
if ( typeof value === 'number' ) {
if ( isNaN ( value ) ) {
2018-09-20 02:56:13 +02:00
warnStyleValueIsNaN ( name , value ) ;
2017-10-14 18:40:54 +02:00
} else if ( ! isFinite ( value ) ) {
2018-09-20 02:56:13 +02:00
warnStyleValueIsInfinity ( name , value ) ;
2017-10-14 18:40:54 +02:00
}
}
} ;
}
2017-12-10 21:51:33 +01:00
var warnValidStyle$1 = warnValidStyle ;
2017-10-14 18:40:54 +02:00
var ariaProperties = {
'aria-current' : 0 , // state
'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 = { } ;
2017-12-10 21:51:33 +01:00
var rARIA = new RegExp ( '^(aria)-[' + ATTRIBUTE _NAME _CHAR + ']*$' ) ;
var rARIACamel = new RegExp ( '^(aria)[A-Z][' + ATTRIBUTE _NAME _CHAR + ']*$' ) ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
var hasOwnProperty$2 = Object . prototype . hasOwnProperty ;
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
function validateProperty ( tagName , name ) {
2018-09-20 02:56:13 +02:00
if ( hasOwnProperty$2 . call ( warnedProperties , name ) && warnedProperties [ name ] ) {
2017-10-14 18:40:54 +02:00
return true ;
}
if ( rARIACamel . test ( name ) ) {
var ariaName = 'aria-' + name . slice ( 4 ) . toLowerCase ( ) ;
2017-12-10 21:51:33 +01:00
var correctName = ariaProperties . hasOwnProperty ( ariaName ) ? ariaName : null ;
2017-10-14 18:40:54 +02:00
// 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 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.' , name ) ;
2017-10-14 18:40:54 +02:00
warnedProperties [ name ] = true ;
return true ;
}
// aria-* attributes should be lowercase; suggest the lowercase version.
if ( name !== correctName ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid ARIA attribute `%s`. Did you mean `%s`?' , name , correctName ) ;
2017-10-14 18:40:54 +02:00
warnedProperties [ name ] = true ;
return true ;
}
}
if ( rARIA . test ( name ) ) {
var lowerCasedName = name . toLowerCase ( ) ;
2017-12-10 21:51:33 +01:00
var standardName = ariaProperties . hasOwnProperty ( lowerCasedName ) ? lowerCasedName : null ;
2017-10-14 18:40:54 +02:00
// 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 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Unknown ARIA attribute `%s`. Did you mean `%s`?' , name , standardName ) ;
2017-10-14 18:40:54 +02:00
warnedProperties [ name ] = true ;
return true ;
}
}
return true ;
}
2017-12-10 21:51:33 +01:00
function warnInvalidARIAProps ( type , props ) {
2017-10-14 18:40:54 +02:00
var invalidProps = [ ] ;
for ( var key in props ) {
2017-12-10 21:51:33 +01:00
var isValid = validateProperty ( type , key ) ;
2017-10-14 18:40:54 +02:00
if ( ! isValid ) {
invalidProps . push ( key ) ;
}
}
var unknownPropString = invalidProps . map ( function ( prop ) {
return '`' + prop + '`' ;
} ) . join ( ', ' ) ;
if ( invalidProps . length === 1 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop' , unknownPropString , type ) ;
2017-10-14 18:40:54 +02:00
} else if ( invalidProps . length > 1 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop' , unknownPropString , type ) ;
2017-10-14 18:40:54 +02:00
}
}
2017-12-10 21:51:33 +01:00
function validateProperties ( type , props ) {
if ( isCustomComponent ( type , props ) ) {
2017-10-14 18:40:54 +02:00
return ;
}
2017-12-10 21:51:33 +01:00
warnInvalidARIAProps ( type , props ) ;
2017-10-14 18:40:54 +02:00
}
var didWarnValueNull = false ;
2017-12-10 21:51:33 +01:00
function validateProperties$1 ( type , props ) {
2017-10-14 18:40:54 +02:00
if ( type !== 'input' && type !== 'textarea' && type !== 'select' ) {
return ;
}
2017-12-10 21:51:33 +01:00
if ( props != null && props . value === null && ! didWarnValueNull ) {
2017-10-14 18:40:54 +02:00
didWarnValueNull = true ;
2017-12-10 21:51:33 +01:00
if ( type === 'select' && props . multiple ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.' , type ) ;
2017-12-10 21:51:33 +01:00
} else {
2018-09-20 02:56:13 +02:00
warning$1 ( false , '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.' , type ) ;
2017-10-14 18:40:54 +02:00
}
}
2017-12-10 21:51:33 +01:00
}
2017-10-14 18:40:54 +02:00
/ * *
2017-12-10 21:51:33 +01:00
* Registers plugins so that they can extract and dispatch events .
*
* @ see { EventPluginHub }
2017-10-14 18:40:54 +02:00
* /
/ * *
2017-12-10 21:51:33 +01:00
* Ordered list of injected plugins .
2017-10-14 18:40:54 +02:00
* /
2017-12-10 21:51:33 +01:00
2017-10-14 18:40:54 +02:00
/ * *
2017-12-10 21:51:33 +01:00
* Mapping from event name to dispatch config
2017-10-14 18:40:54 +02:00
* /
2017-12-10 21:51:33 +01:00
2017-10-14 18:40:54 +02:00
/ * *
2017-12-10 21:51:33 +01:00
* Mapping from registration name to plugin module
2017-10-14 18:40:54 +02:00
* /
2017-12-10 21:51:33 +01:00
var registrationNameModules = { } ;
2017-10-14 18:40:54 +02:00
/ * *
2017-12-10 21:51:33 +01:00
* Mapping from registration name to event name
2017-10-14 18:40:54 +02:00
* /
2017-12-10 21:51:33 +01:00
/ * *
* Mapping from lowercase registration names to the properly cased version ,
* used to warn in the case of missing event handlers . Available
* only in true .
* @ type { Object }
* /
var possibleRegistrationNames = { } ;
// Trust the developer to only use possibleRegistrationNames in true
2017-10-14 18:40:54 +02:00
/ * *
2017-12-10 21:51:33 +01:00
* Injects an ordering of plugins ( by plugin name ) . This allows the ordering
* to be decoupled from injection of the actual plugins so that ordering is
* always deterministic regardless of packaging , on - the - fly injection , etc .
2017-10-14 18:40:54 +02:00
*
2017-12-10 21:51:33 +01:00
* @ param { array } InjectedEventPluginOrder
* @ internal
* @ see { EventPluginHub . injection . injectEventPluginOrder }
2017-10-14 18:40:54 +02:00
* /
/ * *
2017-12-10 21:51:33 +01:00
* Injects plugins to be used by ` EventPluginHub ` . The plugin names must be
* in the ordering injected by ` injectEventPluginOrder ` .
2017-10-14 18:40:54 +02:00
*
2017-12-10 21:51:33 +01:00
* Plugins can be injected as part of page initialization or on - the - fly .
2017-10-14 18:40:54 +02:00
*
2017-12-10 21:51:33 +01:00
* @ param { object } injectedNamesToPlugins Map from names to plugin modules .
* @ internal
* @ see { EventPluginHub . injection . injectEventPluginsByName }
2017-10-14 18:40:54 +02:00
* /
// When adding attributes to the HTML or SVG whitelist, be sure to
// also add them to this module to ensure casing and incorrect name
// warnings.
2017-12-10 21:51:33 +01:00
var possibleStandardNames = {
2017-10-14 18:40:54 +02:00
// 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' ,
2018-09-20 02:56:13 +02:00
class : 'className' ,
2017-10-14 18:40:54 +02:00
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' ,
2018-09-20 02:56:13 +02:00
default : 'default' ,
2017-10-14 18:40:54 +02:00
defaultchecked : 'defaultChecked' ,
defaultvalue : 'defaultValue' ,
defer : 'defer' ,
dir : 'dir' ,
disabled : 'disabled' ,
download : 'download' ,
draggable : 'draggable' ,
enctype : 'encType' ,
2018-09-20 02:56:13 +02:00
for : 'htmlFor' ,
2017-10-14 18:40:54 +02:00
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' ,
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' ,
2018-09-20 02:56:13 +02:00
nomodule : 'noModule' ,
2017-10-14 18:40:54 +02:00
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' ,
2018-09-20 02:56:13 +02:00
in : 'in' ,
2017-10-14 18:40:54 +02:00
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' ,
2017-12-10 21:51:33 +01:00
suppresshydrationwarning : 'suppressHydrationWarning' ,
2017-10-14 18:40:54 +02:00
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' ,
2018-09-20 02:56:13 +02:00
typeof : 'typeof' ,
2017-10-14 18:40:54 +02:00
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'
} ;
2018-09-20 02:56:13 +02:00
var validateProperty$1 = function ( ) { } ;
2017-10-14 18:40:54 +02:00
{
var warnedProperties$1 = { } ;
2018-09-20 02:56:13 +02:00
var _hasOwnProperty = Object . prototype . hasOwnProperty ;
2017-12-10 21:51:33 +01:00
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 + ']*$' ) ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
validateProperty$1 = function ( tagName , name , value , canUseEventSystem ) {
if ( _hasOwnProperty . call ( warnedProperties$1 , name ) && warnedProperties$1 [ name ] ) {
2017-10-14 18:40:54 +02:00
return true ;
}
var lowerCasedName = name . toLowerCase ( ) ;
2017-12-10 21:51:33 +01:00
if ( lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout' ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.' ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
2017-12-10 21:51:33 +01:00
// We can't rely on the event system being injected on the server.
if ( canUseEventSystem ) {
if ( registrationNameModules . hasOwnProperty ( name ) ) {
return true ;
}
var registrationName = possibleRegistrationNames . hasOwnProperty ( lowerCasedName ) ? possibleRegistrationNames [ lowerCasedName ] : null ;
if ( registrationName != null ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid event handler property `%s`. Did you mean `%s`?' , name , registrationName ) ;
2017-12-10 21:51:33 +01:00
warnedProperties$1 [ name ] = true ;
return true ;
}
if ( EVENT _NAME _REGEX . test ( name ) ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Unknown event handler property `%s`. It will be ignored.' , name ) ;
2017-12-10 21:51:33 +01:00
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 ) ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.' , name ) ;
2017-12-10 21:51:33 +01:00
}
2017-10-14 18:40:54 +02:00
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' ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.' ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
if ( lowerCasedName === 'aria' ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.' ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
if ( lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string' ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.' , typeof value ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
if ( typeof value === 'number' && isNaN ( value ) ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.' , name ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
2018-09-20 02:56:13 +02:00
var propertyInfo = getPropertyInfo ( name ) ;
var isReserved = propertyInfo !== null && propertyInfo . type === RESERVED ;
2017-10-14 18:40:54 +02:00
// Known attributes should match the casing specified in the property config.
if ( possibleStandardNames . hasOwnProperty ( lowerCasedName ) ) {
var standardName = possibleStandardNames [ lowerCasedName ] ;
if ( standardName !== name ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid DOM property `%s`. Did you mean `%s`?' , name , standardName ) ;
2017-10-14 18:40:54 +02:00
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.
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.' , name , lowerCasedName ) ;
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return true ;
}
2018-09-20 02:56:13 +02:00
if ( typeof value === 'boolean' && shouldRemoveAttributeWithWarning ( name , value , propertyInfo , false ) ) {
2017-12-10 21:51:33 +01:00
if ( value ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.' , value , name , name , value , name ) ;
2017-12-10 21:51:33 +01:00
} else {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.' , value , name , name , value , name , name , name ) ;
2017-12-10 21:51:33 +01:00
}
2017-10-14 18:40:54 +02:00
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
2018-09-20 02:56:13 +02:00
if ( shouldRemoveAttributeWithWarning ( name , value , propertyInfo , false ) ) {
2017-10-14 18:40:54 +02:00
warnedProperties$1 [ name ] = true ;
return false ;
}
2018-09-20 02:56:13 +02:00
// Warn when passing the strings 'false' or 'true' into a boolean prop
if ( ( value === 'false' || value === 'true' ) && propertyInfo !== null && propertyInfo . type === BOOLEAN ) {
warning$1 ( false , 'Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?' , value , name , value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".' , name , value ) ;
warnedProperties$1 [ name ] = true ;
return true ;
}
2017-10-14 18:40:54 +02:00
return true ;
} ;
}
2017-12-10 21:51:33 +01:00
var warnUnknownProperties = function ( type , props , canUseEventSystem ) {
2017-10-14 18:40:54 +02:00
var unknownProps = [ ] ;
for ( var key in props ) {
2017-12-10 21:51:33 +01:00
var isValid = validateProperty$1 ( type , key , props [ key ] , canUseEventSystem ) ;
2017-10-14 18:40:54 +02:00
if ( ! isValid ) {
unknownProps . push ( key ) ;
}
}
var unknownPropString = unknownProps . map ( function ( prop ) {
return '`' + prop + '`' ;
} ) . join ( ', ' ) ;
if ( unknownProps . length === 1 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior' , unknownPropString , type ) ;
2017-10-14 18:40:54 +02:00
} else if ( unknownProps . length > 1 ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior' , unknownPropString , type ) ;
2017-10-14 18:40:54 +02:00
}
} ;
2017-12-10 21:51:33 +01:00
function validateProperties$2 ( type , props , canUseEventSystem ) {
if ( isCustomComponent ( type , props ) ) {
2017-10-14 18:40:54 +02:00
return ;
}
2017-12-10 21:51:33 +01:00
warnUnknownProperties ( type , props , canUseEventSystem ) ;
2017-10-14 18:40:54 +02:00
}
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
2017-12-10 21:51:33 +01:00
// Based on reading the React.Children implementation. TODO: type this somewhere?
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
var toArray = React . Children . toArray ;
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
// This is only used in DEV.
// Each entry is `this.stack` from a currently executing renderer instance.
// (There may be more than one because ReactDOMServer is reentrant).
// Each stack is an array of frames which may contain nested stacks of elements.
var currentDebugStacks = [ ] ;
var ReactDebugCurrentFrame = void 0 ;
var prevGetCurrentStackImpl = null ;
var getCurrentServerStackImpl = function ( ) {
return '' ;
} ;
var describeStackFrame = function ( element ) {
return '' ;
} ;
var validatePropertiesInDevelopment = function ( type , props ) { } ;
var pushCurrentDebugStack = function ( stack ) { } ;
var pushElementToDebugStack = function ( element ) { } ;
var popCurrentDebugStack = function ( ) { } ;
2017-10-14 18:40:54 +02:00
{
2018-09-20 02:56:13 +02:00
ReactDebugCurrentFrame = ReactSharedInternals . ReactDebugCurrentFrame ;
validatePropertiesInDevelopment = function ( type , props ) {
2017-12-10 21:51:33 +01:00
validateProperties ( type , props ) ;
validateProperties$1 ( type , props ) ;
validateProperties$2 ( type , props , /* canUseEventSystem */ false ) ;
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
describeStackFrame = function ( element ) {
2017-10-14 18:40:54 +02:00
var source = element . _source ;
var type = element . type ;
var name = getComponentName ( type ) ;
var ownerName = null ;
return describeComponentFrame ( name , source , ownerName ) ;
} ;
2018-09-20 02:56:13 +02:00
pushCurrentDebugStack = function ( stack ) {
currentDebugStacks . push ( stack ) ;
if ( currentDebugStacks . length === 1 ) {
// We are entering a server renderer.
// Remember the previous (e.g. client) global stack implementation.
prevGetCurrentStackImpl = ReactDebugCurrentFrame . getCurrentStack ;
ReactDebugCurrentFrame . getCurrentStack = getCurrentServerStackImpl ;
}
} ;
pushElementToDebugStack = function ( element ) {
// For the innermost executing ReactDOMServer call,
var stack = currentDebugStacks [ currentDebugStacks . length - 1 ] ;
// Take the innermost executing frame (e.g. <Foo>),
2017-12-10 21:51:33 +01:00
var frame = stack [ stack . length - 1 ] ;
2018-09-20 02:56:13 +02:00
// and record that it has one more element associated with it.
frame . debugElementStack . push ( element ) ;
// We only need this because we tail-optimize single-element
// children and directly handle them in an inner loop instead of
// creating separate frames for them.
2017-10-14 18:40:54 +02:00
} ;
2018-09-20 02:56:13 +02:00
popCurrentDebugStack = function ( ) {
currentDebugStacks . pop ( ) ;
if ( currentDebugStacks . length === 0 ) {
// We are exiting the server renderer.
// Restore the previous (e.g. client) global stack implementation.
ReactDebugCurrentFrame . getCurrentStack = prevGetCurrentStackImpl ;
prevGetCurrentStackImpl = null ;
2017-10-14 18:40:54 +02:00
}
} ;
2018-09-20 02:56:13 +02:00
getCurrentServerStackImpl = function ( ) {
if ( currentDebugStacks . length === 0 ) {
// Nothing is currently rendering.
2017-12-10 21:51:33 +01:00
return '' ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
// ReactDOMServer is reentrant so there may be multiple calls at the same time.
// Take the frames from the innermost call which is the last in the array.
var frames = currentDebugStacks [ currentDebugStacks . length - 1 ] ;
2017-10-14 18:40:54 +02:00
var stack = '' ;
2018-09-20 02:56:13 +02:00
// Go through every frame in the stack from the innermost one.
for ( var i = frames . length - 1 ; i >= 0 ; i -- ) {
var frame = frames [ i ] ;
// Every frame might have more than one debug element stack entry associated with it.
// This is because single-child nesting doesn't create materialized frames.
// Instead it would push them through `pushElementToDebugStack()`.
2017-12-10 21:51:33 +01:00
var _debugElementStack = frame . debugElementStack ;
for ( var ii = _debugElementStack . length - 1 ; ii >= 0 ; ii -- ) {
stack += describeStackFrame ( _debugElementStack [ ii ] ) ;
2017-10-14 18:40:54 +02:00
}
}
return stack ;
} ;
}
var didWarnDefaultInputValue = false ;
var didWarnDefaultChecked = false ;
var didWarnDefaultSelectValue = false ;
var didWarnDefaultTextareaValue = false ;
var didWarnInvalidOptionChildren = false ;
2017-12-10 21:51:33 +01:00
var didWarnAboutNoopUpdateForComponent = { } ;
2018-09-20 02:56:13 +02:00
var didWarnAboutBadClass = { } ;
var didWarnAboutDeprecatedWillMount = { } ;
var didWarnAboutUndefinedDerivedState = { } ;
var didWarnAboutUninitializedState = { } ;
2017-10-14 18:40:54 +02:00
var valuePropNames = [ 'value' , 'defaultValue' ] ;
var newlineEatingTags = {
listing : true ,
pre : true ,
textarea : true
} ;
// We accept any tag to be rendered but since this gets injected into arbitrary
// HTML, we want to make sure that it's a safe tag.
// http://www.w3.org/TR/REC-xml/#NT-Name
var VALID _TAG _REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/ ; // Simplified subset
var validatedTagCache = { } ;
function validateDangerousTag ( tag ) {
if ( ! validatedTagCache . hasOwnProperty ( tag ) ) {
! VALID _TAG _REGEX . test ( tag ) ? invariant ( false , 'Invalid tag: %s' , tag ) : void 0 ;
validatedTagCache [ tag ] = true ;
}
}
2018-09-20 02:56:13 +02:00
var styleNameCache = { } ;
var processStyleName = function ( styleName ) {
if ( styleNameCache . hasOwnProperty ( styleName ) ) {
return styleNameCache [ styleName ] ;
}
var result = hyphenateStyleName ( styleName ) ;
styleNameCache [ styleName ] = result ;
return result ;
} ;
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
function createMarkupForStyles ( styles ) {
2017-10-14 18:40:54 +02:00
var serialized = '' ;
var delimiter = '' ;
for ( var styleName in styles ) {
if ( ! styles . hasOwnProperty ( styleName ) ) {
continue ;
}
var isCustomProperty = styleName . indexOf ( '--' ) === 0 ;
var styleValue = styles [ styleName ] ;
{
if ( ! isCustomProperty ) {
2018-09-20 02:56:13 +02:00
warnValidStyle$1 ( styleName , styleValue ) ;
2017-10-14 18:40:54 +02:00
}
}
if ( styleValue != null ) {
serialized += delimiter + processStyleName ( styleName ) + ':' ;
2017-12-10 21:51:33 +01:00
serialized += dangerousStyleValue ( styleName , styleValue , isCustomProperty ) ;
2017-10-14 18:40:54 +02:00
delimiter = ';' ;
}
}
return serialized || null ;
}
function warnNoop ( publicInstance , callerName ) {
{
2018-09-20 02:56:13 +02:00
var _constructor = publicInstance . constructor ;
var componentName = _constructor && getComponentName ( _constructor ) || 'ReactClass' ;
2017-12-10 21:51:33 +01:00
var warningKey = componentName + '.' + callerName ;
if ( didWarnAboutNoopUpdateForComponent [ warningKey ] ) {
return ;
}
2018-09-20 02:56:13 +02:00
warningWithoutStack$1 ( false , '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.' , callerName , callerName , componentName ) ;
2017-12-10 21:51:33 +01:00
didWarnAboutNoopUpdateForComponent [ warningKey ] = true ;
2017-10-14 18:40:54 +02:00
}
}
function shouldConstruct ( Component ) {
return Component . prototype && Component . prototype . isReactComponent ;
}
function getNonChildrenInnerMarkup ( props ) {
var innerHTML = props . dangerouslySetInnerHTML ;
if ( innerHTML != null ) {
if ( innerHTML . _ _html != null ) {
return innerHTML . _ _html ;
}
} else {
var content = props . children ;
if ( typeof content === 'string' || typeof content === 'number' ) {
2017-12-10 21:51:33 +01:00
return escapeTextForBrowser ( content ) ;
2017-10-14 18:40:54 +02:00
}
}
return null ;
}
2017-12-10 21:51:33 +01:00
function flattenTopLevelChildren ( children ) {
if ( ! React . isValidElement ( children ) ) {
return toArray ( children ) ;
}
var element = children ;
if ( element . type !== REACT _FRAGMENT _TYPE ) {
return [ element ] ;
}
var fragmentChildren = element . props . children ;
if ( ! React . isValidElement ( fragmentChildren ) ) {
return toArray ( fragmentChildren ) ;
}
var fragmentChildElement = fragmentChildren ;
return [ fragmentChildElement ] ;
}
2017-10-14 18:40:54 +02:00
function flattenOptionChildren ( children ) {
2018-09-20 02:56:13 +02:00
if ( children === undefined || children === null ) {
return children ;
}
2017-10-14 18:40:54 +02:00
var content = '' ;
// Flatten children and warn if they aren't strings or numbers;
// invalid types are ignored.
2017-12-10 21:51:33 +01:00
React . Children . forEach ( children , function ( child ) {
2017-10-14 18:40:54 +02:00
if ( child == null ) {
return ;
}
2018-09-20 02:56:13 +02:00
content += child ;
{
if ( ! didWarnInvalidOptionChildren && typeof child !== 'string' && typeof child !== 'number' ) {
didWarnInvalidOptionChildren = true ;
warning$1 ( false , 'Only strings and numbers are supported as <option> children.' ) ;
2017-10-14 18:40:54 +02:00
}
}
} ) ;
return content ;
}
2018-09-20 02:56:13 +02:00
var emptyObject = { } ;
{
Object . freeze ( emptyObject ) ;
}
2017-10-14 18:40:54 +02:00
function maskContext ( type , context ) {
var contextTypes = type . contextTypes ;
if ( ! contextTypes ) {
return emptyObject ;
}
var maskedContext = { } ;
for ( var contextName in contextTypes ) {
maskedContext [ contextName ] = context [ contextName ] ;
}
return maskedContext ;
}
function checkContextTypes ( typeSpecs , values , location ) {
{
2018-09-20 02:56:13 +02:00
checkPropTypes ( typeSpecs , values , location , 'Component' , getCurrentServerStackImpl ) ;
2017-10-14 18:40:54 +02:00
}
}
function processContext ( type , context ) {
var maskedContext = maskContext ( type , context ) ;
{
if ( type . contextTypes ) {
checkContextTypes ( type . contextTypes , maskedContext , 'context' ) ;
}
}
return maskedContext ;
}
2018-09-20 02:56:13 +02:00
var hasOwnProperty = Object . prototype . hasOwnProperty ;
2017-10-14 18:40:54 +02:00
var STYLE = 'style' ;
2018-09-20 02:56:13 +02:00
var RESERVED _PROPS = {
2017-10-14 18:40:54 +02:00
children : null ,
dangerouslySetInnerHTML : null ,
2017-12-10 21:51:33 +01:00
suppressContentEditableWarning : null ,
suppressHydrationWarning : null
2017-10-14 18:40:54 +02:00
} ;
2017-12-10 21:51:33 +01:00
function createOpenTagMarkup ( tagVerbatim , tagLowercase , props , namespace , makeStaticMarkup , isRootElement ) {
2017-10-14 18:40:54 +02:00
var ret = '<' + tagVerbatim ;
for ( var propKey in props ) {
2018-09-20 02:56:13 +02:00
if ( ! hasOwnProperty . call ( props , propKey ) ) {
2017-10-14 18:40:54 +02:00
continue ;
}
var propValue = props [ propKey ] ;
if ( propValue == null ) {
continue ;
}
if ( propKey === STYLE ) {
2017-12-10 21:51:33 +01:00
propValue = createMarkupForStyles ( propValue ) ;
2017-10-14 18:40:54 +02:00
}
var markup = null ;
2017-12-10 21:51:33 +01:00
if ( isCustomComponent ( tagLowercase , props ) ) {
2018-09-20 02:56:13 +02:00
if ( ! RESERVED _PROPS . hasOwnProperty ( propKey ) ) {
2017-12-10 21:51:33 +01:00
markup = createMarkupForCustomAttribute ( propKey , propValue ) ;
2017-10-14 18:40:54 +02:00
}
} else {
2017-12-10 21:51:33 +01:00
markup = createMarkupForProperty ( propKey , propValue ) ;
2017-10-14 18:40:54 +02:00
}
if ( markup ) {
ret += ' ' + markup ;
}
}
// For static pages, no need to put React ID and checksum. Saves lots of
// bytes.
if ( makeStaticMarkup ) {
return ret ;
}
if ( isRootElement ) {
2017-12-10 21:51:33 +01:00
ret += ' ' + createMarkupForRoot ( ) ;
2017-10-14 18:40:54 +02:00
}
return ret ;
}
function validateRenderResult ( child , type ) {
if ( child === undefined ) {
invariant ( false , '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.' , getComponentName ( type ) || 'Component' ) ;
}
}
function resolve ( child , context ) {
2017-12-10 21:51:33 +01:00
while ( React . isValidElement ( child ) ) {
// Safe because we just checked it's an element.
var element = child ;
2018-09-20 02:56:13 +02:00
var Component = element . type ;
2017-10-14 18:40:54 +02:00
{
2017-12-10 21:51:33 +01:00
pushElementToDebugStack ( element ) ;
2017-10-14 18:40:54 +02:00
}
if ( typeof Component !== 'function' ) {
break ;
}
2018-09-20 02:56:13 +02:00
processChild ( element , Component ) ;
}
// Extra closure so queue and replace can be captured properly
function processChild ( element , Component ) {
2017-10-14 18:40:54 +02:00
var publicContext = processContext ( Component , context ) ;
2018-09-20 02:56:13 +02:00
2017-10-14 18:40:54 +02:00
var queue = [ ] ;
var replace = false ;
var updater = {
isMounted : function ( publicInstance ) {
return false ;
} ,
enqueueForceUpdate : function ( publicInstance ) {
if ( queue === null ) {
warnNoop ( publicInstance , 'forceUpdate' ) ;
return null ;
}
} ,
enqueueReplaceState : function ( publicInstance , completeState ) {
replace = true ;
queue = [ completeState ] ;
} ,
2018-09-20 02:56:13 +02:00
enqueueSetState : function ( publicInstance , currentPartialState ) {
2017-10-14 18:40:54 +02:00
if ( queue === null ) {
warnNoop ( publicInstance , 'setState' ) ;
return null ;
}
2018-09-20 02:56:13 +02:00
queue . push ( currentPartialState ) ;
2017-10-14 18:40:54 +02:00
}
} ;
2018-09-20 02:56:13 +02:00
var inst = void 0 ;
2017-10-14 18:40:54 +02:00
if ( shouldConstruct ( Component ) ) {
2017-12-10 21:51:33 +01:00
inst = new Component ( element . props , publicContext , updater ) ;
2018-09-20 02:56:13 +02:00
if ( typeof Component . getDerivedStateFromProps === 'function' ) {
{
if ( inst . state === null || inst . state === undefined ) {
var componentName = getComponentName ( Component ) || 'Unknown' ;
if ( ! didWarnAboutUninitializedState [ componentName ] ) {
warningWithoutStack$1 ( false , '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.' , componentName , inst . state === null ? 'null' : 'undefined' , componentName ) ;
didWarnAboutUninitializedState [ componentName ] = true ;
}
}
}
var partialState = Component . getDerivedStateFromProps . call ( null , element . props , inst . state ) ;
{
if ( partialState === undefined ) {
var _componentName = getComponentName ( Component ) || 'Unknown' ;
if ( ! didWarnAboutUndefinedDerivedState [ _componentName ] ) {
warningWithoutStack$1 ( false , '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.' , _componentName ) ;
didWarnAboutUndefinedDerivedState [ _componentName ] = true ;
}
}
}
if ( partialState != null ) {
inst . state = _assign ( { } , inst . state , partialState ) ;
}
}
2017-10-14 18:40:54 +02:00
} else {
2018-09-20 02:56:13 +02:00
{
if ( Component . prototype && typeof Component . prototype . render === 'function' ) {
var _componentName2 = getComponentName ( Component ) || 'Unknown' ;
if ( ! didWarnAboutBadClass [ _componentName2 ] ) {
warningWithoutStack$1 ( false , "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.' , _componentName2 , _componentName2 ) ;
didWarnAboutBadClass [ _componentName2 ] = true ;
}
}
}
2017-12-10 21:51:33 +01:00
inst = Component ( element . props , publicContext , updater ) ;
2017-10-14 18:40:54 +02:00
if ( inst == null || inst . render == null ) {
child = inst ;
validateRenderResult ( child , Component ) ;
2018-09-20 02:56:13 +02:00
return ;
2017-10-14 18:40:54 +02:00
}
}
2017-12-10 21:51:33 +01:00
inst . props = element . props ;
2017-10-14 18:40:54 +02:00
inst . context = publicContext ;
inst . updater = updater ;
var initialState = inst . state ;
if ( initialState === undefined ) {
inst . state = initialState = null ;
}
2018-09-20 02:56:13 +02:00
if ( typeof inst . UNSAFE _componentWillMount === 'function' || typeof inst . componentWillMount === 'function' ) {
if ( typeof inst . componentWillMount === 'function' ) {
{
if ( warnAboutDeprecatedLifecycles && inst . componentWillMount . _ _suppressDeprecationWarning !== true ) {
var _componentName3 = getComponentName ( Component ) || 'Unknown' ;
if ( ! didWarnAboutDeprecatedWillMount [ _componentName3 ] ) {
lowPriorityWarning$1 ( false , '%s: componentWillMount() is deprecated and will be ' + 'removed in the next major version. Read about the motivations ' + 'behind this change: ' + 'https://fb.me/react-async-component-lifecycle-hooks' + '\n\n' + 'As a temporary workaround, you can rename to ' + 'UNSAFE_componentWillMount instead.' , _componentName3 ) ;
didWarnAboutDeprecatedWillMount [ _componentName3 ] = true ;
}
}
}
// In order to support react-lifecycles-compat polyfilled components,
// Unsafe lifecycles should not be invoked for any component with the new gDSFP.
if ( typeof Component . getDerivedStateFromProps !== 'function' ) {
inst . componentWillMount ( ) ;
}
}
if ( typeof inst . UNSAFE _componentWillMount === 'function' && typeof Component . getDerivedStateFromProps !== 'function' ) {
// In order to support react-lifecycles-compat polyfilled components,
// Unsafe lifecycles should not be invoked for any component with the new gDSFP.
inst . UNSAFE _componentWillMount ( ) ;
}
2017-10-14 18:40:54 +02:00
if ( queue . length ) {
var oldQueue = queue ;
var oldReplace = replace ;
queue = null ;
replace = false ;
if ( oldReplace && oldQueue . length === 1 ) {
inst . state = oldQueue [ 0 ] ;
} else {
var nextState = oldReplace ? oldQueue [ 0 ] : inst . state ;
var dontMutate = true ;
for ( var i = oldReplace ? 1 : 0 ; i < oldQueue . length ; i ++ ) {
var partial = oldQueue [ i ] ;
2018-09-20 02:56:13 +02:00
var _partialState = typeof partial === 'function' ? partial . call ( inst , nextState , element . props , publicContext ) : partial ;
if ( _partialState != null ) {
2017-10-14 18:40:54 +02:00
if ( dontMutate ) {
dontMutate = false ;
2018-09-20 02:56:13 +02:00
nextState = _assign ( { } , nextState , _partialState ) ;
2017-10-14 18:40:54 +02:00
} else {
2018-09-20 02:56:13 +02:00
_assign ( nextState , _partialState ) ;
2017-10-14 18:40:54 +02:00
}
}
}
inst . state = nextState ;
}
} else {
queue = null ;
}
}
child = inst . render ( ) ;
{
if ( child === undefined && inst . render . _isMockFunction ) {
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
child = null ;
}
}
validateRenderResult ( child , Component ) ;
2018-09-20 02:56:13 +02:00
var childContext = void 0 ;
2017-10-14 18:40:54 +02:00
if ( typeof inst . getChildContext === 'function' ) {
var childContextTypes = Component . childContextTypes ;
2017-12-10 21:51:33 +01:00
if ( typeof childContextTypes === 'object' ) {
childContext = inst . getChildContext ( ) ;
for ( var contextKey in childContext ) {
! ( contextKey in childContextTypes ) ? invariant ( false , '%s.getChildContext(): key "%s" is not defined in childContextTypes.' , getComponentName ( Component ) || 'Unknown' , contextKey ) : void 0 ;
}
} else {
2018-09-20 02:56:13 +02:00
warningWithoutStack$1 ( false , '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().' , getComponentName ( Component ) || 'Unknown' ) ;
2017-10-14 18:40:54 +02:00
}
}
if ( childContext ) {
2017-12-10 21:51:33 +01:00
context = _assign ( { } , context , childContext ) ;
2017-10-14 18:40:54 +02:00
}
}
return { child : child , context : context } ;
}
var ReactDOMServerRenderer = function ( ) {
2018-09-20 02:56:13 +02:00
// DEV-only
2017-12-10 21:51:33 +01:00
function ReactDOMServerRenderer ( children , makeStaticMarkup ) {
2017-10-14 18:40:54 +02:00
_classCallCheck ( this , ReactDOMServerRenderer ) ;
2017-12-10 21:51:33 +01:00
var flatChildren = flattenTopLevelChildren ( children ) ;
2017-10-14 18:40:54 +02:00
var topFrame = {
2018-09-20 02:56:13 +02:00
type : null ,
2017-10-14 18:40:54 +02:00
// Assume all trees start in the HTML namespace (not totally true, but
// this is what we did historically)
domNamespace : Namespaces . html ,
2017-12-10 21:51:33 +01:00
children : flatChildren ,
2017-10-14 18:40:54 +02:00
childIndex : 0 ,
context : emptyObject ,
footer : ''
} ;
{
topFrame . debugElementStack = [ ] ;
}
this . stack = [ topFrame ] ;
this . exhausted = false ;
this . currentSelectValue = null ;
this . previousWasTextNode = false ;
this . makeStaticMarkup = makeStaticMarkup ;
2018-09-20 02:56:13 +02:00
// Context (new API)
this . contextIndex = - 1 ;
this . contextStack = [ ] ;
this . contextValueStack = [ ] ;
{
this . contextProviderStack = [ ] ;
}
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
/ * *
* Note : We use just two stacks regardless of how many context providers you have .
* Providers are always popped in the reverse order to how they were pushed
* so we always know on the way down which provider you ' ll encounter next on the way up .
* On the way down , we push the current provider , and its context value * before *
* we mutated it , onto the stacks . Therefore , on the way up , we always know which
* provider needs to be "restored" to which value .
* https : //github.com/facebook/react/pull/12985#issuecomment-396301248
* /
2017-12-10 21:51:33 +01:00
// TODO: type this more strictly:
2017-10-14 18:40:54 +02:00
2018-09-20 02:56:13 +02:00
ReactDOMServerRenderer . prototype . pushProvider = function pushProvider ( provider ) {
var index = ++ this . contextIndex ;
var context = provider . type . _context ;
var previousValue = context . _currentValue ;
// Remember which value to restore this context to on our way up.
this . contextStack [ index ] = context ;
this . contextValueStack [ index ] = previousValue ;
{
// Only used for push/pop mismatch warnings.
this . contextProviderStack [ index ] = provider ;
}
// Mutate the current value.
context . _currentValue = provider . props . value ;
} ;
ReactDOMServerRenderer . prototype . popProvider = function popProvider ( provider ) {
var index = this . contextIndex ;
{
! ( index > - 1 && provider === this . contextProviderStack [ index ] ) ? warningWithoutStack$1 ( false , 'Unexpected pop.' ) : void 0 ;
}
var context = this . contextStack [ index ] ;
var previousValue = this . contextValueStack [ index ] ;
// "Hide" these null assignments from Flow by using `any`
// because conceptually they are deletions--as long as we
// promise to never access values beyond `this.contextIndex`.
this . contextStack [ index ] = null ;
this . contextValueStack [ index ] = null ;
{
this . contextProviderStack [ index ] = null ;
}
this . contextIndex -- ;
// Restore to the previous value we stored as we were walking down.
context . _currentValue = previousValue ;
} ;
2017-10-14 18:40:54 +02:00
ReactDOMServerRenderer . prototype . read = function read ( bytes ) {
if ( this . exhausted ) {
return null ;
}
var out = '' ;
while ( out . length < bytes ) {
if ( this . stack . length === 0 ) {
this . exhausted = true ;
break ;
}
var frame = this . stack [ this . stack . length - 1 ] ;
if ( frame . childIndex >= frame . children . length ) {
2018-09-20 02:56:13 +02:00
var _footer = frame . footer ;
out += _footer ;
if ( _footer !== '' ) {
2017-12-10 21:51:33 +01:00
this . previousWasTextNode = false ;
}
2017-10-14 18:40:54 +02:00
this . stack . pop ( ) ;
2018-09-20 02:56:13 +02:00
if ( frame . type === 'select' ) {
2017-10-14 18:40:54 +02:00
this . currentSelectValue = null ;
2018-09-20 02:56:13 +02:00
} else if ( frame . type != null && frame . type . type != null && frame . type . type . $$typeof === REACT _PROVIDER _TYPE ) {
var provider = frame . type ;
this . popProvider ( provider ) ;
2017-10-14 18:40:54 +02:00
}
continue ;
}
var child = frame . children [ frame . childIndex ++ ] ;
{
2018-09-20 02:56:13 +02:00
pushCurrentDebugStack ( this . stack ) ;
// We're starting work on this frame, so reset its inner stack.
frame . debugElementStack . length = 0 ;
try {
// Be careful! Make sure this matches the PROD path below.
out += this . render ( child , frame . context , frame . domNamespace ) ;
} finally {
popCurrentDebugStack ( ) ;
}
2017-10-14 18:40:54 +02:00
}
}
return out ;
} ;
ReactDOMServerRenderer . prototype . render = function render ( child , context , parentNamespace ) {
if ( typeof child === 'string' || typeof child === 'number' ) {
var text = '' + child ;
if ( text === '' ) {
return '' ;
}
if ( this . makeStaticMarkup ) {
2017-12-10 21:51:33 +01:00
return escapeTextForBrowser ( text ) ;
2017-10-14 18:40:54 +02:00
}
if ( this . previousWasTextNode ) {
2017-12-10 21:51:33 +01:00
return '<!-- -->' + escapeTextForBrowser ( text ) ;
2017-10-14 18:40:54 +02:00
}
this . previousWasTextNode = true ;
2017-12-10 21:51:33 +01:00
return escapeTextForBrowser ( text ) ;
2017-10-14 18:40:54 +02:00
} else {
2018-09-20 02:56:13 +02:00
var nextChild = void 0 ;
2017-12-10 21:51:33 +01:00
2017-10-14 18:40:54 +02:00
var _resolve = resolve ( child , context ) ;
2017-12-10 21:51:33 +01:00
nextChild = _resolve . child ;
2017-10-14 18:40:54 +02:00
context = _resolve . context ;
2017-12-10 21:51:33 +01:00
if ( nextChild === null || nextChild === false ) {
2017-10-14 18:40:54 +02:00
return '' ;
2017-12-10 21:51:33 +01:00
} else if ( ! React . isValidElement ( nextChild ) ) {
2018-09-20 02:56:13 +02:00
if ( nextChild != null && nextChild . $$typeof != null ) {
// Catch unexpected special types early.
var $$typeof = nextChild . $$typeof ;
! ( $$typeof !== REACT _PORTAL _TYPE ) ? invariant ( false , 'Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.' ) : void 0 ;
// Catch-all to prevent an infinite loop if React.Children.toArray() supports some new type.
invariant ( false , 'Unknown element-like object type: %s. This is likely a bug in React. Please file an issue.' , $$typeof . toString ( ) ) ;
}
2017-12-10 21:51:33 +01:00
var nextChildren = toArray ( nextChild ) ;
var frame = {
2018-09-20 02:56:13 +02:00
type : null ,
2017-12-10 21:51:33 +01:00
domNamespace : parentNamespace ,
children : nextChildren ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
frame . debugElementStack = [ ] ;
2017-10-14 18:40:54 +02:00
}
2017-12-10 21:51:33 +01:00
this . stack . push ( frame ) ;
return '' ;
2018-09-20 02:56:13 +02:00
}
// Safe because we just checked it's an element.
var nextElement = nextChild ;
var elementType = nextElement . type ;
if ( typeof elementType === 'string' ) {
2017-12-10 21:51:33 +01:00
return this . renderDOM ( nextElement , context , parentNamespace ) ;
2017-10-14 18:40:54 +02:00
}
2018-09-20 02:56:13 +02:00
switch ( elementType ) {
case REACT _STRICT _MODE _TYPE :
case REACT _ASYNC _MODE _TYPE :
case REACT _PROFILER _TYPE :
case REACT _FRAGMENT _TYPE :
{
var _nextChildren = toArray ( nextChild . props . children ) ;
var _frame = {
type : null ,
domNamespace : parentNamespace ,
children : _nextChildren ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
_frame . debugElementStack = [ ] ;
}
this . stack . push ( _frame ) ;
return '' ;
}
case REACT _PLACEHOLDER _TYPE :
{
if ( enableSuspenseServerRenderer ) {
var _nextChildren2 = toArray (
// Always use the fallback when synchronously rendering to string.
nextChild . props . fallback ) ;
var _frame2 = {
type : null ,
domNamespace : parentNamespace ,
children : _nextChildren2 ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
_frame2 . debugElementStack = [ ] ;
}
this . stack . push ( _frame2 ) ;
return '' ;
}
}
// eslint-disable-next-line-no-fallthrough
default :
break ;
}
if ( typeof elementType === 'object' && elementType !== null ) {
switch ( elementType . $$typeof ) {
case REACT _FORWARD _REF _TYPE :
{
var element = nextChild ;
var _nextChildren3 = toArray ( elementType . render ( element . props , element . ref ) ) ;
var _frame3 = {
type : null ,
domNamespace : parentNamespace ,
children : _nextChildren3 ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
_frame3 . debugElementStack = [ ] ;
}
this . stack . push ( _frame3 ) ;
return '' ;
}
case REACT _PROVIDER _TYPE :
{
var provider = nextChild ;
var nextProps = provider . props ;
var _nextChildren4 = toArray ( nextProps . children ) ;
var _frame4 = {
type : provider ,
domNamespace : parentNamespace ,
children : _nextChildren4 ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
_frame4 . debugElementStack = [ ] ;
}
this . pushProvider ( provider ) ;
this . stack . push ( _frame4 ) ;
return '' ;
}
case REACT _CONTEXT _TYPE :
{
var consumer = nextChild ;
var _nextProps = consumer . props ;
var nextValue = consumer . type . _currentValue ;
var _nextChildren5 = toArray ( _nextProps . children ( nextValue ) ) ;
var _frame5 = {
type : nextChild ,
domNamespace : parentNamespace ,
children : _nextChildren5 ,
childIndex : 0 ,
context : context ,
footer : ''
} ;
{
_frame5 . debugElementStack = [ ] ;
}
this . stack . push ( _frame5 ) ;
return '' ;
}
default :
break ;
}
}
var info = '' ;
{
var owner = nextElement . _owner ;
if ( elementType === undefined || typeof elementType === 'object' && elementType !== null && Object . keys ( elementType ) . length === 0 ) {
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.' ;
}
var ownerName = owner ? getComponentName ( owner ) : null ;
if ( ownerName ) {
info += '\n\nCheck the render method of `' + ownerName + '`.' ;
}
}
invariant ( false , 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s' , elementType == null ? elementType : typeof elementType , info ) ;
2017-10-14 18:40:54 +02:00
}
} ;
ReactDOMServerRenderer . prototype . renderDOM = function renderDOM ( element , context , parentNamespace ) {
var tag = element . type . toLowerCase ( ) ;
var namespace = parentNamespace ;
if ( parentNamespace === Namespaces . html ) {
namespace = getIntrinsicNamespace ( tag ) ;
}
{
if ( namespace === Namespaces . html ) {
// Should this check be gated by parent namespace? Not sure we want to
// allow <SVG> or <mATH>.
2018-09-20 02:56:13 +02:00
! ( tag === element . type ) ? warning$1 ( false , '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.' , element . type ) : void 0 ;
2017-10-14 18:40:54 +02:00
}
}
validateDangerousTag ( tag ) ;
var props = element . props ;
if ( tag === 'input' ) {
{
2018-09-20 02:56:13 +02:00
ReactControlledValuePropTypes . checkPropTypes ( 'input' , props ) ;
2017-10-14 18:40:54 +02:00
if ( props . checked !== undefined && props . defaultChecked !== undefined && ! didWarnDefaultChecked ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components' , 'A component' , props . type ) ;
2017-10-14 18:40:54 +02:00
didWarnDefaultChecked = true ;
}
if ( props . value !== undefined && props . defaultValue !== undefined && ! didWarnDefaultInputValue ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components' , 'A component' , props . type ) ;
2017-10-14 18:40:54 +02:00
didWarnDefaultInputValue = true ;
}
}
2017-12-10 21:51:33 +01:00
props = _assign ( {
2017-10-14 18:40:54 +02:00
type : undefined
} , props , {
defaultChecked : undefined ,
defaultValue : undefined ,
value : props . value != null ? props . value : props . defaultValue ,
checked : props . checked != null ? props . checked : props . defaultChecked
} ) ;
} else if ( tag === 'textarea' ) {
{
2018-09-20 02:56:13 +02:00
ReactControlledValuePropTypes . checkPropTypes ( 'textarea' , props ) ;
2017-10-14 18:40:54 +02:00
if ( props . value !== undefined && props . defaultValue !== undefined && ! didWarnDefaultTextareaValue ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components' ) ;
2017-10-14 18:40:54 +02:00
didWarnDefaultTextareaValue = true ;
}
}
var initialValue = props . value ;
if ( initialValue == null ) {
var defaultValue = props . defaultValue ;
// TODO (yungsters): Remove support for children content in <textarea>.
var textareaChildren = props . children ;
if ( textareaChildren != null ) {
{
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.' ) ;
2017-10-14 18:40:54 +02:00
}
! ( defaultValue == null ) ? invariant ( false , 'If you supply `defaultValue` on a <textarea>, do not pass children.' ) : void 0 ;
if ( Array . isArray ( textareaChildren ) ) {
! ( textareaChildren . length <= 1 ) ? invariant ( false , '<textarea> can only have at most one child.' ) : void 0 ;
textareaChildren = textareaChildren [ 0 ] ;
}
defaultValue = '' + textareaChildren ;
}
if ( defaultValue == null ) {
defaultValue = '' ;
}
initialValue = defaultValue ;
}
2017-12-10 21:51:33 +01:00
props = _assign ( { } , props , {
2017-10-14 18:40:54 +02:00
value : undefined ,
children : '' + initialValue
} ) ;
} else if ( tag === 'select' ) {
{
2018-09-20 02:56:13 +02:00
ReactControlledValuePropTypes . checkPropTypes ( 'select' , props ) ;
2017-10-14 18:40:54 +02:00
for ( var i = 0 ; i < valuePropNames . length ; i ++ ) {
var propName = valuePropNames [ i ] ;
if ( props [ propName ] == null ) {
continue ;
}
var isArray = Array . isArray ( props [ propName ] ) ;
if ( props . multiple && ! isArray ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.' , propName ) ;
2017-10-14 18:40:54 +02:00
} else if ( ! props . multiple && isArray ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.' , propName ) ;
2017-10-14 18:40:54 +02:00
}
}
if ( props . value !== undefined && props . defaultValue !== undefined && ! didWarnDefaultSelectValue ) {
2018-09-20 02:56:13 +02:00
warning$1 ( false , 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components' ) ;
2017-10-14 18:40:54 +02:00
didWarnDefaultSelectValue = true ;
}
}
this . currentSelectValue = props . value != null ? props . value : props . defaultValue ;
2017-12-10 21:51:33 +01:00
props = _assign ( { } , props , {
2017-10-14 18:40:54 +02:00
value : undefined
} ) ;
} else if ( tag === 'option' ) {
var selected = null ;
var selectValue = this . currentSelectValue ;
var optionChildren = flattenOptionChildren ( props . children ) ;
if ( selectValue != null ) {
2018-09-20 02:56:13 +02:00
var value = void 0 ;
2017-10-14 18:40:54 +02:00
if ( props . value != null ) {
value = props . value + '' ;
} else {
value = optionChildren ;
}
selected = false ;
if ( Array . isArray ( selectValue ) ) {
// multiple
for ( var j = 0 ; j < selectValue . length ; j ++ ) {
if ( '' + selectValue [ j ] === value ) {
selected = true ;
break ;
}
}
} else {
selected = '' + selectValue === value ;
}
2017-12-10 21:51:33 +01:00
props = _assign ( {
2017-10-14 18:40:54 +02:00
selected : undefined ,
children : undefined
} , props , {
selected : selected ,
children : optionChildren
} ) ;
}
}
{
validatePropertiesInDevelopment ( tag , props ) ;
}
2018-09-20 02:56:13 +02:00
assertValidProps ( tag , props ) ;
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
var out = createOpenTagMarkup ( element . type , tag , props , namespace , this . makeStaticMarkup , this . stack . length === 1 ) ;
2017-10-14 18:40:54 +02:00
var footer = '' ;
2017-12-10 21:51:33 +01:00
if ( omittedCloseTags . hasOwnProperty ( tag ) ) {
2017-10-14 18:40:54 +02:00
out += '/>' ;
} else {
out += '>' ;
footer = '</' + element . type + '>' ;
}
2018-09-20 02:56:13 +02:00
var children = void 0 ;
2017-10-14 18:40:54 +02:00
var innerMarkup = getNonChildrenInnerMarkup ( props ) ;
if ( innerMarkup != null ) {
children = [ ] ;
if ( newlineEatingTags [ tag ] && innerMarkup . charAt ( 0 ) === '\n' ) {
// text/html ignores the first character in these tags if it's a newline
// Prefer to break application/xml over text/html (for now) by adding
// a newline specifically to get eaten by the parser. (Alternately for
// textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
// \r is normalized out by HTMLTextAreaElement#value.)
// See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
// See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
// See: <http://www.w3.org/TR/html5/syntax.html#newlines>
// See: Parsing of "textarea" "listing" and "pre" elements
// from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
out += '\n' ;
}
out += innerMarkup ;
} else {
children = toArray ( props . children ) ;
}
var frame = {
domNamespace : getChildNamespace ( parentNamespace , element . type ) ,
2018-09-20 02:56:13 +02:00
type : tag ,
2017-10-14 18:40:54 +02:00
children : children ,
childIndex : 0 ,
context : context ,
footer : footer
} ;
{
frame . debugElementStack = [ ] ;
}
this . stack . push ( frame ) ;
2017-12-10 21:51:33 +01:00
this . previousWasTextNode = false ;
2017-10-14 18:40:54 +02:00
return out ;
} ;
return ReactDOMServerRenderer ;
} ( ) ;
/ * *
* Render a ReactElement to its initial HTML . This should only be used on the
* server .
2017-12-10 21:51:33 +01:00
* See https : //reactjs.org/docs/react-dom-server.html#rendertostring
2017-10-14 18:40:54 +02:00
* /
function renderToString ( element ) {
2017-12-10 21:51:33 +01:00
var renderer = new ReactDOMServerRenderer ( element , false ) ;
2017-10-14 18:40:54 +02:00
var markup = renderer . read ( Infinity ) ;
return markup ;
}
/ * *
* Similar to renderToString , except this doesn ' t create extra DOM attributes
* such as data - react - id that React uses internally .
2017-12-10 21:51:33 +01:00
* See https : //reactjs.org/docs/react-dom-server.html#rendertostaticmarkup
2017-10-14 18:40:54 +02:00
* /
function renderToStaticMarkup ( element ) {
2017-12-10 21:51:33 +01:00
var renderer = new ReactDOMServerRenderer ( element , true ) ;
2017-10-14 18:40:54 +02:00
var markup = renderer . read ( Infinity ) ;
return markup ;
}
2017-12-10 21:51:33 +01:00
function renderToNodeStream ( ) {
invariant ( false , 'ReactDOMServer.renderToNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToString() instead.' ) ;
}
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
function renderToStaticNodeStream ( ) {
invariant ( false , 'ReactDOMServer.renderToStaticNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.' ) ;
}
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
var ReactDOMServerBrowser = {
renderToString : renderToString ,
renderToStaticMarkup : renderToStaticMarkup ,
renderToNodeStream : renderToNodeStream ,
renderToStaticNodeStream : renderToStaticNodeStream ,
version : ReactVersion
2017-10-14 18:40:54 +02:00
} ;
2017-12-10 21:51:33 +01:00
var ReactDOMServerBrowser$1 = Object . freeze ( {
default : ReactDOMServerBrowser
2017-10-14 18:40:54 +02:00
} ) ;
2017-12-10 21:51:33 +01:00
var ReactDOMServer = ( ReactDOMServerBrowser$1 && ReactDOMServerBrowser ) || ReactDOMServerBrowser$1 ;
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
// TODO: decide on the top-level export form.
// This is hacky but makes it work with both Rollup and Jest
2018-09-20 02:56:13 +02:00
var server _browser = ReactDOMServer . default || ReactDOMServer ;
2017-10-14 18:40:54 +02:00
2017-12-10 21:51:33 +01:00
module . exports = server _browser ;
} ) ( ) ;
2017-10-14 18:40:54 +02:00
}