-
-
Save gaearon/ff710198c82f60470c8c4092b9204065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule React-core | |
*/ | |
'use strict'; | |
var warning = require('warning'); | |
var emptyObject = require('emptyObject'); | |
var invariant = require('invariant'); | |
var emptyFunction = require('emptyFunction'); | |
var warning$2 = warning; | |
function warnNoop(publicInstance, callerName) { | |
if (__DEV__) { | |
var constructor = publicInstance.constructor; | |
warning$2(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass'); | |
} | |
} | |
/** | |
* This is the abstract API for an update queue. | |
*/ | |
var ReactNoopUpdateQueue$1 = { | |
/** | |
* Checks whether or not this composite component is mounted. | |
* @param {ReactClass} publicInstance The instance we want to test. | |
* @return {boolean} True if mounted, false otherwise. | |
* @protected | |
* @final | |
*/ | |
isMounted: function (publicInstance) { | |
return false; | |
}, | |
/** | |
* Forces an update. This should only be invoked when it is known with | |
* certainty that we are **not** in a DOM transaction. | |
* | |
* You may want to call this when you know that some deeper aspect of the | |
* component's state has changed but `setState` was not called. | |
* | |
* This will not invoke `shouldComponentUpdate`, but it will invoke | |
* `componentWillUpdate` and `componentDidUpdate`. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueForceUpdate: function (publicInstance, callback, callerName) { | |
warnNoop(publicInstance, 'forceUpdate'); | |
}, | |
/** | |
* Replaces all of the state. Always use this or `setState` to mutate state. | |
* You should treat `this.state` as immutable. | |
* | |
* There is no guarantee that `this.state` will be immediately updated, so | |
* accessing `this.state` after calling this method may return the old value. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object} completeState Next state. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { | |
warnNoop(publicInstance, 'replaceState'); | |
}, | |
/** | |
* Sets a subset of the state. This only exists because _pendingState is | |
* internal. This provides a merging strategy that is not available to deep | |
* properties which is confusing. TODO: Expose pendingState or don't use it | |
* during the merge. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object} partialState Next partial state to be merged with state. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueSetState: function (publicInstance, partialState, callback, callerName) { | |
warnNoop(publicInstance, 'setState'); | |
} | |
}; | |
var ReactNoopUpdateQueue_1 = ReactNoopUpdateQueue$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule canDefineProperty | |
*/ | |
var canDefineProperty$1 = false; | |
if (__DEV__) { | |
try { | |
// $FlowFixMe https://github.com/facebook/flow/issues/285 | |
Object.defineProperty({}, 'x', { get: function () {} }); | |
canDefineProperty$1 = true; | |
} catch (x) { | |
// IE will fail on defineProperty | |
} | |
} | |
var canDefineProperty_1 = canDefineProperty$1; | |
var ReactNoopUpdateQueue = ReactNoopUpdateQueue_1; | |
var canDefineProperty = canDefineProperty_1; | |
var emptyObject$1 = emptyObject; | |
var invariant2 = invariant; | |
var warning$1 = warning; | |
/** | |
* Base class helpers for the updating state of a component. | |
*/ | |
function ReactComponent(props, context, updater) { | |
this.props = props; | |
this.context = context; | |
this.refs = emptyObject$1; | |
// We initialize the default updater but the real one gets injected by the | |
// renderer. | |
this.updater = updater || ReactNoopUpdateQueue; | |
} | |
ReactComponent.prototype.isReactComponent = {}; | |
/** | |
* Sets a subset of the state. Always use this to mutate | |
* state. You should treat `this.state` as immutable. | |
* | |
* There is no guarantee that `this.state` will be immediately updated, so | |
* accessing `this.state` after calling this method may return the old value. | |
* | |
* There is no guarantee that calls to `setState` will run synchronously, | |
* as they may eventually be batched together. You can provide an optional | |
* callback that will be executed when the call to setState is actually | |
* completed. | |
* | |
* When a function is provided to setState, it will be called at some point in | |
* the future (not synchronously). It will be called with the up to date | |
* component arguments (state, props, context). These values can be different | |
* from this.* because your function may be called after receiveProps but before | |
* shouldComponentUpdate, and this new state, props, and context will not yet be | |
* assigned to this. | |
* | |
* @param {object|function} partialState Next partial state or function to | |
* produce next partial state to be merged with current state. | |
* @param {?function} callback Called after state is updated. | |
* @final | |
* @protected | |
*/ | |
ReactComponent.prototype.setState = function (partialState, callback) { | |
invariant2(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.'); | |
this.updater.enqueueSetState(this, partialState, callback, 'setState'); | |
}; | |
/** | |
* Forces an update. This should only be invoked when it is known with | |
* certainty that we are **not** in a DOM transaction. | |
* | |
* You may want to call this when you know that some deeper aspect of the | |
* component's state has changed but `setState` was not called. | |
* | |
* This will not invoke `shouldComponentUpdate`, but it will invoke | |
* `componentWillUpdate` and `componentDidUpdate`. | |
* | |
* @param {?function} callback Called after update is complete. | |
* @final | |
* @protected | |
*/ | |
ReactComponent.prototype.forceUpdate = function (callback) { | |
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); | |
}; | |
/** | |
* Deprecated APIs. These APIs used to exist on classic React classes but since | |
* we would like to deprecate them, we're not going to move them over to this | |
* modern base class. Instead, we define a getter that warns if it's accessed. | |
*/ | |
if (__DEV__) { | |
var deprecatedAPIs = { | |
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], | |
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] | |
}; | |
var defineDeprecationWarning = function (methodName, info) { | |
if (canDefineProperty) { | |
Object.defineProperty(ReactComponent.prototype, methodName, { | |
get: function () { | |
warning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); | |
return undefined; | |
} | |
}); | |
} | |
}; | |
for (var fnName in deprecatedAPIs) { | |
if (deprecatedAPIs.hasOwnProperty(fnName)) { | |
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); | |
} | |
} | |
} | |
/** | |
* Base class helpers for the updating state of a component. | |
*/ | |
function ReactPureComponent(props, context, updater) { | |
// Duplicated from ReactComponent. | |
this.props = props; | |
this.context = context; | |
this.refs = emptyObject$1; | |
// We initialize the default updater but the real one gets injected by the | |
// renderer. | |
this.updater = updater || ReactNoopUpdateQueue; | |
} | |
function ComponentDummy() {} | |
ComponentDummy.prototype = ReactComponent.prototype; | |
ReactPureComponent.prototype = new ComponentDummy(); | |
ReactPureComponent.prototype.constructor = ReactPureComponent; | |
// Avoid an extra prototype jump for these methods. | |
Object.assign(ReactPureComponent.prototype, ReactComponent.prototype); | |
ReactPureComponent.prototype.isPureReactComponent = true; | |
var ReactBaseClasses$1 = { | |
Component: ReactComponent, | |
PureComponent: ReactPureComponent | |
}; | |
var invariant$1 = invariant; | |
/** | |
* Static poolers. Several custom versions for each potential number of | |
* arguments. A completely generic pooler is easy to implement, but would | |
* require accessing the `arguments` object. In each of these, `this` refers to | |
* the Class itself, not an instance. If any others are needed, simply add them | |
* here, or in their own files. | |
*/ | |
var oneArgumentPooler = function (copyFieldsFrom) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, copyFieldsFrom); | |
return instance; | |
} else { | |
return new Klass(copyFieldsFrom); | |
} | |
}; | |
var twoArgumentPooler$1 = function (a1, a2) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2); | |
return instance; | |
} else { | |
return new Klass(a1, a2); | |
} | |
}; | |
var threeArgumentPooler = function (a1, a2, a3) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3); | |
} | |
}; | |
var fourArgumentPooler$1 = function (a1, a2, a3, a4) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3, a4); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3, a4); | |
} | |
}; | |
var standardReleaser = function (instance) { | |
var Klass = this; | |
invariant$1(instance instanceof Klass, 'Trying to release an instance into a pool of a different type.'); | |
instance.destructor(); | |
if (Klass.instancePool.length < Klass.poolSize) { | |
Klass.instancePool.push(instance); | |
} | |
}; | |
var DEFAULT_POOL_SIZE = 10; | |
var DEFAULT_POOLER = oneArgumentPooler; | |
/** | |
* Augments `CopyConstructor` to be a poolable class, augmenting only the class | |
* itself (statically) not adding any prototypical fields. Any CopyConstructor | |
* you give this may have a `poolSize` property, and will look for a | |
* prototypical `destructor` on instances. | |
* | |
* @param {Function} CopyConstructor Constructor that can be used to reset. | |
* @param {Function} pooler Customizable pooler. | |
*/ | |
var addPoolingTo = function (CopyConstructor, pooler) { | |
// Casting as any so that flow ignores the actual implementation and trusts | |
// it to match the type we declared | |
var NewKlass = CopyConstructor; | |
NewKlass.instancePool = []; | |
NewKlass.getPooled = pooler || DEFAULT_POOLER; | |
if (!NewKlass.poolSize) { | |
NewKlass.poolSize = DEFAULT_POOL_SIZE; | |
} | |
NewKlass.release = standardReleaser; | |
return NewKlass; | |
}; | |
var PooledClass$1 = { | |
addPoolingTo: addPoolingTo, | |
oneArgumentPooler: oneArgumentPooler, | |
twoArgumentPooler: twoArgumentPooler$1, | |
threeArgumentPooler: threeArgumentPooler, | |
fourArgumentPooler: fourArgumentPooler$1 | |
}; | |
var PooledClass_1 = PooledClass$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactCurrentOwner | |
* | |
*/ | |
/** | |
* Keeps track of the current owner. | |
* | |
* The current owner is the component who should own any components that are | |
* currently being constructed. | |
*/ | |
var ReactCurrentOwner$1 = { | |
/** | |
* @internal | |
* @type {ReactComponent} | |
*/ | |
current: null | |
}; | |
var ReactCurrentOwner_1 = ReactCurrentOwner$1; | |
/** | |
* Copyright 2014-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactElementSymbol | |
* | |
*/ | |
// The Symbol used to tag the ReactElement type. If there is no native Symbol | |
// nor polyfill, then a plain number is used for performance. | |
var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7; | |
var ReactElementSymbol = REACT_ELEMENT_TYPE$1; | |
var ReactCurrentOwner = ReactCurrentOwner_1; | |
var warning$3 = warning; | |
var canDefineProperty$2 = canDefineProperty_1; | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var REACT_ELEMENT_TYPE = ReactElementSymbol; | |
var RESERVED_PROPS = { | |
key: true, | |
ref: true, | |
__self: true, | |
__source: true | |
}; | |
var specialPropKeyWarningShown; | |
var specialPropRefWarningShown; | |
function hasValidRef(config) { | |
if (__DEV__) { | |
if (hasOwnProperty.call(config, 'ref')) { | |
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; | |
if (getter && getter.isReactWarning) { | |
return false; | |
} | |
} | |
} | |
return config.ref !== undefined; | |
} | |
function hasValidKey(config) { | |
if (__DEV__) { | |
if (hasOwnProperty.call(config, 'key')) { | |
var getter = Object.getOwnPropertyDescriptor(config, 'key').get; | |
if (getter && getter.isReactWarning) { | |
return false; | |
} | |
} | |
} | |
return config.key !== undefined; | |
} | |
function defineKeyPropWarningGetter(props, displayName) { | |
var warnAboutAccessingKey = function () { | |
if (!specialPropKeyWarningShown) { | |
specialPropKeyWarningShown = true; | |
warning$3(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); | |
} | |
}; | |
warnAboutAccessingKey.isReactWarning = true; | |
Object.defineProperty(props, 'key', { | |
get: warnAboutAccessingKey, | |
configurable: true | |
}); | |
} | |
function defineRefPropWarningGetter(props, displayName) { | |
var warnAboutAccessingRef = function () { | |
if (!specialPropRefWarningShown) { | |
specialPropRefWarningShown = true; | |
warning$3(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); | |
} | |
}; | |
warnAboutAccessingRef.isReactWarning = true; | |
Object.defineProperty(props, 'ref', { | |
get: warnAboutAccessingRef, | |
configurable: true | |
}); | |
} | |
/** | |
* Factory method to create a new React element. This no longer adheres to | |
* the class pattern, so do not use new to call it. Also, no instanceof check | |
* will work. Instead test $$typeof field against Symbol.for('react.element') to check | |
* if something is a React Element. | |
* | |
* @param {*} type | |
* @param {*} key | |
* @param {string|object} ref | |
* @param {*} self A *temporary* helper to detect places where `this` is | |
* different from the `owner` when React.createElement is called, so that we | |
* can warn. We want to get rid of owner and replace string `ref`s with arrow | |
* functions, and as long as `this` and owner are the same, there will be no | |
* change in behavior. | |
* @param {*} source An annotation object (added by a transpiler or otherwise) | |
* indicating filename, line number, and/or other information. | |
* @param {*} owner | |
* @param {*} props | |
* @internal | |
*/ | |
var ReactElement$2 = function (type, key, ref, self, source, owner, props) { | |
var element = { | |
// This tag allow us to uniquely identify this as a React Element | |
$$typeof: REACT_ELEMENT_TYPE, | |
// Built-in properties that belong on the element | |
type: type, | |
key: key, | |
ref: ref, | |
props: props, | |
// Record the component responsible for creating this element. | |
_owner: owner | |
}; | |
if (__DEV__) { | |
// The validation flag is currently mutative. We put it on | |
// an external backing store so that we can freeze the whole object. | |
// This can be replaced with a WeakMap once they are implemented in | |
// commonly used development environments. | |
element._store = {}; | |
// To make comparing ReactElements easier for testing purposes, we make | |
// the validation flag non-enumerable (where possible, which should | |
// include every environment we run tests in), so the test framework | |
// ignores it. | |
if (canDefineProperty$2) { | |
Object.defineProperty(element._store, 'validated', { | |
configurable: false, | |
enumerable: false, | |
writable: true, | |
value: false | |
}); | |
// self and source are DEV only properties. | |
Object.defineProperty(element, '_self', { | |
configurable: false, | |
enumerable: false, | |
writable: false, | |
value: self | |
}); | |
// Two elements created in two different places should be considered | |
// equal for testing purposes and therefore we hide it from enumeration. | |
Object.defineProperty(element, '_source', { | |
configurable: false, | |
enumerable: false, | |
writable: false, | |
value: source | |
}); | |
} else { | |
element._store.validated = false; | |
element._self = self; | |
element._source = source; | |
} | |
if (Object.freeze) { | |
Object.freeze(element.props); | |
Object.freeze(element); | |
} | |
} | |
return element; | |
}; | |
/** | |
* Create and return a new ReactElement of the given type. | |
* See https://facebook.github.io/react/docs/react-api.html#createelement | |
*/ | |
ReactElement$2.createElement = function (type, config, children) { | |
var propName; | |
// Reserved names are extracted | |
var props = {}; | |
var key = null; | |
var ref = null; | |
var self = null; | |
var source = null; | |
if (config != null) { | |
if (hasValidRef(config)) { | |
ref = config.ref; | |
} | |
if (hasValidKey(config)) { | |
key = '' + config.key; | |
} | |
self = config.__self === undefined ? null : config.__self; | |
source = config.__source === undefined ? null : config.__source; | |
// Remaining properties are added to a new props object | |
for (propName in config) { | |
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { | |
props[propName] = config[propName]; | |
} | |
} | |
} | |
// Children can be more than one argument, and those are transferred onto | |
// the newly allocated props object. | |
var childrenLength = arguments.length - 2; | |
if (childrenLength === 1) { | |
props.children = children; | |
} else if (childrenLength > 1) { | |
var childArray = Array(childrenLength); | |
for (var i = 0; i < childrenLength; i++) { | |
childArray[i] = arguments[i + 2]; | |
} | |
if (__DEV__) { | |
if (Object.freeze) { | |
Object.freeze(childArray); | |
} | |
} | |
props.children = childArray; | |
} | |
// Resolve default props | |
if (type && type.defaultProps) { | |
var defaultProps = type.defaultProps; | |
for (propName in defaultProps) { | |
if (props[propName] === undefined) { | |
props[propName] = defaultProps[propName]; | |
} | |
} | |
} | |
if (__DEV__) { | |
if (key || ref) { | |
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) { | |
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; | |
if (key) { | |
defineKeyPropWarningGetter(props, displayName); | |
} | |
if (ref) { | |
defineRefPropWarningGetter(props, displayName); | |
} | |
} | |
} | |
} | |
return ReactElement$2(type, key, ref, self, source, ReactCurrentOwner.current, props); | |
}; | |
/** | |
* Return a function that produces ReactElements of a given type. | |
* See https://facebook.github.io/react/docs/react-api.html#createfactory | |
*/ | |
ReactElement$2.createFactory = function (type) { | |
var factory = ReactElement$2.createElement.bind(null, type); | |
// Expose the type on the factory and the prototype so that it can be | |
// easily accessed on elements. E.g. `<Foo />.type === Foo`. | |
// This should not be named `constructor` since this may not be the function | |
// that created the element, and it may not even be a constructor. | |
// Legacy hook TODO: Warn if this is accessed | |
factory.type = type; | |
return factory; | |
}; | |
ReactElement$2.cloneAndReplaceKey = function (oldElement, newKey) { | |
var newElement = ReactElement$2(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); | |
return newElement; | |
}; | |
/** | |
* Clone and return a new ReactElement using element as the starting point. | |
* See https://facebook.github.io/react/docs/react-api.html#cloneelement | |
*/ | |
ReactElement$2.cloneElement = function (element, config, children) { | |
var propName; | |
// Original props are copied | |
var props = Object.assign({}, element.props); | |
// Reserved names are extracted | |
var key = element.key; | |
var ref = element.ref; | |
// Self is preserved since the owner is preserved. | |
var self = element._self; | |
// Source is preserved since cloneElement is unlikely to be targeted by a | |
// transpiler, and the original source is probably a better indicator of the | |
// true owner. | |
var source = element._source; | |
// Owner will be preserved, unless ref is overridden | |
var owner = element._owner; | |
if (config != null) { | |
if (hasValidRef(config)) { | |
// Silently steal the ref from the parent. | |
ref = config.ref; | |
owner = ReactCurrentOwner.current; | |
} | |
if (hasValidKey(config)) { | |
key = '' + config.key; | |
} | |
// Remaining properties override existing props | |
var defaultProps; | |
if (element.type && element.type.defaultProps) { | |
defaultProps = element.type.defaultProps; | |
} | |
for (propName in config) { | |
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { | |
if (config[propName] === undefined && defaultProps !== undefined) { | |
// Resolve default props | |
props[propName] = defaultProps[propName]; | |
} else { | |
props[propName] = config[propName]; | |
} | |
} | |
} | |
} | |
// Children can be more than one argument, and those are transferred onto | |
// the newly allocated props object. | |
var childrenLength = arguments.length - 2; | |
if (childrenLength === 1) { | |
props.children = children; | |
} else if (childrenLength > 1) { | |
var childArray = Array(childrenLength); | |
for (var i = 0; i < childrenLength; i++) { | |
childArray[i] = arguments[i + 2]; | |
} | |
props.children = childArray; | |
} | |
return ReactElement$2(element.type, key, ref, self, source, owner, props); | |
}; | |
/** | |
* Verifies the object is a ReactElement. | |
* See https://facebook.github.io/react/docs/react-api.html#isvalidelement | |
* @param {?object} object | |
* @return {boolean} True if `object` is a valid component. | |
* @final | |
*/ | |
ReactElement$2.isValidElement = function (object) { | |
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; | |
}; | |
var ReactElement_1 = ReactElement$2; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getIteratorFn | |
* | |
*/ | |
/* global Symbol */ | |
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | |
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | |
/** | |
* Returns the iterator method function contained on the iterable object. | |
* | |
* Be sure to invoke the function with the iterable as context: | |
* | |
* var iteratorFn = getIteratorFn(myIterable); | |
* if (iteratorFn) { | |
* var iterator = iteratorFn.call(myIterable); | |
* ... | |
* } | |
* | |
* @param {?object} maybeIterable | |
* @return {?function} | |
*/ | |
function getIteratorFn$1(maybeIterable) { | |
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | |
if (typeof iteratorFn === 'function') { | |
return iteratorFn; | |
} | |
} | |
var getIteratorFn_1 = getIteratorFn$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule KeyEscapeUtils | |
* | |
*/ | |
/** | |
* Escape and wrap key so it is safe to use as a reactid | |
* | |
* @param {string} key to be escaped. | |
* @return {string} the escaped key. | |
*/ | |
function escape(key) { | |
var escapeRegex = /[=:]/g; | |
var escaperLookup = { | |
'=': '=0', | |
':': '=2' | |
}; | |
var escapedString = ('' + key).replace(escapeRegex, function (match) { | |
return escaperLookup[match]; | |
}); | |
return '$' + escapedString; | |
} | |
/** | |
* Unescape and unwrap key for human-readable display | |
* | |
* @param {string} key to unescape. | |
* @return {string} the unescaped key. | |
*/ | |
function unescape(key) { | |
var unescapeRegex = /(=0|=2)/g; | |
var unescaperLookup = { | |
'=0': '=', | |
'=2': ':' | |
}; | |
var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1); | |
return ('' + keySubstring).replace(unescapeRegex, function (match) { | |
return unescaperLookup[match]; | |
}); | |
} | |
var KeyEscapeUtils$1 = { | |
escape: escape, | |
unescape: unescape | |
}; | |
var KeyEscapeUtils_1 = KeyEscapeUtils$1; | |
var ReactCurrentOwner$2 = ReactCurrentOwner_1; | |
var REACT_ELEMENT_TYPE$2 = ReactElementSymbol; | |
var getIteratorFn = getIteratorFn_1; | |
var invariant$2 = invariant; | |
var KeyEscapeUtils = KeyEscapeUtils_1; | |
var warning$4 = warning; | |
var SEPARATOR = '.'; | |
var SUBSEPARATOR = ':'; | |
/** | |
* This is inlined from ReactElement since this file is shared between | |
* isomorphic and renderers. We could extract this to a | |
* | |
*/ | |
/** | |
* TODO: Test that a single child and an array with one item have the same key | |
* pattern. | |
*/ | |
var didWarnAboutMaps = false; | |
/** | |
* Generate a key string that identifies a component within a set. | |
* | |
* @param {*} component A component that could contain a manual key. | |
* @param {number} index Index that is used if a manual key is not provided. | |
* @return {string} | |
*/ | |
function getComponentKey(component, index) { | |
// Do some typechecking here since we call this blindly. We want to ensure | |
// that we don't block potential future ES APIs. | |
if (component && typeof component === 'object' && component.key != null) { | |
// Explicit key | |
return KeyEscapeUtils.escape(component.key); | |
} | |
// Implicit key determined by the index in the set | |
return index.toString(36); | |
} | |
/** | |
* @param {?*} children Children tree container. | |
* @param {!string} nameSoFar Name of the key path so far. | |
* @param {!function} callback Callback to invoke with each child found. | |
* @param {?*} traverseContext Used to pass information throughout the traversal | |
* process. | |
* @return {!number} The number of children in this subtree. | |
*/ | |
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { | |
var type = typeof children; | |
if (type === 'undefined' || type === 'boolean') { | |
// All of the above are perceived as null. | |
children = null; | |
} | |
if (children === null || type === 'string' || type === 'number' || | |
// The following is inlined from ReactElement. This means we can optimize | |
// some checks. React Fiber also inlines this logic for similar purposes. | |
type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE$2) { | |
callback(traverseContext, children, | |
// If it's the only child, treat the name as if it was wrapped in an array | |
// so that it's consistent if the number of children grows. | |
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); | |
return 1; | |
} | |
var child; | |
var nextName; | |
var subtreeCount = 0; // Count of children found in the current subtree. | |
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; | |
if (Array.isArray(children)) { | |
for (var i = 0; i < children.length; i++) { | |
child = children[i]; | |
nextName = nextNamePrefix + getComponentKey(child, i); | |
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | |
} | |
} else { | |
var iteratorFn = getIteratorFn(children); | |
if (iteratorFn) { | |
if (__DEV__) { | |
// Warn about using Maps as children | |
if (iteratorFn === children.entries) { | |
var mapsAsChildrenAddendum = ''; | |
if (ReactCurrentOwner$2.current) { | |
var mapsAsChildrenOwnerName = ReactCurrentOwner$2.current.getName(); | |
if (mapsAsChildrenOwnerName) { | |
mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.'; | |
} | |
} | |
warning$4(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum); | |
didWarnAboutMaps = true; | |
} | |
} | |
var iterator = iteratorFn.call(children); | |
var step; | |
var ii = 0; | |
while (!(step = iterator.next()).done) { | |
child = step.value; | |
nextName = nextNamePrefix + getComponentKey(child, ii++); | |
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | |
} | |
} else if (type === 'object') { | |
var addendum = ''; | |
if (__DEV__) { | |
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.'; | |
if (ReactCurrentOwner$2.current) { | |
var name = ReactCurrentOwner$2.current.getName(); | |
if (name) { | |
addendum += '\n\nCheck the render method of `' + name + '`.'; | |
} | |
} | |
} | |
var childrenString = '' + children; | |
invariant$2(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); | |
} | |
} | |
return subtreeCount; | |
} | |
/** | |
* Traverses children that are typically specified as `props.children`, but | |
* might also be specified through attributes: | |
* | |
* - `traverseAllChildren(this.props.children, ...)` | |
* - `traverseAllChildren(this.props.leftPanelChildren, ...)` | |
* | |
* The `traverseContext` is an optional argument that is passed through the | |
* entire traversal. It can be used to store accumulations or anything else that | |
* the callback might find relevant. | |
* | |
* @param {?*} children Children tree object. | |
* @param {!function} callback To invoke upon traversing each child. | |
* @param {?*} traverseContext Context for traversal. | |
* @return {!number} The number of children in this subtree. | |
*/ | |
function traverseAllChildren$1(children, callback, traverseContext) { | |
if (children == null) { | |
return 0; | |
} | |
return traverseAllChildrenImpl(children, '', callback, traverseContext); | |
} | |
var traverseAllChildren_1 = traverseAllChildren$1; | |
var PooledClass = PooledClass_1; | |
var ReactElement$1 = ReactElement_1; | |
var emptyFunction$1 = emptyFunction; | |
var traverseAllChildren = traverseAllChildren_1; | |
var twoArgumentPooler = PooledClass.twoArgumentPooler; | |
var fourArgumentPooler = PooledClass.fourArgumentPooler; | |
var userProvidedKeyEscapeRegex = /\/+/g; | |
function escapeUserProvidedKey(text) { | |
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); | |
} | |
/** | |
* PooledClass representing the bookkeeping associated with performing a child | |
* traversal. Allows avoiding binding callbacks. | |
* | |
* @constructor ForEachBookKeeping | |
* @param {!function} forEachFunction Function to perform traversal with. | |
* @param {?*} forEachContext Context to perform context with. | |
*/ | |
function ForEachBookKeeping(forEachFunction, forEachContext) { | |
this.func = forEachFunction; | |
this.context = forEachContext; | |
this.count = 0; | |
} | |
ForEachBookKeeping.prototype.destructor = function () { | |
this.func = null; | |
this.context = null; | |
this.count = 0; | |
}; | |
PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler); | |
function forEachSingleChild(bookKeeping, child, name) { | |
var func = bookKeeping.func, | |
context = bookKeeping.context; | |
func.call(context, child, bookKeeping.count++); | |
} | |
/** | |
* Iterates through children that are typically specified as `props.children`. | |
* | |
* See https://facebook.github.io/react/docs/react-api.html#react.children.foreach | |
* | |
* The provided forEachFunc(child, index) will be called for each | |
* leaf child. | |
* | |
* @param {?*} children Children tree container. | |
* @param {function(*, int)} forEachFunc | |
* @param {*} forEachContext Context for forEachContext. | |
*/ | |
function forEachChildren(children, forEachFunc, forEachContext) { | |
if (children == null) { | |
return children; | |
} | |
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext); | |
traverseAllChildren(children, forEachSingleChild, traverseContext); | |
ForEachBookKeeping.release(traverseContext); | |
} | |
/** | |
* PooledClass representing the bookkeeping associated with performing a child | |
* mapping. Allows avoiding binding callbacks. | |
* | |
* @constructor MapBookKeeping | |
* @param {!*} mapResult Object containing the ordered map of results. | |
* @param {!function} mapFunction Function to perform mapping with. | |
* @param {?*} mapContext Context to perform mapping with. | |
*/ | |
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) { | |
this.result = mapResult; | |
this.keyPrefix = keyPrefix; | |
this.func = mapFunction; | |
this.context = mapContext; | |
this.count = 0; | |
} | |
MapBookKeeping.prototype.destructor = function () { | |
this.result = null; | |
this.keyPrefix = null; | |
this.func = null; | |
this.context = null; | |
this.count = 0; | |
}; | |
PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler); | |
function mapSingleChildIntoContext(bookKeeping, child, childKey) { | |
var result = bookKeeping.result, | |
keyPrefix = bookKeeping.keyPrefix, | |
func = bookKeeping.func, | |
context = bookKeeping.context; | |
var mappedChild = func.call(context, child, bookKeeping.count++); | |
if (Array.isArray(mappedChild)) { | |
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction$1.thatReturnsArgument); | |
} else if (mappedChild != null) { | |
if (ReactElement$1.isValidElement(mappedChild)) { | |
mappedChild = ReactElement$1.cloneAndReplaceKey(mappedChild, | |
// Keep both the (mapped) and old keys if they differ, just as | |
// traverseAllChildren used to do for objects as children | |
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); | |
} | |
result.push(mappedChild); | |
} | |
} | |
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { | |
var escapedPrefix = ''; | |
if (prefix != null) { | |
escapedPrefix = escapeUserProvidedKey(prefix) + '/'; | |
} | |
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context); | |
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); | |
MapBookKeeping.release(traverseContext); | |
} | |
/** | |
* Maps children that are typically specified as `props.children`. | |
* | |
* See https://facebook.github.io/react/docs/react-api.html#react.children.map | |
* | |
* The provided mapFunction(child, key, index) will be called for each | |
* leaf child. | |
* | |
* @param {?*} children Children tree container. | |
* @param {function(*, int)} func The map function. | |
* @param {*} context Context for mapFunction. | |
* @return {object} Object containing the ordered map of results. | |
*/ | |
function mapChildren(children, func, context) { | |
if (children == null) { | |
return children; | |
} | |
var result = []; | |
mapIntoWithKeyPrefixInternal(children, result, null, func, context); | |
return result; | |
} | |
function forEachSingleChildDummy(traverseContext, child, name) { | |
return null; | |
} | |
/** | |
* Count the number of children that are typically specified as | |
* `props.children`. | |
* | |
* See https://facebook.github.io/react/docs/react-api.html#react.children.count | |
* | |
* @param {?*} children Children tree container. | |
* @return {number} The number of children. | |
*/ | |
function countChildren(children, context) { | |
return traverseAllChildren(children, forEachSingleChildDummy, null); | |
} | |
/** | |
* Flatten a children object (typically specified as `props.children`) and | |
* return an array with appropriately re-keyed children. | |
* | |
* See https://facebook.github.io/react/docs/react-api.html#react.children.toarray | |
*/ | |
function toArray(children) { | |
var result = []; | |
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction$1.thatReturnsArgument); | |
return result; | |
} | |
var ReactChildren$1 = { | |
forEach: forEachChildren, | |
map: mapChildren, | |
mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal, | |
count: countChildren, | |
toArray: toArray | |
}; | |
var ReactChildren_1 = ReactChildren$1; | |
var ReactBaseClasses$3 = ReactBaseClasses$1; | |
var ReactElement$3 = ReactElement_1; | |
var ReactNoopUpdateQueue$2 = ReactNoopUpdateQueue_1; | |
var emptyObject$2 = emptyObject; | |
var invariant$3 = invariant; | |
var warning$5 = warning; | |
var ReactComponent$1 = ReactBaseClasses$3.Component; | |
var MIXINS_KEY = 'mixins'; | |
// Helper function to allow the creation of anonymous functions which do not | |
// have .name set to the name of the variable being assigned to. | |
function identity(fn) { | |
return fn; | |
} | |
/** | |
* Policies that describe methods in `ReactClassInterface`. | |
*/ | |
/** | |
* Composite components are higher-level components that compose other composite | |
* or host components. | |
* | |
* To create a new type of `ReactClass`, pass a specification of | |
* your new class to `React.createClass`. The only requirement of your class | |
* specification is that you implement a `render` method. | |
* | |
* var MyComponent = React.createClass({ | |
* render: function() { | |
* return <div>Hello World</div>; | |
* } | |
* }); | |
* | |
* The class specification supports a specific protocol of methods that have | |
* special meaning (e.g. `render`). See `ReactClassInterface` for | |
* more the comprehensive protocol. Any other properties and methods in the | |
* class specification will be available on the prototype. | |
* | |
* @interface ReactClassInterface | |
* @internal | |
*/ | |
var ReactClassInterface = { | |
/** | |
* An array of Mixin objects to include when defining your component. | |
* | |
* @type {array} | |
* @optional | |
*/ | |
mixins: 'DEFINE_MANY', | |
/** | |
* An object containing properties and methods that should be defined on | |
* the component's constructor instead of its prototype (static methods). | |
* | |
* @type {object} | |
* @optional | |
*/ | |
statics: 'DEFINE_MANY', | |
/** | |
* Definition of prop types for this component. | |
* | |
* @type {object} | |
* @optional | |
*/ | |
propTypes: 'DEFINE_MANY', | |
/** | |
* Definition of context types for this component. | |
* | |
* @type {object} | |
* @optional | |
*/ | |
contextTypes: 'DEFINE_MANY', | |
/** | |
* Definition of context types this component sets for its children. | |
* | |
* @type {object} | |
* @optional | |
*/ | |
childContextTypes: 'DEFINE_MANY', | |
// ==== Definition methods ==== | |
/** | |
* Invoked when the component is mounted. Values in the mapping will be set on | |
* `this.props` if that prop is not specified (i.e. using an `in` check). | |
* | |
* This method is invoked before `getInitialState` and therefore cannot rely | |
* on `this.state` or use `this.setState`. | |
* | |
* @return {object} | |
* @optional | |
*/ | |
getDefaultProps: 'DEFINE_MANY_MERGED', | |
/** | |
* Invoked once before the component is mounted. The return value will be used | |
* as the initial value of `this.state`. | |
* | |
* getInitialState: function() { | |
* return { | |
* isOn: false, | |
* fooBaz: new BazFoo() | |
* } | |
* } | |
* | |
* @return {object} | |
* @optional | |
*/ | |
getInitialState: 'DEFINE_MANY_MERGED', | |
/** | |
* @return {object} | |
* @optional | |
*/ | |
getChildContext: 'DEFINE_MANY_MERGED', | |
/** | |
* Uses props from `this.props` and state from `this.state` to render the | |
* structure of the component. | |
* | |
* No guarantees are made about when or how often this method is invoked, so | |
* it must not have side effects. | |
* | |
* render: function() { | |
* var name = this.props.name; | |
* return <div>Hello, {name}!</div>; | |
* } | |
* | |
* @return {ReactComponent} | |
* @required | |
*/ | |
render: 'DEFINE_ONCE', | |
// ==== Delegate methods ==== | |
/** | |
* Invoked when the component is initially created and about to be mounted. | |
* This may have side effects, but any external subscriptions or data created | |
* by this method must be cleaned up in `componentWillUnmount`. | |
* | |
* @optional | |
*/ | |
componentWillMount: 'DEFINE_MANY', | |
/** | |
* Invoked when the component has been mounted and has a DOM representation. | |
* However, there is no guarantee that the DOM node is in the document. | |
* | |
* Use this as an opportunity to operate on the DOM when the component has | |
* been mounted (initialized and rendered) for the first time. | |
* | |
* @param {DOMElement} rootNode DOM element representing the component. | |
* @optional | |
*/ | |
componentDidMount: 'DEFINE_MANY', | |
/** | |
* Invoked before the component receives new props. | |
* | |
* Use this as an opportunity to react to a prop transition by updating the | |
* state using `this.setState`. Current props are accessed via `this.props`. | |
* | |
* componentWillReceiveProps: function(nextProps, nextContext) { | |
* this.setState({ | |
* likesIncreasing: nextProps.likeCount > this.props.likeCount | |
* }); | |
* } | |
* | |
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop | |
* transition may cause a state change, but the opposite is not true. If you | |
* need it, you are probably looking for `componentWillUpdate`. | |
* | |
* @param {object} nextProps | |
* @optional | |
*/ | |
componentWillReceiveProps: 'DEFINE_MANY', | |
/** | |
* Invoked while deciding if the component should be updated as a result of | |
* receiving new props, state and/or context. | |
* | |
* Use this as an opportunity to `return false` when you're certain that the | |
* transition to the new props/state/context will not require a component | |
* update. | |
* | |
* shouldComponentUpdate: function(nextProps, nextState, nextContext) { | |
* return !equal(nextProps, this.props) || | |
* !equal(nextState, this.state) || | |
* !equal(nextContext, this.context); | |
* } | |
* | |
* @param {object} nextProps | |
* @param {?object} nextState | |
* @param {?object} nextContext | |
* @return {boolean} True if the component should update. | |
* @optional | |
*/ | |
shouldComponentUpdate: 'DEFINE_ONCE', | |
/** | |
* Invoked when the component is about to update due to a transition from | |
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState` | |
* and `nextContext`. | |
* | |
* Use this as an opportunity to perform preparation before an update occurs. | |
* | |
* NOTE: You **cannot** use `this.setState()` in this method. | |
* | |
* @param {object} nextProps | |
* @param {?object} nextState | |
* @param {?object} nextContext | |
* @param {ReactReconcileTransaction} transaction | |
* @optional | |
*/ | |
componentWillUpdate: 'DEFINE_MANY', | |
/** | |
* Invoked when the component's DOM representation has been updated. | |
* | |
* Use this as an opportunity to operate on the DOM when the component has | |
* been updated. | |
* | |
* @param {object} prevProps | |
* @param {?object} prevState | |
* @param {?object} prevContext | |
* @param {DOMElement} rootNode DOM element representing the component. | |
* @optional | |
*/ | |
componentDidUpdate: 'DEFINE_MANY', | |
/** | |
* Invoked when the component is about to be removed from its parent and have | |
* its DOM representation destroyed. | |
* | |
* Use this as an opportunity to deallocate any external resources. | |
* | |
* NOTE: There is no `componentDidUnmount` since your component will have been | |
* destroyed by that point. | |
* | |
* @optional | |
*/ | |
componentWillUnmount: 'DEFINE_MANY', | |
// ==== Advanced methods ==== | |
/** | |
* Updates the component's currently mounted DOM representation. | |
* | |
* By default, this implements React's rendering and reconciliation algorithm. | |
* Sophisticated clients may wish to override this. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
* @overridable | |
*/ | |
updateComponent: 'OVERRIDE_BASE' | |
}; | |
/** | |
* Mapping from class specification keys to special processing functions. | |
* | |
* Although these are declared like instance properties in the specification | |
* when defining classes using `React.createClass`, they are actually static | |
* and are accessible on the constructor instead of the prototype. Despite | |
* being static, they must be defined outside of the "statics" key under | |
* which all other static methods are defined. | |
*/ | |
var RESERVED_SPEC_KEYS = { | |
displayName: function (Constructor, displayName) { | |
Constructor.displayName = displayName; | |
}, | |
mixins: function (Constructor, mixins) { | |
if (mixins) { | |
for (var i = 0; i < mixins.length; i++) { | |
mixSpecIntoComponent(Constructor, mixins[i]); | |
} | |
} | |
}, | |
childContextTypes: function (Constructor, childContextTypes) { | |
if (__DEV__) { | |
validateTypeDef(Constructor, childContextTypes, 'child context'); | |
} | |
Constructor.childContextTypes = Object.assign({}, Constructor.childContextTypes, childContextTypes); | |
}, | |
contextTypes: function (Constructor, contextTypes) { | |
if (__DEV__) { | |
validateTypeDef(Constructor, contextTypes, 'context'); | |
} | |
Constructor.contextTypes = Object.assign({}, Constructor.contextTypes, contextTypes); | |
}, | |
/** | |
* Special case getDefaultProps which should move into statics but requires | |
* automatic merging. | |
*/ | |
getDefaultProps: function (Constructor, getDefaultProps) { | |
if (Constructor.getDefaultProps) { | |
Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps); | |
} else { | |
Constructor.getDefaultProps = getDefaultProps; | |
} | |
}, | |
propTypes: function (Constructor, propTypes) { | |
if (__DEV__) { | |
validateTypeDef(Constructor, propTypes, 'prop'); | |
} | |
Constructor.propTypes = Object.assign({}, Constructor.propTypes, propTypes); | |
}, | |
statics: function (Constructor, statics) { | |
mixStaticSpecIntoComponent(Constructor, statics); | |
}, | |
autobind: function () {} }; | |
function validateTypeDef(Constructor, typeDef, location) { | |
for (var propName in typeDef) { | |
if (typeDef.hasOwnProperty(propName)) { | |
// use a warning instead of an invariant so components | |
// don't show up in prod but only in __DEV__ | |
warning$5(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', location, propName); | |
} | |
} | |
} | |
function validateMethodOverride(isAlreadyDefined, name) { | |
var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null; | |
// Disallow overriding of base class methods unless explicitly allowed. | |
if (ReactClassMixin.hasOwnProperty(name)) { | |
invariant$3(specPolicy === 'OVERRIDE_BASE', 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name); | |
} | |
// Disallow defining methods more than once unless explicitly allowed. | |
if (isAlreadyDefined) { | |
invariant$3(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name); | |
} | |
} | |
/** | |
* Mixin helper which handles policy validation and reserved | |
* specification keys when building React classes. | |
*/ | |
function mixSpecIntoComponent(Constructor, spec) { | |
if (!spec) { | |
if (__DEV__) { | |
var typeofSpec = typeof spec; | |
var isMixinValid = typeofSpec === 'object' && spec !== null; | |
warning$5(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec); | |
} | |
return; | |
} | |
invariant$3(typeof spec !== 'function', 'ReactClass: You\'re attempting to ' + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.'); | |
invariant$3(!ReactElement$3.isValidElement(spec), 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.'); | |
var proto = Constructor.prototype; | |
var autoBindPairs = proto.__reactAutoBindPairs; | |
// By handling mixins before any other properties, we ensure the same | |
// chaining order is applied to methods with DEFINE_MANY policy, whether | |
// mixins are listed before or after these methods in the spec. | |
if (spec.hasOwnProperty(MIXINS_KEY)) { | |
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins); | |
} | |
for (var name in spec) { | |
if (!spec.hasOwnProperty(name)) { | |
continue; | |
} | |
if (name === MIXINS_KEY) { | |
// We have already handled mixins in a special case above. | |
continue; | |
} | |
var property = spec[name]; | |
var isAlreadyDefined = proto.hasOwnProperty(name); | |
validateMethodOverride(isAlreadyDefined, name); | |
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { | |
RESERVED_SPEC_KEYS[name](Constructor, property); | |
} else { | |
// Setup methods on prototype: | |
// The following member methods should not be automatically bound: | |
// 1. Expected ReactClass methods (in the "interface"). | |
// 2. Overridden methods (that were mixed in). | |
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); | |
var isFunction = typeof property === 'function'; | |
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false; | |
if (shouldAutoBind) { | |
autoBindPairs.push(name, property); | |
proto[name] = property; | |
} else { | |
if (isAlreadyDefined) { | |
var specPolicy = ReactClassInterface[name]; | |
// These cases should already be caught by validateMethodOverride. | |
invariant$3(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY'), 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name); | |
// For methods which are defined more than once, call the existing | |
// methods before calling the new property, merging if appropriate. | |
if (specPolicy === 'DEFINE_MANY_MERGED') { | |
proto[name] = createMergedResultFunction(proto[name], property); | |
} else if (specPolicy === 'DEFINE_MANY') { | |
proto[name] = createChainedFunction(proto[name], property); | |
} | |
} else { | |
proto[name] = property; | |
if (__DEV__) { | |
// Add verbose displayName to the function, which helps when looking | |
// at profiling tools. | |
if (typeof property === 'function' && spec.displayName) { | |
proto[name].displayName = spec.displayName + '_' + name; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
function mixStaticSpecIntoComponent(Constructor, statics) { | |
if (!statics) { | |
return; | |
} | |
for (var name in statics) { | |
var property = statics[name]; | |
if (!statics.hasOwnProperty(name)) { | |
continue; | |
} | |
var isReserved = name in RESERVED_SPEC_KEYS; | |
invariant$3(!isReserved, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name); | |
var isInherited = name in Constructor; | |
invariant$3(!isInherited, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name); | |
Constructor[name] = property; | |
} | |
} | |
/** | |
* Merge two objects, but throw if both contain the same key. | |
* | |
* @param {object} one The first object, which is mutated. | |
* @param {object} two The second object | |
* @return {object} one after it has been mutated to contain everything in two. | |
*/ | |
function mergeIntoWithNoDuplicateKeys(one, two) { | |
invariant$3(one && two && typeof one === 'object' && typeof two === 'object', 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.'); | |
for (var key in two) { | |
if (two.hasOwnProperty(key)) { | |
invariant$3(one[key] === undefined, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key); | |
one[key] = two[key]; | |
} | |
} | |
return one; | |
} | |
/** | |
* Creates a function that invokes two functions and merges their return values. | |
* | |
* @param {function} one Function to invoke first. | |
* @param {function} two Function to invoke second. | |
* @return {function} Function that invokes the two argument functions. | |
* @private | |
*/ | |
function createMergedResultFunction(one, two) { | |
return function mergedResult() { | |
var a = one.apply(this, arguments); | |
var b = two.apply(this, arguments); | |
if (a == null) { | |
return b; | |
} else if (b == null) { | |
return a; | |
} | |
var c = {}; | |
mergeIntoWithNoDuplicateKeys(c, a); | |
mergeIntoWithNoDuplicateKeys(c, b); | |
return c; | |
}; | |
} | |
/** | |
* Creates a function that invokes two functions and ignores their return vales. | |
* | |
* @param {function} one Function to invoke first. | |
* @param {function} two Function to invoke second. | |
* @return {function} Function that invokes the two argument functions. | |
* @private | |
*/ | |
function createChainedFunction(one, two) { | |
return function chainedFunction() { | |
one.apply(this, arguments); | |
two.apply(this, arguments); | |
}; | |
} | |
/** | |
* Binds a method to the component. | |
* | |
* @param {object} component Component whose method is going to be bound. | |
* @param {function} method Method to be bound. | |
* @return {function} The bound method. | |
*/ | |
function bindAutoBindMethod(component, method) { | |
var boundMethod = method.bind(component); | |
if (__DEV__) { | |
boundMethod.__reactBoundContext = component; | |
boundMethod.__reactBoundMethod = method; | |
boundMethod.__reactBoundArguments = null; | |
var componentName = component.constructor.displayName; | |
var _bind = boundMethod.bind; | |
boundMethod.bind = function (newThis) { | |
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | |
args[_key - 1] = arguments[_key]; | |
} | |
// User is trying to bind() an autobound method; we effectively will | |
// ignore the value of "this" that the user is trying to use, so | |
// let's warn. | |
if (newThis !== component && newThis !== null) { | |
warning$5(false, 'bind(): React component methods may only be bound to the ' + 'component instance.\n\nSee %s', componentName); | |
} else if (!args.length) { | |
warning$5(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call.\n\nSee %s', componentName); | |
return boundMethod; | |
} | |
var reboundMethod = _bind.apply(boundMethod, arguments); | |
reboundMethod.__reactBoundContext = component; | |
reboundMethod.__reactBoundMethod = method; | |
reboundMethod.__reactBoundArguments = args; | |
return reboundMethod; | |
}; | |
} | |
return boundMethod; | |
} | |
/** | |
* Binds all auto-bound methods in a component. | |
* | |
* @param {object} component Component whose method is going to be bound. | |
*/ | |
function bindAutoBindMethods(component) { | |
var pairs = component.__reactAutoBindPairs; | |
for (var i = 0; i < pairs.length; i += 2) { | |
var autoBindKey = pairs[i]; | |
var method = pairs[i + 1]; | |
component[autoBindKey] = bindAutoBindMethod(component, method); | |
} | |
} | |
/** | |
* Add more to the ReactClass base class. These are all legacy features and | |
* therefore not already part of the modern ReactComponent. | |
*/ | |
var ReactClassMixin = { | |
/** | |
* TODO: This will be deprecated because state should always keep a consistent | |
* type signature and the only use case for this, is to avoid that. | |
*/ | |
replaceState: function (newState, callback) { | |
this.updater.enqueueReplaceState(this, newState, callback, 'replaceState'); | |
}, | |
/** | |
* Checks whether or not this composite component is mounted. | |
* @return {boolean} True if mounted, false otherwise. | |
* @protected | |
* @final | |
*/ | |
isMounted: function () { | |
return this.updater.isMounted(this); | |
} | |
}; | |
var ReactClassComponent = function () {}; | |
Object.assign(ReactClassComponent.prototype, ReactComponent$1.prototype, ReactClassMixin); | |
/** | |
* Module for creating composite components. | |
* | |
* @class ReactClass | |
*/ | |
var ReactClass$1 = { | |
/** | |
* Creates a composite component class given a class specification. | |
* See https://facebook.github.io/react/docs/react-api.html#createclass | |
* | |
* @param {object} spec Class specification (which must define `render`). | |
* @return {function} Component constructor function. | |
* @public | |
*/ | |
createClass: function (spec) { | |
// To keep our warnings more understandable, we'll use a little hack here to | |
// ensure that Constructor.name !== 'Constructor'. This makes sure we don't | |
// unnecessarily identify a class without displayName as 'Constructor'. | |
var Constructor = identity(function (props, context, updater) { | |
// This constructor gets overridden by mocks. The argument is used | |
// by mocks to assert on what gets mounted. | |
if (__DEV__) { | |
warning$5(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory'); | |
} | |
// Wire up auto-binding | |
if (this.__reactAutoBindPairs.length) { | |
bindAutoBindMethods(this); | |
} | |
this.props = props; | |
this.context = context; | |
this.refs = emptyObject$2; | |
this.updater = updater || ReactNoopUpdateQueue$2; | |
this.state = null; | |
// ReactClasses doesn't have constructors. Instead, they use the | |
// getInitialState and componentWillMount methods for initialization. | |
var initialState = this.getInitialState ? this.getInitialState() : null; | |
if (__DEV__) { | |
// We allow auto-mocks to proceed as if they're returning null. | |
if (initialState === undefined && this.getInitialState._isMockFunction) { | |
// This is probably bad practice. Consider warning here and | |
// deprecating this convenience. | |
initialState = null; | |
} | |
} | |
invariant$3(typeof initialState === 'object' && !Array.isArray(initialState), '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent'); | |
this.state = initialState; | |
}); | |
Constructor.prototype = new ReactClassComponent(); | |
Constructor.prototype.constructor = Constructor; | |
Constructor.prototype.__reactAutoBindPairs = []; | |
mixSpecIntoComponent(Constructor, spec); | |
// Initialize the defaultProps property after all mixins have been merged. | |
if (Constructor.getDefaultProps) { | |
Constructor.defaultProps = Constructor.getDefaultProps(); | |
} | |
if (__DEV__) { | |
// This is a tag to indicate that the use of these method names is ok, | |
// since it's used with createClass. If it's not, then it's likely a | |
// mistake so we'll warn you to use the static property, property | |
// initializer or constructor respectively. | |
if (Constructor.getDefaultProps) { | |
Constructor.getDefaultProps.isReactClassApproved = {}; | |
} | |
if (Constructor.prototype.getInitialState) { | |
Constructor.prototype.getInitialState.isReactClassApproved = {}; | |
} | |
} | |
invariant$3(Constructor.prototype.render, 'createClass(...): Class specification must implement a `render` method.'); | |
if (__DEV__) { | |
warning$5(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component'); | |
warning$5(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component'); | |
} | |
// Reduce time spent doing lookups by setting these on the prototype. | |
for (var methodName in ReactClassInterface) { | |
if (!Constructor.prototype[methodName]) { | |
Constructor.prototype[methodName] = null; | |
} | |
} | |
return Constructor; | |
} | |
}; | |
var ReactClass_1 = ReactClass$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactTypeOfWork | |
* | |
*/ | |
var ReactTypeOfWork$1 = { | |
IndeterminateComponent: 0, // Before we know whether it is functional or class | |
FunctionalComponent: 1, | |
ClassComponent: 2, | |
HostRoot: 3, // Root of a host tree. Could be nested inside another node. | |
HostPortal: 4, // A subtree. Could be an entry point to a different renderer. | |
HostComponent: 5, | |
HostText: 6, | |
CoroutineComponent: 7, | |
CoroutineHandlerPhase: 8, | |
YieldComponent: 9, | |
Fragment: 10 | |
}; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule getComponentName | |
*/ | |
function getComponentName$2(instanceOrFiber) { | |
if (typeof instanceOrFiber.getName === 'function') { | |
// Stack reconciler | |
var instance = instanceOrFiber; | |
return instance.getName(); | |
} | |
if (typeof instanceOrFiber.tag === 'number') { | |
// Fiber reconciler | |
var fiber = instanceOrFiber; | |
var type = fiber.type; | |
if (typeof type === 'string') { | |
return type; | |
} | |
if (typeof type === 'function') { | |
return type.displayName || type.name; | |
} | |
} | |
return null; | |
} | |
var getComponentName_1 = getComponentName$2; | |
var ReactCurrentOwner$4 = ReactCurrentOwner_1; | |
var ReactTypeOfWork = ReactTypeOfWork$1; | |
var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent; | |
var FunctionalComponent = ReactTypeOfWork.FunctionalComponent; | |
var ClassComponent = ReactTypeOfWork.ClassComponent; | |
var HostComponent = ReactTypeOfWork.HostComponent; | |
var getComponentName$1 = getComponentName_1; | |
var invariant$4 = invariant; | |
var warning$7 = warning; | |
function isNative(fn) { | |
// Based on isNative() from Lodash | |
var funcToString = Function.prototype.toString; | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var reIsNative = RegExp('^' + funcToString | |
// Take an example native function source for comparison | |
.call(hasOwnProperty) | |
// Strip regex characters so we can use it for regex | |
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') | |
// Remove hasOwnProperty from the template to make it generic | |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); | |
try { | |
var source = funcToString.call(fn); | |
return reIsNative.test(source); | |
} catch (err) { | |
return false; | |
} | |
} | |
var canUseCollections = | |
// Array.from | |
typeof Array.from === 'function' && | |
// Map | |
typeof Map === 'function' && isNative(Map) && | |
// Map.prototype.keys | |
Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) && | |
// Set | |
typeof Set === 'function' && isNative(Set) && | |
// Set.prototype.keys | |
Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys); | |
var setItem; | |
var getItem; | |
var removeItem; | |
var getItemIDs; | |
var addRoot; | |
var removeRoot; | |
var getRootIDs; | |
if (canUseCollections) { | |
var itemMap = new Map(); | |
var rootIDSet = new Set(); | |
setItem = function (id, item) { | |
itemMap.set(id, item); | |
}; | |
getItem = function (id) { | |
return itemMap.get(id); | |
}; | |
removeItem = function (id) { | |
itemMap['delete'](id); | |
}; | |
getItemIDs = function () { | |
return Array.from(itemMap.keys()); | |
}; | |
addRoot = function (id) { | |
rootIDSet.add(id); | |
}; | |
removeRoot = function (id) { | |
rootIDSet['delete'](id); | |
}; | |
getRootIDs = function () { | |
return Array.from(rootIDSet.keys()); | |
}; | |
} else { | |
var itemByKey = {}; | |
var rootByKey = {}; | |
// Use non-numeric keys to prevent V8 performance issues: | |
// https://github.com/facebook/react/pull/7232 | |
var getKeyFromID = function (id) { | |
return '.' + id; | |
}; | |
var getIDFromKey = function (key) { | |
return parseInt(key.substr(1), 10); | |
}; | |
setItem = function (id, item) { | |
var key = getKeyFromID(id); | |
itemByKey[key] = item; | |
}; | |
getItem = function (id) { | |
var key = getKeyFromID(id); | |
return itemByKey[key]; | |
}; | |
removeItem = function (id) { | |
var key = getKeyFromID(id); | |
delete itemByKey[key]; | |
}; | |
getItemIDs = function () { | |
return Object.keys(itemByKey).map(getIDFromKey); | |
}; | |
addRoot = function (id) { | |
var key = getKeyFromID(id); | |
rootByKey[key] = true; | |
}; | |
removeRoot = function (id) { | |
var key = getKeyFromID(id); | |
delete rootByKey[key]; | |
}; | |
getRootIDs = function () { | |
return Object.keys(rootByKey).map(getIDFromKey); | |
}; | |
} | |
var unmountedIDs = []; | |
function purgeDeep(id) { | |
var item = getItem(id); | |
if (item) { | |
var childIDs = item.childIDs; | |
removeItem(id); | |
childIDs.forEach(purgeDeep); | |
} | |
} | |
function describeComponentFrame(name, source, ownerName) { | |
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); | |
} | |
function getDisplayName(element) { | |
if (element == null) { | |
return '#empty'; | |
} else if (typeof element === 'string' || typeof element === 'number') { | |
return '#text'; | |
} else if (typeof element.type === 'string') { | |
return element.type; | |
} else { | |
return element.type.displayName || element.type.name || 'Unknown'; | |
} | |
} | |
function describeID(id) { | |
var name = ReactComponentTreeHook$1.getDisplayName(id); | |
var element = ReactComponentTreeHook$1.getElement(id); | |
var ownerID = ReactComponentTreeHook$1.getOwnerID(id); | |
var ownerName; | |
if (ownerID) { | |
ownerName = ReactComponentTreeHook$1.getDisplayName(ownerID); | |
} | |
warning$7(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id); | |
return describeComponentFrame(name, element && element._source, ownerName); | |
} | |
function describeFiber(fiber) { | |
switch (fiber.tag) { | |
case IndeterminateComponent: | |
case FunctionalComponent: | |
case ClassComponent: | |
case HostComponent: | |
var owner = fiber._debugOwner; | |
var source = fiber._debugSource; | |
var name = getComponentName$1(fiber); | |
var ownerName = null; | |
if (owner) { | |
ownerName = getComponentName$1(owner); | |
} | |
return describeComponentFrame(name, source, ownerName); | |
default: | |
return ''; | |
} | |
} | |
var ReactComponentTreeHook$1 = { | |
onSetChildren: function (id, nextChildIDs) { | |
var item = getItem(id); | |
invariant$4(item, 'Item must have been set'); | |
item.childIDs = nextChildIDs; | |
for (var i = 0; i < nextChildIDs.length; i++) { | |
var nextChildID = nextChildIDs[i]; | |
var nextChild = getItem(nextChildID); | |
invariant$4(nextChild, 'Expected hook events to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$4(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null, 'Expected onSetChildren() to fire for a container child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$4(nextChild.isMounted, 'Expected onMountComponent() to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
if (nextChild.parentID == null) { | |
nextChild.parentID = id; | |
// TODO: This shouldn't be necessary but mounting a new root during in | |
// componentWillMount currently causes not-yet-mounted components to | |
// be purged from our tree data so their parent id is missing. | |
} | |
invariant$4(nextChild.parentID === id, 'Expected onBeforeMountComponent() parent and onSetChildren() to ' + 'be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id); | |
} | |
}, | |
onBeforeMountComponent: function (id, element, parentID) { | |
var item = { | |
element: element, | |
parentID: parentID, | |
text: null, | |
childIDs: [], | |
isMounted: false, | |
updateCount: 0 | |
}; | |
setItem(id, item); | |
}, | |
onBeforeUpdateComponent: function (id, element) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.element = element; | |
}, | |
onMountComponent: function (id) { | |
var item = getItem(id); | |
invariant$4(item, 'Item must have been set'); | |
item.isMounted = true; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
addRoot(id); | |
} | |
}, | |
onUpdateComponent: function (id) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.updateCount++; | |
}, | |
onUnmountComponent: function (id) { | |
var item = getItem(id); | |
if (item) { | |
// We need to check if it exists. | |
// `item` might not exist if it is inside an error boundary, and a sibling | |
// error boundary child threw while mounting. Then this instance never | |
// got a chance to mount, but it still gets an unmounting event during | |
// the error boundary cleanup. | |
item.isMounted = false; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
removeRoot(id); | |
} | |
} | |
unmountedIDs.push(id); | |
}, | |
purgeUnmountedComponents: function () { | |
if (ReactComponentTreeHook$1._preventPurging) { | |
// Should only be used for testing. | |
return; | |
} | |
for (var i = 0; i < unmountedIDs.length; i++) { | |
var id = unmountedIDs[i]; | |
purgeDeep(id); | |
} | |
unmountedIDs.length = 0; | |
}, | |
isMounted: function (id) { | |
var item = getItem(id); | |
return item ? item.isMounted : false; | |
}, | |
getCurrentStackAddendum: function (topElement) { | |
var info = ''; | |
if (topElement) { | |
var name = getDisplayName(topElement); | |
var owner = topElement._owner; | |
info += describeComponentFrame(name, topElement._source, owner && getComponentName$1(owner)); | |
} | |
var currentOwner = ReactCurrentOwner$4.current; | |
if (currentOwner) { | |
if (typeof currentOwner.tag === 'number') { | |
var workInProgress = currentOwner; | |
// Safe because if current owner exists, we are reconciling, | |
// and it is guaranteed to be the work-in-progress version. | |
info += ReactComponentTreeHook$1.getStackAddendumByWorkInProgressFiber(workInProgress); | |
} else if (typeof currentOwner._debugID === 'number') { | |
info += ReactComponentTreeHook$1.getStackAddendumByID(currentOwner._debugID); | |
} | |
} | |
return info; | |
}, | |
getStackAddendumByID: function (id) { | |
var info = ''; | |
while (id) { | |
info += describeID(id); | |
id = ReactComponentTreeHook$1.getParentID(id); | |
} | |
return info; | |
}, | |
// This function can only be called with a work-in-progress fiber and | |
// only during begin or complete phase. Do not call it under any other | |
// circumstances. | |
getStackAddendumByWorkInProgressFiber: function (workInProgress) { | |
var info = ''; | |
var node = workInProgress; | |
do { | |
info += describeFiber(node); | |
// Otherwise this return pointer might point to the wrong tree: | |
node = node['return']; | |
} while (node); | |
return info; | |
}, | |
getChildIDs: function (id) { | |
var item = getItem(id); | |
return item ? item.childIDs : []; | |
}, | |
getDisplayName: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (!element) { | |
return null; | |
} | |
return getDisplayName(element); | |
}, | |
getElement: function (id) { | |
var item = getItem(id); | |
return item ? item.element : null; | |
}, | |
getOwnerID: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (!element || !element._owner) { | |
return null; | |
} | |
return element._owner._debugID; | |
}, | |
getParentID: function (id) { | |
var item = getItem(id); | |
return item ? item.parentID : null; | |
}, | |
getSource: function (id) { | |
var item = getItem(id); | |
var element = item ? item.element : null; | |
var source = element != null ? element._source : null; | |
return source; | |
}, | |
getText: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (typeof element === 'string') { | |
return element; | |
} else if (typeof element === 'number') { | |
return '' + element; | |
} else { | |
return null; | |
} | |
}, | |
getUpdateCount: function (id) { | |
var item = getItem(id); | |
return item ? item.updateCount : 0; | |
}, | |
getRootIDs: getRootIDs, | |
getRegisteredIDs: getItemIDs | |
}; | |
var ReactComponentTreeHook_1 = ReactComponentTreeHook$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule ReactPropTypesSecret | |
*/ | |
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | |
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; | |
var ReactPropTypesSecret = ReactPropTypesSecret_1; | |
var invariant$5 = invariant; | |
var warning$8 = warning; | |
var loggedTypeFailures = {}; | |
/** | |
* Assert that the values match with the type specs. | |
* Error messages are memorized and will only be shown once. | |
* | |
* @param {object} typeSpecs Map of name to a ReactPropType | |
* @param {object} values Runtime values that need to be type-checked | |
* @param {string} location e.g. "prop", "context", "child context" | |
* @param {string} componentName Name of the component for error messages. | |
* @param {?Function} getStack Returns the component stack. | |
* @private | |
*/ | |
function checkPropTypes$2(typeSpecs, values, location, componentName, getStack) { | |
if (__DEV__) { | |
for (var typeSpecName in typeSpecs) { | |
if (typeSpecs.hasOwnProperty(typeSpecName)) { | |
var error; | |
// Prop type validation may throw. In case they do, we don't want to | |
// fail the render phase where it didn't fail before. So we log it. | |
// After these have been cleaned up, we'll let them throw. | |
try { | |
// This is intentionally an invariant that gets caught. It's the same | |
// behavior as without this statement except with a better message. | |
invariant$5(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName); | |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); | |
} catch (ex) { | |
error = ex; | |
} | |
warning$8(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); | |
if (error instanceof Error && !(error.message in loggedTypeFailures)) { | |
// Only monitor this failure once because there tends to be a lot of the | |
// same error. | |
loggedTypeFailures[error.message] = true; | |
var stack = getStack ? getStack() : ''; | |
warning$8(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); | |
} | |
} | |
} | |
} | |
} | |
var checkPropTypes_1 = checkPropTypes$2; | |
var ReactDebugCurrentFrame$1 = {}; | |
if (__DEV__) { | |
var _require$1 = ReactComponentTreeHook_1, | |
getStackAddendumByID = _require$1.getStackAddendumByID, | |
getStackAddendumByWorkInProgressFiber = _require$1.getStackAddendumByWorkInProgressFiber, | |
getCurrentStackAddendum = _require$1.getCurrentStackAddendum; | |
// Component that is being worked on | |
ReactDebugCurrentFrame$1.current = null; | |
// Element that is being cloned or created | |
ReactDebugCurrentFrame$1.element = null; | |
ReactDebugCurrentFrame$1.getStackAddendum = function () { | |
var stack = null; | |
var current = ReactDebugCurrentFrame$1.current; | |
var element = ReactDebugCurrentFrame$1.element; | |
if (current !== null) { | |
if (typeof current === 'number') { | |
// DebugID from Stack. | |
var debugID = current; | |
stack = getStackAddendumByID(debugID); | |
} else if (typeof current.tag === 'number') { | |
// This is a Fiber. | |
// The stack will only be correct if this is a work in progress | |
// version and we're calling it during reconciliation. | |
var workInProgress = current; | |
stack = getStackAddendumByWorkInProgressFiber(workInProgress); | |
} | |
} else if (element !== null) { | |
stack = getCurrentStackAddendum(element); | |
} | |
return stack; | |
}; | |
} | |
var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1; | |
var checkPropTypes$1 = checkPropTypes_1; | |
var _require = ReactDebugCurrentFrame_1; | |
var getStackAddendum = _require.getStackAddendum; | |
function checkReactTypeSpec$1(typeSpecs, values, location, componentName) { | |
checkPropTypes$1(typeSpecs, values, location, componentName, getStackAddendum); | |
} | |
var checkReactTypeSpec_1 = checkReactTypeSpec$1; | |
var ReactCurrentOwner$3 = ReactCurrentOwner_1; | |
var ReactComponentTreeHook = ReactComponentTreeHook_1; | |
var ReactElement$5 = ReactElement_1; | |
var checkReactTypeSpec = checkReactTypeSpec_1; | |
var canDefineProperty$3 = canDefineProperty_1; | |
var getComponentName = getComponentName_1; | |
var getIteratorFn$2 = getIteratorFn_1; | |
if (__DEV__) { | |
var warning$6 = warning; | |
var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1; | |
} | |
function getDeclarationErrorAddendum() { | |
if (ReactCurrentOwner$3.current) { | |
var name = getComponentName(ReactCurrentOwner$3.current); | |
if (name) { | |
return '\n\nCheck the render method of `' + name + '`.'; | |
} | |
} | |
return ''; | |
} | |
function getSourceInfoErrorAddendum(elementProps) { | |
if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { | |
var source = elementProps.__source; | |
var fileName = source.fileName.replace(/^.*[\\\/]/, ''); | |
var lineNumber = source.lineNumber; | |
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; | |
} | |
return ''; | |
} | |
/** | |
* Warn if there's no key explicitly set on dynamic arrays of children or | |
* object keys are not valid. This allows us to keep track of children between | |
* updates. | |
*/ | |
var ownerHasKeyUseWarning = {}; | |
function getCurrentComponentErrorInfo(parentType) { | |
var info = getDeclarationErrorAddendum(); | |
if (!info) { | |
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; | |
if (parentName) { | |
info = '\n\nCheck the top-level render call using <' + parentName + '>.'; | |
} | |
} | |
return info; | |
} | |
/** | |
* Warn if the element doesn't have an explicit key assigned to it. | |
* This element is in an array. The array could grow and shrink or be | |
* reordered. All children that haven't already been validated are required to | |
* have a "key" property assigned to it. Error statuses are cached so a warning | |
* will only be shown once. | |
* | |
* @internal | |
* @param {ReactElement} element Element that requires a key. | |
* @param {*} parentType element's parent's type. | |
*/ | |
function validateExplicitKey(element, parentType) { | |
if (!element._store || element._store.validated || element.key != null) { | |
return; | |
} | |
element._store.validated = true; | |
var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {}); | |
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); | |
if (memoizer[currentComponentErrorInfo]) { | |
return; | |
} | |
memoizer[currentComponentErrorInfo] = true; | |
// Usually the current owner is the offender, but if it accepts children as a | |
// property, it may be the creator of the child that's responsible for | |
// assigning it a key. | |
var childOwner = ''; | |
if (element && element._owner && element._owner !== ReactCurrentOwner$3.current) { | |
// Give the component that originally created this child. | |
childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.'; | |
} | |
warning$6(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeHook.getCurrentStackAddendum(element)); | |
} | |
/** | |
* Ensure that every element either is passed in a static location, in an | |
* array with an explicit keys property defined, or in an object literal | |
* with valid key property. | |
* | |
* @internal | |
* @param {ReactNode} node Statically passed child of any type. | |
* @param {*} parentType node's parent's type. | |
*/ | |
function validateChildKeys(node, parentType) { | |
if (typeof node !== 'object') { | |
return; | |
} | |
if (Array.isArray(node)) { | |
for (var i = 0; i < node.length; i++) { | |
var child = node[i]; | |
if (ReactElement$5.isValidElement(child)) { | |
validateExplicitKey(child, parentType); | |
} | |
} | |
} else if (ReactElement$5.isValidElement(node)) { | |
// This element was passed in a valid location. | |
if (node._store) { | |
node._store.validated = true; | |
} | |
} else if (node) { | |
var iteratorFn = getIteratorFn$2(node); | |
// Entry iterators provide implicit keys. | |
if (iteratorFn) { | |
if (iteratorFn !== node.entries) { | |
var iterator = iteratorFn.call(node); | |
var step; | |
while (!(step = iterator.next()).done) { | |
if (ReactElement$5.isValidElement(step.value)) { | |
validateExplicitKey(step.value, parentType); | |
} | |
} | |
} | |
} | |
} | |
} | |
/** | |
* Given an element, validate that its props follow the propTypes definition, | |
* provided by the type. | |
* | |
* @param {ReactElement} element | |
*/ | |
function validatePropTypes(element) { | |
var componentClass = element.type; | |
if (typeof componentClass !== 'function') { | |
return; | |
} | |
var name = componentClass.displayName || componentClass.name; | |
if (componentClass.propTypes) { | |
checkReactTypeSpec(componentClass.propTypes, element.props, 'prop', name); | |
} | |
if (typeof componentClass.getDefaultProps === 'function') { | |
warning$6(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.'); | |
} | |
} | |
var ReactElementValidator$2 = { | |
createElement: function (type, props, children) { | |
var validType = typeof type === 'string' || typeof type === 'function'; | |
// We warn in this case but don't throw. We expect the element creation to | |
// succeed and there will likely be errors in render. | |
if (!validType) { | |
var info = ''; | |
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { | |
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.'; | |
} | |
var sourceInfo = getSourceInfoErrorAddendum(props); | |
if (sourceInfo) { | |
info += sourceInfo; | |
} else { | |
info += getDeclarationErrorAddendum(); | |
} | |
info += ReactComponentTreeHook.getCurrentStackAddendum(); | |
warning$6(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info); | |
} | |
var element = ReactElement$5.createElement.apply(this, arguments); | |
// The result can be nullish if a mock or a custom function is used. | |
// TODO: Drop this when these are no longer allowed as the type argument. | |
if (element == null) { | |
return element; | |
} | |
if (__DEV__) { | |
ReactDebugCurrentFrame.element = element; | |
} | |
// Skip key warning if the type isn't valid since our key validation logic | |
// doesn't expect a non-string/function type and can throw confusing errors. | |
// We don't want exception behavior to differ between dev and prod. | |
// (Rendering will throw with a helpful message and as soon as the type is | |
// fixed, the key warnings will appear.) | |
if (validType) { | |
for (var i = 2; i < arguments.length; i++) { | |
validateChildKeys(arguments[i], type); | |
} | |
} | |
validatePropTypes(element); | |
if (__DEV__) { | |
ReactDebugCurrentFrame.element = null; | |
} | |
return element; | |
}, | |
createFactory: function (type) { | |
var validatedFactory = ReactElementValidator$2.createElement.bind(null, type); | |
// Legacy hook TODO: Warn if this is accessed | |
validatedFactory.type = type; | |
if (__DEV__) { | |
if (canDefineProperty$3) { | |
Object.defineProperty(validatedFactory, 'type', { | |
enumerable: false, | |
get: function () { | |
warning$6(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); | |
Object.defineProperty(this, 'type', { | |
value: type | |
}); | |
return type; | |
} | |
}); | |
} | |
} | |
return validatedFactory; | |
}, | |
cloneElement: function (element, props, children) { | |
var newElement = ReactElement$5.cloneElement.apply(this, arguments); | |
if (__DEV__) { | |
ReactDebugCurrentFrame.element = newElement; | |
} | |
for (var i = 2; i < arguments.length; i++) { | |
validateChildKeys(arguments[i], newElement.type); | |
} | |
validatePropTypes(newElement); | |
if (__DEV__) { | |
ReactDebugCurrentFrame.element = null; | |
} | |
return newElement; | |
} | |
}; | |
var ReactElementValidator_1 = ReactElementValidator$2; | |
var ReactElement$4 = ReactElement_1; | |
/** | |
* Create a factory that creates HTML tag elements. | |
* | |
* @private | |
*/ | |
var createDOMFactory = ReactElement$4.createFactory; | |
if (__DEV__) { | |
var ReactElementValidator$1 = ReactElementValidator_1; | |
createDOMFactory = ReactElementValidator$1.createFactory; | |
} | |
/** | |
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes. | |
* This is also accessible via `React.DOM`. | |
* | |
* @public | |
*/ | |
var ReactDOMFactories$1 = { | |
a: createDOMFactory('a'), | |
abbr: createDOMFactory('abbr'), | |
address: createDOMFactory('address'), | |
area: createDOMFactory('area'), | |
article: createDOMFactory('article'), | |
aside: createDOMFactory('aside'), | |
audio: createDOMFactory('audio'), | |
b: createDOMFactory('b'), | |
base: createDOMFactory('base'), | |
bdi: createDOMFactory('bdi'), | |
bdo: createDOMFactory('bdo'), | |
big: createDOMFactory('big'), | |
blockquote: createDOMFactory('blockquote'), | |
body: createDOMFactory('body'), | |
br: createDOMFactory('br'), | |
button: createDOMFactory('button'), | |
canvas: createDOMFactory('canvas'), | |
caption: createDOMFactory('caption'), | |
cite: createDOMFactory('cite'), | |
code: createDOMFactory('code'), | |
col: createDOMFactory('col'), | |
colgroup: createDOMFactory('colgroup'), | |
data: createDOMFactory('data'), | |
datalist: createDOMFactory('datalist'), | |
dd: createDOMFactory('dd'), | |
del: createDOMFactory('del'), | |
details: createDOMFactory('details'), | |
dfn: createDOMFactory('dfn'), | |
dialog: createDOMFactory('dialog'), | |
div: createDOMFactory('div'), | |
dl: createDOMFactory('dl'), | |
dt: createDOMFactory('dt'), | |
em: createDOMFactory('em'), | |
embed: createDOMFactory('embed'), | |
fieldset: createDOMFactory('fieldset'), | |
figcaption: createDOMFactory('figcaption'), | |
figure: createDOMFactory('figure'), | |
footer: createDOMFactory('footer'), | |
form: createDOMFactory('form'), | |
h1: createDOMFactory('h1'), | |
h2: createDOMFactory('h2'), | |
h3: createDOMFactory('h3'), | |
h4: createDOMFactory('h4'), | |
h5: createDOMFactory('h5'), | |
h6: createDOMFactory('h6'), | |
head: createDOMFactory('head'), | |
header: createDOMFactory('header'), | |
hgroup: createDOMFactory('hgroup'), | |
hr: createDOMFactory('hr'), | |
html: createDOMFactory('html'), | |
i: createDOMFactory('i'), | |
iframe: createDOMFactory('iframe'), | |
img: createDOMFactory('img'), | |
input: createDOMFactory('input'), | |
ins: createDOMFactory('ins'), | |
kbd: createDOMFactory('kbd'), | |
keygen: createDOMFactory('keygen'), | |
label: createDOMFactory('label'), | |
legend: createDOMFactory('legend'), | |
li: createDOMFactory('li'), | |
link: createDOMFactory('link'), | |
main: createDOMFactory('main'), | |
map: createDOMFactory('map'), | |
mark: createDOMFactory('mark'), | |
menu: createDOMFactory('menu'), | |
menuitem: createDOMFactory('menuitem'), | |
meta: createDOMFactory('meta'), | |
meter: createDOMFactory('meter'), | |
nav: createDOMFactory('nav'), | |
noscript: createDOMFactory('noscript'), | |
object: createDOMFactory('object'), | |
ol: createDOMFactory('ol'), | |
optgroup: createDOMFactory('optgroup'), | |
option: createDOMFactory('option'), | |
output: createDOMFactory('output'), | |
p: createDOMFactory('p'), | |
param: createDOMFactory('param'), | |
picture: createDOMFactory('picture'), | |
pre: createDOMFactory('pre'), | |
progress: createDOMFactory('progress'), | |
q: createDOMFactory('q'), | |
rp: createDOMFactory('rp'), | |
rt: createDOMFactory('rt'), | |
ruby: createDOMFactory('ruby'), | |
s: createDOMFactory('s'), | |
samp: createDOMFactory('samp'), | |
script: createDOMFactory('script'), | |
section: createDOMFactory('section'), | |
select: createDOMFactory('select'), | |
small: createDOMFactory('small'), | |
source: createDOMFactory('source'), | |
span: createDOMFactory('span'), | |
strong: createDOMFactory('strong'), | |
style: createDOMFactory('style'), | |
sub: createDOMFactory('sub'), | |
summary: createDOMFactory('summary'), | |
sup: createDOMFactory('sup'), | |
table: createDOMFactory('table'), | |
tbody: createDOMFactory('tbody'), | |
td: createDOMFactory('td'), | |
textarea: createDOMFactory('textarea'), | |
tfoot: createDOMFactory('tfoot'), | |
th: createDOMFactory('th'), | |
thead: createDOMFactory('thead'), | |
time: createDOMFactory('time'), | |
title: createDOMFactory('title'), | |
tr: createDOMFactory('tr'), | |
track: createDOMFactory('track'), | |
u: createDOMFactory('u'), | |
ul: createDOMFactory('ul'), | |
'var': createDOMFactory('var'), | |
video: createDOMFactory('video'), | |
wbr: createDOMFactory('wbr'), | |
// SVG | |
circle: createDOMFactory('circle'), | |
clipPath: createDOMFactory('clipPath'), | |
defs: createDOMFactory('defs'), | |
ellipse: createDOMFactory('ellipse'), | |
g: createDOMFactory('g'), | |
image: createDOMFactory('image'), | |
line: createDOMFactory('line'), | |
linearGradient: createDOMFactory('linearGradient'), | |
mask: createDOMFactory('mask'), | |
path: createDOMFactory('path'), | |
pattern: createDOMFactory('pattern'), | |
polygon: createDOMFactory('polygon'), | |
polyline: createDOMFactory('polyline'), | |
radialGradient: createDOMFactory('radialGradient'), | |
rect: createDOMFactory('rect'), | |
stop: createDOMFactory('stop'), | |
svg: createDOMFactory('svg'), | |
text: createDOMFactory('text'), | |
tspan: createDOMFactory('tspan') | |
}; | |
var ReactDOMFactories_1 = ReactDOMFactories$1; | |
var ReactElement$6 = ReactElement_1; | |
var ReactPropTypesSecret$2 = ReactPropTypesSecret_1; | |
var emptyFunction$2 = emptyFunction; | |
var getIteratorFn$3 = getIteratorFn_1; | |
var invariant$6 = invariant; | |
var warning$9 = warning; | |
/** | |
* Collection of methods that allow declaration and validation of props that are | |
* supplied to React components. Example usage: | |
* | |
* var Props = require('ReactPropTypes'); | |
* var MyArticle = React.createClass({ | |
* propTypes: { | |
* // An optional string prop named "description". | |
* description: Props.string, | |
* | |
* // A required enum prop named "category". | |
* category: Props.oneOf(['News','Photos']).isRequired, | |
* | |
* // A prop named "dialog" that requires an instance of Dialog. | |
* dialog: Props.instanceOf(Dialog).isRequired | |
* }, | |
* render: function() { ... } | |
* }); | |
* | |
* A more formal specification of how these methods are used: | |
* | |
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) | |
* decl := ReactPropTypes.{type}(.isRequired)? | |
* | |
* Each and every declaration produces a function with the same signature. This | |
* allows the creation of custom validation functions. For example: | |
* | |
* var MyLink = React.createClass({ | |
* propTypes: { | |
* // An optional string or URI prop named "href". | |
* href: function(props, propName, componentName) { | |
* var propValue = props[propName]; | |
* if (propValue != null && typeof propValue !== 'string' && | |
* !(propValue instanceof URI)) { | |
* return new Error( | |
* 'Expected a string or an URI for ' + propName + ' in ' + | |
* componentName | |
* ); | |
* } | |
* } | |
* }, | |
* render: function() {...} | |
* }); | |
* | |
* @internal | |
*/ | |
var ANONYMOUS = '<<anonymous>>'; | |
var ReactPropTypes$1; | |
if (__DEV__) { | |
// Keep in sync with production version below | |
ReactPropTypes$1 = { | |
array: createPrimitiveTypeChecker('array'), | |
bool: createPrimitiveTypeChecker('boolean'), | |
func: createPrimitiveTypeChecker('function'), | |
number: createPrimitiveTypeChecker('number'), | |
object: createPrimitiveTypeChecker('object'), | |
string: createPrimitiveTypeChecker('string'), | |
symbol: createPrimitiveTypeChecker('symbol'), | |
any: createAnyTypeChecker(), | |
arrayOf: createArrayOfTypeChecker, | |
element: createElementTypeChecker(), | |
instanceOf: createInstanceTypeChecker, | |
node: createNodeChecker(), | |
objectOf: createObjectOfTypeChecker, | |
oneOf: createEnumTypeChecker, | |
oneOfType: createUnionTypeChecker, | |
shape: createShapeTypeChecker | |
}; | |
} else { | |
var productionTypeChecker = function () { | |
invariant$6(false, 'React.PropTypes type checking code is stripped in production.'); | |
}; | |
productionTypeChecker.isRequired = productionTypeChecker; | |
var getProductionTypeChecker = function () { | |
return productionTypeChecker; | |
}; | |
// Keep in sync with development version above | |
ReactPropTypes$1 = { | |
array: productionTypeChecker, | |
bool: productionTypeChecker, | |
func: productionTypeChecker, | |
number: productionTypeChecker, | |
object: productionTypeChecker, | |
string: productionTypeChecker, | |
symbol: productionTypeChecker, | |
any: productionTypeChecker, | |
arrayOf: getProductionTypeChecker, | |
element: productionTypeChecker, | |
instanceOf: getProductionTypeChecker, | |
node: productionTypeChecker, | |
objectOf: getProductionTypeChecker, | |
oneOf: getProductionTypeChecker, | |
oneOfType: getProductionTypeChecker, | |
shape: getProductionTypeChecker | |
}; | |
} | |
/** | |
* inlined Object.is polyfill to avoid requiring consumers ship their own | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | |
*/ | |
/*eslint-disable no-self-compare*/ | |
function is(x, y) { | |
// SameValue algorithm | |
if (x === y) { | |
// Steps 1-5, 7-10 | |
// Steps 6.b-6.e: +0 != -0 | |
return x !== 0 || 1 / x === 1 / y; | |
} else { | |
// Step 6.a: NaN == NaN | |
return x !== x && y !== y; | |
} | |
} | |
/*eslint-enable no-self-compare*/ | |
/** | |
* We use an Error-like object for backward compatibility as people may call | |
* PropTypes directly and inspect their output. However, we don't use real | |
* Errors anymore. We don't inspect their stack anyway, and creating them | |
* is prohibitively expensive if they are created too often, such as what | |
* happens in oneOfType() for any type before the one that matched. | |
*/ | |
function PropTypeError(message) { | |
this.message = message; | |
this.stack = ''; | |
} | |
// Make `instanceof Error` still work for returned errors. | |
PropTypeError.prototype = Error.prototype; | |
function createChainableTypeChecker(validate) { | |
if (__DEV__) { | |
var manualPropTypeCallCache = {}; | |
} | |
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { | |
componentName = componentName || ANONYMOUS; | |
propFullName = propFullName || propName; | |
if (__DEV__) { | |
if (secret !== ReactPropTypesSecret$2 && typeof console !== 'undefined') { | |
var cacheKey = componentName + ':' + propName; | |
if (!manualPropTypeCallCache[cacheKey]) { | |
warning$9(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName); | |
manualPropTypeCallCache[cacheKey] = true; | |
} | |
} | |
} | |
if (props[propName] == null) { | |
if (isRequired) { | |
if (props[propName] === null) { | |
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); | |
} | |
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); | |
} | |
return null; | |
} else { | |
return validate(props, propName, componentName, location, propFullName); | |
} | |
} | |
var chainedCheckType = checkType.bind(null, false); | |
chainedCheckType.isRequired = checkType.bind(null, true); | |
return chainedCheckType; | |
} | |
function createPrimitiveTypeChecker(expectedType) { | |
function validate(props, propName, componentName, location, propFullName, secret) { | |
var propValue = props[propName]; | |
var propType = getPropType(propValue); | |
if (propType !== expectedType) { | |
// `propValue` being instance of, say, date/regexp, pass the 'object' | |
// check, but we can offer a more precise error message here rather than | |
// 'of type `object`'. | |
var preciseType = getPreciseType(propValue); | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createAnyTypeChecker() { | |
return createChainableTypeChecker(emptyFunction$2.thatReturnsNull); | |
} | |
function createArrayOfTypeChecker(typeChecker) { | |
function validate(props, propName, componentName, location, propFullName) { | |
if (typeof typeChecker !== 'function') { | |
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); | |
} | |
var propValue = props[propName]; | |
if (!Array.isArray(propValue)) { | |
var propType = getPropType(propValue); | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); | |
} | |
for (var i = 0; i < propValue.length; i++) { | |
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret$2); | |
if (error instanceof Error) { | |
return error; | |
} | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createElementTypeChecker() { | |
function validate(props, propName, componentName, location, propFullName) { | |
var propValue = props[propName]; | |
if (!ReactElement$6.isValidElement(propValue)) { | |
var propType = getPropType(propValue); | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createInstanceTypeChecker(expectedClass) { | |
function validate(props, propName, componentName, location, propFullName) { | |
if (!(props[propName] instanceof expectedClass)) { | |
var expectedClassName = expectedClass.name || ANONYMOUS; | |
var actualClassName = getClassName(props[propName]); | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createEnumTypeChecker(expectedValues) { | |
if (!Array.isArray(expectedValues)) { | |
warning$9(false, 'Invalid argument supplied to oneOf, expected an instance of array.'); | |
return emptyFunction$2.thatReturnsNull; | |
} | |
function validate(props, propName, componentName, location, propFullName) { | |
var propValue = props[propName]; | |
for (var i = 0; i < expectedValues.length; i++) { | |
if (is(propValue, expectedValues[i])) { | |
return null; | |
} | |
} | |
var valuesString = JSON.stringify(expectedValues); | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createObjectOfTypeChecker(typeChecker) { | |
function validate(props, propName, componentName, location, propFullName) { | |
if (typeof typeChecker !== 'function') { | |
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); | |
} | |
var propValue = props[propName]; | |
var propType = getPropType(propValue); | |
if (propType !== 'object') { | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); | |
} | |
for (var key in propValue) { | |
if (propValue.hasOwnProperty(key)) { | |
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$2); | |
if (error instanceof Error) { | |
return error; | |
} | |
} | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createUnionTypeChecker(arrayOfTypeCheckers) { | |
if (!Array.isArray(arrayOfTypeCheckers)) { | |
warning$9(false, 'Invalid argument supplied to oneOfType, expected an instance of array.'); | |
return emptyFunction$2.thatReturnsNull; | |
} | |
function validate(props, propName, componentName, location, propFullName) { | |
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { | |
var checker = arrayOfTypeCheckers[i]; | |
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret$2) == null) { | |
return null; | |
} | |
} | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createNodeChecker() { | |
function validate(props, propName, componentName, location, propFullName) { | |
if (!isNode(props[propName])) { | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function createShapeTypeChecker(shapeTypes) { | |
function validate(props, propName, componentName, location, propFullName) { | |
var propValue = props[propName]; | |
var propType = getPropType(propValue); | |
if (propType !== 'object') { | |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); | |
} | |
for (var key in shapeTypes) { | |
var checker = shapeTypes[key]; | |
if (!checker) { | |
continue; | |
} | |
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret$2); | |
if (error) { | |
return error; | |
} | |
} | |
return null; | |
} | |
return createChainableTypeChecker(validate); | |
} | |
function isNode(propValue) { | |
switch (typeof propValue) { | |
case 'number': | |
case 'string': | |
case 'undefined': | |
return true; | |
case 'boolean': | |
return !propValue; | |
case 'object': | |
if (Array.isArray(propValue)) { | |
return propValue.every(isNode); | |
} | |
if (propValue === null || ReactElement$6.isValidElement(propValue)) { | |
return true; | |
} | |
var iteratorFn = getIteratorFn$3(propValue); | |
if (iteratorFn) { | |
var iterator = iteratorFn.call(propValue); | |
var step; | |
if (iteratorFn !== propValue.entries) { | |
while (!(step = iterator.next()).done) { | |
if (!isNode(step.value)) { | |
return false; | |
} | |
} | |
} else { | |
// Iterator will provide entry [k,v] tuples rather than values. | |
while (!(step = iterator.next()).done) { | |
var entry = step.value; | |
if (entry) { | |
if (!isNode(entry[1])) { | |
return false; | |
} | |
} | |
} | |
} | |
} else { | |
return false; | |
} | |
return true; | |
default: | |
return false; | |
} | |
} | |
function isSymbol(propType, propValue) { | |
// Native Symbol. | |
if (propType === 'symbol') { | |
return true; | |
} | |
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' | |
if (propValue['@@toStringTag'] === 'Symbol') { | |
return true; | |
} | |
// Fallback for non-spec compliant Symbols which are polyfilled. | |
if (typeof Symbol === 'function' && propValue instanceof Symbol) { | |
return true; | |
} | |
return false; | |
} | |
// Equivalent of `typeof` but with special handling for array and regexp. | |
function getPropType(propValue) { | |
var propType = typeof propValue; | |
if (Array.isArray(propValue)) { | |
return 'array'; | |
} | |
if (propValue instanceof RegExp) { | |
// Old webkits (at least until Android 4.0) return 'function' rather than | |
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/ | |
// passes PropTypes.object. | |
return 'object'; | |
} | |
if (isSymbol(propType, propValue)) { | |
return 'symbol'; | |
} | |
return propType; | |
} | |
// This handles more types than `getPropType`. Only used for error messages. | |
// See `createPrimitiveTypeChecker`. | |
function getPreciseType(propValue) { | |
var propType = getPropType(propValue); | |
if (propType === 'object') { | |
if (propValue instanceof Date) { | |
return 'date'; | |
} else if (propValue instanceof RegExp) { | |
return 'regexp'; | |
} | |
} | |
return propType; | |
} | |
// Returns class name of the object, if any. | |
function getClassName(propValue) { | |
if (!propValue.constructor || !propValue.constructor.name) { | |
return ANONYMOUS; | |
} | |
return propValue.constructor.name; | |
} | |
var ReactPropTypes_1 = ReactPropTypes$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactVersion | |
*/ | |
var ReactVersion$1 = '16.0.0-alpha.3'; | |
var ReactElement$7 = ReactElement_1; | |
var invariant$7 = invariant; | |
/** | |
* Returns the first child in a collection of children and verifies that there | |
* is only one child in the collection. | |
* | |
* See https://facebook.github.io/react/docs/react-api.html#react.children.only | |
* | |
* The current implementation of this function assumes that a single child gets | |
* passed without a wrapper, but the purpose of this helper function is to | |
* abstract away the particular structure of children. | |
* | |
* @param {?object} children Child collection structure. | |
* @return {ReactElement} The first and only `ReactElement` contained in the | |
* structure. | |
*/ | |
function onlyChild$1(children) { | |
invariant$7(ReactElement$7.isValidElement(children), 'React.Children.only expected to receive a single React element child.'); | |
return children; | |
} | |
var onlyChild_1 = onlyChild$1; | |
var ReactBaseClasses = ReactBaseClasses$1; | |
var ReactChildren = ReactChildren_1; | |
var ReactClass = ReactClass_1; | |
var ReactDOMFactories = ReactDOMFactories_1; | |
var ReactElement = ReactElement_1; | |
var ReactPropTypes = ReactPropTypes_1; | |
var ReactVersion = ReactVersion$1; | |
var onlyChild = onlyChild_1; | |
var warning2 = warning; | |
var checkPropTypes = checkPropTypes_1; | |
var createElement = ReactElement.createElement; | |
var createFactory = ReactElement.createFactory; | |
var cloneElement = ReactElement.cloneElement; | |
if (__DEV__) { | |
var ReactElementValidator = ReactElementValidator_1; | |
createElement = ReactElementValidator.createElement; | |
createFactory = ReactElementValidator.createFactory; | |
cloneElement = ReactElementValidator.cloneElement; | |
} | |
var createMixin = function (mixin) { | |
return mixin; | |
}; | |
if (__DEV__) { | |
var warnedForCreateMixin = false; | |
createMixin = function (mixin) { | |
warning2(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. You ' + 'can use this mixin directly instead.'); | |
warnedForCreateMixin = true; | |
return mixin; | |
}; | |
} | |
var React$1 = { | |
// Modern | |
Children: { | |
map: ReactChildren.map, | |
forEach: ReactChildren.forEach, | |
count: ReactChildren.count, | |
toArray: ReactChildren.toArray, | |
only: onlyChild | |
}, | |
Component: ReactBaseClasses.Component, | |
PureComponent: ReactBaseClasses.PureComponent, | |
createElement: createElement, | |
cloneElement: cloneElement, | |
isValidElement: ReactElement.isValidElement, | |
checkPropTypes: checkPropTypes, | |
// Classic | |
PropTypes: ReactPropTypes, | |
createClass: ReactClass.createClass, | |
createFactory: createFactory, | |
createMixin: createMixin, | |
// This looks DOM specific but these are actually isomorphic helpers | |
// since they are just generating DOM strings. | |
DOM: ReactDOMFactories, | |
version: ReactVersion | |
}; | |
var React_1 = React$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactInstanceMap | |
*/ | |
/** | |
* `ReactInstanceMap` maintains a mapping from a public facing stateful | |
* instance (key) and the internal representation (value). This allows public | |
* methods to accept the user facing instance as an argument and map them back | |
* to internal methods. | |
*/ | |
// TODO: Replace this with ES6: var ReactInstanceMap = new Map(); | |
var ReactInstanceMap = { | |
/** | |
* This API should be called `delete` but we'd have to make sure to always | |
* transform these to strings for IE support. When this transform is fully | |
* supported we can rename it. | |
*/ | |
remove: function (key) { | |
key._reactInternalInstance = undefined; | |
}, | |
get: function (key) { | |
return key._reactInternalInstance; | |
}, | |
has: function (key) { | |
return key._reactInternalInstance !== undefined; | |
}, | |
set: function (key, value) { | |
key._reactInternalInstance = value; | |
} | |
}; | |
var ReactInstanceMap_1 = ReactInstanceMap; | |
var KeyEscapeUtils$2 = KeyEscapeUtils_1; | |
var traverseAllChildren$2 = traverseAllChildren_1; | |
var warning$10 = warning; | |
var ReactComponentTreeHook$2; | |
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') { | |
// Temporary hack. | |
// Inline requires don't work well with Jest: | |
// https://github.com/facebook/react/issues/7240 | |
// Remove the inline requires when we don't need them anymore: | |
// https://github.com/facebook/react/pull/7178 | |
ReactComponentTreeHook$2 = ReactComponentTreeHook_1; | |
} | |
/** | |
* @param {function} traverseContext Context passed through traversal. | |
* @param {?ReactComponent} child React child component. | |
* @param {!string} name String name of key path to child. | |
* @param {number=} selfDebugID Optional debugID of the current internal instance. | |
*/ | |
function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID) { | |
// We found a component instance. | |
if (traverseContext && typeof traverseContext === 'object') { | |
var result = traverseContext; | |
var keyUnique = result[name] === undefined; | |
if (__DEV__) { | |
if (!ReactComponentTreeHook$2) { | |
ReactComponentTreeHook$2 = ReactComponentTreeHook_1; | |
} | |
if (!keyUnique) { | |
warning$10(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils$2.unescape(name), ReactComponentTreeHook$2.getStackAddendumByID(selfDebugID)); | |
} | |
} | |
if (keyUnique && child != null) { | |
result[name] = child; | |
} | |
} | |
} | |
/** | |
* Flattens children that are typically specified as `props.children`. Any null | |
* children will not be included in the resulting object. | |
* @return {!object} flattened children keyed by name. | |
*/ | |
function flattenChildren(children, selfDebugID) { | |
if (children == null) { | |
return children; | |
} | |
var result = {}; | |
if (__DEV__) { | |
traverseAllChildren$2(children, function (traverseContext, child, name) { | |
return flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID); | |
}, result); | |
} else { | |
traverseAllChildren$2(children, flattenSingleChildIntoContext, result); | |
} | |
return result; | |
} | |
var flattenChildren_1 = flattenChildren; | |
var React = React_1; | |
// `version` will be added here by the React module. | |
var ReactFBEntry = Object.assign({ | |
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { | |
ReactCurrentOwner: ReactCurrentOwner_1, | |
getComponentName: getComponentName_1, | |
ReactInstanceMap: ReactInstanceMap_1, | |
flattenChildren: flattenChildren_1 | |
} | |
}, React); | |
if (__DEV__) { | |
Object.assign(ReactFBEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, { | |
// ReactComponentTreeHook should not be included in production. | |
ReactComponentTreeHook: ReactComponentTreeHook_1 | |
}); | |
} | |
var ReactFBEntry_1 = ReactFBEntry; | |
module.exports = ReactFBEntry_1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOM-core | |
*/ | |
'use strict'; | |
var React = require('React'); | |
var invariant = require('invariant'); | |
var warning = require('warning'); | |
var ExecutionEnvironment = require('ExecutionEnvironment'); | |
var emptyFunction = require('emptyFunction'); | |
var EventListener = require('EventListener'); | |
var getUnboundedScrollPosition = require('getUnboundedScrollPosition'); | |
var containsNode = require('containsNode'); | |
var focusNode = require('focusNode'); | |
var getActiveElement = require('getActiveElement'); | |
var shallowEqual = require('shallowEqual'); | |
var createNodesFromMarkup = require('createNodesFromMarkup'); | |
var performanceNow = require('performanceNow'); | |
var camelizeStyleName = require('camelizeStyleName'); | |
var hyphenateStyleName = require('hyphenateStyleName'); | |
var memoizeStringOnly = require('memoizeStringOnly'); | |
var emptyObject = require('emptyObject'); | |
var invariant$1 = invariant; | |
function checkMask(value, bitmask) { | |
return (value & bitmask) === bitmask; | |
} | |
var DOMPropertyInjection = { | |
/** | |
* Mapping from normalized, camelcased property names to a configuration that | |
* specifies how the associated DOM property should be accessed or rendered. | |
*/ | |
MUST_USE_PROPERTY: 0x1, | |
HAS_BOOLEAN_VALUE: 0x4, | |
HAS_NUMERIC_VALUE: 0x8, | |
HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8, | |
HAS_OVERLOADED_BOOLEAN_VALUE: 0x20, | |
/** | |
* Inject some specialized knowledge about the DOM. This takes a config object | |
* with the following properties: | |
* | |
* isCustomAttribute: function that given an attribute name will return true | |
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-* | |
* attributes where it's impossible to enumerate all of the possible | |
* attribute names, | |
* | |
* Properties: object mapping DOM property name to one of the | |
* DOMPropertyInjection constants or null. If your attribute isn't in here, | |
* it won't get written to the DOM. | |
* | |
* DOMAttributeNames: object mapping React attribute name to the DOM | |
* attribute name. Attribute names not specified use the **lowercase** | |
* normalized name. | |
* | |
* DOMAttributeNamespaces: object mapping React attribute name to the DOM | |
* attribute namespace URL. (Attribute names not specified use no namespace.) | |
* | |
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. | |
* Property names not specified use the normalized name. | |
* | |
* DOMMutationMethods: Properties that require special mutation methods. If | |
* `value` is undefined, the mutation method should unset the property. | |
* | |
* @param {object} domPropertyConfig the config as described above. | |
*/ | |
injectDOMPropertyConfig: function (domPropertyConfig) { | |
var Injection = DOMPropertyInjection; | |
var Properties = domPropertyConfig.Properties || {}; | |
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; | |
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; | |
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {}; | |
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; | |
if (domPropertyConfig.isCustomAttribute) { | |
DOMProperty$1._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute); | |
} | |
for (var propName in Properties) { | |
invariant$1(!DOMProperty$1.properties.hasOwnProperty(propName), 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName); | |
var lowerCased = propName.toLowerCase(); | |
var propConfig = Properties[propName]; | |
var propertyInfo = { | |
attributeName: lowerCased, | |
attributeNamespace: null, | |
propertyName: propName, | |
mutationMethod: null, | |
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), | |
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), | |
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), | |
hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), | |
hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE) | |
}; | |
invariant$1(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName); | |
if (__DEV__) { | |
DOMProperty$1.getPossibleStandardName[lowerCased] = propName; | |
} | |
if (DOMAttributeNames.hasOwnProperty(propName)) { | |
var attributeName = DOMAttributeNames[propName]; | |
propertyInfo.attributeName = attributeName; | |
if (__DEV__) { | |
DOMProperty$1.getPossibleStandardName[attributeName] = propName; | |
} | |
} | |
if (DOMAttributeNamespaces.hasOwnProperty(propName)) { | |
propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; | |
} | |
if (DOMPropertyNames.hasOwnProperty(propName)) { | |
propertyInfo.propertyName = DOMPropertyNames[propName]; | |
} | |
if (DOMMutationMethods.hasOwnProperty(propName)) { | |
propertyInfo.mutationMethod = DOMMutationMethods[propName]; | |
} | |
DOMProperty$1.properties[propName] = propertyInfo; | |
} | |
} | |
}; | |
/* eslint-disable max-len */ | |
var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; | |
/* eslint-enable max-len */ | |
/** | |
* DOMProperty exports lookup objects that can be used like functions: | |
* | |
* > DOMProperty.isValid['id'] | |
* true | |
* > DOMProperty.isValid['foobar'] | |
* undefined | |
* | |
* Although this may be confusing, it performs better in general. | |
* | |
* @see http://jsperf.com/key-exists | |
* @see http://jsperf.com/key-missing | |
*/ | |
var DOMProperty$1 = { | |
ID_ATTRIBUTE_NAME: 'data-reactid', | |
ROOT_ATTRIBUTE_NAME: 'data-reactroot', | |
ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR, | |
ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040', | |
/** | |
* Map from property "standard name" to an object with info about how to set | |
* the property in the DOM. Each object contains: | |
* | |
* attributeName: | |
* Used when rendering markup or with `*Attribute()`. | |
* attributeNamespace | |
* propertyName: | |
* Used on DOM node instances. (This includes properties that mutate due to | |
* external factors.) | |
* mutationMethod: | |
* If non-null, used instead of the property or `setAttribute()` after | |
* initial render. | |
* mustUseProperty: | |
* Whether the property must be accessed and mutated as an object property. | |
* hasBooleanValue: | |
* Whether the property should be removed when set to a falsey value. | |
* hasNumericValue: | |
* Whether the property must be numeric or parse as a numeric and should be | |
* removed when set to a falsey value. | |
* hasPositiveNumericValue: | |
* Whether the property must be positive numeric or parse as a positive | |
* numeric and should be removed when set to a falsey value. | |
* hasOverloadedBooleanValue: | |
* Whether the property can be used as a flag as well as with a value. | |
* Removed when strictly equal to false; present without a value when | |
* strictly equal to true; present with a value otherwise. | |
*/ | |
properties: {}, | |
/** | |
* Mapping from lowercase property names to the properly cased version, used | |
* to warn in the case of missing properties. Available only in __DEV__. | |
* | |
* autofocus is predefined, because adding it to the property whitelist | |
* causes unintended side effects. | |
* | |
* @type {Object} | |
*/ | |
getPossibleStandardName: __DEV__ ? { autofocus: 'autoFocus' } : null, | |
/** | |
* All of the isCustomAttribute() functions that have been injected. | |
*/ | |
_isCustomAttributeFunctions: [], | |
/** | |
* Checks whether a property name is a custom attribute. | |
* @method | |
*/ | |
isCustomAttribute: function (attributeName) { | |
for (var i = 0; i < DOMProperty$1._isCustomAttributeFunctions.length; i++) { | |
var isCustomAttributeFn = DOMProperty$1._isCustomAttributeFunctions[i]; | |
if (isCustomAttributeFn(attributeName)) { | |
return true; | |
} | |
} | |
return false; | |
}, | |
injection: DOMPropertyInjection | |
}; | |
var DOMProperty_1 = DOMProperty$1; | |
/** | |
* Copyright 2015-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOMComponentFlags | |
*/ | |
var ReactDOMComponentFlags$1 = { | |
hasCachedChildNodes: 1 << 0 | |
}; | |
var ReactDOMComponentFlags_1 = ReactDOMComponentFlags$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactTypeOfWork | |
* | |
*/ | |
var ReactTypeOfWork = { | |
IndeterminateComponent: 0, // Before we know whether it is functional or class | |
FunctionalComponent: 1, | |
ClassComponent: 2, | |
HostRoot: 3, // Root of a host tree. Could be nested inside another node. | |
HostPortal: 4, // A subtree. Could be an entry point to a different renderer. | |
HostComponent: 5, | |
HostText: 6, | |
CoroutineComponent: 7, | |
CoroutineHandlerPhase: 8, | |
YieldComponent: 9, | |
Fragment: 10 | |
}; | |
var DOMProperty = DOMProperty_1; | |
var ReactDOMComponentFlags = ReactDOMComponentFlags_1; | |
var _require = ReactTypeOfWork; | |
var HostComponent = _require.HostComponent; | |
var HostText = _require.HostText; | |
var invariant2 = invariant; | |
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME; | |
var Flags = ReactDOMComponentFlags; | |
var randomKey = Math.random().toString(36).slice(2); | |
var internalInstanceKey = '__reactInternalInstance$' + randomKey; | |
var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; | |
/** | |
* Check if a given node should be cached. | |
*/ | |
function shouldPrecacheNode(node, nodeID) { | |
return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === '' + nodeID || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' '; | |
} | |
/** | |
* Drill down (through composites and empty components) until we get a host or | |
* host text component. | |
* | |
* This is pretty polymorphic but unavoidable with the current structure we have | |
* for `_renderedChildren`. | |
*/ | |
function getRenderedHostOrTextFromComponent(component) { | |
var rendered; | |
while (rendered = component._renderedComponent) { | |
component = rendered; | |
} | |
return component; | |
} | |
/** | |
* Populate `_hostNode` on the rendered host/text component with the given | |
* DOM node. The passed `inst` can be a composite. | |
*/ | |
function precacheNode(inst, node) { | |
var hostInst = getRenderedHostOrTextFromComponent(inst); | |
hostInst._hostNode = node; | |
node[internalInstanceKey] = hostInst; | |
} | |
function precacheFiberNode(hostInst, node) { | |
node[internalInstanceKey] = hostInst; | |
} | |
function uncacheNode(inst) { | |
var node = inst._hostNode; | |
if (node) { | |
delete node[internalInstanceKey]; | |
inst._hostNode = null; | |
} | |
} | |
/** | |
* Populate `_hostNode` on each child of `inst`, assuming that the children | |
* match up with the DOM (element) children of `node`. | |
* | |
* We cache entire levels at once to avoid an n^2 problem where we access the | |
* children of a node sequentially and have to walk from the start to our target | |
* node every time. | |
* | |
* Since we update `_renderedChildren` and the actual DOM at (slightly) | |
* different times, we could race here and see a newer `_renderedChildren` than | |
* the DOM nodes we see. To avoid this, ReactMultiChild calls | |
* `prepareToManageChildren` before we change `_renderedChildren`, at which | |
* time the container's child nodes are always cached (until it unmounts). | |
*/ | |
function precacheChildNodes(inst, node) { | |
if (inst._flags & Flags.hasCachedChildNodes) { | |
return; | |
} | |
var children = inst._renderedChildren; | |
var childNode = node.firstChild; | |
outer: for (var name in children) { | |
if (!children.hasOwnProperty(name)) { | |
continue; | |
} | |
var childInst = children[name]; | |
var childID = getRenderedHostOrTextFromComponent(childInst)._domID; | |
if (childID === 0) { | |
// We're currently unmounting this child in ReactMultiChild; skip it. | |
continue; | |
} | |
// We assume the child nodes are in the same order as the child instances. | |
for (; childNode !== null; childNode = childNode.nextSibling) { | |
if (shouldPrecacheNode(childNode, childID)) { | |
precacheNode(childInst, childNode); | |
continue outer; | |
} | |
} | |
// We reached the end of the DOM children without finding an ID match. | |
invariant2(false, 'Unable to find element with ID %s.', childID); | |
} | |
inst._flags |= Flags.hasCachedChildNodes; | |
} | |
/** | |
* Given a DOM node, return the closest ReactDOMComponent or | |
* ReactDOMTextComponent instance ancestor. | |
*/ | |
function getClosestInstanceFromNode(node) { | |
if (node[internalInstanceKey]) { | |
return node[internalInstanceKey]; | |
} | |
// Walk up the tree until we find an ancestor whose instance we have cached. | |
var parents = []; | |
while (!node[internalInstanceKey]) { | |
parents.push(node); | |
if (node.parentNode) { | |
node = node.parentNode; | |
} else { | |
// Top of the tree. This node must not be part of a React tree (or is | |
// unmounted, potentially). | |
return null; | |
} | |
} | |
var closest; | |
var inst = node[internalInstanceKey]; | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
// In Fiber, this will always be the deepest root. | |
return inst; | |
} | |
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) { | |
closest = inst; | |
if (parents.length) { | |
precacheChildNodes(inst, node); | |
} | |
} | |
return closest; | |
} | |
/** | |
* Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent | |
* instance, or null if the node was not rendered by this React. | |
*/ | |
function getInstanceFromNode(node) { | |
var inst = node[internalInstanceKey]; | |
if (inst) { | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
return inst; | |
} else if (inst._hostNode === node) { | |
return inst; | |
} else { | |
return null; | |
} | |
} | |
inst = getClosestInstanceFromNode(node); | |
if (inst != null && inst._hostNode === node) { | |
return inst; | |
} else { | |
return null; | |
} | |
} | |
/** | |
* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding | |
* DOM node. | |
*/ | |
function getNodeFromInstance(inst) { | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
// In Fiber this, is just the state node right now. We assume it will be | |
// a host component or host text. | |
return inst.stateNode; | |
} | |
// Without this first invariant2, passing a non-DOM-component triggers the next | |
// invariant2 for a missing parent, which is super confusing. | |
invariant2(inst._hostNode !== undefined, 'getNodeFromInstance: Invalid argument.'); | |
if (inst._hostNode) { | |
return inst._hostNode; | |
} | |
// Walk up the tree until we find an ancestor whose DOM node we have cached. | |
var parents = []; | |
while (!inst._hostNode) { | |
parents.push(inst); | |
invariant2(inst._hostParent, 'React DOM tree root should always have a node reference.'); | |
inst = inst._hostParent; | |
} | |
// Now parents contains each ancestor that does *not* have a cached native | |
// node, and `inst` is the deepest ancestor that does. | |
for (; parents.length; inst = parents.pop()) { | |
precacheChildNodes(inst, inst._hostNode); | |
} | |
return inst._hostNode; | |
} | |
function getFiberCurrentPropsFromNode(node) { | |
return node[internalEventHandlersKey] || null; | |
} | |
function updateFiberProps(node, props) { | |
node[internalEventHandlersKey] = props; | |
} | |
var ReactDOMComponentTree$1 = { | |
getClosestInstanceFromNode: getClosestInstanceFromNode, | |
getInstanceFromNode: getInstanceFromNode, | |
getNodeFromInstance: getNodeFromInstance, | |
precacheChildNodes: precacheChildNodes, | |
precacheNode: precacheNode, | |
uncacheNode: uncacheNode, | |
precacheFiberNode: precacheFiberNode, | |
getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode, | |
updateFiberProps: updateFiberProps | |
}; | |
var ReactDOMComponentTree_1 = ReactDOMComponentTree$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ARIADOMPropertyConfig | |
*/ | |
var ARIADOMPropertyConfig$1 = { | |
Properties: { | |
// Global States and Properties | |
'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 | |
}, | |
DOMAttributeNames: {}, | |
DOMPropertyNames: {} | |
}; | |
var ARIADOMPropertyConfig_1 = ARIADOMPropertyConfig$1; | |
var invariant$3 = invariant; | |
/** | |
* Injectable ordering of event plugins. | |
*/ | |
var eventPluginOrder = null; | |
/** | |
* Injectable mapping from names to event plugin modules. | |
*/ | |
var namesToPlugins = {}; | |
/** | |
* Recomputes the plugin list using the injected plugins and plugin ordering. | |
* | |
* @private | |
*/ | |
function recomputePluginOrdering() { | |
if (!eventPluginOrder) { | |
// Wait until an `eventPluginOrder` is injected. | |
return; | |
} | |
for (var pluginName in namesToPlugins) { | |
var pluginModule = namesToPlugins[pluginName]; | |
var pluginIndex = eventPluginOrder.indexOf(pluginName); | |
invariant$3(pluginIndex > -1, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName); | |
if (EventPluginRegistry$1.plugins[pluginIndex]) { | |
continue; | |
} | |
invariant$3(pluginModule.extractEvents, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName); | |
EventPluginRegistry$1.plugins[pluginIndex] = pluginModule; | |
var publishedEvents = pluginModule.eventTypes; | |
for (var eventName in publishedEvents) { | |
invariant$3(publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName), 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName); | |
} | |
} | |
} | |
/** | |
* Publishes an event so that it can be dispatched by the supplied plugin. | |
* | |
* @param {object} dispatchConfig Dispatch configuration for the event. | |
* @param {object} PluginModule Plugin publishing the event. | |
* @return {boolean} True if the event was successfully published. | |
* @private | |
*/ | |
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { | |
invariant$3(!EventPluginRegistry$1.eventNameDispatchConfigs.hasOwnProperty(eventName), 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName); | |
EventPluginRegistry$1.eventNameDispatchConfigs[eventName] = dispatchConfig; | |
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | |
if (phasedRegistrationNames) { | |
for (var phaseName in phasedRegistrationNames) { | |
if (phasedRegistrationNames.hasOwnProperty(phaseName)) { | |
var phasedRegistrationName = phasedRegistrationNames[phaseName]; | |
publishRegistrationName(phasedRegistrationName, pluginModule, eventName); | |
} | |
} | |
return true; | |
} else if (dispatchConfig.registrationName) { | |
publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); | |
return true; | |
} | |
return false; | |
} | |
/** | |
* Publishes a registration name that is used to identify dispatched events. | |
* | |
* @param {string} registrationName Registration name to add. | |
* @param {object} PluginModule Plugin publishing the event. | |
* @private | |
*/ | |
function publishRegistrationName(registrationName, pluginModule, eventName) { | |
invariant$3(!EventPluginRegistry$1.registrationNameModules[registrationName], 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName); | |
EventPluginRegistry$1.registrationNameModules[registrationName] = pluginModule; | |
EventPluginRegistry$1.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; | |
if (__DEV__) { | |
var lowerCasedName = registrationName.toLowerCase(); | |
EventPluginRegistry$1.possibleRegistrationNames[lowerCasedName] = registrationName; | |
if (registrationName === 'onDoubleClick') { | |
EventPluginRegistry$1.possibleRegistrationNames.ondblclick = registrationName; | |
} | |
} | |
} | |
/** | |
* Registers plugins so that they can extract and dispatch events. | |
* | |
* @see {EventPluginHub} | |
*/ | |
var EventPluginRegistry$1 = { | |
/** | |
* Ordered list of injected plugins. | |
*/ | |
plugins: [], | |
/** | |
* Mapping from event name to dispatch config | |
*/ | |
eventNameDispatchConfigs: {}, | |
/** | |
* Mapping from registration name to plugin module | |
*/ | |
registrationNameModules: {}, | |
/** | |
* Mapping from registration name to event name | |
*/ | |
registrationNameDependencies: {}, | |
/** | |
* Mapping from lowercase registration names to the properly cased version, | |
* used to warn in the case of missing event handlers. Available | |
* only in __DEV__. | |
* @type {Object} | |
*/ | |
possibleRegistrationNames: __DEV__ ? {} : null, | |
// Trust the developer to only use possibleRegistrationNames in __DEV__ | |
/** | |
* 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. | |
* | |
* @param {array} InjectedEventPluginOrder | |
* @internal | |
* @see {EventPluginHub.injection.injectEventPluginOrder} | |
*/ | |
injectEventPluginOrder: function (injectedEventPluginOrder) { | |
invariant$3(!eventPluginOrder, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.'); | |
// Clone the ordering so it cannot be dynamically mutated. | |
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); | |
recomputePluginOrdering(); | |
}, | |
/** | |
* Injects plugins to be used by `EventPluginHub`. The plugin names must be | |
* in the ordering injected by `injectEventPluginOrder`. | |
* | |
* Plugins can be injected as part of page initialization or on-the-fly. | |
* | |
* @param {object} injectedNamesToPlugins Map from names to plugin modules. | |
* @internal | |
* @see {EventPluginHub.injection.injectEventPluginsByName} | |
*/ | |
injectEventPluginsByName: function (injectedNamesToPlugins) { | |
var isOrderingDirty = false; | |
for (var pluginName in injectedNamesToPlugins) { | |
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { | |
continue; | |
} | |
var pluginModule = injectedNamesToPlugins[pluginName]; | |
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { | |
invariant$3(!namesToPlugins[pluginName], 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName); | |
namesToPlugins[pluginName] = pluginModule; | |
isOrderingDirty = true; | |
} | |
} | |
if (isOrderingDirty) { | |
recomputePluginOrdering(); | |
} | |
}, | |
/** | |
* Looks up the plugin for the supplied event. | |
* | |
* @param {object} event A synthetic event. | |
* @return {?object} The plugin that created the supplied event. | |
* @internal | |
*/ | |
getPluginModuleForEvent: function (event) { | |
var dispatchConfig = event.dispatchConfig; | |
if (dispatchConfig.registrationName) { | |
return EventPluginRegistry$1.registrationNameModules[dispatchConfig.registrationName] || null; | |
} | |
if (dispatchConfig.phasedRegistrationNames !== undefined) { | |
// pulling phasedRegistrationNames out of dispatchConfig helps Flow see | |
// that it is not undefined. | |
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | |
for (var phase in phasedRegistrationNames) { | |
if (!phasedRegistrationNames.hasOwnProperty(phase)) { | |
continue; | |
} | |
var pluginModule = EventPluginRegistry$1.registrationNameModules[phasedRegistrationNames[phase]]; | |
if (pluginModule) { | |
return pluginModule; | |
} | |
} | |
} | |
return null; | |
}, | |
/** | |
* Exposed for unit testing. | |
* @private | |
*/ | |
_resetEventPlugins: function () { | |
eventPluginOrder = null; | |
for (var pluginName in namesToPlugins) { | |
if (namesToPlugins.hasOwnProperty(pluginName)) { | |
delete namesToPlugins[pluginName]; | |
} | |
} | |
EventPluginRegistry$1.plugins.length = 0; | |
var eventNameDispatchConfigs = EventPluginRegistry$1.eventNameDispatchConfigs; | |
for (var eventName in eventNameDispatchConfigs) { | |
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) { | |
delete eventNameDispatchConfigs[eventName]; | |
} | |
} | |
var registrationNameModules = EventPluginRegistry$1.registrationNameModules; | |
for (var registrationName in registrationNameModules) { | |
if (registrationNameModules.hasOwnProperty(registrationName)) { | |
delete registrationNameModules[registrationName]; | |
} | |
} | |
if (__DEV__) { | |
var possibleRegistrationNames = EventPluginRegistry$1.possibleRegistrationNames; | |
for (var lowerCasedName in possibleRegistrationNames) { | |
if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) { | |
delete possibleRegistrationNames[lowerCasedName]; | |
} | |
} | |
} | |
} | |
}; | |
var EventPluginRegistry_1 = EventPluginRegistry$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactErrorUtils | |
* | |
*/ | |
var caughtError = null; | |
/** | |
* Call a function while guarding against errors that happens within it. | |
* Returns an error if it throws, otherwise null. | |
* | |
* @param {String} name of the guard to use for logging or debugging | |
* @param {Function} func The function to invoke | |
* @param {*} context The context to use when calling the function | |
* @param {...*} args Arguments for function | |
*/ | |
var ReactErrorUtils$2 = { | |
invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) { | |
var funcArgs = Array.prototype.slice.call(arguments, 3); | |
try { | |
func.apply(context, funcArgs); | |
} catch (error) { | |
return error; | |
} | |
return null; | |
}, | |
/** | |
* Same as invokeGuardedCallback, but instead of returning an error, it stores | |
* it in a global so it can be rethrown by `rethrowCaughtError` later. | |
* | |
* @param {String} name of the guard to use for logging or debugging | |
* @param {Function} func The function to invoke | |
* @param {*} context The context to use when calling the function | |
* @param {...*} args Arguments for function | |
*/ | |
invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) { | |
var error = ReactErrorUtils$2.invokeGuardedCallback.apply(this, arguments); | |
if (error !== null && caughtError === null) { | |
caughtError = error; | |
} | |
}, | |
/** | |
* During execution of guarded functions we will capture the first error which | |
* we will rethrow to be handled by the top level error handler. | |
*/ | |
rethrowCaughtError: function () { | |
if (caughtError) { | |
var error = caughtError; | |
caughtError = null; | |
throw error; | |
} | |
} | |
}; | |
if (__DEV__) { | |
/** | |
* To help development we can get better devtools integration by simulating a | |
* real browser event. | |
*/ | |
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { | |
var fakeNode = document.createElement('React'); | |
var depth = 0; | |
ReactErrorUtils$2.invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) { | |
depth++; | |
var thisDepth = depth; | |
var funcArgs = Array.prototype.slice.call(arguments, 3); | |
var boundFunc = function () { | |
func.apply(context, funcArgs); | |
}; | |
var fakeEventError = null; | |
var onFakeEventError = function (event) { | |
// Don't capture nested errors | |
if (depth === thisDepth) { | |
fakeEventError = event.error; | |
} | |
}; | |
var evtType = 'react-' + (name ? name : 'invokeguardedcallback') + '-' + depth; | |
window.addEventListener('error', onFakeEventError); | |
fakeNode.addEventListener(evtType, boundFunc, false); | |
var evt = document.createEvent('Event'); | |
evt.initEvent(evtType, false, false); | |
fakeNode.dispatchEvent(evt); | |
fakeNode.removeEventListener(evtType, boundFunc, false); | |
window.removeEventListener('error', onFakeEventError); | |
depth--; | |
return fakeEventError; | |
}; | |
} | |
} | |
var ReactErrorUtils_1 = ReactErrorUtils$2; | |
var ReactErrorUtils$1 = ReactErrorUtils_1; | |
var invariant$4 = invariant; | |
var warning$2 = warning; | |
/** | |
* Injected dependencies: | |
*/ | |
/** | |
* - `ComponentTree`: [required] Module that can convert between React instances | |
* and actual node references. | |
*/ | |
var ComponentTree; | |
var injection = { | |
injectComponentTree: function (Injected) { | |
ComponentTree = Injected; | |
if (__DEV__) { | |
warning$2(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); | |
} | |
} | |
}; | |
function isEndish(topLevelType) { | |
return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel'; | |
} | |
function isMoveish(topLevelType) { | |
return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove'; | |
} | |
function isStartish(topLevelType) { | |
return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart'; | |
} | |
var validateEventDispatches; | |
if (__DEV__) { | |
validateEventDispatches = function (event) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
var listenersIsArr = Array.isArray(dispatchListeners); | |
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; | |
var instancesIsArr = Array.isArray(dispatchInstances); | |
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; | |
warning$2(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.'); | |
}; | |
} | |
/** | |
* Dispatch the event to the listener. | |
* @param {SyntheticEvent} event SyntheticEvent to handle | |
* @param {boolean} simulated If the event is simulated (changes exn behavior) | |
* @param {function} listener Application-level callback | |
* @param {*} inst Internal component instance | |
*/ | |
function executeDispatch(event, simulated, listener, inst) { | |
var type = event.type || 'unknown-event'; | |
event.currentTarget = EventPluginUtils$2.getNodeFromInstance(inst); | |
ReactErrorUtils$1.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); | |
event.currentTarget = null; | |
} | |
/** | |
* Standard/simple iteration through an event's collected dispatches. | |
*/ | |
function executeDispatchesInOrder(event, simulated) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
if (Array.isArray(dispatchListeners)) { | |
for (var i = 0; i < dispatchListeners.length; i++) { | |
if (event.isPropagationStopped()) { | |
break; | |
} | |
// Listeners and Instances are two parallel arrays that are always in sync. | |
executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]); | |
} | |
} else if (dispatchListeners) { | |
executeDispatch(event, simulated, dispatchListeners, dispatchInstances); | |
} | |
event._dispatchListeners = null; | |
event._dispatchInstances = null; | |
} | |
/** | |
* Standard/simple iteration through an event's collected dispatches, but stops | |
* at the first dispatch execution returning true, and returns that id. | |
* | |
* @return {?string} id of the first dispatch execution who's listener returns | |
* true, or null if no listener returned true. | |
*/ | |
function executeDispatchesInOrderStopAtTrueImpl(event) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
if (Array.isArray(dispatchListeners)) { | |
for (var i = 0; i < dispatchListeners.length; i++) { | |
if (event.isPropagationStopped()) { | |
break; | |
} | |
// Listeners and Instances are two parallel arrays that are always in sync. | |
if (dispatchListeners[i](event, dispatchInstances[i])) { | |
return dispatchInstances[i]; | |
} | |
} | |
} else if (dispatchListeners) { | |
if (dispatchListeners(event, dispatchInstances)) { | |
return dispatchInstances; | |
} | |
} | |
return null; | |
} | |
/** | |
* @see executeDispatchesInOrderStopAtTrueImpl | |
*/ | |
function executeDispatchesInOrderStopAtTrue(event) { | |
var ret = executeDispatchesInOrderStopAtTrueImpl(event); | |
event._dispatchInstances = null; | |
event._dispatchListeners = null; | |
return ret; | |
} | |
/** | |
* Execution of a "direct" dispatch - there must be at most one dispatch | |
* accumulated on the event or it is considered an error. It doesn't really make | |
* sense for an event with multiple dispatches (bubbled) to keep track of the | |
* return values at each dispatch execution, but it does tend to make sense when | |
* dealing with "direct" dispatches. | |
* | |
* @return {*} The return value of executing the single dispatch. | |
*/ | |
function executeDirectDispatch(event) { | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
var dispatchListener = event._dispatchListeners; | |
var dispatchInstance = event._dispatchInstances; | |
invariant$4(!Array.isArray(dispatchListener), 'executeDirectDispatch(...): Invalid `event`.'); | |
event.currentTarget = dispatchListener ? EventPluginUtils$2.getNodeFromInstance(dispatchInstance) : null; | |
var res = dispatchListener ? dispatchListener(event) : null; | |
event.currentTarget = null; | |
event._dispatchListeners = null; | |
event._dispatchInstances = null; | |
return res; | |
} | |
/** | |
* @param {SyntheticEvent} event | |
* @return {boolean} True iff number of dispatches accumulated is greater than 0. | |
*/ | |
function hasDispatches(event) { | |
return !!event._dispatchListeners; | |
} | |
/** | |
* General utilities that are useful in creating custom Event Plugins. | |
*/ | |
var EventPluginUtils$2 = { | |
isEndish: isEndish, | |
isMoveish: isMoveish, | |
isStartish: isStartish, | |
executeDirectDispatch: executeDirectDispatch, | |
executeDispatchesInOrder: executeDispatchesInOrder, | |
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue, | |
hasDispatches: hasDispatches, | |
getFiberCurrentPropsFromNode: function (node) { | |
return ComponentTree.getFiberCurrentPropsFromNode(node); | |
}, | |
getInstanceFromNode: function (node) { | |
return ComponentTree.getInstanceFromNode(node); | |
}, | |
getNodeFromInstance: function (node) { | |
return ComponentTree.getNodeFromInstance(node); | |
}, | |
injection: injection | |
}; | |
var EventPluginUtils_1 = EventPluginUtils$2; | |
var invariant$5 = invariant; | |
/** | |
* Accumulates items that must not be null or undefined into the first one. This | |
* is used to conserve memory by avoiding array allocations, and thus sacrifices | |
* API cleanness. Since `current` can be null before being passed in and not | |
* null after this function, make sure to assign it back to `current`: | |
* | |
* `a = accumulateInto(a, b);` | |
* | |
* This API should be sparingly used. Try `accumulate` for something cleaner. | |
* | |
* @return {*|array<*>} An accumulation of items. | |
*/ | |
function accumulateInto$2(current, next) { | |
invariant$5(next != null, 'accumulateInto(...): Accumulated items must not be null or undefined.'); | |
if (current == null) { | |
return next; | |
} | |
// Both are not empty. Warning: Never call x.concat(y) when you are not | |
// certain that x is an Array (x could be a string with concat method). | |
if (Array.isArray(current)) { | |
if (Array.isArray(next)) { | |
current.push.apply(current, next); | |
return current; | |
} | |
current.push(next); | |
return current; | |
} | |
if (Array.isArray(next)) { | |
// A bit too dangerous to mutate `next`. | |
return [current].concat(next); | |
} | |
return [current, next]; | |
} | |
var accumulateInto_1 = accumulateInto$2; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule forEachAccumulated | |
* | |
*/ | |
/** | |
* @param {array} arr an "accumulation" of items which is either an Array or | |
* a single item. Useful when paired with the `accumulate` module. This is a | |
* simple utility that allows us to reason about a collection of items, but | |
* handling the case when there is exactly one item (and we do not need to | |
* allocate an array). | |
* @param {function} cb Callback invoked with each element or a collection. | |
* @param {?} [scope] Scope used as `this` in a callback. | |
*/ | |
function forEachAccumulated$2(arr, cb, scope) { | |
if (Array.isArray(arr)) { | |
arr.forEach(cb, scope); | |
} else if (arr) { | |
cb.call(scope, arr); | |
} | |
} | |
var forEachAccumulated_1 = forEachAccumulated$2; | |
var EventPluginRegistry = EventPluginRegistry_1; | |
var EventPluginUtils$1 = EventPluginUtils_1; | |
var ReactErrorUtils = ReactErrorUtils_1; | |
var accumulateInto$1 = accumulateInto_1; | |
var forEachAccumulated$1 = forEachAccumulated_1; | |
var invariant$2 = invariant; | |
/** | |
* Internal queue of events that have accumulated their dispatches and are | |
* waiting to have their dispatches executed. | |
*/ | |
var eventQueue = null; | |
/** | |
* Dispatches an event and releases it back into the pool, unless persistent. | |
* | |
* @param {?object} event Synthetic event to be dispatched. | |
* @param {boolean} simulated If the event is simulated (changes exn behavior) | |
* @private | |
*/ | |
var executeDispatchesAndRelease = function (event, simulated) { | |
if (event) { | |
EventPluginUtils$1.executeDispatchesInOrder(event, simulated); | |
if (!event.isPersistent()) { | |
event.constructor.release(event); | |
} | |
} | |
}; | |
var executeDispatchesAndReleaseSimulated = function (e) { | |
return executeDispatchesAndRelease(e, true); | |
}; | |
var executeDispatchesAndReleaseTopLevel = function (e) { | |
return executeDispatchesAndRelease(e, false); | |
}; | |
function isInteractive(tag) { | |
return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; | |
} | |
function shouldPreventMouseEvent(name, type, props) { | |
switch (name) { | |
case 'onClick': | |
case 'onClickCapture': | |
case 'onDoubleClick': | |
case 'onDoubleClickCapture': | |
case 'onMouseDown': | |
case 'onMouseDownCapture': | |
case 'onMouseMove': | |
case 'onMouseMoveCapture': | |
case 'onMouseUp': | |
case 'onMouseUpCapture': | |
return !!(props.disabled && isInteractive(type)); | |
default: | |
return false; | |
} | |
} | |
/** | |
* This is a unified interface for event plugins to be installed and configured. | |
* | |
* Event plugins can implement the following properties: | |
* | |
* `extractEvents` {function(string, DOMEventTarget, string, object): *} | |
* Required. When a top-level event is fired, this method is expected to | |
* extract synthetic events that will in turn be queued and dispatched. | |
* | |
* `eventTypes` {object} | |
* Optional, plugins that fire events must publish a mapping of registration | |
* names that are used to register listeners. Values of this mapping must | |
* be objects that contain `registrationName` or `phasedRegistrationNames`. | |
* | |
* `executeDispatch` {function(object, function, string)} | |
* Optional, allows plugins to override how an event gets dispatched. By | |
* default, the listener is simply invoked. | |
* | |
* Each plugin that is injected into `EventsPluginHub` is immediately operable. | |
* | |
* @public | |
*/ | |
var EventPluginHub$2 = { | |
/** | |
* Methods for injecting dependencies. | |
*/ | |
injection: { | |
/** | |
* @param {array} InjectedEventPluginOrder | |
* @public | |
*/ | |
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder, | |
/** | |
* @param {object} injectedNamesToPlugins Map from names to plugin modules. | |
*/ | |
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName | |
}, | |
/** | |
* @param {object} inst The instance, which is the source of events. | |
* @param {string} registrationName Name of listener (e.g. `onClick`). | |
* @return {?function} The stored callback. | |
*/ | |
getListener: function (inst, registrationName) { | |
var listener; | |
// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not | |
// live here; needs to be moved to a better place soon | |
if (typeof inst.tag === 'number') { | |
var props = EventPluginUtils$1.getFiberCurrentPropsFromNode(inst.stateNode); | |
if (!props) { | |
// Work in progress. | |
return null; | |
} | |
listener = props[registrationName]; | |
if (shouldPreventMouseEvent(registrationName, inst.type, props)) { | |
return null; | |
} | |
} else { | |
if (typeof inst._currentElement === 'string') { | |
// Text node, let it bubble through. | |
return null; | |
} | |
if (!inst._rootNodeID) { | |
// If the instance is already unmounted, we have no listeners. | |
return null; | |
} | |
var _props = inst._currentElement.props; | |
listener = _props[registrationName]; | |
if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, _props)) { | |
return null; | |
} | |
} | |
invariant$2(!listener || typeof listener === 'function', 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener); | |
return listener; | |
}, | |
/** | |
* Allows registered plugins an opportunity to extract events from top-level | |
* native browser events. | |
* | |
* @return {*} An accumulation of synthetic events. | |
* @internal | |
*/ | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var events; | |
var plugins = EventPluginRegistry.plugins; | |
for (var i = 0; i < plugins.length; i++) { | |
// Not every plugin in the ordering may be loaded at runtime. | |
var possiblePlugin = plugins[i]; | |
if (possiblePlugin) { | |
var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
if (extractedEvents) { | |
events = accumulateInto$1(events, extractedEvents); | |
} | |
} | |
} | |
return events; | |
}, | |
/** | |
* Enqueues a synthetic event that should be dispatched when | |
* `processEventQueue` is invoked. | |
* | |
* @param {*} events An accumulation of synthetic events. | |
* @internal | |
*/ | |
enqueueEvents: function (events) { | |
if (events) { | |
eventQueue = accumulateInto$1(eventQueue, events); | |
} | |
}, | |
/** | |
* Dispatches all synthetic events on the event queue. | |
* | |
* @internal | |
*/ | |
processEventQueue: function (simulated) { | |
// Set `eventQueue` to null before processing it so that we can tell if more | |
// events get enqueued while processing. | |
var processingEventQueue = eventQueue; | |
eventQueue = null; | |
if (simulated) { | |
forEachAccumulated$1(processingEventQueue, executeDispatchesAndReleaseSimulated); | |
} else { | |
forEachAccumulated$1(processingEventQueue, executeDispatchesAndReleaseTopLevel); | |
} | |
invariant$2(!eventQueue, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.'); | |
// This would be a good time to rethrow if any of the event handlers threw. | |
ReactErrorUtils.rethrowCaughtError(); | |
} | |
}; | |
var EventPluginHub_1 = EventPluginHub$2; | |
var _require$1 = ReactTypeOfWork; | |
var HostComponent$1 = _require$1.HostComponent; | |
function getParent(inst) { | |
if (inst._hostParent !== undefined) { | |
return inst._hostParent; | |
} | |
if (typeof inst.tag === 'number') { | |
do { | |
inst = inst['return']; | |
// TODO: If this is a HostRoot we might want to bail out. | |
// That is depending on if we want nested subtrees (layers) to bubble | |
// events to their parent. We could also go through parentNode on the | |
// host node but that wouldn't work for React Native and doesn't let us | |
// do the portal feature. | |
} while (inst && inst.tag !== HostComponent$1); | |
if (inst) { | |
return inst; | |
} | |
} | |
return null; | |
} | |
/** | |
* Return the lowest common ancestor of A and B, or null if they are in | |
* different trees. | |
*/ | |
function getLowestCommonAncestor(instA, instB) { | |
var depthA = 0; | |
for (var tempA = instA; tempA; tempA = getParent(tempA)) { | |
depthA++; | |
} | |
var depthB = 0; | |
for (var tempB = instB; tempB; tempB = getParent(tempB)) { | |
depthB++; | |
} | |
// If A is deeper, crawl up. | |
while (depthA - depthB > 0) { | |
instA = getParent(instA); | |
depthA--; | |
} | |
// If B is deeper, crawl up. | |
while (depthB - depthA > 0) { | |
instB = getParent(instB); | |
depthB--; | |
} | |
// Walk in lockstep until we find a match. | |
var depth = depthA; | |
while (depth--) { | |
if (instA === instB || instA === instB.alternate) { | |
return instA; | |
} | |
instA = getParent(instA); | |
instB = getParent(instB); | |
} | |
return null; | |
} | |
/** | |
* Return if A is an ancestor of B. | |
*/ | |
function isAncestor(instA, instB) { | |
while (instB) { | |
if (instA === instB || instA === instB.alternate) { | |
return true; | |
} | |
instB = getParent(instB); | |
} | |
return false; | |
} | |
/** | |
* Return the parent instance of the passed-in instance. | |
*/ | |
function getParentInstance(inst) { | |
return getParent(inst); | |
} | |
/** | |
* Simulates the traversal of a two-phase, capture/bubble event dispatch. | |
*/ | |
function traverseTwoPhase(inst, fn, arg) { | |
var path = []; | |
while (inst) { | |
path.push(inst); | |
inst = getParent(inst); | |
} | |
var i; | |
for (i = path.length; i-- > 0;) { | |
fn(path[i], 'captured', arg); | |
} | |
for (i = 0; i < path.length; i++) { | |
fn(path[i], 'bubbled', arg); | |
} | |
} | |
/** | |
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that | |
* should would receive a `mouseEnter` or `mouseLeave` event. | |
* | |
* Does not invoke the callback on the nearest common ancestor because nothing | |
* "entered" or "left" that element. | |
*/ | |
function traverseEnterLeave(from, to, fn, argFrom, argTo) { | |
var common = from && to ? getLowestCommonAncestor(from, to) : null; | |
var pathFrom = []; | |
while (from && from !== common) { | |
pathFrom.push(from); | |
from = getParent(from); | |
} | |
var pathTo = []; | |
while (to && to !== common) { | |
pathTo.push(to); | |
to = getParent(to); | |
} | |
var i; | |
for (i = 0; i < pathFrom.length; i++) { | |
fn(pathFrom[i], 'bubbled', argFrom); | |
} | |
for (i = pathTo.length; i-- > 0;) { | |
fn(pathTo[i], 'captured', argTo); | |
} | |
} | |
var ReactTreeTraversal$1 = { | |
isAncestor: isAncestor, | |
getLowestCommonAncestor: getLowestCommonAncestor, | |
getParentInstance: getParentInstance, | |
traverseTwoPhase: traverseTwoPhase, | |
traverseEnterLeave: traverseEnterLeave | |
}; | |
var EventPluginHub$1 = EventPluginHub_1; | |
var ReactTreeTraversal = ReactTreeTraversal$1; | |
var accumulateInto = accumulateInto_1; | |
var forEachAccumulated = forEachAccumulated_1; | |
var warning$1 = warning; | |
var getListener = EventPluginHub$1.getListener; | |
/** | |
* Some event types have a notion of different registration names for different | |
* "phases" of propagation. This finds listeners by a given phase. | |
*/ | |
function listenerAtPhase(inst, event, propagationPhase) { | |
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; | |
return getListener(inst, registrationName); | |
} | |
/** | |
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function | |
* here, allows us to not have to bind or create functions for each event. | |
* Mutating the event's members allows us to not have to create a wrapping | |
* "dispatch" object that pairs the event with the listener. | |
*/ | |
function accumulateDirectionalDispatches(inst, phase, event) { | |
if (__DEV__) { | |
warning$1(inst, 'Dispatching inst must not be null'); | |
} | |
var listener = listenerAtPhase(inst, event, phase); | |
if (listener) { | |
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | |
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); | |
} | |
} | |
/** | |
* Collect dispatches (must be entirely collected before dispatching - see unit | |
* tests). Lazily allocate the array to conserve memory. We must loop through | |
* each event and perform the traversal for each one. We cannot perform a | |
* single traversal for the entire collection of events because each event may | |
* have a different target. | |
*/ | |
function accumulateTwoPhaseDispatchesSingle(event) { | |
if (event && event.dispatchConfig.phasedRegistrationNames) { | |
ReactTreeTraversal.traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); | |
} | |
} | |
/** | |
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. | |
*/ | |
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { | |
if (event && event.dispatchConfig.phasedRegistrationNames) { | |
var targetInst = event._targetInst; | |
var parentInst = targetInst ? ReactTreeTraversal.getParentInstance(targetInst) : null; | |
ReactTreeTraversal.traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); | |
} | |
} | |
/** | |
* Accumulates without regard to direction, does not look for phased | |
* registration names. Same as `accumulateDirectDispatchesSingle` but without | |
* requiring that the `dispatchMarker` be the same as the dispatched ID. | |
*/ | |
function accumulateDispatches(inst, ignoredDirection, event) { | |
if (event && event.dispatchConfig.registrationName) { | |
var registrationName = event.dispatchConfig.registrationName; | |
var listener = getListener(inst, registrationName); | |
if (listener) { | |
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); | |
event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); | |
} | |
} | |
} | |
/** | |
* Accumulates dispatches on an `SyntheticEvent`, but only for the | |
* `dispatchMarker`. | |
* @param {SyntheticEvent} event | |
*/ | |
function accumulateDirectDispatchesSingle(event) { | |
if (event && event.dispatchConfig.registrationName) { | |
accumulateDispatches(event._targetInst, null, event); | |
} | |
} | |
function accumulateTwoPhaseDispatches(events) { | |
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); | |
} | |
function accumulateTwoPhaseDispatchesSkipTarget(events) { | |
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); | |
} | |
function accumulateEnterLeaveDispatches(leave, enter, from, to) { | |
ReactTreeTraversal.traverseEnterLeave(from, to, accumulateDispatches, leave, enter); | |
} | |
function accumulateDirectDispatches(events) { | |
forEachAccumulated(events, accumulateDirectDispatchesSingle); | |
} | |
/** | |
* A small set of propagation patterns, each of which will accept a small amount | |
* of information, and generate a set of "dispatch ready event objects" - which | |
* are sets of events that have already been annotated with a set of dispatched | |
* listener functions/ids. The API is designed this way to discourage these | |
* propagation strategies from actually executing the dispatches, since we | |
* always want to collect the entire set of dispatches before executing even a | |
* single one. | |
* | |
* @constructor EventPropagators | |
*/ | |
var EventPropagators$1 = { | |
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches, | |
accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget, | |
accumulateDirectDispatches: accumulateDirectDispatches, | |
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches | |
}; | |
var EventPropagators_1 = EventPropagators$1; | |
var invariant$6 = invariant; | |
/** | |
* Static poolers. Several custom versions for each potential number of | |
* arguments. A completely generic pooler is easy to implement, but would | |
* require accessing the `arguments` object. In each of these, `this` refers to | |
* the Class itself, not an instance. If any others are needed, simply add them | |
* here, or in their own files. | |
*/ | |
var oneArgumentPooler = function (copyFieldsFrom) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, copyFieldsFrom); | |
return instance; | |
} else { | |
return new Klass(copyFieldsFrom); | |
} | |
}; | |
var twoArgumentPooler = function (a1, a2) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2); | |
return instance; | |
} else { | |
return new Klass(a1, a2); | |
} | |
}; | |
var threeArgumentPooler = function (a1, a2, a3) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3); | |
} | |
}; | |
var fourArgumentPooler = function (a1, a2, a3, a4) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3, a4); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3, a4); | |
} | |
}; | |
var standardReleaser = function (instance) { | |
var Klass = this; | |
invariant$6(instance instanceof Klass, 'Trying to release an instance into a pool of a different type.'); | |
instance.destructor(); | |
if (Klass.instancePool.length < Klass.poolSize) { | |
Klass.instancePool.push(instance); | |
} | |
}; | |
var DEFAULT_POOL_SIZE = 10; | |
var DEFAULT_POOLER = oneArgumentPooler; | |
/** | |
* Augments `CopyConstructor` to be a poolable class, augmenting only the class | |
* itself (statically) not adding any prototypical fields. Any CopyConstructor | |
* you give this may have a `poolSize` property, and will look for a | |
* prototypical `destructor` on instances. | |
* | |
* @param {Function} CopyConstructor Constructor that can be used to reset. | |
* @param {Function} pooler Customizable pooler. | |
*/ | |
var addPoolingTo = function (CopyConstructor, pooler) { | |
// Casting as any so that flow ignores the actual implementation and trusts | |
// it to match the type we declared | |
var NewKlass = CopyConstructor; | |
NewKlass.instancePool = []; | |
NewKlass.getPooled = pooler || DEFAULT_POOLER; | |
if (!NewKlass.poolSize) { | |
NewKlass.poolSize = DEFAULT_POOL_SIZE; | |
} | |
NewKlass.release = standardReleaser; | |
return NewKlass; | |
}; | |
var PooledClass$1 = { | |
addPoolingTo: addPoolingTo, | |
oneArgumentPooler: oneArgumentPooler, | |
twoArgumentPooler: twoArgumentPooler, | |
threeArgumentPooler: threeArgumentPooler, | |
fourArgumentPooler: fourArgumentPooler | |
}; | |
var PooledClass_1 = PooledClass$1; | |
var ExecutionEnvironment$2 = ExecutionEnvironment; | |
var contentKey = null; | |
/** | |
* Gets the key used to access text content on a DOM node. | |
* | |
* @return {?string} Key used to access text content. | |
* @internal | |
*/ | |
function getTextContentAccessor$1() { | |
if (!contentKey && ExecutionEnvironment$2.canUseDOM) { | |
// Prefer textContent to innerText because many browsers support both but | |
// SVG <text> elements don't support innerText even when <div> does. | |
contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText'; | |
} | |
return contentKey; | |
} | |
var getTextContentAccessor_1 = getTextContentAccessor$1; | |
var PooledClass = PooledClass_1; | |
var getTextContentAccessor = getTextContentAccessor_1; | |
/** | |
* This helper class stores information about text content of a target node, | |
* allowing comparison of content before and after a given event. | |
* | |
* Identify the node where selection currently begins, then observe | |
* both its text content and its current position in the DOM. Since the | |
* browser may natively replace the target node during composition, we can | |
* use its position to find its replacement. | |
* | |
* @param {DOMEventTarget} root | |
*/ | |
function FallbackCompositionState$1(root) { | |
this._root = root; | |
this._startText = this.getText(); | |
this._fallbackText = null; | |
} | |
Object.assign(FallbackCompositionState$1.prototype, { | |
destructor: function () { | |
this._root = null; | |
this._startText = null; | |
this._fallbackText = null; | |
}, | |
/** | |
* Get current text of input. | |
* | |
* @return {string} | |
*/ | |
getText: function () { | |
if ('value' in this._root) { | |
return this._root.value; | |
} | |
return this._root[getTextContentAccessor()]; | |
}, | |
/** | |
* Determine the differing substring between the initially stored | |
* text content and the current content. | |
* | |
* @return {string} | |
*/ | |
getData: function () { | |
if (this._fallbackText) { | |
return this._fallbackText; | |
} | |
var start; | |
var startValue = this._startText; | |
var startLength = startValue.length; | |
var end; | |
var endValue = this.getText(); | |
var endLength = endValue.length; | |
for (start = 0; start < startLength; start++) { | |
if (startValue[start] !== endValue[start]) { | |
break; | |
} | |
} | |
var minEnd = startLength - start; | |
for (end = 1; end <= minEnd; end++) { | |
if (startValue[startLength - end] !== endValue[endLength - end]) { | |
break; | |
} | |
} | |
var sliceTail = end > 1 ? 1 - end : undefined; | |
this._fallbackText = endValue.slice(start, sliceTail); | |
return this._fallbackText; | |
} | |
}); | |
PooledClass.addPoolingTo(FallbackCompositionState$1); | |
var FallbackCompositionState_1 = FallbackCompositionState$1; | |
var PooledClass$2 = PooledClass_1; | |
var emptyFunction$1 = emptyFunction; | |
var warning$3 = warning; | |
var didWarnForAddedNewProperty = false; | |
var isProxySupported = typeof Proxy === 'function'; | |
var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var EventInterface = { | |
type: null, | |
target: null, | |
// currentTarget is set when dispatching; no use in copying it here | |
currentTarget: emptyFunction$1.thatReturnsNull, | |
eventPhase: null, | |
bubbles: null, | |
cancelable: null, | |
timeStamp: function (event) { | |
return event.timeStamp || Date.now(); | |
}, | |
defaultPrevented: null, | |
isTrusted: null | |
}; | |
/** | |
* Synthetic events are dispatched by event plugins, typically in response to a | |
* top-level event delegation handler. | |
* | |
* These systems should generally use pooling to reduce the frequency of garbage | |
* collection. The system should check `isPersistent` to determine whether the | |
* event should be released into the pool after being dispatched. Users that | |
* need a persisted event should invoke `persist`. | |
* | |
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by | |
* normalizing browser quirks. Subclasses do not necessarily have to implement a | |
* DOM interface; custom application-specific events can also subclass this. | |
* | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {*} targetInst Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @param {DOMEventTarget} nativeEventTarget Target node. | |
*/ | |
function SyntheticEvent$1(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { | |
if (__DEV__) { | |
// these have a getter/setter for warnings | |
delete this.nativeEvent; | |
delete this.preventDefault; | |
delete this.stopPropagation; | |
} | |
this.dispatchConfig = dispatchConfig; | |
this._targetInst = targetInst; | |
this.nativeEvent = nativeEvent; | |
var Interface = this.constructor.Interface; | |
for (var propName in Interface) { | |
if (!Interface.hasOwnProperty(propName)) { | |
continue; | |
} | |
if (__DEV__) { | |
delete this[propName]; // this has a getter/setter for warnings | |
} | |
var normalize = Interface[propName]; | |
if (normalize) { | |
this[propName] = normalize(nativeEvent); | |
} else { | |
if (propName === 'target') { | |
this.target = nativeEventTarget; | |
} else { | |
this[propName] = nativeEvent[propName]; | |
} | |
} | |
} | |
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; | |
if (defaultPrevented) { | |
this.isDefaultPrevented = emptyFunction$1.thatReturnsTrue; | |
} else { | |
this.isDefaultPrevented = emptyFunction$1.thatReturnsFalse; | |
} | |
this.isPropagationStopped = emptyFunction$1.thatReturnsFalse; | |
return this; | |
} | |
Object.assign(SyntheticEvent$1.prototype, { | |
preventDefault: function () { | |
this.defaultPrevented = true; | |
var event = this.nativeEvent; | |
if (!event) { | |
return; | |
} | |
if (event.preventDefault) { | |
event.preventDefault(); | |
} else if (typeof event.returnValue !== 'unknown') { | |
// eslint-disable-line valid-typeof | |
event.returnValue = false; | |
} | |
this.isDefaultPrevented = emptyFunction$1.thatReturnsTrue; | |
}, | |
stopPropagation: function () { | |
var event = this.nativeEvent; | |
if (!event) { | |
return; | |
} | |
if (event.stopPropagation) { | |
event.stopPropagation(); | |
} else if (typeof event.cancelBubble !== 'unknown') { | |
// eslint-disable-line valid-typeof | |
// The ChangeEventPlugin registers a "propertychange" event for | |
// IE. This event does not support bubbling or cancelling, and | |
// any references to cancelBubble throw "Member not found". A | |
// typeof check of "unknown" circumvents this issue (and is also | |
// IE specific). | |
event.cancelBubble = true; | |
} | |
this.isPropagationStopped = emptyFunction$1.thatReturnsTrue; | |
}, | |
/** | |
* We release all dispatched `SyntheticEvent`s after each event loop, adding | |
* them back into the pool. This allows a way to hold onto a reference that | |
* won't be added back into the pool. | |
*/ | |
persist: function () { | |
this.isPersistent = emptyFunction$1.thatReturnsTrue; | |
}, | |
/** | |
* Checks if this event should be released back into the pool. | |
* | |
* @return {boolean} True if this should not be released, false otherwise. | |
*/ | |
isPersistent: emptyFunction$1.thatReturnsFalse, | |
/** | |
* `PooledClass` looks for `destructor` on each instance it releases. | |
*/ | |
destructor: function () { | |
var Interface = this.constructor.Interface; | |
for (var propName in Interface) { | |
if (__DEV__) { | |
Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); | |
} else { | |
this[propName] = null; | |
} | |
} | |
for (var i = 0; i < shouldBeReleasedProperties.length; i++) { | |
this[shouldBeReleasedProperties[i]] = null; | |
} | |
if (__DEV__) { | |
Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); | |
Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction$1)); | |
Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction$1)); | |
} | |
} | |
}); | |
SyntheticEvent$1.Interface = EventInterface; | |
if (__DEV__) { | |
if (isProxySupported) { | |
/*eslint-disable no-func-assign */ | |
SyntheticEvent$1 = new Proxy(SyntheticEvent$1, { | |
construct: function (target, args) { | |
return this.apply(target, Object.create(target.prototype), args); | |
}, | |
apply: function (constructor, that, args) { | |
return new Proxy(constructor.apply(that, args), { | |
set: function (target, prop, value) { | |
if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { | |
warning$3(didWarnForAddedNewProperty || target.isPersistent(), 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re adding a new property in the synthetic event object. ' + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); | |
didWarnForAddedNewProperty = true; | |
} | |
target[prop] = value; | |
return true; | |
} | |
}); | |
} | |
}); | |
/*eslint-enable no-func-assign */ | |
} | |
} | |
/** | |
* Helper to reduce boilerplate when creating subclasses. | |
* | |
* @param {function} Class | |
* @param {?object} Interface | |
*/ | |
SyntheticEvent$1.augmentClass = function (Class, Interface) { | |
var Super = this; | |
var E = function () {}; | |
E.prototype = Super.prototype; | |
var prototype = new E(); | |
Object.assign(prototype, Class.prototype); | |
Class.prototype = prototype; | |
Class.prototype.constructor = Class; | |
Class.Interface = Object.assign({}, Super.Interface, Interface); | |
Class.augmentClass = Super.augmentClass; | |
PooledClass$2.addPoolingTo(Class, PooledClass$2.fourArgumentPooler); | |
}; | |
PooledClass$2.addPoolingTo(SyntheticEvent$1, PooledClass$2.fourArgumentPooler); | |
var SyntheticEvent_1 = SyntheticEvent$1; | |
/** | |
* Helper to nullify syntheticEvent instance properties when destructing | |
* | |
* @param {object} SyntheticEvent | |
* @param {String} propName | |
* @return {object} defineProperty object | |
*/ | |
function getPooledWarningPropertyDefinition(propName, getVal) { | |
var isFunction = typeof getVal === 'function'; | |
return { | |
configurable: true, | |
set: set, | |
get: get | |
}; | |
function set(val) { | |
var action = isFunction ? 'setting the method' : 'setting the property'; | |
warn(action, 'This is effectively a no-op'); | |
return val; | |
} | |
function get() { | |
var action = isFunction ? 'accessing the method' : 'accessing the property'; | |
var result = isFunction ? 'This is a no-op function' : 'This is set to null'; | |
warn(action, result); | |
return getVal; | |
} | |
function warn(action, result) { | |
var warningCondition = false; | |
warning$3(warningCondition, 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' + 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); | |
} | |
} | |
var SyntheticEvent = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents | |
*/ | |
var CompositionEventInterface = { | |
data: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticCompositionEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent.augmentClass(SyntheticCompositionEvent$1, CompositionEventInterface); | |
var SyntheticCompositionEvent_1 = SyntheticCompositionEvent$1; | |
var SyntheticEvent$2 = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 | |
* /#events-inputevents | |
*/ | |
var InputEventInterface = { | |
data: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticInputEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$2.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$2.augmentClass(SyntheticInputEvent$1, InputEventInterface); | |
var SyntheticInputEvent_1 = SyntheticInputEvent$1; | |
var EventPropagators = EventPropagators_1; | |
var ExecutionEnvironment$1 = ExecutionEnvironment; | |
var FallbackCompositionState = FallbackCompositionState_1; | |
var SyntheticCompositionEvent = SyntheticCompositionEvent_1; | |
var SyntheticInputEvent = SyntheticInputEvent_1; | |
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space | |
var START_KEYCODE = 229; | |
var canUseCompositionEvent = ExecutionEnvironment$1.canUseDOM && 'CompositionEvent' in window; | |
var documentMode = null; | |
if (ExecutionEnvironment$1.canUseDOM && 'documentMode' in document) { | |
documentMode = document.documentMode; | |
} | |
// Webkit offers a very useful `textInput` event that can be used to | |
// directly represent `beforeInput`. The IE `textinput` event is not as | |
// useful, so we don't use it. | |
var canUseTextInputEvent = ExecutionEnvironment$1.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto(); | |
// In IE9+, we have access to composition events, but the data supplied | |
// by the native compositionend event may be incorrect. Japanese ideographic | |
// spaces, for instance (\u3000) are not recorded correctly. | |
var useFallbackCompositionData = ExecutionEnvironment$1.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); | |
/** | |
* Opera <= 12 includes TextEvent in window, but does not fire | |
* text input events. Rely on keypress instead. | |
*/ | |
function isPresto() { | |
var opera = window.opera; | |
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; | |
} | |
var SPACEBAR_CODE = 32; | |
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); | |
// Events and their corresponding property names. | |
var eventTypes = { | |
beforeInput: { | |
phasedRegistrationNames: { | |
bubbled: 'onBeforeInput', | |
captured: 'onBeforeInputCapture' | |
}, | |
dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste'] | |
}, | |
compositionEnd: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionEnd', | |
captured: 'onCompositionEndCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionEnd', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
}, | |
compositionStart: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionStart', | |
captured: 'onCompositionStartCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionStart', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
}, | |
compositionUpdate: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionUpdate', | |
captured: 'onCompositionUpdateCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionUpdate', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
} | |
}; | |
// Track whether we've ever handled a keypress on the space key. | |
var hasSpaceKeypress = false; | |
/** | |
* Return whether a native keypress event is assumed to be a command. | |
* This is required because Firefox fires `keypress` events for key commands | |
* (cut, copy, select-all, etc.) even though no character is inserted. | |
*/ | |
function isKeypressCommand(nativeEvent) { | |
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && | |
// ctrlKey && altKey is equivalent to AltGr, and is not a command. | |
!(nativeEvent.ctrlKey && nativeEvent.altKey); | |
} | |
/** | |
* Translate native top level events into event types. | |
* | |
* @param {string} topLevelType | |
* @return {object} | |
*/ | |
function getCompositionEventType(topLevelType) { | |
switch (topLevelType) { | |
case 'topCompositionStart': | |
return eventTypes.compositionStart; | |
case 'topCompositionEnd': | |
return eventTypes.compositionEnd; | |
case 'topCompositionUpdate': | |
return eventTypes.compositionUpdate; | |
} | |
} | |
/** | |
* Does our fallback best-guess model think this event signifies that | |
* composition has begun? | |
* | |
* @param {string} topLevelType | |
* @param {object} nativeEvent | |
* @return {boolean} | |
*/ | |
function isFallbackCompositionStart(topLevelType, nativeEvent) { | |
return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE; | |
} | |
/** | |
* Does our fallback mode think that this event is the end of composition? | |
* | |
* @param {string} topLevelType | |
* @param {object} nativeEvent | |
* @return {boolean} | |
*/ | |
function isFallbackCompositionEnd(topLevelType, nativeEvent) { | |
switch (topLevelType) { | |
case 'topKeyUp': | |
// Command keys insert or clear IME input. | |
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; | |
case 'topKeyDown': | |
// Expect IME keyCode on each keydown. If we get any other | |
// code we must have exited earlier. | |
return nativeEvent.keyCode !== START_KEYCODE; | |
case 'topKeyPress': | |
case 'topMouseDown': | |
case 'topBlur': | |
// Events are not possible without cancelling IME. | |
return true; | |
default: | |
return false; | |
} | |
} | |
/** | |
* Google Input Tools provides composition data via a CustomEvent, | |
* with the `data` property populated in the `detail` object. If this | |
* is available on the event object, use it. If not, this is a plain | |
* composition event and we have nothing special to extract. | |
* | |
* @param {object} nativeEvent | |
* @return {?string} | |
*/ | |
function getDataFromCustomEvent(nativeEvent) { | |
var detail = nativeEvent.detail; | |
if (typeof detail === 'object' && 'data' in detail) { | |
return detail.data; | |
} | |
return null; | |
} | |
// Track the current IME composition fallback object, if any. | |
var currentComposition = null; | |
/** | |
* @return {?object} A SyntheticCompositionEvent. | |
*/ | |
function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var eventType; | |
var fallbackData; | |
if (canUseCompositionEvent) { | |
eventType = getCompositionEventType(topLevelType); | |
} else if (!currentComposition) { | |
if (isFallbackCompositionStart(topLevelType, nativeEvent)) { | |
eventType = eventTypes.compositionStart; | |
} | |
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
eventType = eventTypes.compositionEnd; | |
} | |
if (!eventType) { | |
return null; | |
} | |
if (useFallbackCompositionData) { | |
// The current composition is stored statically and must not be | |
// overwritten while composition continues. | |
if (!currentComposition && eventType === eventTypes.compositionStart) { | |
currentComposition = FallbackCompositionState.getPooled(nativeEventTarget); | |
} else if (eventType === eventTypes.compositionEnd) { | |
if (currentComposition) { | |
fallbackData = currentComposition.getData(); | |
} | |
} | |
} | |
var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); | |
if (fallbackData) { | |
// Inject data generated from fallback path into the synthetic event. | |
// This matches the property of native CompositionEventInterface. | |
event.data = fallbackData; | |
} else { | |
var customData = getDataFromCustomEvent(nativeEvent); | |
if (customData !== null) { | |
event.data = customData; | |
} | |
} | |
EventPropagators.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {object} nativeEvent Native browser event. | |
* @return {?string} The string corresponding to this `beforeInput` event. | |
*/ | |
function getNativeBeforeInputChars(topLevelType, nativeEvent) { | |
switch (topLevelType) { | |
case 'topCompositionEnd': | |
return getDataFromCustomEvent(nativeEvent); | |
case 'topKeyPress': | |
/** | |
* If native `textInput` events are available, our goal is to make | |
* use of them. However, there is a special case: the spacebar key. | |
* In Webkit, preventing default on a spacebar `textInput` event | |
* cancels character insertion, but it *also* causes the browser | |
* to fall back to its default spacebar behavior of scrolling the | |
* page. | |
* | |
* Tracking at: | |
* https://code.google.com/p/chromium/issues/detail?id=355103 | |
* | |
* To avoid this issue, use the keypress event as if no `textInput` | |
* event is available. | |
*/ | |
var which = nativeEvent.which; | |
if (which !== SPACEBAR_CODE) { | |
return null; | |
} | |
hasSpaceKeypress = true; | |
return SPACEBAR_CHAR; | |
case 'topTextInput': | |
// Record the characters to be added to the DOM. | |
var chars = nativeEvent.data; | |
// If it's a spacebar character, assume that we have already handled | |
// it at the keypress level and bail immediately. Android Chrome | |
// doesn't give us keycodes, so we need to blacklist it. | |
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { | |
return null; | |
} | |
return chars; | |
default: | |
// For other native event types, do nothing. | |
return null; | |
} | |
} | |
/** | |
* For browsers that do not provide the `textInput` event, extract the | |
* appropriate string to use for SyntheticInputEvent. | |
* | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {object} nativeEvent Native browser event. | |
* @return {?string} The fallback string for this `beforeInput` event. | |
*/ | |
function getFallbackBeforeInputChars(topLevelType, nativeEvent) { | |
// If we are currently composing (IME) and using a fallback to do so, | |
// try to extract the composed characters from the fallback object. | |
// If composition event is available, we extract a string only at | |
// compositionevent, otherwise extract it at fallback events. | |
if (currentComposition) { | |
if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
var chars = currentComposition.getData(); | |
FallbackCompositionState.release(currentComposition); | |
currentComposition = null; | |
return chars; | |
} | |
return null; | |
} | |
switch (topLevelType) { | |
case 'topPaste': | |
// If a paste event occurs after a keypress, throw out the input | |
// chars. Paste events should not lead to BeforeInput events. | |
return null; | |
case 'topKeyPress': | |
/** | |
* As of v27, Firefox may fire keypress events even when no character | |
* will be inserted. A few possibilities: | |
* | |
* - `which` is `0`. Arrow keys, Esc key, etc. | |
* | |
* - `which` is the pressed key code, but no char is available. | |
* Ex: 'AltGr + d` in Polish. There is no modified character for | |
* this key combination and no character is inserted into the | |
* document, but FF fires the keypress for char code `100` anyway. | |
* No `input` event will occur. | |
* | |
* - `which` is the pressed key code, but a command combination is | |
* being used. Ex: `Cmd+C`. No character is inserted, and no | |
* `input` event will occur. | |
*/ | |
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) { | |
return String.fromCharCode(nativeEvent.which); | |
} | |
return null; | |
case 'topCompositionEnd': | |
return useFallbackCompositionData ? null : nativeEvent.data; | |
default: | |
return null; | |
} | |
} | |
/** | |
* Extract a SyntheticInputEvent for `beforeInput`, based on either native | |
* `textInput` or fallback behavior. | |
* | |
* @return {?object} A SyntheticInputEvent. | |
*/ | |
function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var chars; | |
if (canUseTextInputEvent) { | |
chars = getNativeBeforeInputChars(topLevelType, nativeEvent); | |
} else { | |
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); | |
} | |
// If no characters are being inserted, no BeforeInput event should | |
// be fired. | |
if (!chars) { | |
return null; | |
} | |
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); | |
event.data = chars; | |
EventPropagators.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* Create an `onBeforeInput` event to match | |
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. | |
* | |
* This event plugin is based on the native `textInput` event | |
* available in Chrome, Safari, Opera, and IE. This event fires after | |
* `onKeyPress` and `onCompositionEnd`, but before `onInput`. | |
* | |
* `beforeInput` is spec'd but not implemented in any browsers, and | |
* the `input` event does not provide any useful information about what has | |
* actually been added, contrary to the spec. Thus, `textInput` is the best | |
* available event to identify the characters that have actually been inserted | |
* into the target node. | |
* | |
* This plugin is also responsible for emitting `composition` events, thus | |
* allowing us to share composition fallback code for both `beforeInput` and | |
* `composition` event types. | |
*/ | |
var BeforeInputEventPlugin$1 = { | |
eventTypes: eventTypes, | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
return [extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget)]; | |
} | |
}; | |
var BeforeInputEventPlugin_1 = BeforeInputEventPlugin$1; | |
var EventPluginUtils$3 = EventPluginUtils_1; | |
var invariant$7 = invariant; | |
// Use to restore controlled state after a change event has fired. | |
var fiberHostComponent = null; | |
var ReactControlledComponentInjection = { | |
injectFiberControlledHostComponent: function (hostComponentImpl) { | |
// The fiber implementation doesn't use dynamic dispatch so we need to | |
// inject the implementation. | |
fiberHostComponent = hostComponentImpl; | |
} | |
}; | |
var restoreTarget = null; | |
var restoreQueue = null; | |
function restoreStateOfTarget(target) { | |
// We perform this translation at the end of the event loop so that we | |
// always receive the correct fiber here | |
var internalInstance = EventPluginUtils$3.getInstanceFromNode(target); | |
if (!internalInstance) { | |
// Unmounted | |
return; | |
} | |
if (typeof internalInstance.tag === 'number') { | |
invariant$7(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function', 'Fiber needs to be injected to handle a fiber target for controlled ' + 'events.'); | |
var props = EventPluginUtils$3.getFiberCurrentPropsFromNode(internalInstance.stateNode); | |
fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props); | |
return; | |
} | |
invariant$7(typeof internalInstance.restoreControlledState === 'function', 'The internal instance must be a React host component.'); | |
// If it is not a Fiber, we can just use dynamic dispatch. | |
internalInstance.restoreControlledState(); | |
} | |
var ReactControlledComponent$1 = { | |
injection: ReactControlledComponentInjection, | |
enqueueStateRestore: function (target) { | |
if (restoreTarget) { | |
if (restoreQueue) { | |
restoreQueue.push(target); | |
} else { | |
restoreQueue = [target]; | |
} | |
} else { | |
restoreTarget = target; | |
} | |
}, | |
restoreStateIfNeeded: function () { | |
if (!restoreTarget) { | |
return; | |
} | |
var target = restoreTarget; | |
var queuedTargets = restoreQueue; | |
restoreTarget = null; | |
restoreQueue = null; | |
restoreStateOfTarget(target); | |
if (queuedTargets) { | |
for (var i = 0; i < queuedTargets.length; i++) { | |
restoreStateOfTarget(queuedTargets[i]); | |
} | |
} | |
} | |
}; | |
var ReactControlledComponent_1 = ReactControlledComponent$1; | |
var ReactControlledComponent$2 = ReactControlledComponent_1; | |
// Used as a way to call batchedUpdates when we don't know if we're in a Fiber | |
// or Stack context. Such as when we're dispatching events or if third party | |
// libraries need to call batchedUpdates. Eventually, this API will go away when | |
// everything is batched by default. We'll then have a similar API to opt-out of | |
// scheduled work and instead do synchronous work. | |
// Defaults | |
var stackBatchedUpdates = function (fn, a, b, c, d, e) { | |
return fn(a, b, c, d, e); | |
}; | |
var fiberBatchedUpdates = function (fn, bookkeeping) { | |
return fn(bookkeeping); | |
}; | |
function performFiberBatchedUpdates(fn, bookkeeping) { | |
// If we have Fiber loaded, we need to wrap this in a batching call so that | |
// Fiber can apply its default priority for this call. | |
return fiberBatchedUpdates(fn, bookkeeping); | |
} | |
function batchedUpdates(fn, bookkeeping) { | |
// We first perform work with the stack batching strategy, by passing our | |
// indirection to it. | |
return stackBatchedUpdates(performFiberBatchedUpdates, fn, bookkeeping); | |
} | |
var isNestingBatched = false; | |
function batchedUpdatesWithControlledComponents(fn, bookkeeping) { | |
if (isNestingBatched) { | |
// If we are currently inside another batch, we need to wait until it | |
// fully completes before restoring state. Therefore, we add the target to | |
// a queue of work. | |
return batchedUpdates(fn, bookkeeping); | |
} | |
isNestingBatched = true; | |
try { | |
return batchedUpdates(fn, bookkeeping); | |
} finally { | |
// Here we wait until all updates have propagated, which is important | |
// when using controlled components within layers: | |
// https://github.com/facebook/react/issues/1698 | |
// Then we restore state of any controlled component. | |
isNestingBatched = false; | |
ReactControlledComponent$2.restoreStateIfNeeded(); | |
} | |
} | |
var ReactGenericBatchingInjection = { | |
injectStackBatchedUpdates: function (_batchedUpdates) { | |
stackBatchedUpdates = _batchedUpdates; | |
}, | |
injectFiberBatchedUpdates: function (_batchedUpdates) { | |
fiberBatchedUpdates = _batchedUpdates; | |
} | |
}; | |
var ReactGenericBatching$2 = { | |
batchedUpdates: batchedUpdatesWithControlledComponents, | |
injection: ReactGenericBatchingInjection | |
}; | |
var ReactGenericBatching_1 = ReactGenericBatching$2; | |
var ReactDOMComponentTree$4 = ReactDOMComponentTree_1; | |
function isCheckable(elem) { | |
var type = elem.type; | |
var nodeName = elem.nodeName; | |
return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); | |
} | |
function getTracker(inst) { | |
if (typeof inst.tag === 'number') { | |
inst = inst.stateNode; | |
} | |
return inst._wrapperState.valueTracker; | |
} | |
function attachTracker(inst, tracker) { | |
inst._wrapperState.valueTracker = tracker; | |
} | |
function detachTracker(inst) { | |
delete inst._wrapperState.valueTracker; | |
} | |
function getValueFromNode(node) { | |
var value; | |
if (node) { | |
value = isCheckable(node) ? '' + node.checked : node.value; | |
} | |
return value; | |
} | |
function trackValueOnNode(node, inst) { | |
var valueField = isCheckable(node) ? 'checked' : 'value'; | |
var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); | |
var currentValue = '' + node[valueField]; | |
// if someone has already defined a value or Safari, then bail | |
// and don't track value will cause over reporting of changes, | |
// but it's better then a hard failure | |
// (needed for certain tests that spyOn input values and Safari) | |
if (node.hasOwnProperty(valueField) || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { | |
return; | |
} | |
Object.defineProperty(node, valueField, { | |
enumerable: descriptor.enumerable, | |
configurable: true, | |
get: function () { | |
return descriptor.get.call(this); | |
}, | |
set: function (value) { | |
currentValue = '' + value; | |
descriptor.set.call(this, value); | |
} | |
}); | |
var tracker = { | |
getValue: function () { | |
return currentValue; | |
}, | |
setValue: function (value) { | |
currentValue = '' + value; | |
}, | |
stopTracking: function () { | |
detachTracker(inst); | |
delete node[valueField]; | |
} | |
}; | |
return tracker; | |
} | |
var inputValueTracking$1 = { | |
// exposed for testing | |
_getTrackerFromNode: function (node) { | |
return getTracker(ReactDOMComponentTree$4.getInstanceFromNode(node)); | |
}, | |
trackNode: function (node) { | |
if (node._wrapperState.valueTracker) { | |
return; | |
} | |
node._wrapperState.valueTracker = trackValueOnNode(node, node); | |
}, | |
track: function (inst) { | |
if (getTracker(inst)) { | |
return; | |
} | |
var node = ReactDOMComponentTree$4.getNodeFromInstance(inst); | |
attachTracker(inst, trackValueOnNode(node, inst)); | |
}, | |
updateValueIfChanged: function (inst) { | |
if (!inst) { | |
return false; | |
} | |
var tracker = getTracker(inst); | |
if (!tracker) { | |
if (typeof inst.tag === 'number') { | |
inputValueTracking$1.trackNode(inst.stateNode); | |
} else { | |
inputValueTracking$1.track(inst); | |
} | |
return true; | |
} | |
var lastValue = tracker.getValue(); | |
var nextValue = getValueFromNode(ReactDOMComponentTree$4.getNodeFromInstance(inst)); | |
if (nextValue !== lastValue) { | |
tracker.setValue(nextValue); | |
return true; | |
} | |
return false; | |
}, | |
stopTracking: function (inst) { | |
var tracker = getTracker(inst); | |
if (tracker) { | |
tracker.stopTracking(); | |
} | |
} | |
}; | |
var inputValueTracking_1 = inputValueTracking$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getEventTarget | |
*/ | |
/** | |
* Gets the target node from a native browser event by accounting for | |
* inconsistencies in browser DOM APIs. | |
* | |
* @param {object} nativeEvent Native browser event. | |
* @return {DOMEventTarget} Target node. | |
*/ | |
function getEventTarget$1(nativeEvent) { | |
var target = nativeEvent.target || nativeEvent.srcElement || window; | |
// Normalize SVG <use> element events #4963 | |
if (target.correspondingUseElement) { | |
target = target.correspondingUseElement; | |
} | |
// Safari may fire events on text nodes (Node.TEXT_NODE is 3). | |
// @see http://www.quirksmode.org/js/events_properties.html | |
return target.nodeType === 3 ? target.parentNode : target; | |
} | |
var getEventTarget_1 = getEventTarget$1; | |
var ExecutionEnvironment$4 = ExecutionEnvironment; | |
var useHasFeature; | |
if (ExecutionEnvironment$4.canUseDOM) { | |
useHasFeature = document.implementation && document.implementation.hasFeature && | |
// always returns true in newer browsers as per the standard. | |
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature | |
document.implementation.hasFeature('', '') !== true; | |
} | |
/** | |
* Checks if an event is supported in the current execution environment. | |
* | |
* NOTE: This will not work correctly for non-generic events such as `change`, | |
* `reset`, `load`, `error`, and `select`. | |
* | |
* Borrows from Modernizr. | |
* | |
* @param {string} eventNameSuffix Event name, e.g. "click". | |
* @param {?boolean} capture Check if the capture phase is supported. | |
* @return {boolean} True if the event is supported. | |
* @internal | |
* @license Modernizr 3.0.0pre (Custom Build) | MIT | |
*/ | |
function isEventSupported$1(eventNameSuffix, capture) { | |
if (!ExecutionEnvironment$4.canUseDOM || capture && !('addEventListener' in document)) { | |
return false; | |
} | |
var eventName = 'on' + eventNameSuffix; | |
var isSupported = eventName in document; | |
if (!isSupported) { | |
var element = document.createElement('div'); | |
element.setAttribute(eventName, 'return;'); | |
isSupported = typeof element[eventName] === 'function'; | |
} | |
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { | |
// This is the only way to test support for the `wheel` event in IE9+. | |
isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); | |
} | |
return isSupported; | |
} | |
var isEventSupported_1 = isEventSupported$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule isTextInputElement | |
* | |
*/ | |
/** | |
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary | |
*/ | |
var supportedInputTypes = { | |
'color': true, | |
'date': true, | |
'datetime': true, | |
'datetime-local': true, | |
'email': true, | |
'month': true, | |
'number': true, | |
'password': true, | |
'range': true, | |
'search': true, | |
'tel': true, | |
'text': true, | |
'time': true, | |
'url': true, | |
'week': true | |
}; | |
function isTextInputElement$1(elem) { | |
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | |
if (nodeName === 'input') { | |
return !!supportedInputTypes[elem.type]; | |
} | |
if (nodeName === 'textarea') { | |
return true; | |
} | |
return false; | |
} | |
var isTextInputElement_1 = isTextInputElement$1; | |
var EventPluginHub$3 = EventPluginHub_1; | |
var EventPropagators$2 = EventPropagators_1; | |
var ExecutionEnvironment$3 = ExecutionEnvironment; | |
var ReactControlledComponent = ReactControlledComponent_1; | |
var ReactDOMComponentTree$3 = ReactDOMComponentTree_1; | |
var ReactGenericBatching$1 = ReactGenericBatching_1; | |
var SyntheticEvent$3 = SyntheticEvent_1; | |
var inputValueTracking = inputValueTracking_1; | |
var getEventTarget = getEventTarget_1; | |
var isEventSupported = isEventSupported_1; | |
var isTextInputElement = isTextInputElement_1; | |
var eventTypes$1 = { | |
change: { | |
phasedRegistrationNames: { | |
bubbled: 'onChange', | |
captured: 'onChangeCapture' | |
}, | |
dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange'] | |
} | |
}; | |
function createAndAccumulateChangeEvent(inst, nativeEvent, target) { | |
var event = SyntheticEvent$3.getPooled(eventTypes$1.change, inst, nativeEvent, target); | |
event.type = 'change'; | |
// Flag this event loop as needing state restore. | |
ReactControlledComponent.enqueueStateRestore(target); | |
EventPropagators$2.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* For IE shims | |
*/ | |
var activeElement = null; | |
var activeElementInst = null; | |
/** | |
* SECTION: handle `change` event | |
*/ | |
function shouldUseChangeEvent(elem) { | |
var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); | |
return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; | |
} | |
var doesChangeEventBubble = false; | |
if (ExecutionEnvironment$3.canUseDOM) { | |
// See `handleChange` comment below | |
doesChangeEventBubble = isEventSupported('change') && (!document.documentMode || document.documentMode > 8); | |
} | |
function manualDispatchChangeEvent(nativeEvent) { | |
var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); | |
// If change and propertychange bubbled, we'd just bind to it like all the | |
// other events and have it go through ReactBrowserEventEmitter. Since it | |
// doesn't, we manually listen for the events and so we have to enqueue and | |
// process the abstract event manually. | |
// | |
// Batching is necessary here in order to ensure that all event handlers run | |
// before the next rerender (including event handlers attached to ancestor | |
// elements instead of directly on the input). Without this, controlled | |
// components don't work properly in conjunction with event bubbling because | |
// the component is rerendered and the value reverted before all the event | |
// handlers can run. See https://github.com/facebook/react/issues/708. | |
ReactGenericBatching$1.batchedUpdates(runEventInBatch, event); | |
} | |
function runEventInBatch(event) { | |
EventPluginHub$3.enqueueEvents(event); | |
EventPluginHub$3.processEventQueue(false); | |
} | |
function startWatchingForChangeEventIE8(target, targetInst) { | |
activeElement = target; | |
activeElementInst = targetInst; | |
activeElement.attachEvent('onchange', manualDispatchChangeEvent); | |
} | |
function stopWatchingForChangeEventIE8() { | |
if (!activeElement) { | |
return; | |
} | |
activeElement.detachEvent('onchange', manualDispatchChangeEvent); | |
activeElement = null; | |
activeElementInst = null; | |
} | |
function getInstIfValueChanged(targetInst) { | |
if (inputValueTracking.updateValueIfChanged(targetInst)) { | |
return targetInst; | |
} | |
} | |
function getTargetInstForChangeEvent(topLevelType, targetInst) { | |
if (topLevelType === 'topChange') { | |
return targetInst; | |
} | |
} | |
function handleEventsForChangeEventIE8(topLevelType, target, targetInst) { | |
if (topLevelType === 'topFocus') { | |
// stopWatching() should be a noop here but we call it just in case we | |
// missed a blur event somehow. | |
stopWatchingForChangeEventIE8(); | |
startWatchingForChangeEventIE8(target, targetInst); | |
} else if (topLevelType === 'topBlur') { | |
stopWatchingForChangeEventIE8(); | |
} | |
} | |
/** | |
* SECTION: handle `input` event | |
*/ | |
var isInputEventSupported = false; | |
if (ExecutionEnvironment$3.canUseDOM) { | |
// IE9 claims to support the input event but fails to trigger it when | |
// deleting text, so we ignore its input events. | |
isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9); | |
} | |
/** | |
* (For IE <=9) Starts tracking propertychange events on the passed-in element | |
* and override the value property so that we can distinguish user events from | |
* value changes in JS. | |
*/ | |
function startWatchingForValueChange(target, targetInst) { | |
activeElement = target; | |
activeElementInst = targetInst; | |
activeElement.attachEvent('onpropertychange', handlePropertyChange); | |
} | |
/** | |
* (For IE <=9) Removes the event listeners from the currently-tracked element, | |
* if any exists. | |
*/ | |
function stopWatchingForValueChange() { | |
if (!activeElement) { | |
return; | |
} | |
activeElement.detachEvent('onpropertychange', handlePropertyChange); | |
activeElement = null; | |
activeElementInst = null; | |
} | |
/** | |
* (For IE <=9) Handles a propertychange event, sending a `change` event if | |
* the value of the active element has changed. | |
*/ | |
function handlePropertyChange(nativeEvent) { | |
if (nativeEvent.propertyName !== 'value') { | |
return; | |
} | |
if (getInstIfValueChanged(activeElementInst)) { | |
manualDispatchChangeEvent(nativeEvent); | |
} | |
} | |
function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { | |
if (topLevelType === 'topFocus') { | |
// In IE8, we can capture almost all .value changes by adding a | |
// propertychange handler and looking for events with propertyName | |
// equal to 'value' | |
// In IE9, propertychange fires for most input events but is buggy and | |
// doesn't fire when text is deleted, but conveniently, selectionchange | |
// appears to fire in all of the remaining cases so we catch those and | |
// forward the event if the value has changed | |
// In either case, we don't want to call the event handler if the value | |
// is changed from JS so we redefine a setter for `.value` that updates | |
// our activeElementValue variable, allowing us to ignore those changes | |
// | |
// stopWatching() should be a noop here but we call it just in case we | |
// missed a blur event somehow. | |
stopWatchingForValueChange(); | |
startWatchingForValueChange(target, targetInst); | |
} else if (topLevelType === 'topBlur') { | |
stopWatchingForValueChange(); | |
} | |
} | |
// For IE8 and IE9. | |
function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { | |
if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') { | |
// On the selectionchange event, the target is just document which isn't | |
// helpful for us so just check activeElement instead. | |
// | |
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire | |
// propertychange on the first input event after setting `value` from a | |
// script and fires only keydown, keypress, keyup. Catching keyup usually | |
// gets it and catching keydown lets us fire an event for the first | |
// keystroke if user does a key repeat (it'll be a little delayed: right | |
// before the second keystroke). Other input methods (e.g., paste) seem to | |
// fire selectionchange normally. | |
return getInstIfValueChanged(activeElementInst); | |
} | |
} | |
/** | |
* SECTION: handle `click` event | |
*/ | |
function shouldUseClickEvent(elem) { | |
// Use the `click` event to detect changes to checkbox and radio inputs. | |
// This approach works across all browsers, whereas `change` does not fire | |
// until `blur` in IE8. | |
var nodeName = elem.nodeName; | |
return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); | |
} | |
function getTargetInstForClickEvent(topLevelType, targetInst) { | |
if (topLevelType === 'topClick') { | |
return getInstIfValueChanged(targetInst); | |
} | |
} | |
function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { | |
if (topLevelType === 'topInput' || topLevelType === 'topChange') { | |
return getInstIfValueChanged(targetInst); | |
} | |
} | |
/** | |
* This plugin creates an `onChange` event that normalizes change events | |
* across form elements. This event fires at a time when it's possible to | |
* change the element's value without seeing a flicker. | |
* | |
* Supported elements are: | |
* - input (see `isTextInputElement`) | |
* - textarea | |
* - select | |
*/ | |
var ChangeEventPlugin$1 = { | |
eventTypes: eventTypes$1, | |
_isInputEventSupported: isInputEventSupported, | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var targetNode = targetInst ? ReactDOMComponentTree$3.getNodeFromInstance(targetInst) : window; | |
var getTargetInstFunc, handleEventFunc; | |
if (shouldUseChangeEvent(targetNode)) { | |
if (doesChangeEventBubble) { | |
getTargetInstFunc = getTargetInstForChangeEvent; | |
} else { | |
handleEventFunc = handleEventsForChangeEventIE8; | |
} | |
} else if (isTextInputElement(targetNode)) { | |
if (isInputEventSupported) { | |
getTargetInstFunc = getTargetInstForInputOrChangeEvent; | |
} else { | |
getTargetInstFunc = getTargetInstForInputEventPolyfill; | |
handleEventFunc = handleEventsForInputEventPolyfill; | |
} | |
} else if (shouldUseClickEvent(targetNode)) { | |
getTargetInstFunc = getTargetInstForClickEvent; | |
} | |
if (getTargetInstFunc) { | |
var inst = getTargetInstFunc(topLevelType, targetInst); | |
if (inst) { | |
var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget); | |
return event; | |
} | |
} | |
if (handleEventFunc) { | |
handleEventFunc(topLevelType, targetNode, targetInst); | |
} | |
} | |
}; | |
var ChangeEventPlugin_1 = ChangeEventPlugin$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule DOMEventPluginOrder | |
*/ | |
/** | |
* Module that is injectable into `EventPluginHub`, that specifies a | |
* deterministic ordering of `EventPlugin`s. A convenient way to reason about | |
* plugins, without having to package every one of them. This is better than | |
* having plugins be ordered in the same order that they are injected because | |
* that ordering would be influenced by the packaging order. | |
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that | |
* preventing default on events is convenient in `SimpleEventPlugin` handlers. | |
*/ | |
var DOMEventPluginOrder$1 = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin']; | |
var DOMEventPluginOrder_1 = DOMEventPluginOrder$1; | |
var SyntheticEvent$4 = SyntheticEvent_1; | |
var getEventTarget$2 = getEventTarget_1; | |
/** | |
* @interface UIEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var UIEventInterface = { | |
view: function (event) { | |
if (event.view) { | |
return event.view; | |
} | |
var target = getEventTarget$2(event); | |
if (target.window === target) { | |
// target is a window object | |
return target; | |
} | |
var doc = target.ownerDocument; | |
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. | |
if (doc) { | |
return doc.defaultView || doc.parentWindow; | |
} else { | |
return window; | |
} | |
}, | |
detail: function (event) { | |
return event.detail || 0; | |
} | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticEvent} | |
*/ | |
function SyntheticUIEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$4.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$4.augmentClass(SyntheticUIEvent$1, UIEventInterface); | |
var SyntheticUIEvent_1 = SyntheticUIEvent$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ViewportMetrics | |
*/ | |
var ViewportMetrics$1 = { | |
currentScrollLeft: 0, | |
currentScrollTop: 0, | |
refreshScrollValues: function (scrollPosition) { | |
ViewportMetrics$1.currentScrollLeft = scrollPosition.x; | |
ViewportMetrics$1.currentScrollTop = scrollPosition.y; | |
} | |
}; | |
var ViewportMetrics_1 = ViewportMetrics$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getEventModifierState | |
*/ | |
/** | |
* Translation from modifier key to the associated property in the event. | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers | |
*/ | |
var modifierKeyToProp = { | |
'Alt': 'altKey', | |
'Control': 'ctrlKey', | |
'Meta': 'metaKey', | |
'Shift': 'shiftKey' | |
}; | |
// IE8 does not implement getModifierState so we simply map it to the only | |
// modifier keys exposed by the event itself, does not support Lock-keys. | |
// Currently, all major browsers except Chrome seems to support Lock-keys. | |
function modifierStateGetter(keyArg) { | |
var syntheticEvent = this; | |
var nativeEvent = syntheticEvent.nativeEvent; | |
if (nativeEvent.getModifierState) { | |
return nativeEvent.getModifierState(keyArg); | |
} | |
var keyProp = modifierKeyToProp[keyArg]; | |
return keyProp ? !!nativeEvent[keyProp] : false; | |
} | |
function getEventModifierState$1(nativeEvent) { | |
return modifierStateGetter; | |
} | |
var getEventModifierState_1 = getEventModifierState$1; | |
var SyntheticUIEvent = SyntheticUIEvent_1; | |
var ViewportMetrics = ViewportMetrics_1; | |
var getEventModifierState = getEventModifierState_1; | |
/** | |
* @interface MouseEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var MouseEventInterface = { | |
screenX: null, | |
screenY: null, | |
clientX: null, | |
clientY: null, | |
ctrlKey: null, | |
shiftKey: null, | |
altKey: null, | |
metaKey: null, | |
getModifierState: getEventModifierState, | |
button: function (event) { | |
// Webkit, Firefox, IE9+ | |
// which: 1 2 3 | |
// button: 0 1 2 (standard) | |
var button = event.button; | |
if ('which' in event) { | |
return button; | |
} | |
// IE<9 | |
// which: undefined | |
// button: 0 0 0 | |
// button: 1 4 2 (onmouseup) | |
return button === 2 ? 2 : button === 4 ? 1 : 0; | |
}, | |
buttons: null, | |
relatedTarget: function (event) { | |
return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement); | |
}, | |
// "Proprietary" Interface. | |
pageX: function (event) { | |
return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft; | |
}, | |
pageY: function (event) { | |
return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop; | |
} | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticMouseEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticUIEvent.augmentClass(SyntheticMouseEvent$1, MouseEventInterface); | |
var SyntheticMouseEvent_1 = SyntheticMouseEvent$1; | |
var EventPropagators$3 = EventPropagators_1; | |
var ReactDOMComponentTree$5 = ReactDOMComponentTree_1; | |
var SyntheticMouseEvent = SyntheticMouseEvent_1; | |
var eventTypes$2 = { | |
mouseEnter: { | |
registrationName: 'onMouseEnter', | |
dependencies: ['topMouseOut', 'topMouseOver'] | |
}, | |
mouseLeave: { | |
registrationName: 'onMouseLeave', | |
dependencies: ['topMouseOut', 'topMouseOver'] | |
} | |
}; | |
var EnterLeaveEventPlugin$1 = { | |
eventTypes: eventTypes$2, | |
/** | |
* For almost every interaction we care about, there will be both a top-level | |
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that | |
* we do not extract duplicate events. However, moving the mouse into the | |
* browser from outside will not fire a `mouseout` event. In this case, we use | |
* the `mouseover` top-level event. | |
*/ | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { | |
return null; | |
} | |
if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') { | |
// Must not be a mouse in or mouse out - ignoring. | |
return null; | |
} | |
var win; | |
if (nativeEventTarget.window === nativeEventTarget) { | |
// `nativeEventTarget` is probably a window object. | |
win = nativeEventTarget; | |
} else { | |
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8. | |
var doc = nativeEventTarget.ownerDocument; | |
if (doc) { | |
win = doc.defaultView || doc.parentWindow; | |
} else { | |
win = window; | |
} | |
} | |
var from; | |
var to; | |
if (topLevelType === 'topMouseOut') { | |
from = targetInst; | |
var related = nativeEvent.relatedTarget || nativeEvent.toElement; | |
to = related ? ReactDOMComponentTree$5.getClosestInstanceFromNode(related) : null; | |
} else { | |
// Moving to a node from outside the window. | |
from = null; | |
to = targetInst; | |
} | |
if (from === to) { | |
// Nothing pertains to our managed components. | |
return null; | |
} | |
var fromNode = from == null ? win : ReactDOMComponentTree$5.getNodeFromInstance(from); | |
var toNode = to == null ? win : ReactDOMComponentTree$5.getNodeFromInstance(to); | |
var leave = SyntheticMouseEvent.getPooled(eventTypes$2.mouseLeave, from, nativeEvent, nativeEventTarget); | |
leave.type = 'mouseleave'; | |
leave.target = fromNode; | |
leave.relatedTarget = toNode; | |
var enter = SyntheticMouseEvent.getPooled(eventTypes$2.mouseEnter, to, nativeEvent, nativeEventTarget); | |
enter.type = 'mouseenter'; | |
enter.target = toNode; | |
enter.relatedTarget = fromNode; | |
EventPropagators$3.accumulateEnterLeaveDispatches(leave, enter, from, to); | |
return [leave, enter]; | |
} | |
}; | |
var EnterLeaveEventPlugin_1 = EnterLeaveEventPlugin$1; | |
var DOMProperty$3 = DOMProperty_1; | |
var MUST_USE_PROPERTY = DOMProperty$3.injection.MUST_USE_PROPERTY; | |
var HAS_BOOLEAN_VALUE = DOMProperty$3.injection.HAS_BOOLEAN_VALUE; | |
var HAS_NUMERIC_VALUE = DOMProperty$3.injection.HAS_NUMERIC_VALUE; | |
var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty$3.injection.HAS_POSITIVE_NUMERIC_VALUE; | |
var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty$3.injection.HAS_OVERLOADED_BOOLEAN_VALUE; | |
var HTMLDOMPropertyConfig$1 = { | |
isCustomAttribute: RegExp.prototype.test.bind(new RegExp('^(data|aria)-[' + DOMProperty$3.ATTRIBUTE_NAME_CHAR + ']*$')), | |
Properties: { | |
/** | |
* Standard Properties | |
*/ | |
accept: 0, | |
acceptCharset: 0, | |
accessKey: 0, | |
action: 0, | |
allowFullScreen: HAS_BOOLEAN_VALUE, | |
allowTransparency: 0, | |
alt: 0, | |
// specifies target context for links with `preload` type | |
as: 0, | |
async: HAS_BOOLEAN_VALUE, | |
autoComplete: 0, | |
// autoFocus is polyfilled/normalized by AutoFocusUtils | |
// autoFocus: HAS_BOOLEAN_VALUE, | |
autoPlay: HAS_BOOLEAN_VALUE, | |
capture: HAS_BOOLEAN_VALUE, | |
cellPadding: 0, | |
cellSpacing: 0, | |
charSet: 0, | |
challenge: 0, | |
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | |
cite: 0, | |
classID: 0, | |
className: 0, | |
cols: HAS_POSITIVE_NUMERIC_VALUE, | |
colSpan: 0, | |
content: 0, | |
contentEditable: 0, | |
contextMenu: 0, | |
controls: HAS_BOOLEAN_VALUE, | |
coords: 0, | |
crossOrigin: 0, | |
data: 0, // For `<object />` acts as `src`. | |
dateTime: 0, | |
'default': HAS_BOOLEAN_VALUE, | |
defer: HAS_BOOLEAN_VALUE, | |
dir: 0, | |
disabled: HAS_BOOLEAN_VALUE, | |
download: HAS_OVERLOADED_BOOLEAN_VALUE, | |
draggable: 0, | |
encType: 0, | |
form: 0, | |
formAction: 0, | |
formEncType: 0, | |
formMethod: 0, | |
formNoValidate: HAS_BOOLEAN_VALUE, | |
formTarget: 0, | |
frameBorder: 0, | |
headers: 0, | |
height: 0, | |
hidden: HAS_BOOLEAN_VALUE, | |
high: 0, | |
href: 0, | |
hrefLang: 0, | |
htmlFor: 0, | |
httpEquiv: 0, | |
id: 0, | |
inputMode: 0, | |
integrity: 0, | |
is: 0, | |
keyParams: 0, | |
keyType: 0, | |
kind: 0, | |
label: 0, | |
lang: 0, | |
list: 0, | |
loop: HAS_BOOLEAN_VALUE, | |
low: 0, | |
manifest: 0, | |
marginHeight: 0, | |
marginWidth: 0, | |
max: 0, | |
maxLength: 0, | |
media: 0, | |
mediaGroup: 0, | |
method: 0, | |
min: 0, | |
minLength: 0, | |
// Caution; `option.selected` is not updated if `select.multiple` is | |
// disabled with `removeAttribute`. | |
multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | |
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | |
name: 0, | |
nonce: 0, | |
noValidate: HAS_BOOLEAN_VALUE, | |
open: HAS_BOOLEAN_VALUE, | |
optimum: 0, | |
pattern: 0, | |
placeholder: 0, | |
playsInline: HAS_BOOLEAN_VALUE, | |
poster: 0, | |
preload: 0, | |
profile: 0, | |
radioGroup: 0, | |
readOnly: HAS_BOOLEAN_VALUE, | |
referrerPolicy: 0, | |
rel: 0, | |
required: HAS_BOOLEAN_VALUE, | |
reversed: HAS_BOOLEAN_VALUE, | |
role: 0, | |
rows: HAS_POSITIVE_NUMERIC_VALUE, | |
rowSpan: HAS_NUMERIC_VALUE, | |
sandbox: 0, | |
scope: 0, | |
scoped: HAS_BOOLEAN_VALUE, | |
scrolling: 0, | |
seamless: HAS_BOOLEAN_VALUE, | |
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, | |
shape: 0, | |
size: HAS_POSITIVE_NUMERIC_VALUE, | |
sizes: 0, | |
// support for projecting regular DOM Elements via V1 named slots ( shadow dom ) | |
slot: 0, | |
span: HAS_POSITIVE_NUMERIC_VALUE, | |
spellCheck: 0, | |
src: 0, | |
srcDoc: 0, | |
srcLang: 0, | |
srcSet: 0, | |
start: HAS_NUMERIC_VALUE, | |
step: 0, | |
style: 0, | |
summary: 0, | |
tabIndex: 0, | |
target: 0, | |
title: 0, | |
// Setting .type throws on non-<input> tags | |
type: 0, | |
useMap: 0, | |
value: 0, | |
width: 0, | |
wmode: 0, | |
wrap: 0, | |
/** | |
* RDFa Properties | |
*/ | |
about: 0, | |
datatype: 0, | |
inlist: 0, | |
prefix: 0, | |
// property is also supported for OpenGraph in meta tags. | |
property: 0, | |
resource: 0, | |
'typeof': 0, | |
vocab: 0, | |
/** | |
* Non-standard Properties | |
*/ | |
// autoCapitalize and autoCorrect are supported in Mobile Safari for | |
// keyboard hints. | |
autoCapitalize: 0, | |
autoCorrect: 0, | |
// autoSave allows WebKit/Blink to persist values of input fields on page reloads | |
autoSave: 0, | |
// color is for Safari mask-icon link | |
color: 0, | |
// itemProp, itemScope, itemType are for | |
// Microdata support. See http://schema.org/docs/gs.html | |
itemProp: 0, | |
itemScope: HAS_BOOLEAN_VALUE, | |
itemType: 0, | |
// itemID and itemRef are for Microdata support as well but | |
// only specified in the WHATWG spec document. See | |
// https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api | |
itemID: 0, | |
itemRef: 0, | |
// results show looking glass icon and recent searches on input | |
// search fields in WebKit/Blink | |
results: 0, | |
// IE-only attribute that specifies security restrictions on an iframe | |
// as an alternative to the sandbox attribute on IE<10 | |
security: 0, | |
// IE-only attribute that controls focus behavior | |
unselectable: 0 | |
}, | |
DOMAttributeNames: { | |
acceptCharset: 'accept-charset', | |
className: 'class', | |
htmlFor: 'for', | |
httpEquiv: 'http-equiv' | |
}, | |
DOMPropertyNames: {} | |
}; | |
var HTMLDOMPropertyConfig_1 = HTMLDOMPropertyConfig$1; | |
var EventPluginHub$4 = EventPluginHub_1; | |
function runEventQueueInBatch(events) { | |
EventPluginHub$4.enqueueEvents(events); | |
EventPluginHub$4.processEventQueue(false); | |
} | |
var ReactEventEmitterMixin$1 = { | |
/** | |
* Streams a fired top-level event to `EventPluginHub` where plugins have the | |
* opportunity to create `ReactEvent`s to be dispatched. | |
*/ | |
handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var events = EventPluginHub$4.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
runEventQueueInBatch(events); | |
} | |
}; | |
var ReactEventEmitterMixin_1 = ReactEventEmitterMixin$1; | |
var ExecutionEnvironment$5 = ExecutionEnvironment; | |
/** | |
* Generate a mapping of standard vendor prefixes using the defined style property and event name. | |
* | |
* @param {string} styleProp | |
* @param {string} eventName | |
* @returns {object} | |
*/ | |
function makePrefixMap(styleProp, eventName) { | |
var prefixes = {}; | |
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); | |
prefixes['Webkit' + styleProp] = 'webkit' + eventName; | |
prefixes['Moz' + styleProp] = 'moz' + eventName; | |
prefixes['ms' + styleProp] = 'MS' + eventName; | |
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); | |
return prefixes; | |
} | |
/** | |
* A list of event names to a configurable list of vendor prefixes. | |
*/ | |
var vendorPrefixes = { | |
animationend: makePrefixMap('Animation', 'AnimationEnd'), | |
animationiteration: makePrefixMap('Animation', 'AnimationIteration'), | |
animationstart: makePrefixMap('Animation', 'AnimationStart'), | |
transitionend: makePrefixMap('Transition', 'TransitionEnd') | |
}; | |
/** | |
* Event names that have already been detected and prefixed (if applicable). | |
*/ | |
var prefixedEventNames = {}; | |
/** | |
* Element to check for prefixes on. | |
*/ | |
var style = {}; | |
/** | |
* Bootstrap if a DOM exists. | |
*/ | |
if (ExecutionEnvironment$5.canUseDOM) { | |
style = document.createElement('div').style; | |
// On some platforms, in particular some releases of Android 4.x, | |
// the un-prefixed "animation" and "transition" properties are defined on the | |
// style object but the events that fire will still be prefixed, so we need | |
// to check if the un-prefixed events are usable, and if not remove them from the map. | |
if (!('AnimationEvent' in window)) { | |
delete vendorPrefixes.animationend.animation; | |
delete vendorPrefixes.animationiteration.animation; | |
delete vendorPrefixes.animationstart.animation; | |
} | |
// Same as above | |
if (!('TransitionEvent' in window)) { | |
delete vendorPrefixes.transitionend.transition; | |
} | |
} | |
/** | |
* Attempts to determine the correct vendor prefixed event name. | |
* | |
* @param {string} eventName | |
* @returns {string} | |
*/ | |
function getVendorPrefixedEventName$1(eventName) { | |
if (prefixedEventNames[eventName]) { | |
return prefixedEventNames[eventName]; | |
} else if (!vendorPrefixes[eventName]) { | |
return eventName; | |
} | |
var prefixMap = vendorPrefixes[eventName]; | |
for (var styleProp in prefixMap) { | |
if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { | |
return prefixedEventNames[eventName] = prefixMap[styleProp]; | |
} | |
} | |
return ''; | |
} | |
var getVendorPrefixedEventName_1 = getVendorPrefixedEventName$1; | |
var EventPluginRegistry$2 = EventPluginRegistry_1; | |
var ReactEventEmitterMixin = ReactEventEmitterMixin_1; | |
var ViewportMetrics$2 = ViewportMetrics_1; | |
var getVendorPrefixedEventName = getVendorPrefixedEventName_1; | |
var isEventSupported$2 = isEventSupported_1; | |
/** | |
* Summary of `ReactBrowserEventEmitter` event handling: | |
* | |
* - Top-level delegation is used to trap most native browser events. This | |
* may only occur in the main thread and is the responsibility of | |
* ReactEventListener, which is injected and can therefore support pluggable | |
* event sources. This is the only work that occurs in the main thread. | |
* | |
* - We normalize and de-duplicate events to account for browser quirks. This | |
* may be done in the worker thread. | |
* | |
* - Forward these native events (with the associated top-level type used to | |
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want | |
* to extract any synthetic events. | |
* | |
* - The `EventPluginHub` will then process each event by annotating them with | |
* "dispatches", a sequence of listeners and IDs that care about that event. | |
* | |
* - The `EventPluginHub` then dispatches the events. | |
* | |
* Overview of React and the event system: | |
* | |
* +------------+ . | |
* | DOM | . | |
* +------------+ . | |
* | . | |
* v . | |
* +------------+ . | |
* | ReactEvent | . | |
* | Listener | . | |
* +------------+ . +-----------+ | |
* | . +--------+|SimpleEvent| | |
* | . | |Plugin | | |
* +-----|------+ . v +-----------+ | |
* | | | . +--------------+ +------------+ | |
* | +-----------.--->|EventPluginHub| | Event | | |
* | | . | | +-----------+ | Propagators| | |
* | ReactEvent | . | | |TapEvent | |------------| | |
* | Emitter | . | |<---+|Plugin | |other plugin| | |
* | | . | | +-----------+ | utilities | | |
* | +-----------.--->| | +------------+ | |
* | | | . +--------------+ | |
* +-----|------+ . ^ +-----------+ | |
* | . | |Enter/Leave| | |
* + . +-------+|Plugin | | |
* +-------------+ . +-----------+ | |
* | application | . | |
* |-------------| . | |
* | | . | |
* | | . | |
* +-------------+ . | |
* . | |
* React Core . General Purpose Event Plugin System | |
*/ | |
var hasEventPageXY; | |
var alreadyListeningTo = {}; | |
var isMonitoringScrollValue = false; | |
var reactTopListenersCounter = 0; | |
// For events like 'submit' which don't consistently bubble (which we trap at a | |
// lower node than `document`), binding at `document` would cause duplicate | |
// events so we don't include them here | |
var topEventMapping = { | |
topAbort: 'abort', | |
topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend', | |
topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration', | |
topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart', | |
topBlur: 'blur', | |
topCancel: 'cancel', | |
topCanPlay: 'canplay', | |
topCanPlayThrough: 'canplaythrough', | |
topChange: 'change', | |
topClick: 'click', | |
topClose: 'close', | |
topCompositionEnd: 'compositionend', | |
topCompositionStart: 'compositionstart', | |
topCompositionUpdate: 'compositionupdate', | |
topContextMenu: 'contextmenu', | |
topCopy: 'copy', | |
topCut: 'cut', | |
topDoubleClick: 'dblclick', | |
topDrag: 'drag', | |
topDragEnd: 'dragend', | |
topDragEnter: 'dragenter', | |
topDragExit: 'dragexit', | |
topDragLeave: 'dragleave', | |
topDragOver: 'dragover', | |
topDragStart: 'dragstart', | |
topDrop: 'drop', | |
topDurationChange: 'durationchange', | |
topEmptied: 'emptied', | |
topEncrypted: 'encrypted', | |
topEnded: 'ended', | |
topError: 'error', | |
topFocus: 'focus', | |
topInput: 'input', | |
topKeyDown: 'keydown', | |
topKeyPress: 'keypress', | |
topKeyUp: 'keyup', | |
topLoadedData: 'loadeddata', | |
topLoadedMetadata: 'loadedmetadata', | |
topLoadStart: 'loadstart', | |
topMouseDown: 'mousedown', | |
topMouseMove: 'mousemove', | |
topMouseOut: 'mouseout', | |
topMouseOver: 'mouseover', | |
topMouseUp: 'mouseup', | |
topPaste: 'paste', | |
topPause: 'pause', | |
topPlay: 'play', | |
topPlaying: 'playing', | |
topProgress: 'progress', | |
topRateChange: 'ratechange', | |
topScroll: 'scroll', | |
topSeeked: 'seeked', | |
topSeeking: 'seeking', | |
topSelectionChange: 'selectionchange', | |
topStalled: 'stalled', | |
topSuspend: 'suspend', | |
topTextInput: 'textInput', | |
topTimeUpdate: 'timeupdate', | |
topToggle: 'toggle', | |
topTouchCancel: 'touchcancel', | |
topTouchEnd: 'touchend', | |
topTouchMove: 'touchmove', | |
topTouchStart: 'touchstart', | |
topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend', | |
topVolumeChange: 'volumechange', | |
topWaiting: 'waiting', | |
topWheel: 'wheel' | |
}; | |
/** | |
* To ensure no conflicts with other potential React instances on the page | |
*/ | |
var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); | |
function getListeningForDocument(mountAt) { | |
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` | |
// directly. | |
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { | |
mountAt[topListenersIDKey] = reactTopListenersCounter++; | |
alreadyListeningTo[mountAt[topListenersIDKey]] = {}; | |
} | |
return alreadyListeningTo[mountAt[topListenersIDKey]]; | |
} | |
var ReactBrowserEventEmitter$1 = Object.assign({}, ReactEventEmitterMixin, { | |
/** | |
* Injectable event backend | |
*/ | |
ReactEventListener: null, | |
injection: { | |
/** | |
* @param {object} ReactEventListener | |
*/ | |
injectReactEventListener: function (ReactEventListener) { | |
ReactEventListener.setHandleTopLevel(ReactBrowserEventEmitter$1.handleTopLevel); | |
ReactBrowserEventEmitter$1.ReactEventListener = ReactEventListener; | |
} | |
}, | |
/** | |
* Sets whether or not any created callbacks should be enabled. | |
* | |
* @param {boolean} enabled True if callbacks should be enabled. | |
*/ | |
setEnabled: function (enabled) { | |
if (ReactBrowserEventEmitter$1.ReactEventListener) { | |
ReactBrowserEventEmitter$1.ReactEventListener.setEnabled(enabled); | |
} | |
}, | |
/** | |
* @return {boolean} True if callbacks are enabled. | |
*/ | |
isEnabled: function () { | |
return !!(ReactBrowserEventEmitter$1.ReactEventListener && ReactBrowserEventEmitter$1.ReactEventListener.isEnabled()); | |
}, | |
/** | |
* We listen for bubbled touch events on the document object. | |
* | |
* Firefox v8.01 (and possibly others) exhibited strange behavior when | |
* mounting `onmousemove` events at some node that was not the document | |
* element. The symptoms were that if your mouse is not moving over something | |
* contained within that mount point (for example on the background) the | |
* top-level listeners for `onmousemove` won't be called. However, if you | |
* register the `mousemove` on the document object, then it will of course | |
* catch all `mousemove`s. This along with iOS quirks, justifies restricting | |
* top-level listeners to the document object only, at least for these | |
* movement types of events and possibly all events. | |
* | |
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
* | |
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but | |
* they bubble to document. | |
* | |
* @param {string} registrationName Name of listener (e.g. `onClick`). | |
* @param {object} contentDocumentHandle Document which owns the container | |
*/ | |
listenTo: function (registrationName, contentDocumentHandle) { | |
var mountAt = contentDocumentHandle; | |
var isListening = getListeningForDocument(mountAt); | |
var dependencies = EventPluginRegistry$2.registrationNameDependencies[registrationName]; | |
for (var i = 0; i < dependencies.length; i++) { | |
var dependency = dependencies[i]; | |
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { | |
if (dependency === 'topWheel') { | |
if (isEventSupported$2('wheel')) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'wheel', mountAt); | |
} else if (isEventSupported$2('mousewheel')) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'mousewheel', mountAt); | |
} else { | |
// Firefox needs to capture a different mouse scroll event. | |
// @see http://www.quirksmode.org/dom/events/tests/scroll.html | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt); | |
} | |
} else if (dependency === 'topScroll') { | |
if (isEventSupported$2('scroll', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topScroll', 'scroll', mountAt); | |
} else { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topScroll', 'scroll', ReactBrowserEventEmitter$1.ReactEventListener.WINDOW_HANDLE); | |
} | |
} else if (dependency === 'topFocus' || dependency === 'topBlur') { | |
if (isEventSupported$2('focus', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topFocus', 'focus', mountAt); | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topBlur', 'blur', mountAt); | |
} else if (isEventSupported$2('focusin')) { | |
// IE has `focusin` and `focusout` events which bubble. | |
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topFocus', 'focusin', mountAt); | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topBlur', 'focusout', mountAt); | |
} | |
// to make sure blur and focus event listeners are only attached once | |
isListening.topBlur = true; | |
isListening.topFocus = true; | |
} else if (dependency === 'topCancel') { | |
if (isEventSupported$2('cancel', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topCancel', 'cancel', mountAt); | |
} | |
isListening.topCancel = true; | |
} else if (dependency === 'topClose') { | |
if (isEventSupported$2('close', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topClose', 'close', mountAt); | |
} | |
isListening.topClose = true; | |
} else if (topEventMapping.hasOwnProperty(dependency)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt); | |
} | |
isListening[dependency] = true; | |
} | |
} | |
}, | |
isListeningToAllDependencies: function (registrationName, mountAt) { | |
var isListening = getListeningForDocument(mountAt); | |
var dependencies = EventPluginRegistry$2.registrationNameDependencies[registrationName]; | |
for (var i = 0; i < dependencies.length; i++) { | |
var dependency = dependencies[i]; | |
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
trapBubbledEvent: function (topLevelType, handlerBaseName, handle) { | |
return ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent(topLevelType, handlerBaseName, handle); | |
}, | |
trapCapturedEvent: function (topLevelType, handlerBaseName, handle) { | |
return ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent(topLevelType, handlerBaseName, handle); | |
}, | |
/** | |
* Protect against document.createEvent() returning null | |
* Some popup blocker extensions appear to do this: | |
* https://github.com/facebook/react/issues/6887 | |
*/ | |
supportsEventPageXY: function () { | |
if (!document.createEvent) { | |
return false; | |
} | |
var ev = document.createEvent('MouseEvent'); | |
return ev != null && 'pageX' in ev; | |
}, | |
/** | |
* Listens to window scroll and resize events. We cache scroll values so that | |
* application code can access them without triggering reflows. | |
* | |
* ViewportMetrics is only used by SyntheticMouse/TouchEvent and only when | |
* pageX/pageY isn't supported (legacy browsers). | |
* | |
* NOTE: Scroll events do not bubble. | |
* | |
* @see http://www.quirksmode.org/dom/events/scroll.html | |
*/ | |
ensureScrollValueMonitoring: function () { | |
if (hasEventPageXY === undefined) { | |
hasEventPageXY = ReactBrowserEventEmitter$1.supportsEventPageXY(); | |
} | |
if (!hasEventPageXY && !isMonitoringScrollValue) { | |
var refresh = ViewportMetrics$2.refreshScrollValues; | |
ReactBrowserEventEmitter$1.ReactEventListener.monitorScrollValue(refresh); | |
isMonitoringScrollValue = true; | |
} | |
} | |
}); | |
var ReactBrowserEventEmitter_1 = ReactBrowserEventEmitter$1; | |
var EventListener$1 = EventListener; | |
var ExecutionEnvironment$6 = ExecutionEnvironment; | |
var PooledClass$3 = PooledClass_1; | |
var ReactDOMComponentTree$6 = ReactDOMComponentTree_1; | |
var ReactGenericBatching$3 = ReactGenericBatching_1; | |
var ReactTypeOfWork$2 = ReactTypeOfWork; | |
var getEventTarget$3 = getEventTarget_1; | |
var getUnboundedScrollPosition$1 = getUnboundedScrollPosition; | |
var HostRoot = ReactTypeOfWork$2.HostRoot; | |
/** | |
* Find the deepest React component completely containing the root of the | |
* passed-in instance (for use when entire React trees are nested within each | |
* other). If React trees are not nested, returns null. | |
*/ | |
function findRootContainerNode(inst) { | |
// TODO: It may be a good idea to cache this to prevent unnecessary DOM | |
// traversal, but caching is difficult to do correctly without using a | |
// mutation observer to listen for all DOM changes. | |
if (typeof inst.tag === 'number') { | |
while (inst['return']) { | |
inst = inst['return']; | |
} | |
if (inst.tag !== HostRoot) { | |
// This can happen if we're in a detached tree. | |
return null; | |
} | |
return inst.stateNode.containerInfo; | |
} else { | |
while (inst._hostParent) { | |
inst = inst._hostParent; | |
} | |
var rootNode = ReactDOMComponentTree$6.getNodeFromInstance(inst); | |
return rootNode.parentNode; | |
} | |
} | |
// Used to store ancestor hierarchy in top level callback | |
function TopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { | |
this.topLevelType = topLevelType; | |
this.nativeEvent = nativeEvent; | |
this.targetInst = targetInst; | |
this.ancestors = []; | |
} | |
Object.assign(TopLevelCallbackBookKeeping.prototype, { | |
destructor: function () { | |
this.topLevelType = null; | |
this.nativeEvent = null; | |
this.targetInst = null; | |
this.ancestors.length = 0; | |
} | |
}); | |
PooledClass$3.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass$3.threeArgumentPooler); | |
function handleTopLevelImpl(bookKeeping) { | |
var targetInst = bookKeeping.targetInst; | |
// Loop through the hierarchy, in case there's any nested components. | |
// It's important that we build the array of ancestors before calling any | |
// event handlers, because event handlers can modify the DOM, leading to | |
// inconsistencies with ReactMount's node cache. See #1105. | |
var ancestor = targetInst; | |
do { | |
if (!ancestor) { | |
bookKeeping.ancestors.push(ancestor); | |
break; | |
} | |
var root = findRootContainerNode(ancestor); | |
if (!root) { | |
break; | |
} | |
bookKeeping.ancestors.push(ancestor); | |
ancestor = ReactDOMComponentTree$6.getClosestInstanceFromNode(root); | |
} while (ancestor); | |
for (var i = 0; i < bookKeeping.ancestors.length; i++) { | |
targetInst = bookKeeping.ancestors[i]; | |
ReactEventListener$1._handleTopLevel(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget$3(bookKeeping.nativeEvent)); | |
} | |
} | |
function scrollValueMonitor(cb) { | |
var scrollPosition = getUnboundedScrollPosition$1(window); | |
cb(scrollPosition); | |
} | |
var ReactEventListener$1 = { | |
_enabled: true, | |
_handleTopLevel: null, | |
WINDOW_HANDLE: ExecutionEnvironment$6.canUseDOM ? window : null, | |
setHandleTopLevel: function (handleTopLevel) { | |
ReactEventListener$1._handleTopLevel = handleTopLevel; | |
}, | |
setEnabled: function (enabled) { | |
ReactEventListener$1._enabled = !!enabled; | |
}, | |
isEnabled: function () { | |
return ReactEventListener$1._enabled; | |
}, | |
/** | |
* Traps top-level events by using event bubbling. | |
* | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {string} handlerBaseName Event name (e.g. "click"). | |
* @param {object} element Element on which to attach listener. | |
* @return {?object} An object with a remove function which will forcefully | |
* remove the listener. | |
* @internal | |
*/ | |
trapBubbledEvent: function (topLevelType, handlerBaseName, element) { | |
if (!element) { | |
return null; | |
} | |
return EventListener$1.listen(element, handlerBaseName, ReactEventListener$1.dispatchEvent.bind(null, topLevelType)); | |
}, | |
/** | |
* Traps a top-level event by using event capturing. | |
* | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {string} handlerBaseName Event name (e.g. "click"). | |
* @param {object} element Element on which to attach listener. | |
* @return {?object} An object with a remove function which will forcefully | |
* remove the listener. | |
* @internal | |
*/ | |
trapCapturedEvent: function (topLevelType, handlerBaseName, element) { | |
if (!element) { | |
return null; | |
} | |
return EventListener$1.capture(element, handlerBaseName, ReactEventListener$1.dispatchEvent.bind(null, topLevelType)); | |
}, | |
monitorScrollValue: function (refresh) { | |
var callback = scrollValueMonitor.bind(null, refresh); | |
EventListener$1.listen(window, 'scroll', callback); | |
}, | |
dispatchEvent: function (topLevelType, nativeEvent) { | |
if (!ReactEventListener$1._enabled) { | |
return; | |
} | |
var nativeEventTarget = getEventTarget$3(nativeEvent); | |
var targetInst = ReactDOMComponentTree$6.getClosestInstanceFromNode(nativeEventTarget); | |
var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent, targetInst); | |
try { | |
// Event queue being processed in the same cycle allows | |
// `preventDefault`. | |
ReactGenericBatching$3.batchedUpdates(handleTopLevelImpl, bookKeeping); | |
} finally { | |
TopLevelCallbackBookKeeping.release(bookKeeping); | |
} | |
} | |
}; | |
var ReactEventListener_1 = ReactEventListener$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule SVGDOMPropertyConfig | |
*/ | |
var NS = { | |
xlink: 'http://www.w3.org/1999/xlink', | |
xml: 'http://www.w3.org/XML/1998/namespace' | |
}; | |
// We use attributes for everything SVG so let's avoid some duplication and run | |
// code instead. | |
// The following are all specified in the HTML config already so we exclude here. | |
// - class (as className) | |
// - color | |
// - height | |
// - id | |
// - lang | |
// - max | |
// - media | |
// - method | |
// - min | |
// - name | |
// - style | |
// - target | |
// - type | |
// - width | |
var ATTRS = { | |
accentHeight: 'accent-height', | |
accumulate: 0, | |
additive: 0, | |
alignmentBaseline: 'alignment-baseline', | |
allowReorder: 'allowReorder', | |
alphabetic: 0, | |
amplitude: 0, | |
arabicForm: 'arabic-form', | |
ascent: 0, | |
attributeName: 'attributeName', | |
attributeType: 'attributeType', | |
autoReverse: 'autoReverse', | |
azimuth: 0, | |
baseFrequency: 'baseFrequency', | |
baseProfile: 'baseProfile', | |
baselineShift: 'baseline-shift', | |
bbox: 0, | |
begin: 0, | |
bias: 0, | |
by: 0, | |
calcMode: 'calcMode', | |
capHeight: 'cap-height', | |
clip: 0, | |
clipPath: 'clip-path', | |
clipRule: 'clip-rule', | |
clipPathUnits: 'clipPathUnits', | |
colorInterpolation: 'color-interpolation', | |
colorInterpolationFilters: 'color-interpolation-filters', | |
colorProfile: 'color-profile', | |
colorRendering: 'color-rendering', | |
contentScriptType: 'contentScriptType', | |
contentStyleType: 'contentStyleType', | |
cursor: 0, | |
cx: 0, | |
cy: 0, | |
d: 0, | |
decelerate: 0, | |
descent: 0, | |
diffuseConstant: 'diffuseConstant', | |
direction: 0, | |
display: 0, | |
divisor: 0, | |
dominantBaseline: 'dominant-baseline', | |
dur: 0, | |
dx: 0, | |
dy: 0, | |
edgeMode: 'edgeMode', | |
elevation: 0, | |
enableBackground: 'enable-background', | |
end: 0, | |
exponent: 0, | |
externalResourcesRequired: 'externalResourcesRequired', | |
fill: 0, | |
fillOpacity: 'fill-opacity', | |
fillRule: 'fill-rule', | |
filter: 0, | |
filterRes: 'filterRes', | |
filterUnits: 'filterUnits', | |
floodColor: 'flood-color', | |
floodOpacity: 'flood-opacity', | |
focusable: 0, | |
fontFamily: 'font-family', | |
fontSize: 'font-size', | |
fontSizeAdjust: 'font-size-adjust', | |
fontStretch: 'font-stretch', | |
fontStyle: 'font-style', | |
fontVariant: 'font-variant', | |
fontWeight: 'font-weight', | |
format: 0, | |
from: 0, | |
fx: 0, | |
fy: 0, | |
g1: 0, | |
g2: 0, | |
glyphName: 'glyph-name', | |
glyphOrientationHorizontal: 'glyph-orientation-horizontal', | |
glyphOrientationVertical: 'glyph-orientation-vertical', | |
glyphRef: 'glyphRef', | |
gradientTransform: 'gradientTransform', | |
gradientUnits: 'gradientUnits', | |
hanging: 0, | |
horizAdvX: 'horiz-adv-x', | |
horizOriginX: 'horiz-origin-x', | |
ideographic: 0, | |
imageRendering: 'image-rendering', | |
'in': 0, | |
in2: 0, | |
intercept: 0, | |
k: 0, | |
k1: 0, | |
k2: 0, | |
k3: 0, | |
k4: 0, | |
kernelMatrix: 'kernelMatrix', | |
kernelUnitLength: 'kernelUnitLength', | |
kerning: 0, | |
keyPoints: 'keyPoints', | |
keySplines: 'keySplines', | |
keyTimes: 'keyTimes', | |
lengthAdjust: 'lengthAdjust', | |
letterSpacing: 'letter-spacing', | |
lightingColor: 'lighting-color', | |
limitingConeAngle: 'limitingConeAngle', | |
local: 0, | |
markerEnd: 'marker-end', | |
markerMid: 'marker-mid', | |
markerStart: 'marker-start', | |
markerHeight: 'markerHeight', | |
markerUnits: 'markerUnits', | |
markerWidth: 'markerWidth', | |
mask: 0, | |
maskContentUnits: 'maskContentUnits', | |
maskUnits: 'maskUnits', | |
mathematical: 0, | |
mode: 0, | |
numOctaves: 'numOctaves', | |
offset: 0, | |
opacity: 0, | |
operator: 0, | |
order: 0, | |
orient: 0, | |
orientation: 0, | |
origin: 0, | |
overflow: 0, | |
overlinePosition: 'overline-position', | |
overlineThickness: 'overline-thickness', | |
paintOrder: 'paint-order', | |
panose1: 'panose-1', | |
pathLength: 'pathLength', | |
patternContentUnits: 'patternContentUnits', | |
patternTransform: 'patternTransform', | |
patternUnits: 'patternUnits', | |
pointerEvents: 'pointer-events', | |
points: 0, | |
pointsAtX: 'pointsAtX', | |
pointsAtY: 'pointsAtY', | |
pointsAtZ: 'pointsAtZ', | |
preserveAlpha: 'preserveAlpha', | |
preserveAspectRatio: 'preserveAspectRatio', | |
primitiveUnits: 'primitiveUnits', | |
r: 0, | |
radius: 0, | |
refX: 'refX', | |
refY: 'refY', | |
renderingIntent: 'rendering-intent', | |
repeatCount: 'repeatCount', | |
repeatDur: 'repeatDur', | |
requiredExtensions: 'requiredExtensions', | |
requiredFeatures: 'requiredFeatures', | |
restart: 0, | |
result: 0, | |
rotate: 0, | |
rx: 0, | |
ry: 0, | |
scale: 0, | |
seed: 0, | |
shapeRendering: 'shape-rendering', | |
slope: 0, | |
spacing: 0, | |
specularConstant: 'specularConstant', | |
specularExponent: 'specularExponent', | |
speed: 0, | |
spreadMethod: 'spreadMethod', | |
startOffset: 'startOffset', | |
stdDeviation: 'stdDeviation', | |
stemh: 0, | |
stemv: 0, | |
stitchTiles: 'stitchTiles', | |
stopColor: 'stop-color', | |
stopOpacity: 'stop-opacity', | |
strikethroughPosition: 'strikethrough-position', | |
strikethroughThickness: 'strikethrough-thickness', | |
string: 0, | |
stroke: 0, | |
strokeDasharray: 'stroke-dasharray', | |
strokeDashoffset: 'stroke-dashoffset', | |
strokeLinecap: 'stroke-linecap', | |
strokeLinejoin: 'stroke-linejoin', | |
strokeMiterlimit: 'stroke-miterlimit', | |
strokeOpacity: 'stroke-opacity', | |
strokeWidth: 'stroke-width', | |
surfaceScale: 'surfaceScale', | |
systemLanguage: 'systemLanguage', | |
tableValues: 'tableValues', | |
targetX: 'targetX', | |
targetY: 'targetY', | |
textAnchor: 'text-anchor', | |
textDecoration: 'text-decoration', | |
textRendering: 'text-rendering', | |
textLength: 'textLength', | |
to: 0, | |
transform: 0, | |
u1: 0, | |
u2: 0, | |
underlinePosition: 'underline-position', | |
underlineThickness: 'underline-thickness', | |
unicode: 0, | |
unicodeBidi: 'unicode-bidi', | |
unicodeRange: 'unicode-range', | |
unitsPerEm: 'units-per-em', | |
vAlphabetic: 'v-alphabetic', | |
vHanging: 'v-hanging', | |
vIdeographic: 'v-ideographic', | |
vMathematical: 'v-mathematical', | |
values: 0, | |
vectorEffect: 'vector-effect', | |
version: 0, | |
vertAdvY: 'vert-adv-y', | |
vertOriginX: 'vert-origin-x', | |
vertOriginY: 'vert-origin-y', | |
viewBox: 'viewBox', | |
viewTarget: 'viewTarget', | |
visibility: 0, | |
widths: 0, | |
wordSpacing: 'word-spacing', | |
writingMode: 'writing-mode', | |
x: 0, | |
xHeight: 'x-height', | |
x1: 0, | |
x2: 0, | |
xChannelSelector: 'xChannelSelector', | |
xlinkActuate: 'xlink:actuate', | |
xlinkArcrole: 'xlink:arcrole', | |
xlinkHref: 'xlink:href', | |
xlinkRole: 'xlink:role', | |
xlinkShow: 'xlink:show', | |
xlinkTitle: 'xlink:title', | |
xlinkType: 'xlink:type', | |
xmlBase: 'xml:base', | |
xmlns: 0, | |
xmlnsXlink: 'xmlns:xlink', | |
xmlLang: 'xml:lang', | |
xmlSpace: 'xml:space', | |
y: 0, | |
y1: 0, | |
y2: 0, | |
yChannelSelector: 'yChannelSelector', | |
z: 0, | |
zoomAndPan: 'zoomAndPan' | |
}; | |
var SVGDOMPropertyConfig$1 = { | |
Properties: {}, | |
DOMAttributeNamespaces: { | |
xlinkActuate: NS.xlink, | |
xlinkArcrole: NS.xlink, | |
xlinkHref: NS.xlink, | |
xlinkRole: NS.xlink, | |
xlinkShow: NS.xlink, | |
xlinkTitle: NS.xlink, | |
xlinkType: NS.xlink, | |
xmlBase: NS.xml, | |
xmlLang: NS.xml, | |
xmlSpace: NS.xml | |
}, | |
DOMAttributeNames: {} | |
}; | |
Object.keys(ATTRS).forEach(function (key) { | |
SVGDOMPropertyConfig$1.Properties[key] = 0; | |
if (ATTRS[key]) { | |
SVGDOMPropertyConfig$1.DOMAttributeNames[key] = ATTRS[key]; | |
} | |
}); | |
var SVGDOMPropertyConfig_1 = SVGDOMPropertyConfig$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getNodeForCharacterOffset | |
*/ | |
/** | |
* Given any node return the first leaf node without children. | |
* | |
* @param {DOMElement|DOMTextNode} node | |
* @return {DOMElement|DOMTextNode} | |
*/ | |
function getLeafNode(node) { | |
while (node && node.firstChild) { | |
node = node.firstChild; | |
} | |
return node; | |
} | |
/** | |
* Get the next sibling within a container. This will walk up the | |
* DOM if a node's siblings have been exhausted. | |
* | |
* @param {DOMElement|DOMTextNode} node | |
* @return {?DOMElement|DOMTextNode} | |
*/ | |
function getSiblingNode(node) { | |
while (node) { | |
if (node.nextSibling) { | |
return node.nextSibling; | |
} | |
node = node.parentNode; | |
} | |
} | |
/** | |
* Get object describing the nodes which contain characters at offset. | |
* | |
* @param {DOMElement|DOMTextNode} root | |
* @param {number} offset | |
* @return {?object} | |
*/ | |
function getNodeForCharacterOffset$1(root, offset) { | |
var node = getLeafNode(root); | |
var nodeStart = 0; | |
var nodeEnd = 0; | |
while (node) { | |
if (node.nodeType === 3) { | |
nodeEnd = nodeStart + node.textContent.length; | |
if (nodeStart <= offset && nodeEnd >= offset) { | |
return { | |
node: node, | |
offset: offset - nodeStart | |
}; | |
} | |
nodeStart = nodeEnd; | |
} | |
node = getLeafNode(getSiblingNode(node)); | |
} | |
} | |
var getNodeForCharacterOffset_1 = getNodeForCharacterOffset$1; | |
var ExecutionEnvironment$8 = ExecutionEnvironment; | |
var getNodeForCharacterOffset = getNodeForCharacterOffset_1; | |
var getTextContentAccessor$2 = getTextContentAccessor_1; | |
/** | |
* While `isCollapsed` is available on the Selection object and `collapsed` | |
* is available on the Range object, IE11 sometimes gets them wrong. | |
* If the anchor/focus nodes and offsets are the same, the range is collapsed. | |
*/ | |
function isCollapsed(anchorNode, anchorOffset, focusNode$$1, focusOffset) { | |
return anchorNode === focusNode$$1 && anchorOffset === focusOffset; | |
} | |
/** | |
* Get the appropriate anchor and focus node/offset pairs for IE. | |
* | |
* The catch here is that IE's selection API doesn't provide information | |
* about whether the selection is forward or backward, so we have to | |
* behave as though it's always forward. | |
* | |
* IE text differs from modern selection in that it behaves as though | |
* block elements end with a new line. This means character offsets will | |
* differ between the two APIs. | |
* | |
* @param {DOMElement} node | |
* @return {object} | |
*/ | |
function getIEOffsets(node) { | |
var selection = document.selection; | |
var selectedRange = selection.createRange(); | |
var selectedLength = selectedRange.text.length; | |
// Duplicate selection so we can move range without breaking user selection. | |
var fromStart = selectedRange.duplicate(); | |
fromStart.moveToElementText(node); | |
fromStart.setEndPoint('EndToStart', selectedRange); | |
var startOffset = fromStart.text.length; | |
var endOffset = startOffset + selectedLength; | |
return { | |
start: startOffset, | |
end: endOffset | |
}; | |
} | |
/** | |
* @param {DOMElement} node | |
* @return {?object} | |
*/ | |
function getModernOffsets(node) { | |
var selection = window.getSelection && window.getSelection(); | |
if (!selection || selection.rangeCount === 0) { | |
return null; | |
} | |
var anchorNode = selection.anchorNode; | |
var anchorOffset = selection.anchorOffset; | |
var focusNode$$1 = selection.focusNode; | |
var focusOffset = selection.focusOffset; | |
var currentRange = selection.getRangeAt(0); | |
// In Firefox, range.startContainer and range.endContainer can be "anonymous | |
// divs", e.g. the up/down buttons on an <input type="number">. Anonymous | |
// divs do not seem to expose properties, triggering a "Permission denied | |
// error" if any of its properties are accessed. The only seemingly possible | |
// way to avoid erroring is to access a property that typically works for | |
// non-anonymous divs and catch any error that may otherwise arise. See | |
// https://bugzilla.mozilla.org/show_bug.cgi?id=208427 | |
try { | |
/* eslint-disable no-unused-expressions */ | |
currentRange.startContainer.nodeType; | |
currentRange.endContainer.nodeType; | |
/* eslint-enable no-unused-expressions */ | |
} catch (e) { | |
return null; | |
} | |
// If the node and offset values are the same, the selection is collapsed. | |
// `Selection.isCollapsed` is available natively, but IE sometimes gets | |
// this value wrong. | |
var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset); | |
var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length; | |
var tempRange = currentRange.cloneRange(); | |
tempRange.selectNodeContents(node); | |
tempRange.setEnd(currentRange.startContainer, currentRange.startOffset); | |
var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset); | |
var start = isTempRangeCollapsed ? 0 : tempRange.toString().length; | |
var end = start + rangeLength; | |
// Detect whether the selection is backward. | |
var detectionRange = document.createRange(); | |
detectionRange.setStart(anchorNode, anchorOffset); | |
detectionRange.setEnd(focusNode$$1, focusOffset); | |
var isBackward = detectionRange.collapsed; | |
return { | |
start: isBackward ? end : start, | |
end: isBackward ? start : end | |
}; | |
} | |
/** | |
* @param {DOMElement|DOMTextNode} node | |
* @param {object} offsets | |
*/ | |
function setIEOffsets(node, offsets) { | |
var range = document.selection.createRange().duplicate(); | |
var start, end; | |
if (offsets.end === undefined) { | |
start = offsets.start; | |
end = start; | |
} else if (offsets.start > offsets.end) { | |
start = offsets.end; | |
end = offsets.start; | |
} else { | |
start = offsets.start; | |
end = offsets.end; | |
} | |
range.moveToElementText(node); | |
range.moveStart('character', start); | |
range.setEndPoint('EndToStart', range); | |
range.moveEnd('character', end - start); | |
range.select(); | |
} | |
/** | |
* In modern non-IE browsers, we can support both forward and backward | |
* selections. | |
* | |
* Note: IE10+ supports the Selection object, but it does not support | |
* the `extend` method, which means that even in modern IE, it's not possible | |
* to programmatically create a backward selection. Thus, for all IE | |
* versions, we use the old IE API to create our selections. | |
* | |
* @param {DOMElement|DOMTextNode} node | |
* @param {object} offsets | |
*/ | |
function setModernOffsets(node, offsets) { | |
if (!window.getSelection) { | |
return; | |
} | |
var selection = window.getSelection(); | |
var length = node[getTextContentAccessor$2()].length; | |
var start = Math.min(offsets.start, length); | |
var end = offsets.end === undefined ? start : Math.min(offsets.end, length); | |
// IE 11 uses modern selection, but doesn't support the extend method. | |
// Flip backward selections, so we can set with a single range. | |
if (!selection.extend && start > end) { | |
var temp = end; | |
end = start; | |
start = temp; | |
} | |
var startMarker = getNodeForCharacterOffset(node, start); | |
var endMarker = getNodeForCharacterOffset(node, end); | |
if (startMarker && endMarker) { | |
var range = document.createRange(); | |
range.setStart(startMarker.node, startMarker.offset); | |
selection.removeAllRanges(); | |
if (start > end) { | |
selection.addRange(range); | |
selection.extend(endMarker.node, endMarker.offset); | |
} else { | |
range.setEnd(endMarker.node, endMarker.offset); | |
selection.addRange(range); | |
} | |
} | |
} | |
var useIEOffsets = ExecutionEnvironment$8.canUseDOM && 'selection' in document && !('getSelection' in window); | |
var ReactDOMSelection$1 = { | |
/** | |
* @param {DOMElement} node | |
*/ | |
getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets, | |
/** | |
* @param {DOMElement|DOMTextNode} node | |
* @param {object} offsets | |
*/ | |
setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets | |
}; | |
var ReactDOMSelection_1 = ReactDOMSelection$1; | |
var ReactDOMSelection = ReactDOMSelection_1; | |
var containsNode$1 = containsNode; | |
var focusNode$1 = focusNode; | |
var getActiveElement$2 = getActiveElement; | |
function isInDocument(node) { | |
return containsNode$1(document.documentElement, node); | |
} | |
/** | |
* @ReactInputSelection: React input selection module. Based on Selection.js, | |
* but modified to be suitable for react and has a couple of bug fixes (doesn't | |
* assume buttons have range selections allowed). | |
* Input selection module for React. | |
*/ | |
var ReactInputSelection$1 = { | |
hasSelectionCapabilities: function (elem) { | |
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | |
return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true'); | |
}, | |
getSelectionInformation: function () { | |
var focusedElem = getActiveElement$2(); | |
return { | |
focusedElem: focusedElem, | |
selectionRange: ReactInputSelection$1.hasSelectionCapabilities(focusedElem) ? ReactInputSelection$1.getSelection(focusedElem) : null | |
}; | |
}, | |
/** | |
* @restoreSelection: If any selection information was potentially lost, | |
* restore it. This is useful when performing operations that could remove dom | |
* nodes and place them back in, resulting in focus being lost. | |
*/ | |
restoreSelection: function (priorSelectionInformation) { | |
var curFocusedElem = getActiveElement$2(); | |
var priorFocusedElem = priorSelectionInformation.focusedElem; | |
var priorSelectionRange = priorSelectionInformation.selectionRange; | |
if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) { | |
if (ReactInputSelection$1.hasSelectionCapabilities(priorFocusedElem)) { | |
ReactInputSelection$1.setSelection(priorFocusedElem, priorSelectionRange); | |
} | |
// Focusing a node can change the scroll position, which is undesirable | |
var ancestors = []; | |
var ancestor = priorFocusedElem; | |
while (ancestor = ancestor.parentNode) { | |
if (ancestor.nodeType === 1) { | |
ancestors.push({ | |
element: ancestor, | |
left: ancestor.scrollLeft, | |
top: ancestor.scrollTop | |
}); | |
} | |
} | |
focusNode$1(priorFocusedElem); | |
for (var i = 0; i < ancestors.length; i++) { | |
var info = ancestors[i]; | |
info.element.scrollLeft = info.left; | |
info.element.scrollTop = info.top; | |
} | |
} | |
}, | |
/** | |
* @getSelection: Gets the selection bounds of a focused textarea, input or | |
* contentEditable node. | |
* -@input: Look up selection bounds of this input | |
* -@return {start: selectionStart, end: selectionEnd} | |
*/ | |
getSelection: function (input) { | |
var selection; | |
if ('selectionStart' in input) { | |
// Modern browser with input or textarea. | |
selection = { | |
start: input.selectionStart, | |
end: input.selectionEnd | |
}; | |
} else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') { | |
// IE8 input. | |
var range = document.selection.createRange(); | |
// There can only be one selection per document in IE, so it must | |
// be in our element. | |
if (range.parentElement() === input) { | |
selection = { | |
start: -range.moveStart('character', -input.value.length), | |
end: -range.moveEnd('character', -input.value.length) | |
}; | |
} | |
} else { | |
// Content editable or old IE textarea. | |
selection = ReactDOMSelection.getOffsets(input); | |
} | |
return selection || { start: 0, end: 0 }; | |
}, | |
/** | |
* @setSelection: Sets the selection bounds of a textarea or input and focuses | |
* the input. | |
* -@input Set selection bounds of this input or textarea | |
* -@offsets Object of same form that is returned from get* | |
*/ | |
setSelection: function (input, offsets) { | |
var start = offsets.start; | |
var end = offsets.end; | |
if (end === undefined) { | |
end = start; | |
} | |
if ('selectionStart' in input) { | |
input.selectionStart = start; | |
input.selectionEnd = Math.min(end, input.value.length); | |
} else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') { | |
var range = input.createTextRange(); | |
range.collapse(true); | |
range.moveStart('character', start); | |
range.moveEnd('character', end - start); | |
range.select(); | |
} else { | |
ReactDOMSelection.setOffsets(input, offsets); | |
} | |
} | |
}; | |
var ReactInputSelection_1 = ReactInputSelection$1; | |
var EventPropagators$4 = EventPropagators_1; | |
var ExecutionEnvironment$7 = ExecutionEnvironment; | |
var ReactBrowserEventEmitter$2 = ReactBrowserEventEmitter_1; | |
var ReactDOMComponentTree$7 = ReactDOMComponentTree_1; | |
var ReactInputSelection = ReactInputSelection_1; | |
var SyntheticEvent$5 = SyntheticEvent_1; | |
var getActiveElement$1 = getActiveElement; | |
var isTextInputElement$2 = isTextInputElement_1; | |
var shallowEqual$1 = shallowEqual; | |
var skipSelectionChangeEvent = ExecutionEnvironment$7.canUseDOM && 'documentMode' in document && document.documentMode <= 11; | |
var eventTypes$3 = { | |
select: { | |
phasedRegistrationNames: { | |
bubbled: 'onSelect', | |
captured: 'onSelectCapture' | |
}, | |
dependencies: ['topBlur', 'topContextMenu', 'topFocus', 'topKeyDown', 'topKeyUp', 'topMouseDown', 'topMouseUp', 'topSelectionChange'] | |
} | |
}; | |
var activeElement$1 = null; | |
var activeElementInst$1 = null; | |
var lastSelection = null; | |
var mouseDown = false; | |
// Track whether all listeners exists for this plugin. If none exist, we do | |
// not extract events. See #3639. | |
var isListeningToAllDependencies = ReactBrowserEventEmitter$2.isListeningToAllDependencies; | |
/** | |
* Get an object which is a unique representation of the current selection. | |
* | |
* The return value will not be consistent across nodes or browsers, but | |
* two identical selections on the same node will return identical objects. | |
* | |
* @param {DOMElement} node | |
* @return {object} | |
*/ | |
function getSelection(node) { | |
if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) { | |
return { | |
start: node.selectionStart, | |
end: node.selectionEnd | |
}; | |
} else if (window.getSelection) { | |
var selection = window.getSelection(); | |
return { | |
anchorNode: selection.anchorNode, | |
anchorOffset: selection.anchorOffset, | |
focusNode: selection.focusNode, | |
focusOffset: selection.focusOffset | |
}; | |
} else if (document.selection) { | |
var range = document.selection.createRange(); | |
return { | |
parentElement: range.parentElement(), | |
text: range.text, | |
top: range.boundingTop, | |
left: range.boundingLeft | |
}; | |
} | |
} | |
/** | |
* Poll selection to see whether it's changed. | |
* | |
* @param {object} nativeEvent | |
* @return {?SyntheticEvent} | |
*/ | |
function constructSelectEvent(nativeEvent, nativeEventTarget) { | |
// Ensure we have the right element, and that the user is not dragging a | |
// selection (this matches native `select` event behavior). In HTML5, select | |
// fires only on input and textarea thus if there's no focused element we | |
// won't dispatch. | |
if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement$1()) { | |
return null; | |
} | |
// Only fire when selection has actually changed. | |
var currentSelection = getSelection(activeElement$1); | |
if (!lastSelection || !shallowEqual$1(lastSelection, currentSelection)) { | |
lastSelection = currentSelection; | |
var syntheticEvent = SyntheticEvent$5.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget); | |
syntheticEvent.type = 'select'; | |
syntheticEvent.target = activeElement$1; | |
EventPropagators$4.accumulateTwoPhaseDispatches(syntheticEvent); | |
return syntheticEvent; | |
} | |
return null; | |
} | |
/** | |
* This plugin creates an `onSelect` event that normalizes select events | |
* across form elements. | |
* | |
* Supported elements are: | |
* - input (see `isTextInputElement`) | |
* - textarea | |
* - contentEditable | |
* | |
* This differs from native browser implementations in the following ways: | |
* - Fires on contentEditable fields as well as inputs. | |
* - Fires for collapsed selection. | |
* - Fires after user input. | |
*/ | |
var SelectEventPlugin$1 = { | |
eventTypes: eventTypes$3, | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var doc = nativeEventTarget.window === nativeEventTarget ? nativeEventTarget.document : nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument; | |
if (!doc || !isListeningToAllDependencies('onSelect', doc)) { | |
return null; | |
} | |
var targetNode = targetInst ? ReactDOMComponentTree$7.getNodeFromInstance(targetInst) : window; | |
switch (topLevelType) { | |
// Track the input node that has focus. | |
case 'topFocus': | |
if (isTextInputElement$2(targetNode) || targetNode.contentEditable === 'true') { | |
activeElement$1 = targetNode; | |
activeElementInst$1 = targetInst; | |
lastSelection = null; | |
} | |
break; | |
case 'topBlur': | |
activeElement$1 = null; | |
activeElementInst$1 = null; | |
lastSelection = null; | |
break; | |
// Don't fire the event while the user is dragging. This matches the | |
// semantics of the native select event. | |
case 'topMouseDown': | |
mouseDown = true; | |
break; | |
case 'topContextMenu': | |
case 'topMouseUp': | |
mouseDown = false; | |
return constructSelectEvent(nativeEvent, nativeEventTarget); | |
// Chrome and IE fire non-standard event when selection is changed (and | |
// sometimes when it hasn't). IE's event fires out of order with respect | |
// to key and input events on deletion, so we discard it. | |
// | |
// Firefox doesn't support selectionchange, so check selection status | |
// after each key entry. The selection changes after keydown and before | |
// keyup, but we check on keydown as well in the case of holding down a | |
// key, when multiple keydown events are fired but only one keyup is. | |
// This is also our approach for IE handling, for the reason above. | |
case 'topSelectionChange': | |
if (skipSelectionChangeEvent) { | |
break; | |
} | |
// falls through | |
case 'topKeyDown': | |
case 'topKeyUp': | |
return constructSelectEvent(nativeEvent, nativeEventTarget); | |
} | |
return null; | |
} | |
}; | |
var SelectEventPlugin_1 = SelectEventPlugin$1; | |
var SyntheticEvent$7 = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent | |
*/ | |
var AnimationEventInterface = { | |
animationName: null, | |
elapsedTime: null, | |
pseudoElement: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticEvent} | |
*/ | |
function SyntheticAnimationEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$7.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$7.augmentClass(SyntheticAnimationEvent$1, AnimationEventInterface); | |
var SyntheticAnimationEvent_1 = SyntheticAnimationEvent$1; | |
var SyntheticEvent$8 = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/clipboard-apis/ | |
*/ | |
var ClipboardEventInterface = { | |
clipboardData: function (event) { | |
return 'clipboardData' in event ? event.clipboardData : window.clipboardData; | |
} | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticClipboardEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$8.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$8.augmentClass(SyntheticClipboardEvent$1, ClipboardEventInterface); | |
var SyntheticClipboardEvent_1 = SyntheticClipboardEvent$1; | |
var SyntheticUIEvent$3 = SyntheticUIEvent_1; | |
/** | |
* @interface FocusEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var FocusEventInterface = { | |
relatedTarget: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticFocusEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticUIEvent$3.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticUIEvent$3.augmentClass(SyntheticFocusEvent$1, FocusEventInterface); | |
var SyntheticFocusEvent_1 = SyntheticFocusEvent$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getEventCharCode | |
*/ | |
/** | |
* `charCode` represents the actual "character code" and is safe to use with | |
* `String.fromCharCode`. As such, only keys that correspond to printable | |
* characters produce a valid `charCode`, the only exception to this is Enter. | |
* The Tab-key is considered non-printable and does not have a `charCode`, | |
* presumably because it does not produce a tab-character in browsers. | |
* | |
* @param {object} nativeEvent Native browser event. | |
* @return {number} Normalized `charCode` property. | |
*/ | |
function getEventCharCode$2(nativeEvent) { | |
var charCode; | |
var keyCode = nativeEvent.keyCode; | |
if ('charCode' in nativeEvent) { | |
charCode = nativeEvent.charCode; | |
// FF does not set `charCode` for the Enter-key, check against `keyCode`. | |
if (charCode === 0 && keyCode === 13) { | |
charCode = 13; | |
} | |
} else { | |
// IE8 does not implement `charCode`, but `keyCode` has the correct value. | |
charCode = keyCode; | |
} | |
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them. | |
// Must not discard the (non-)printable Enter-key. | |
if (charCode >= 32 || charCode === 13) { | |
return charCode; | |
} | |
return 0; | |
} | |
var getEventCharCode_1 = getEventCharCode$2; | |
var getEventCharCode$3 = getEventCharCode_1; | |
/** | |
* Normalization of deprecated HTML5 `key` values | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | |
*/ | |
var normalizeKey = { | |
'Esc': 'Escape', | |
'Spacebar': ' ', | |
'Left': 'ArrowLeft', | |
'Up': 'ArrowUp', | |
'Right': 'ArrowRight', | |
'Down': 'ArrowDown', | |
'Del': 'Delete', | |
'Win': 'OS', | |
'Menu': 'ContextMenu', | |
'Apps': 'ContextMenu', | |
'Scroll': 'ScrollLock', | |
'MozPrintableKey': 'Unidentified' | |
}; | |
/** | |
* Translation from legacy `keyCode` to HTML5 `key` | |
* Only special keys supported, all others depend on keyboard layout or browser | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names | |
*/ | |
var translateToKey = { | |
8: 'Backspace', | |
9: 'Tab', | |
12: 'Clear', | |
13: 'Enter', | |
16: 'Shift', | |
17: 'Control', | |
18: 'Alt', | |
19: 'Pause', | |
20: 'CapsLock', | |
27: 'Escape', | |
32: ' ', | |
33: 'PageUp', | |
34: 'PageDown', | |
35: 'End', | |
36: 'Home', | |
37: 'ArrowLeft', | |
38: 'ArrowUp', | |
39: 'ArrowRight', | |
40: 'ArrowDown', | |
45: 'Insert', | |
46: 'Delete', | |
112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6', | |
118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12', | |
144: 'NumLock', | |
145: 'ScrollLock', | |
224: 'Meta' | |
}; | |
/** | |
* @param {object} nativeEvent Native browser event. | |
* @return {string} Normalized `key` property. | |
*/ | |
function getEventKey$1(nativeEvent) { | |
if (nativeEvent.key) { | |
// Normalize inconsistent values reported by browsers due to | |
// implementations of a working draft specification. | |
// FireFox implements `key` but returns `MozPrintableKey` for all | |
// printable characters (normalized to `Unidentified`), ignore it. | |
var key = normalizeKey[nativeEvent.key] || nativeEvent.key; | |
if (key !== 'Unidentified') { | |
return key; | |
} | |
} | |
// Browser does not implement `key`, polyfill as much of it as we can. | |
if (nativeEvent.type === 'keypress') { | |
var charCode = getEventCharCode$3(nativeEvent); | |
// The enter-key is technically both printable and non-printable and can | |
// thus be captured by `keypress`, no other non-printable key should. | |
return charCode === 13 ? 'Enter' : String.fromCharCode(charCode); | |
} | |
if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') { | |
// While user keyboard layout determines the actual meaning of each | |
// `keyCode` value, almost all function keys have a universal value. | |
return translateToKey[nativeEvent.keyCode] || 'Unidentified'; | |
} | |
return ''; | |
} | |
var getEventKey_1 = getEventKey$1; | |
var SyntheticUIEvent$4 = SyntheticUIEvent_1; | |
var getEventCharCode$1 = getEventCharCode_1; | |
var getEventKey = getEventKey_1; | |
var getEventModifierState$2 = getEventModifierState_1; | |
/** | |
* @interface KeyboardEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var KeyboardEventInterface = { | |
key: getEventKey, | |
location: null, | |
ctrlKey: null, | |
shiftKey: null, | |
altKey: null, | |
metaKey: null, | |
repeat: null, | |
locale: null, | |
getModifierState: getEventModifierState$2, | |
// Legacy Interface | |
charCode: function (event) { | |
// `charCode` is the result of a KeyPress event and represents the value of | |
// the actual printable character. | |
// KeyPress is deprecated, but its replacement is not yet final and not | |
// implemented in any major browser. Only KeyPress has charCode. | |
if (event.type === 'keypress') { | |
return getEventCharCode$1(event); | |
} | |
return 0; | |
}, | |
keyCode: function (event) { | |
// `keyCode` is the result of a KeyDown/Up event and represents the value of | |
// physical keyboard key. | |
// The actual meaning of the value depends on the users' keyboard layout | |
// which cannot be detected. Assuming that it is a US keyboard layout | |
// provides a surprisingly accurate mapping for US and European users. | |
// Due to this, it is left to the user to implement at this time. | |
if (event.type === 'keydown' || event.type === 'keyup') { | |
return event.keyCode; | |
} | |
return 0; | |
}, | |
which: function (event) { | |
// `which` is an alias for either `keyCode` or `charCode` depending on the | |
// type of the event. | |
if (event.type === 'keypress') { | |
return getEventCharCode$1(event); | |
} | |
if (event.type === 'keydown' || event.type === 'keyup') { | |
return event.keyCode; | |
} | |
return 0; | |
} | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticKeyboardEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticUIEvent$4.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticUIEvent$4.augmentClass(SyntheticKeyboardEvent$1, KeyboardEventInterface); | |
var SyntheticKeyboardEvent_1 = SyntheticKeyboardEvent$1; | |
var SyntheticMouseEvent$3 = SyntheticMouseEvent_1; | |
/** | |
* @interface DragEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var DragEventInterface = { | |
dataTransfer: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticDragEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticMouseEvent$3.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticMouseEvent$3.augmentClass(SyntheticDragEvent$1, DragEventInterface); | |
var SyntheticDragEvent_1 = SyntheticDragEvent$1; | |
var SyntheticUIEvent$5 = SyntheticUIEvent_1; | |
var getEventModifierState$3 = getEventModifierState_1; | |
/** | |
* @interface TouchEvent | |
* @see http://www.w3.org/TR/touch-events/ | |
*/ | |
var TouchEventInterface = { | |
touches: null, | |
targetTouches: null, | |
changedTouches: null, | |
altKey: null, | |
metaKey: null, | |
ctrlKey: null, | |
shiftKey: null, | |
getModifierState: getEventModifierState$3 | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticTouchEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticUIEvent$5.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticUIEvent$5.augmentClass(SyntheticTouchEvent$1, TouchEventInterface); | |
var SyntheticTouchEvent_1 = SyntheticTouchEvent$1; | |
var SyntheticEvent$9 = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events- | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent | |
*/ | |
var TransitionEventInterface = { | |
propertyName: null, | |
elapsedTime: null, | |
pseudoElement: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticEvent} | |
*/ | |
function SyntheticTransitionEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$9.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$9.augmentClass(SyntheticTransitionEvent$1, TransitionEventInterface); | |
var SyntheticTransitionEvent_1 = SyntheticTransitionEvent$1; | |
var SyntheticMouseEvent$4 = SyntheticMouseEvent_1; | |
/** | |
* @interface WheelEvent | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var WheelEventInterface = { | |
deltaX: function (event) { | |
return 'deltaX' in event ? event.deltaX : | |
// Fallback to `wheelDeltaX` for Webkit and normalize (right is positive). | |
'wheelDeltaX' in event ? -event.wheelDeltaX : 0; | |
}, | |
deltaY: function (event) { | |
return 'deltaY' in event ? event.deltaY : | |
// Fallback to `wheelDeltaY` for Webkit and normalize (down is positive). | |
'wheelDeltaY' in event ? -event.wheelDeltaY : | |
// Fallback to `wheelDelta` for IE<9 and normalize (down is positive). | |
'wheelDelta' in event ? -event.wheelDelta : 0; | |
}, | |
deltaZ: null, | |
// Browsers without "deltaMode" is reporting in raw wheel delta where one | |
// notch on the scroll is always +/- 120, roughly equivalent to pixels. | |
// A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or | |
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size. | |
deltaMode: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticMouseEvent} | |
*/ | |
function SyntheticWheelEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticMouseEvent$4.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticMouseEvent$4.augmentClass(SyntheticWheelEvent$1, WheelEventInterface); | |
var SyntheticWheelEvent_1 = SyntheticWheelEvent$1; | |
var EventPropagators$5 = EventPropagators_1; | |
var SyntheticAnimationEvent = SyntheticAnimationEvent_1; | |
var SyntheticClipboardEvent = SyntheticClipboardEvent_1; | |
var SyntheticEvent$6 = SyntheticEvent_1; | |
var SyntheticFocusEvent = SyntheticFocusEvent_1; | |
var SyntheticKeyboardEvent = SyntheticKeyboardEvent_1; | |
var SyntheticMouseEvent$2 = SyntheticMouseEvent_1; | |
var SyntheticDragEvent = SyntheticDragEvent_1; | |
var SyntheticTouchEvent = SyntheticTouchEvent_1; | |
var SyntheticTransitionEvent = SyntheticTransitionEvent_1; | |
var SyntheticUIEvent$2 = SyntheticUIEvent_1; | |
var SyntheticWheelEvent = SyntheticWheelEvent_1; | |
var getEventCharCode = getEventCharCode_1; | |
var invariant$8 = invariant; | |
/** | |
* Turns | |
* ['abort', ...] | |
* into | |
* eventTypes = { | |
* 'abort': { | |
* phasedRegistrationNames: { | |
* bubbled: 'onAbort', | |
* captured: 'onAbortCapture', | |
* }, | |
* dependencies: ['topAbort'], | |
* }, | |
* ... | |
* }; | |
* topLevelEventsToDispatchConfig = { | |
* 'topAbort': { sameConfig } | |
* }; | |
*/ | |
var eventTypes$4 = {}; | |
var topLevelEventsToDispatchConfig = {}; | |
['abort', 'animationEnd', 'animationIteration', 'animationStart', 'blur', 'cancel', 'canPlay', 'canPlayThrough', 'click', 'close', 'contextMenu', 'copy', 'cut', 'doubleClick', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'progress', 'rateChange', 'reset', 'scroll', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'toggle', 'touchCancel', 'touchEnd', 'touchMove', 'touchStart', 'transitionEnd', 'volumeChange', 'waiting', 'wheel'].forEach(function (event) { | |
var capitalizedEvent = event[0].toUpperCase() + event.slice(1); | |
var onEvent = 'on' + capitalizedEvent; | |
var topEvent = 'top' + capitalizedEvent; | |
var type = { | |
phasedRegistrationNames: { | |
bubbled: onEvent, | |
captured: onEvent + 'Capture' | |
}, | |
dependencies: [topEvent] | |
}; | |
eventTypes$4[event] = type; | |
topLevelEventsToDispatchConfig[topEvent] = type; | |
}); | |
var SimpleEventPlugin$1 = { | |
eventTypes: eventTypes$4, | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; | |
if (!dispatchConfig) { | |
return null; | |
} | |
var EventConstructor; | |
switch (topLevelType) { | |
case 'topAbort': | |
case 'topCancel': | |
case 'topCanPlay': | |
case 'topCanPlayThrough': | |
case 'topClose': | |
case 'topDurationChange': | |
case 'topEmptied': | |
case 'topEncrypted': | |
case 'topEnded': | |
case 'topError': | |
case 'topInput': | |
case 'topInvalid': | |
case 'topLoad': | |
case 'topLoadedData': | |
case 'topLoadedMetadata': | |
case 'topLoadStart': | |
case 'topPause': | |
case 'topPlay': | |
case 'topPlaying': | |
case 'topProgress': | |
case 'topRateChange': | |
case 'topReset': | |
case 'topSeeked': | |
case 'topSeeking': | |
case 'topStalled': | |
case 'topSubmit': | |
case 'topSuspend': | |
case 'topTimeUpdate': | |
case 'topToggle': | |
case 'topVolumeChange': | |
case 'topWaiting': | |
// HTML Events | |
// @see http://www.w3.org/TR/html5/index.html#events-0 | |
EventConstructor = SyntheticEvent$6; | |
break; | |
case 'topKeyPress': | |
// Firefox creates a keypress event for function keys too. This removes | |
// the unwanted keypress events. Enter is however both printable and | |
// non-printable. One would expect Tab to be as well (but it isn't). | |
if (getEventCharCode(nativeEvent) === 0) { | |
return null; | |
} | |
/* falls through */ | |
case 'topKeyDown': | |
case 'topKeyUp': | |
EventConstructor = SyntheticKeyboardEvent; | |
break; | |
case 'topBlur': | |
case 'topFocus': | |
EventConstructor = SyntheticFocusEvent; | |
break; | |
case 'topClick': | |
// Firefox creates a click event on right mouse clicks. This removes the | |
// unwanted click events. | |
if (nativeEvent.button === 2) { | |
return null; | |
} | |
/* falls through */ | |
case 'topDoubleClick': | |
case 'topMouseDown': | |
case 'topMouseMove': | |
case 'topMouseUp': | |
// TODO: Disabled elements should not respond to mouse events | |
/* falls through */ | |
case 'topMouseOut': | |
case 'topMouseOver': | |
case 'topContextMenu': | |
EventConstructor = SyntheticMouseEvent$2; | |
break; | |
case 'topDrag': | |
case 'topDragEnd': | |
case 'topDragEnter': | |
case 'topDragExit': | |
case 'topDragLeave': | |
case 'topDragOver': | |
case 'topDragStart': | |
case 'topDrop': | |
EventConstructor = SyntheticDragEvent; | |
break; | |
case 'topTouchCancel': | |
case 'topTouchEnd': | |
case 'topTouchMove': | |
case 'topTouchStart': | |
EventConstructor = SyntheticTouchEvent; | |
break; | |
case 'topAnimationEnd': | |
case 'topAnimationIteration': | |
case 'topAnimationStart': | |
EventConstructor = SyntheticAnimationEvent; | |
break; | |
case 'topTransitionEnd': | |
EventConstructor = SyntheticTransitionEvent; | |
break; | |
case 'topScroll': | |
EventConstructor = SyntheticUIEvent$2; | |
break; | |
case 'topWheel': | |
EventConstructor = SyntheticWheelEvent; | |
break; | |
case 'topCopy': | |
case 'topCut': | |
case 'topPaste': | |
EventConstructor = SyntheticClipboardEvent; | |
break; | |
} | |
invariant$8(EventConstructor, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType); | |
var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget); | |
EventPropagators$5.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
}; | |
var SimpleEventPlugin_1 = SimpleEventPlugin$1; | |
var ARIADOMPropertyConfig = ARIADOMPropertyConfig_1; | |
var BeforeInputEventPlugin = BeforeInputEventPlugin_1; | |
var DOMProperty$2 = DOMProperty_1; | |
var ChangeEventPlugin = ChangeEventPlugin_1; | |
var DOMEventPluginOrder = DOMEventPluginOrder_1; | |
var EnterLeaveEventPlugin = EnterLeaveEventPlugin_1; | |
var EventPluginHub = EventPluginHub_1; | |
var EventPluginUtils = EventPluginUtils_1; | |
var HTMLDOMPropertyConfig = HTMLDOMPropertyConfig_1; | |
var ReactBrowserEventEmitter = ReactBrowserEventEmitter_1; | |
var ReactDOMComponentTree$2 = ReactDOMComponentTree_1; | |
var ReactEventListener = ReactEventListener_1; | |
var SVGDOMPropertyConfig = SVGDOMPropertyConfig_1; | |
var SelectEventPlugin = SelectEventPlugin_1; | |
var SimpleEventPlugin = SimpleEventPlugin_1; | |
var alreadyInjected = false; | |
function inject() { | |
if (alreadyInjected) { | |
// TODO: This is currently true because these injections are shared between | |
// the client and the server package. They should be built independently | |
// and not share any injection state. Then this problem will be solved. | |
return; | |
} | |
alreadyInjected = true; | |
ReactBrowserEventEmitter.injection.injectReactEventListener(ReactEventListener); | |
/** | |
* Inject modules for resolving DOM hierarchy and plugin ordering. | |
*/ | |
EventPluginHub.injection.injectEventPluginOrder(DOMEventPluginOrder); | |
EventPluginUtils.injection.injectComponentTree(ReactDOMComponentTree$2); | |
/** | |
* Some important event plugins included by default (without having to require | |
* them). | |
*/ | |
EventPluginHub.injection.injectEventPluginsByName({ | |
SimpleEventPlugin: SimpleEventPlugin, | |
EnterLeaveEventPlugin: EnterLeaveEventPlugin, | |
ChangeEventPlugin: ChangeEventPlugin, | |
SelectEventPlugin: SelectEventPlugin, | |
BeforeInputEventPlugin: BeforeInputEventPlugin | |
}); | |
DOMProperty$2.injection.injectDOMPropertyConfig(ARIADOMPropertyConfig); | |
DOMProperty$2.injection.injectDOMPropertyConfig(HTMLDOMPropertyConfig); | |
DOMProperty$2.injection.injectDOMPropertyConfig(SVGDOMPropertyConfig); | |
} | |
var ReactDOMInjection$1 = { | |
inject: inject | |
}; | |
var invariant$9 = invariant; | |
var injected = false; | |
var ReactComponentEnvironment$1 = { | |
/** | |
* Optionally injectable hook for swapping out mount images in the middle of | |
* the tree. | |
*/ | |
replaceNodeWithMarkup: null, | |
/** | |
* Optionally injectable hook for processing a queue of child updates. Will | |
* later move into MultiChildComponents. | |
*/ | |
processChildrenUpdates: null, | |
injection: { | |
injectEnvironment: function (environment) { | |
invariant$9(!injected, 'ReactCompositeComponent: injectEnvironment() can only be called once.'); | |
ReactComponentEnvironment$1.replaceNodeWithMarkup = environment.replaceNodeWithMarkup; | |
ReactComponentEnvironment$1.processChildrenUpdates = environment.processChildrenUpdates; | |
injected = true; | |
} | |
} | |
}; | |
var ReactComponentEnvironment_1 = ReactComponentEnvironment$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule DOMNamespaces | |
*/ | |
var DOMNamespaces$1 = { | |
html: 'http://www.w3.org/1999/xhtml', | |
mathml: 'http://www.w3.org/1998/Math/MathML', | |
svg: 'http://www.w3.org/2000/svg' | |
}; | |
var DOMNamespaces_1 = DOMNamespaces$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule createMicrosoftUnsafeLocalFunction | |
*/ | |
/* globals MSApp */ | |
/** | |
* Create a function which has 'unsafe' privileges (required by windows8 apps) | |
*/ | |
var createMicrosoftUnsafeLocalFunction$3 = function (func) { | |
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { | |
return function (arg0, arg1, arg2, arg3) { | |
MSApp.execUnsafeLocalFunction(function () { | |
return func(arg0, arg1, arg2, arg3); | |
}); | |
}; | |
} else { | |
return func; | |
} | |
}; | |
var createMicrosoftUnsafeLocalFunction_1 = createMicrosoftUnsafeLocalFunction$3; | |
var ExecutionEnvironment$9 = ExecutionEnvironment; | |
var DOMNamespaces$2 = DOMNamespaces_1; | |
var WHITESPACE_TEST = /^[ \r\n\t\f]/; | |
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/; | |
var createMicrosoftUnsafeLocalFunction$2 = createMicrosoftUnsafeLocalFunction_1; | |
// SVG temp container for IE lacking innerHTML | |
var reusableSVGContainer; | |
/** | |
* Set the innerHTML property of a node, ensuring that whitespace is preserved | |
* even in IE8. | |
* | |
* @param {DOMElement} node | |
* @param {string} html | |
* @internal | |
*/ | |
var setInnerHTML$2 = createMicrosoftUnsafeLocalFunction$2(function (node, html) { | |
// IE does not have innerHTML for SVG nodes, so instead we inject the | |
// new markup in a temp node and then move the child nodes across into | |
// the target node | |
if (node.namespaceURI === DOMNamespaces$2.svg && !('innerHTML' in node)) { | |
reusableSVGContainer = reusableSVGContainer || document.createElement('div'); | |
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>'; | |
var svgNode = reusableSVGContainer.firstChild; | |
while (svgNode.firstChild) { | |
node.appendChild(svgNode.firstChild); | |
} | |
} else { | |
node.innerHTML = html; | |
} | |
}); | |
if (ExecutionEnvironment$9.canUseDOM) { | |
// IE8: When updating a just created node with innerHTML only leading | |
// whitespace is removed. When updating an existing node with innerHTML | |
// whitespace in root TextNodes is also collapsed. | |
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html | |
// Feature detection; only IE8 is known to behave improperly like this. | |
var testElement = document.createElement('div'); | |
testElement.innerHTML = ' '; | |
if (testElement.innerHTML === '') { | |
setInnerHTML$2 = function (node, html) { | |
// Magic theory: IE8 supposedly differentiates between added and updated | |
// nodes when processing innerHTML, innerHTML on updated nodes suffers | |
// from worse whitespace behavior. Re-adding a node like this triggers | |
// the initial and more favorable whitespace behavior. | |
// TODO: What to do on a detached node? | |
if (node.parentNode) { | |
node.parentNode.replaceChild(node, node); | |
} | |
// We also implement a workaround for non-visible tags disappearing into | |
// thin air on IE8, this only happens if there is no visible text | |
// in-front of the non-visible tags. Piggyback on the whitespace fix | |
// and simply check if any non-visible tags appear in the source. | |
if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) { | |
// Recover leading whitespace by temporarily prepending any character. | |
// \uFEFF has the potential advantage of being zero-width/invisible. | |
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode | |
// in hopes that this is preserved even if "\uFEFF" is transformed to | |
// the actual Unicode character (by Babel, for example). | |
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216 | |
node.innerHTML = String.fromCharCode(0xFEFF) + html; | |
// deleteData leaves an empty `TextNode` which offsets the index of all | |
// children. Definitely want to avoid this. | |
var textNode = node.firstChild; | |
if (textNode.data.length === 1) { | |
node.removeChild(textNode); | |
} else { | |
textNode.deleteData(0, 1); | |
} | |
} else { | |
node.innerHTML = html; | |
} | |
}; | |
} | |
testElement = null; | |
} | |
var setInnerHTML_1 = setInnerHTML$2; | |
/** | |
* Copyright 2016-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* Based on the escape-html library, which is used under the MIT License below: | |
* | |
* Copyright (c) 2012-2013 TJ Holowaychuk | |
* Copyright (c) 2015 Andreas Lubbe | |
* Copyright (c) 2015 Tiancheng "Timothy" Gu | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* 'Software'), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be | |
* included in all copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
* | |
* @providesModule escapeTextContentForBrowser | |
*/ | |
// code copied and modified from escape-html | |
/** | |
* Module variables. | |
* @private | |
*/ | |
var matchHtmlRegExp = /["'&<>]/; | |
/** | |
* Escape special characters in the given string of html. | |
* | |
* @param {string} string The string to escape for inserting into HTML | |
* @return {string} | |
* @public | |
*/ | |
function escapeHtml(string) { | |
var str = '' + string; | |
var match = matchHtmlRegExp.exec(str); | |
if (!match) { | |
return str; | |
} | |
var escape; | |
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. | |
*/ | |
function escapeTextContentForBrowser$1(text) { | |
if (typeof text === 'boolean' || typeof text === 'number') { | |
// this shortcircuit helps perf for types that we know will never have | |
// special characters, especially given that this function is used often | |
// for numeric dom ids. | |
return '' + text; | |
} | |
return escapeHtml(text); | |
} | |
var escapeTextContentForBrowser_1 = escapeTextContentForBrowser$1; | |
var ExecutionEnvironment$10 = ExecutionEnvironment; | |
var escapeTextContentForBrowser = escapeTextContentForBrowser_1; | |
var setInnerHTML$3 = setInnerHTML_1; | |
/** | |
* Set the textContent property of a node, ensuring that whitespace is preserved | |
* even in IE8. innerText is a poor substitute for textContent and, among many | |
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves | |
* as it should. | |
* | |
* @param {DOMElement} node | |
* @param {string} text | |
* @internal | |
*/ | |
var setTextContent$2 = function (node, text) { | |
if (text) { | |
var firstChild = node.firstChild; | |
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) { | |
firstChild.nodeValue = text; | |
return; | |
} | |
} | |
node.textContent = text; | |
}; | |
if (ExecutionEnvironment$10.canUseDOM) { | |
if (!('textContent' in document.documentElement)) { | |
setTextContent$2 = function (node, text) { | |
if (node.nodeType === 3) { | |
node.nodeValue = text; | |
return; | |
} | |
setInnerHTML$3(node, escapeTextContentForBrowser(text)); | |
}; | |
} | |
} | |
var setTextContent_1 = setTextContent$2; | |
var DOMNamespaces = DOMNamespaces_1; | |
var setInnerHTML$1 = setInnerHTML_1; | |
var createMicrosoftUnsafeLocalFunction$1 = createMicrosoftUnsafeLocalFunction_1; | |
var setTextContent$1 = setTextContent_1; | |
var ELEMENT_NODE_TYPE = 1; | |
var DOCUMENT_FRAGMENT_NODE_TYPE = 11; | |
/** | |
* In IE (8-11) and Edge, appending nodes with no children is dramatically | |
* faster than appending a full subtree, so we essentially queue up the | |
* .appendChild calls here and apply them so each node is added to its parent | |
* before any children are added. | |
* | |
* In other browsers, doing so is slower or neutral compared to the other order | |
* (in Firefox, twice as slow) so we only do this inversion in IE. | |
* | |
* See https://github.com/spicyj/innerhtml-vs-createelement-vs-clonenode. | |
*/ | |
var enableLazy = typeof document !== 'undefined' && typeof document.documentMode === 'number' || typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && /\bEdge\/\d/.test(navigator.userAgent); | |
function insertTreeChildren(tree) { | |
if (!enableLazy) { | |
return; | |
} | |
var node = tree.node; | |
var children = tree.children; | |
if (children.length) { | |
for (var i = 0; i < children.length; i++) { | |
insertTreeBefore(node, children[i], null); | |
} | |
} else if (tree.html != null) { | |
setInnerHTML$1(node, tree.html); | |
} else if (tree.text != null) { | |
setTextContent$1(node, tree.text); | |
} | |
} | |
var insertTreeBefore = createMicrosoftUnsafeLocalFunction$1(function (parentNode, tree, referenceNode) { | |
// DocumentFragments aren't actually part of the DOM after insertion so | |
// appending children won't update the DOM. We need to ensure the fragment | |
// is properly populated first, breaking out of our lazy approach for just | |
// this level. Also, some <object> plugins (like Flash Player) will read | |
// <param> nodes immediately upon insertion into the DOM, so <object> | |
// must also be populated prior to insertion into the DOM. | |
if (tree.node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE || tree.node.nodeType === ELEMENT_NODE_TYPE && tree.node.nodeName.toLowerCase() === 'object' && (tree.node.namespaceURI == null || tree.node.namespaceURI === DOMNamespaces.html)) { | |
insertTreeChildren(tree); | |
parentNode.insertBefore(tree.node, referenceNode); | |
} else { | |
parentNode.insertBefore(tree.node, referenceNode); | |
insertTreeChildren(tree); | |
} | |
}); | |
function replaceChildWithTree(oldNode, newTree) { | |
oldNode.parentNode.replaceChild(newTree.node, oldNode); | |
insertTreeChildren(newTree); | |
} | |
function queueChild(parentTree, childTree) { | |
if (enableLazy) { | |
parentTree.children.push(childTree); | |
} else { | |
parentTree.node.appendChild(childTree.node); | |
} | |
} | |
function queueHTML(tree, html) { | |
if (enableLazy) { | |
tree.html = html; | |
} else { | |
setInnerHTML$1(tree.node, html); | |
} | |
} | |
function queueText(tree, text) { | |
if (enableLazy) { | |
tree.text = text; | |
} else { | |
setTextContent$1(tree.node, text); | |
} | |
} | |
function toString() { | |
return this.node.nodeName; | |
} | |
function DOMLazyTree$1(node) { | |
return { | |
node: node, | |
children: [], | |
html: null, | |
text: null, | |
toString: toString | |
}; | |
} | |
DOMLazyTree$1.insertTreeBefore = insertTreeBefore; | |
DOMLazyTree$1.replaceChildWithTree = replaceChildWithTree; | |
DOMLazyTree$1.queueChild = queueChild; | |
DOMLazyTree$1.queueHTML = queueHTML; | |
DOMLazyTree$1.queueText = queueText; | |
var DOMLazyTree_1 = DOMLazyTree$1; | |
var DOMLazyTree$2 = DOMLazyTree_1; | |
var ExecutionEnvironment$11 = ExecutionEnvironment; | |
var createNodesFromMarkup$1 = createNodesFromMarkup; | |
var emptyFunction$2 = emptyFunction; | |
var invariant$10 = invariant; | |
var Danger$1 = { | |
/** | |
* Replaces a node with a string of markup at its current position within its | |
* parent. The markup must render into a single root node. | |
* | |
* @param {DOMElement} oldChild Child node to replace. | |
* @param {string} markup Markup to render in place of the child node. | |
* @internal | |
*/ | |
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) { | |
invariant$10(ExecutionEnvironment$11.canUseDOM, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.'); | |
invariant$10(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.'); | |
invariant$10(oldChild.nodeName !== 'HTML', 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().'); | |
if (typeof markup === 'string') { | |
var newChild = createNodesFromMarkup$1(markup, emptyFunction$2)[0]; | |
oldChild.parentNode.replaceChild(newChild, oldChild); | |
} else { | |
DOMLazyTree$2.replaceChildWithTree(oldChild, markup); | |
} | |
} | |
}; | |
var Danger_1 = Danger$1; | |
var warning$5 = warning; | |
var ReactInvalidSetStateWarningHook$1 = {}; | |
if (__DEV__) { | |
var processingChildContext = false; | |
var warnInvalidSetState = function () { | |
warning$5(!processingChildContext, 'setState(...): Cannot call setState() inside getChildContext()'); | |
}; | |
ReactInvalidSetStateWarningHook$1 = { | |
onBeginProcessingChildContext: function () { | |
processingChildContext = true; | |
}, | |
onEndProcessingChildContext: function () { | |
processingChildContext = false; | |
}, | |
onSetState: function () { | |
warnInvalidSetState(); | |
} | |
}; | |
} | |
var ReactInvalidSetStateWarningHook_1 = ReactInvalidSetStateWarningHook$1; | |
/** | |
* Copyright 2016-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactHostOperationHistoryHook | |
* | |
*/ | |
// Trust the developer to only use this with a __DEV__ check | |
var ReactHostOperationHistoryHook$1 = null; | |
if (__DEV__) { | |
var history = []; | |
ReactHostOperationHistoryHook$1 = { | |
onHostOperation: function (operation) { | |
history.push(operation); | |
}, | |
clearHistory: function () { | |
if (ReactHostOperationHistoryHook$1._preventClearing) { | |
// Should only be used for tests. | |
return; | |
} | |
history = []; | |
}, | |
getHistory: function () { | |
return history; | |
} | |
}; | |
} | |
var ReactHostOperationHistoryHook_1 = ReactHostOperationHistoryHook$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactCurrentOwner | |
* | |
*/ | |
/** | |
* Keeps track of the current owner. | |
* | |
* The current owner is the component who should own any components that are | |
* currently being constructed. | |
*/ | |
var ReactCurrentOwner$1 = { | |
/** | |
* @internal | |
* @type {ReactComponent} | |
*/ | |
current: null | |
}; | |
var ReactCurrentOwner_1 = ReactCurrentOwner$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule getComponentName | |
*/ | |
function getComponentName$1(instanceOrFiber) { | |
if (typeof instanceOrFiber.getName === 'function') { | |
// Stack reconciler | |
var instance = instanceOrFiber; | |
return instance.getName(); | |
} | |
if (typeof instanceOrFiber.tag === 'number') { | |
// Fiber reconciler | |
var fiber = instanceOrFiber; | |
var type = fiber.type; | |
if (typeof type === 'string') { | |
return type; | |
} | |
if (typeof type === 'function') { | |
return type.displayName || type.name; | |
} | |
} | |
return null; | |
} | |
var getComponentName_1 = getComponentName$1; | |
var ReactCurrentOwner = ReactCurrentOwner_1; | |
var ReactTypeOfWork$3 = ReactTypeOfWork; | |
var IndeterminateComponent = ReactTypeOfWork$3.IndeterminateComponent; | |
var FunctionalComponent = ReactTypeOfWork$3.FunctionalComponent; | |
var ClassComponent = ReactTypeOfWork$3.ClassComponent; | |
var HostComponent$2 = ReactTypeOfWork$3.HostComponent; | |
var getComponentName = getComponentName_1; | |
var invariant$11 = invariant; | |
var warning$6 = warning; | |
function isNative(fn) { | |
// Based on isNative() from Lodash | |
var funcToString = Function.prototype.toString; | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var reIsNative = RegExp('^' + funcToString | |
// Take an example native function source for comparison | |
.call(hasOwnProperty) | |
// Strip regex characters so we can use it for regex | |
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') | |
// Remove hasOwnProperty from the template to make it generic | |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); | |
try { | |
var source = funcToString.call(fn); | |
return reIsNative.test(source); | |
} catch (err) { | |
return false; | |
} | |
} | |
var canUseCollections = | |
// Array.from | |
typeof Array.from === 'function' && | |
// Map | |
typeof Map === 'function' && isNative(Map) && | |
// Map.prototype.keys | |
Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) && | |
// Set | |
typeof Set === 'function' && isNative(Set) && | |
// Set.prototype.keys | |
Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys); | |
var setItem; | |
var getItem; | |
var removeItem; | |
var getItemIDs; | |
var addRoot; | |
var removeRoot; | |
var getRootIDs; | |
if (canUseCollections) { | |
var itemMap = new Map(); | |
var rootIDSet = new Set(); | |
setItem = function (id, item) { | |
itemMap.set(id, item); | |
}; | |
getItem = function (id) { | |
return itemMap.get(id); | |
}; | |
removeItem = function (id) { | |
itemMap['delete'](id); | |
}; | |
getItemIDs = function () { | |
return Array.from(itemMap.keys()); | |
}; | |
addRoot = function (id) { | |
rootIDSet.add(id); | |
}; | |
removeRoot = function (id) { | |
rootIDSet['delete'](id); | |
}; | |
getRootIDs = function () { | |
return Array.from(rootIDSet.keys()); | |
}; | |
} else { | |
var itemByKey = {}; | |
var rootByKey = {}; | |
// Use non-numeric keys to prevent V8 performance issues: | |
// https://github.com/facebook/react/pull/7232 | |
var getKeyFromID = function (id) { | |
return '.' + id; | |
}; | |
var getIDFromKey = function (key) { | |
return parseInt(key.substr(1), 10); | |
}; | |
setItem = function (id, item) { | |
var key = getKeyFromID(id); | |
itemByKey[key] = item; | |
}; | |
getItem = function (id) { | |
var key = getKeyFromID(id); | |
return itemByKey[key]; | |
}; | |
removeItem = function (id) { | |
var key = getKeyFromID(id); | |
delete itemByKey[key]; | |
}; | |
getItemIDs = function () { | |
return Object.keys(itemByKey).map(getIDFromKey); | |
}; | |
addRoot = function (id) { | |
var key = getKeyFromID(id); | |
rootByKey[key] = true; | |
}; | |
removeRoot = function (id) { | |
var key = getKeyFromID(id); | |
delete rootByKey[key]; | |
}; | |
getRootIDs = function () { | |
return Object.keys(rootByKey).map(getIDFromKey); | |
}; | |
} | |
var unmountedIDs = []; | |
function purgeDeep(id) { | |
var item = getItem(id); | |
if (item) { | |
var childIDs = item.childIDs; | |
removeItem(id); | |
childIDs.forEach(purgeDeep); | |
} | |
} | |
function describeComponentFrame(name, source, ownerName) { | |
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); | |
} | |
function getDisplayName(element) { | |
if (element == null) { | |
return '#empty'; | |
} else if (typeof element === 'string' || typeof element === 'number') { | |
return '#text'; | |
} else if (typeof element.type === 'string') { | |
return element.type; | |
} else { | |
return element.type.displayName || element.type.name || 'Unknown'; | |
} | |
} | |
function describeID(id) { | |
var name = ReactComponentTreeHook$1.getDisplayName(id); | |
var element = ReactComponentTreeHook$1.getElement(id); | |
var ownerID = ReactComponentTreeHook$1.getOwnerID(id); | |
var ownerName; | |
if (ownerID) { | |
ownerName = ReactComponentTreeHook$1.getDisplayName(ownerID); | |
} | |
warning$6(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id); | |
return describeComponentFrame(name, element && element._source, ownerName); | |
} | |
function describeFiber(fiber) { | |
switch (fiber.tag) { | |
case IndeterminateComponent: | |
case FunctionalComponent: | |
case ClassComponent: | |
case HostComponent$2: | |
var owner = fiber._debugOwner; | |
var source = fiber._debugSource; | |
var name = getComponentName(fiber); | |
var ownerName = null; | |
if (owner) { | |
ownerName = getComponentName(owner); | |
} | |
return describeComponentFrame(name, source, ownerName); | |
default: | |
return ''; | |
} | |
} | |
var ReactComponentTreeHook$1 = { | |
onSetChildren: function (id, nextChildIDs) { | |
var item = getItem(id); | |
invariant$11(item, 'Item must have been set'); | |
item.childIDs = nextChildIDs; | |
for (var i = 0; i < nextChildIDs.length; i++) { | |
var nextChildID = nextChildIDs[i]; | |
var nextChild = getItem(nextChildID); | |
invariant$11(nextChild, 'Expected hook events to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$11(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null, 'Expected onSetChildren() to fire for a container child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$11(nextChild.isMounted, 'Expected onMountComponent() to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
if (nextChild.parentID == null) { | |
nextChild.parentID = id; | |
// TODO: This shouldn't be necessary but mounting a new root during in | |
// componentWillMount currently causes not-yet-mounted components to | |
// be purged from our tree data so their parent id is missing. | |
} | |
invariant$11(nextChild.parentID === id, 'Expected onBeforeMountComponent() parent and onSetChildren() to ' + 'be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id); | |
} | |
}, | |
onBeforeMountComponent: function (id, element, parentID) { | |
var item = { | |
element: element, | |
parentID: parentID, | |
text: null, | |
childIDs: [], | |
isMounted: false, | |
updateCount: 0 | |
}; | |
setItem(id, item); | |
}, | |
onBeforeUpdateComponent: function (id, element) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.element = element; | |
}, | |
onMountComponent: function (id) { | |
var item = getItem(id); | |
invariant$11(item, 'Item must have been set'); | |
item.isMounted = true; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
addRoot(id); | |
} | |
}, | |
onUpdateComponent: function (id) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.updateCount++; | |
}, | |
onUnmountComponent: function (id) { | |
var item = getItem(id); | |
if (item) { | |
// We need to check if it exists. | |
// `item` might not exist if it is inside an error boundary, and a sibling | |
// error boundary child threw while mounting. Then this instance never | |
// got a chance to mount, but it still gets an unmounting event during | |
// the error boundary cleanup. | |
item.isMounted = false; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
removeRoot(id); | |
} | |
} | |
unmountedIDs.push(id); | |
}, | |
purgeUnmountedComponents: function () { | |
if (ReactComponentTreeHook$1._preventPurging) { | |
// Should only be used for testing. | |
return; | |
} | |
for (var i = 0; i < unmountedIDs.length; i++) { | |
var id = unmountedIDs[i]; | |
purgeDeep(id); | |
} | |
unmountedIDs.length = 0; | |
}, | |
isMounted: function (id) { | |
var item = getItem(id); | |
return item ? item.isMounted : false; | |
}, | |
getCurrentStackAddendum: function (topElement) { | |
var info = ''; | |
if (topElement) { | |
var name = getDisplayName(topElement); | |
var owner = topElement._owner; | |
info += describeComponentFrame(name, topElement._source, owner && getComponentName(owner)); | |
} | |
var currentOwner = ReactCurrentOwner.current; | |
if (currentOwner) { | |
if (typeof currentOwner.tag === 'number') { | |
var workInProgress = currentOwner; | |
// Safe because if current owner exists, we are reconciling, | |
// and it is guaranteed to be the work-in-progress version. | |
info += ReactComponentTreeHook$1.getStackAddendumByWorkInProgressFiber(workInProgress); | |
} else if (typeof currentOwner._debugID === 'number') { | |
info += ReactComponentTreeHook$1.getStackAddendumByID(currentOwner._debugID); | |
} | |
} | |
return info; | |
}, | |
getStackAddendumByID: function (id) { | |
var info = ''; | |
while (id) { | |
info += describeID(id); | |
id = ReactComponentTreeHook$1.getParentID(id); | |
} | |
return info; | |
}, | |
// This function can only be called with a work-in-progress fiber and | |
// only during begin or complete phase. Do not call it under any other | |
// circumstances. | |
getStackAddendumByWorkInProgressFiber: function (workInProgress) { | |
var info = ''; | |
var node = workInProgress; | |
do { | |
info += describeFiber(node); | |
// Otherwise this return pointer might point to the wrong tree: | |
node = node['return']; | |
} while (node); | |
return info; | |
}, | |
getChildIDs: function (id) { | |
var item = getItem(id); | |
return item ? item.childIDs : []; | |
}, | |
getDisplayName: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (!element) { | |
return null; | |
} | |
return getDisplayName(element); | |
}, | |
getElement: function (id) { | |
var item = getItem(id); | |
return item ? item.element : null; | |
}, | |
getOwnerID: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (!element || !element._owner) { | |
return null; | |
} | |
return element._owner._debugID; | |
}, | |
getParentID: function (id) { | |
var item = getItem(id); | |
return item ? item.parentID : null; | |
}, | |
getSource: function (id) { | |
var item = getItem(id); | |
var element = item ? item.element : null; | |
var source = element != null ? element._source : null; | |
return source; | |
}, | |
getText: function (id) { | |
var element = ReactComponentTreeHook$1.getElement(id); | |
if (typeof element === 'string') { | |
return element; | |
} else if (typeof element === 'number') { | |
return '' + element; | |
} else { | |
return null; | |
} | |
}, | |
getUpdateCount: function (id) { | |
var item = getItem(id); | |
return item ? item.updateCount : 0; | |
}, | |
getRootIDs: getRootIDs, | |
getRegisteredIDs: getItemIDs | |
}; | |
var ReactComponentTreeHook_1 = ReactComponentTreeHook$1; | |
var ReactInvalidSetStateWarningHook = ReactInvalidSetStateWarningHook_1; | |
var ReactHostOperationHistoryHook = ReactHostOperationHistoryHook_1; | |
var ReactComponentTreeHook = ReactComponentTreeHook_1; | |
var ExecutionEnvironment$12 = ExecutionEnvironment; | |
var performanceNow$1 = performanceNow; | |
var warning$4 = warning; | |
// Trust the developer to only use this with a __DEV__ check | |
var ReactDebugTool$1 = null; | |
if (__DEV__) { | |
var hooks = []; | |
var didHookThrowForEvent = {}; | |
var callHook = function (event, fn, context, arg1, arg2, arg3, arg4, arg5) { | |
try { | |
fn.call(context, arg1, arg2, arg3, arg4, arg5); | |
} catch (e) { | |
warning$4(didHookThrowForEvent[event], 'Exception thrown by hook while handling %s: %s', event, e + '\n' + e.stack); | |
didHookThrowForEvent[event] = true; | |
} | |
}; | |
var emitEvent = function (event, arg1, arg2, arg3, arg4, arg5) { | |
for (var i = 0; i < hooks.length; i++) { | |
var hook = hooks[i]; | |
var fn = hook[event]; | |
if (fn) { | |
callHook(event, fn, hook, arg1, arg2, arg3, arg4, arg5); | |
} | |
} | |
}; | |
var isProfiling = false; | |
var flushHistory = []; | |
var lifeCycleTimerStack = []; | |
var currentFlushNesting = 0; | |
var currentFlushMeasurements = []; | |
var currentFlushStartTime = 0; | |
var currentTimerDebugID = null; | |
var currentTimerStartTime = 0; | |
var currentTimerNestedFlushDuration = 0; | |
var currentTimerType = null; | |
var lifeCycleTimerHasWarned = false; | |
var clearHistory = function () { | |
ReactComponentTreeHook.purgeUnmountedComponents(); | |
ReactHostOperationHistoryHook.clearHistory(); | |
}; | |
var getTreeSnapshot = function (registeredIDs) { | |
return registeredIDs.reduce(function (tree, id) { | |
var ownerID = ReactComponentTreeHook.getOwnerID(id); | |
var parentID = ReactComponentTreeHook.getParentID(id); | |
tree[id] = { | |
displayName: ReactComponentTreeHook.getDisplayName(id), | |
text: ReactComponentTreeHook.getText(id), | |
updateCount: ReactComponentTreeHook.getUpdateCount(id), | |
childIDs: ReactComponentTreeHook.getChildIDs(id), | |
// Text nodes don't have owners but this is close enough. | |
ownerID: ownerID || parentID && ReactComponentTreeHook.getOwnerID(parentID) || 0, | |
parentID: parentID | |
}; | |
return tree; | |
}, {}); | |
}; | |
var resetMeasurements = function () { | |
var previousStartTime = currentFlushStartTime; | |
var previousMeasurements = currentFlushMeasurements; | |
var previousOperations = ReactHostOperationHistoryHook.getHistory(); | |
if (currentFlushNesting === 0) { | |
currentFlushStartTime = 0; | |
currentFlushMeasurements = []; | |
clearHistory(); | |
return; | |
} | |
if (previousMeasurements.length || previousOperations.length) { | |
var registeredIDs = ReactComponentTreeHook.getRegisteredIDs(); | |
flushHistory.push({ | |
duration: performanceNow$1() - previousStartTime, | |
measurements: previousMeasurements || [], | |
operations: previousOperations || [], | |
treeSnapshot: getTreeSnapshot(registeredIDs) | |
}); | |
} | |
clearHistory(); | |
currentFlushStartTime = performanceNow$1(); | |
currentFlushMeasurements = []; | |
}; | |
var checkDebugID = function (debugID) { | |
var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | |
if (allowRoot && debugID === 0) { | |
return; | |
} | |
if (!debugID) { | |
warning$4(false, 'ReactDebugTool: debugID may not be empty.'); | |
} | |
}; | |
var beginLifeCycleTimer = function (debugID, timerType) { | |
if (currentFlushNesting === 0) { | |
return; | |
} | |
if (currentTimerType && !lifeCycleTimerHasWarned) { | |
warning$4(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); | |
lifeCycleTimerHasWarned = true; | |
} | |
currentTimerStartTime = performanceNow$1(); | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = debugID; | |
currentTimerType = timerType; | |
}; | |
var endLifeCycleTimer = function (debugID, timerType) { | |
if (currentFlushNesting === 0) { | |
return; | |
} | |
if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) { | |
warning$4(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); | |
lifeCycleTimerHasWarned = true; | |
} | |
if (isProfiling) { | |
currentFlushMeasurements.push({ | |
timerType: timerType, | |
instanceID: debugID, | |
duration: performanceNow$1() - currentTimerStartTime - currentTimerNestedFlushDuration | |
}); | |
} | |
currentTimerStartTime = 0; | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = null; | |
currentTimerType = null; | |
}; | |
var pauseCurrentLifeCycleTimer = function () { | |
var currentTimer = { | |
startTime: currentTimerStartTime, | |
nestedFlushStartTime: performanceNow$1(), | |
debugID: currentTimerDebugID, | |
timerType: currentTimerType | |
}; | |
lifeCycleTimerStack.push(currentTimer); | |
currentTimerStartTime = 0; | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = null; | |
currentTimerType = null; | |
}; | |
var resumeCurrentLifeCycleTimer = function () { | |
var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(), | |
startTime = _lifeCycleTimerStack$.startTime, | |
nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime, | |
debugID = _lifeCycleTimerStack$.debugID, | |
timerType = _lifeCycleTimerStack$.timerType; | |
var nestedFlushDuration = performanceNow$1() - nestedFlushStartTime; | |
currentTimerStartTime = startTime; | |
currentTimerNestedFlushDuration += nestedFlushDuration; | |
currentTimerDebugID = debugID; | |
currentTimerType = timerType; | |
}; | |
var lastMarkTimeStamp = 0; | |
var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; | |
var shouldMark = function (debugID) { | |
if (!isProfiling || !canUsePerformanceMeasure) { | |
return false; | |
} | |
var element = ReactComponentTreeHook.getElement(debugID); | |
if (element == null || typeof element !== 'object') { | |
return false; | |
} | |
var isHostElement = typeof element.type === 'string'; | |
if (isHostElement) { | |
return false; | |
} | |
return true; | |
}; | |
var markBegin = function (debugID, markType) { | |
if (!shouldMark(debugID)) { | |
return; | |
} | |
var markName = debugID + '::' + markType; | |
lastMarkTimeStamp = performanceNow$1(); | |
performance.mark(markName); | |
}; | |
var markEnd = function (debugID, markType) { | |
if (!shouldMark(debugID)) { | |
return; | |
} | |
var markName = debugID + '::' + markType; | |
var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown'; | |
// Chrome has an issue of dropping markers recorded too fast: | |
// https://bugs.chromium.org/p/chromium/issues/detail?id=640652 | |
// To work around this, we will not report very small measurements. | |
// I determined the magic number by tweaking it back and forth. | |
// 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe. | |
// When the bug is fixed, we can `measure()` unconditionally if we want to. | |
var timeStamp = performanceNow$1(); | |
if (timeStamp - lastMarkTimeStamp > 0.1) { | |
var measurementName = displayName + ' [' + markType + ']'; | |
performance.measure(measurementName, markName); | |
} | |
performance.clearMarks(markName); | |
performance.clearMeasures(measurementName); | |
}; | |
ReactDebugTool$1 = { | |
addHook: function (hook) { | |
hooks.push(hook); | |
}, | |
removeHook: function (hook) { | |
for (var i = 0; i < hooks.length; i++) { | |
if (hooks[i] === hook) { | |
hooks.splice(i, 1); | |
i--; | |
} | |
} | |
}, | |
isProfiling: function () { | |
return isProfiling; | |
}, | |
beginProfiling: function () { | |
if (isProfiling) { | |
return; | |
} | |
isProfiling = true; | |
flushHistory.length = 0; | |
resetMeasurements(); | |
ReactDebugTool$1.addHook(ReactHostOperationHistoryHook); | |
}, | |
endProfiling: function () { | |
if (!isProfiling) { | |
return; | |
} | |
isProfiling = false; | |
resetMeasurements(); | |
ReactDebugTool$1.removeHook(ReactHostOperationHistoryHook); | |
}, | |
getFlushHistory: function () { | |
return flushHistory; | |
}, | |
onBeginFlush: function () { | |
currentFlushNesting++; | |
resetMeasurements(); | |
pauseCurrentLifeCycleTimer(); | |
emitEvent('onBeginFlush'); | |
}, | |
onEndFlush: function () { | |
resetMeasurements(); | |
currentFlushNesting--; | |
resumeCurrentLifeCycleTimer(); | |
emitEvent('onEndFlush'); | |
}, | |
onBeginLifeCycleTimer: function (debugID, timerType) { | |
checkDebugID(debugID); | |
emitEvent('onBeginLifeCycleTimer', debugID, timerType); | |
markBegin(debugID, timerType); | |
beginLifeCycleTimer(debugID, timerType); | |
}, | |
onEndLifeCycleTimer: function (debugID, timerType) { | |
checkDebugID(debugID); | |
endLifeCycleTimer(debugID, timerType); | |
markEnd(debugID, timerType); | |
emitEvent('onEndLifeCycleTimer', debugID, timerType); | |
}, | |
onBeginProcessingChildContext: function () { | |
emitEvent('onBeginProcessingChildContext'); | |
}, | |
onEndProcessingChildContext: function () { | |
emitEvent('onEndProcessingChildContext'); | |
}, | |
onHostOperation: function (operation) { | |
checkDebugID(operation.instanceID); | |
emitEvent('onHostOperation', operation); | |
}, | |
onSetState: function () { | |
emitEvent('onSetState'); | |
}, | |
onSetChildren: function (debugID, childDebugIDs) { | |
checkDebugID(debugID); | |
childDebugIDs.forEach(checkDebugID); | |
emitEvent('onSetChildren', debugID, childDebugIDs); | |
}, | |
onBeforeMountComponent: function (debugID, element, parentDebugID) { | |
checkDebugID(debugID); | |
checkDebugID(parentDebugID, true); | |
emitEvent('onBeforeMountComponent', debugID, element, parentDebugID); | |
markBegin(debugID, 'mount'); | |
}, | |
onMountComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'mount'); | |
emitEvent('onMountComponent', debugID); | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
checkDebugID(debugID); | |
emitEvent('onBeforeUpdateComponent', debugID, element); | |
markBegin(debugID, 'update'); | |
}, | |
onUpdateComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'update'); | |
emitEvent('onUpdateComponent', debugID); | |
}, | |
onBeforeUnmountComponent: function (debugID) { | |
checkDebugID(debugID); | |
emitEvent('onBeforeUnmountComponent', debugID); | |
markBegin(debugID, 'unmount'); | |
}, | |
onUnmountComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'unmount'); | |
emitEvent('onUnmountComponent', debugID); | |
}, | |
onTestEvent: function () { | |
emitEvent('onTestEvent'); | |
} | |
}; | |
ReactDebugTool$1.addHook(ReactInvalidSetStateWarningHook); | |
ReactDebugTool$1.addHook(ReactComponentTreeHook); | |
var url = ExecutionEnvironment$12.canUseDOM && window.location.href || ''; | |
if (/[?&]react_perf\b/.test(url)) { | |
ReactDebugTool$1.beginProfiling(); | |
} | |
} | |
var ReactDebugTool_1 = ReactDebugTool$1; | |
// Trust the developer to only use ReactInstrumentation with a __DEV__ check | |
var debugTool = null; | |
if (__DEV__) { | |
var ReactDebugTool = ReactDebugTool_1; | |
debugTool = ReactDebugTool; | |
} | |
var ReactInstrumentation$2 = { debugTool: debugTool }; | |
var DOMLazyTree = DOMLazyTree_1; | |
var Danger = Danger_1; | |
var ReactDOMComponentTree$9 = ReactDOMComponentTree_1; | |
var ReactInstrumentation$1 = ReactInstrumentation$2; | |
var createMicrosoftUnsafeLocalFunction = createMicrosoftUnsafeLocalFunction_1; | |
var setInnerHTML = setInnerHTML_1; | |
var setTextContent = setTextContent_1; | |
function getNodeAfter(parentNode, node) { | |
// Special case for text components, which return [open, close] comments | |
// from getHostNode. | |
if (Array.isArray(node)) { | |
node = node[1]; | |
} | |
return node ? node.nextSibling : parentNode.firstChild; | |
} | |
/** | |
* Inserts `childNode` as a child of `parentNode` at the `index`. | |
* | |
* @param {DOMElement} parentNode Parent node in which to insert. | |
* @param {DOMElement} childNode Child node to insert. | |
* @param {number} index Index at which to insert the child. | |
* @internal | |
*/ | |
var insertChildAt = createMicrosoftUnsafeLocalFunction(function (parentNode, childNode, referenceNode) { | |
// We rely exclusively on `insertBefore(node, null)` instead of also using | |
// `appendChild(node)`. (Using `undefined` is not allowed by all browsers so | |
// we are careful to use `null`.) | |
parentNode.insertBefore(childNode, referenceNode); | |
}); | |
function insertLazyTreeChildAt(parentNode, childTree, referenceNode) { | |
DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode); | |
} | |
function moveChild(parentNode, childNode, referenceNode) { | |
if (Array.isArray(childNode)) { | |
moveDelimitedText(parentNode, childNode[0], childNode[1], referenceNode); | |
} else { | |
insertChildAt(parentNode, childNode, referenceNode); | |
} | |
} | |
function removeChild(parentNode, childNode) { | |
if (Array.isArray(childNode)) { | |
var closingComment = childNode[1]; | |
childNode = childNode[0]; | |
removeDelimitedText(parentNode, childNode, closingComment); | |
parentNode.removeChild(closingComment); | |
} | |
parentNode.removeChild(childNode); | |
} | |
function moveDelimitedText(parentNode, openingComment, closingComment, referenceNode) { | |
var node = openingComment; | |
while (true) { | |
var nextNode = node.nextSibling; | |
insertChildAt(parentNode, node, referenceNode); | |
if (node === closingComment) { | |
break; | |
} | |
node = nextNode; | |
} | |
} | |
function removeDelimitedText(parentNode, startNode, closingComment) { | |
while (true) { | |
var node = startNode.nextSibling; | |
if (node === closingComment) { | |
// The closing comment is removed by ReactMultiChild. | |
break; | |
} else { | |
parentNode.removeChild(node); | |
} | |
} | |
} | |
function replaceDelimitedText(openingComment, closingComment, stringText) { | |
var parentNode = openingComment.parentNode; | |
var nodeAfterComment = openingComment.nextSibling; | |
if (nodeAfterComment === closingComment) { | |
// There are no text nodes between the opening and closing comments; insert | |
// a new one if stringText isn't empty. | |
if (stringText) { | |
insertChildAt(parentNode, document.createTextNode(stringText), nodeAfterComment); | |
} | |
} else { | |
if (stringText) { | |
// Set the text content of the first node after the opening comment, and | |
// remove all following nodes up until the closing comment. | |
setTextContent(nodeAfterComment, stringText); | |
removeDelimitedText(parentNode, nodeAfterComment, closingComment); | |
} else { | |
removeDelimitedText(parentNode, openingComment, closingComment); | |
} | |
} | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$9.getInstanceFromNode(openingComment)._debugID, | |
type: 'replace text', | |
payload: stringText | |
}); | |
} | |
} | |
var dangerouslyReplaceNodeWithMarkup = Danger.dangerouslyReplaceNodeWithMarkup; | |
if (__DEV__) { | |
dangerouslyReplaceNodeWithMarkup = function (oldChild, markup, prevInstance) { | |
Danger.dangerouslyReplaceNodeWithMarkup(oldChild, markup); | |
if (prevInstance._debugID !== 0) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: prevInstance._debugID, | |
type: 'replace with', | |
payload: markup.toString() | |
}); | |
} else { | |
var nextInstance = ReactDOMComponentTree$9.getInstanceFromNode(markup.node); | |
if (nextInstance._debugID !== 0) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: nextInstance._debugID, | |
type: 'mount', | |
payload: markup.toString() | |
}); | |
} | |
} | |
}; | |
} | |
/** | |
* Operations for updating with DOM children. | |
*/ | |
var DOMChildrenOperations$1 = { | |
dangerouslyReplaceNodeWithMarkup: dangerouslyReplaceNodeWithMarkup, | |
replaceDelimitedText: replaceDelimitedText, | |
/** | |
* Updates a component's children by processing a series of updates. The | |
* update configurations are each expected to have a `parentNode` property. | |
* | |
* @param {array<object>} updates List of update configurations. | |
* @internal | |
*/ | |
processUpdates: function (parentNode, updates) { | |
if (__DEV__) { | |
var parentNodeDebugID = ReactDOMComponentTree$9.getInstanceFromNode(parentNode)._debugID; | |
} | |
for (var k = 0; k < updates.length; k++) { | |
var update = updates[k]; | |
switch (update.type) { | |
case 'INSERT_MARKUP': | |
insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode)); | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: parentNodeDebugID, | |
type: 'insert child', | |
payload: { toIndex: update.toIndex, content: update.content.toString() } | |
}); | |
} | |
break; | |
case 'MOVE_EXISTING': | |
moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode)); | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: parentNodeDebugID, | |
type: 'move child', | |
payload: { fromIndex: update.fromIndex, toIndex: update.toIndex } | |
}); | |
} | |
break; | |
case 'SET_MARKUP': | |
setInnerHTML(parentNode, update.content); | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: parentNodeDebugID, | |
type: 'replace children', | |
payload: update.content.toString() | |
}); | |
} | |
break; | |
case 'TEXT_CONTENT': | |
setTextContent(parentNode, update.content); | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: parentNodeDebugID, | |
type: 'replace text', | |
payload: update.content.toString() | |
}); | |
} | |
break; | |
case 'REMOVE_NODE': | |
removeChild(parentNode, update.fromNode); | |
if (__DEV__) { | |
ReactInstrumentation$1.debugTool.onHostOperation({ | |
instanceID: parentNodeDebugID, | |
type: 'remove child', | |
payload: { fromIndex: update.fromIndex } | |
}); | |
} | |
break; | |
} | |
} | |
} | |
}; | |
var DOMChildrenOperations_1 = DOMChildrenOperations$1; | |
var DOMChildrenOperations$2 = DOMChildrenOperations_1; | |
var ReactDOMComponentTree$10 = ReactDOMComponentTree_1; | |
/** | |
* Operations used to process updates to DOM nodes. | |
*/ | |
var ReactDOMIDOperations$1 = { | |
/** | |
* Updates a component's children by processing a series of updates. | |
* | |
* @param {array<object>} updates List of update configurations. | |
* @internal | |
*/ | |
dangerouslyProcessChildrenUpdates: function (parentInst, updates) { | |
var node = ReactDOMComponentTree$10.getNodeFromInstance(parentInst); | |
DOMChildrenOperations$2.processUpdates(node, updates); | |
} | |
}; | |
var ReactDOMIDOperations_1 = ReactDOMIDOperations$1; | |
var DOMChildrenOperations = DOMChildrenOperations_1; | |
var ReactDOMIDOperations = ReactDOMIDOperations_1; | |
/** | |
* Abstracts away all functionality of the reconciler that requires knowledge of | |
* the browser context. TODO: These callers should be refactored to avoid the | |
* need for this injection. | |
*/ | |
var ReactComponentBrowserEnvironment$1 = { | |
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates, | |
replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup | |
}; | |
var ReactComponentBrowserEnvironment_1 = ReactComponentBrowserEnvironment$1; | |
var ReactDOMComponentTree$12 = ReactDOMComponentTree_1; | |
var focusNode$2 = focusNode; | |
var AutoFocusUtils$1 = { | |
focusDOMComponent: function () { | |
focusNode$2(ReactDOMComponentTree$12.getNodeFromInstance(this)); | |
} | |
}; | |
var AutoFocusUtils_1 = AutoFocusUtils$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule CSSProperty | |
*/ | |
/** | |
* CSS properties which accept numbers but are not in units of "px". | |
*/ | |
var isUnitlessNumber = { | |
animationIterationCount: true, | |
borderImageOutset: true, | |
borderImageSlice: true, | |
borderImageWidth: true, | |
boxFlex: true, | |
boxFlexGroup: true, | |
boxOrdinalGroup: true, | |
columnCount: true, | |
flex: true, | |
flexGrow: true, | |
flexPositive: true, | |
flexShrink: true, | |
flexNegative: true, | |
flexOrder: true, | |
gridRow: true, | |
gridColumn: true, | |
fontWeight: true, | |
lineClamp: true, | |
lineHeight: true, | |
opacity: true, | |
order: true, | |
orphans: true, | |
tabSize: true, | |
widows: true, | |
zIndex: true, | |
zoom: true, | |
// SVG-related properties | |
fillOpacity: true, | |
floodOpacity: true, | |
stopOpacity: true, | |
strokeDasharray: true, | |
strokeDashoffset: true, | |
strokeMiterlimit: true, | |
strokeOpacity: true, | |
strokeWidth: true | |
}; | |
/** | |
* @param {string} prefix vendor-specific prefix, eg: Webkit | |
* @param {string} key style name, eg: transitionDuration | |
* @return {string} style name prefixed with `prefix`, properly camelCased, eg: | |
* WebkitTransitionDuration | |
*/ | |
function prefixKey(prefix, key) { | |
return prefix + key.charAt(0).toUpperCase() + key.substring(1); | |
} | |
/** | |
* Support style names that may come passed in prefixed by adding permutations | |
* of vendor prefixes. | |
*/ | |
var prefixes = ['Webkit', 'ms', 'Moz', 'O']; | |
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an | |
// infinite loop, because it iterates over the newly added props too. | |
Object.keys(isUnitlessNumber).forEach(function (prop) { | |
prefixes.forEach(function (prefix) { | |
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; | |
}); | |
}); | |
/** | |
* Most style properties can be unset by doing .style[prop] = '' but IE8 | |
* doesn't like doing that with shorthand properties so for the properties that | |
* IE8 breaks on, which are listed here, we instead unset each of the | |
* individual properties. See http://bugs.jquery.com/ticket/12385. | |
* The 4-value 'clock' properties like margin, padding, border-width seem to | |
* behave without any problems. Curiously, list-style works too without any | |
* special prodding. | |
*/ | |
var shorthandPropertyExpansions = { | |
background: { | |
backgroundAttachment: true, | |
backgroundColor: true, | |
backgroundImage: true, | |
backgroundPositionX: true, | |
backgroundPositionY: true, | |
backgroundRepeat: true | |
}, | |
backgroundPosition: { | |
backgroundPositionX: true, | |
backgroundPositionY: true | |
}, | |
border: { | |
borderWidth: true, | |
borderStyle: true, | |
borderColor: true | |
}, | |
borderBottom: { | |
borderBottomWidth: true, | |
borderBottomStyle: true, | |
borderBottomColor: true | |
}, | |
borderLeft: { | |
borderLeftWidth: true, | |
borderLeftStyle: true, | |
borderLeftColor: true | |
}, | |
borderRight: { | |
borderRightWidth: true, | |
borderRightStyle: true, | |
borderRightColor: true | |
}, | |
borderTop: { | |
borderTopWidth: true, | |
borderTopStyle: true, | |
borderTopColor: true | |
}, | |
font: { | |
fontStyle: true, | |
fontVariant: true, | |
fontWeight: true, | |
fontSize: true, | |
lineHeight: true, | |
fontFamily: true | |
}, | |
outline: { | |
outlineWidth: true, | |
outlineStyle: true, | |
outlineColor: true | |
} | |
}; | |
var CSSProperty$1 = { | |
isUnitlessNumber: isUnitlessNumber, | |
shorthandPropertyExpansions: shorthandPropertyExpansions | |
}; | |
var CSSProperty_1 = CSSProperty$1; | |
var CSSProperty$2 = CSSProperty_1; | |
var isUnitlessNumber$1 = CSSProperty$2.isUnitlessNumber; | |
/** | |
* 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`. | |
* @param {ReactDOMComponent} component | |
* @return {string} Normalized style value with dimensions applied. | |
*/ | |
function dangerousStyleValue$1(name, value, component) { | |
// 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 (typeof value === 'number' && value !== 0 && !(isUnitlessNumber$1.hasOwnProperty(name) && isUnitlessNumber$1[name])) { | |
return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers | |
} | |
return ('' + value).trim(); | |
} | |
var dangerousStyleValue_1 = dangerousStyleValue$1; | |
if (__DEV__) { | |
var getComponentName$3 = getComponentName_1; | |
var _require$3 = ReactComponentTreeHook_1, | |
getStackAddendumByWorkInProgressFiber = _require$3.getStackAddendumByWorkInProgressFiber; | |
} | |
function getCurrentFiberOwnerName$1() { | |
if (__DEV__) { | |
var fiber = ReactDebugCurrentFiber.current; | |
if (fiber === null) { | |
return null; | |
} | |
if (fiber._debugOwner != null) { | |
return getComponentName$3(fiber._debugOwner); | |
} | |
} | |
return null; | |
} | |
function getCurrentFiberStackAddendum() { | |
if (__DEV__) { | |
var fiber = ReactDebugCurrentFiber.current; | |
if (fiber === null) { | |
return null; | |
} | |
// Safe because if current fiber exists, we are reconciling, | |
// and it is guaranteed to be the work-in-progress version. | |
return getStackAddendumByWorkInProgressFiber(fiber); | |
} | |
return null; | |
} | |
var ReactDebugCurrentFiber = { | |
current: null, | |
phase: null, | |
getCurrentFiberOwnerName: getCurrentFiberOwnerName$1, | |
getCurrentFiberStackAddendum: getCurrentFiberStackAddendum | |
}; | |
var ReactDebugCurrentFiber_1 = ReactDebugCurrentFiber; | |
var CSSProperty = CSSProperty_1; | |
var ExecutionEnvironment$13 = ExecutionEnvironment; | |
var camelizeStyleName$1 = camelizeStyleName; | |
var dangerousStyleValue = dangerousStyleValue_1; | |
var getComponentName$2 = getComponentName_1; | |
var hyphenateStyleName$1 = hyphenateStyleName; | |
var memoizeStringOnly$1 = memoizeStringOnly; | |
var warning$8 = warning; | |
if (__DEV__) { | |
var _require$2 = ReactDebugCurrentFiber_1, | |
getCurrentFiberOwnerName = _require$2.getCurrentFiberOwnerName; | |
} | |
var processStyleName = memoizeStringOnly$1(function (styleName) { | |
return hyphenateStyleName$1(styleName); | |
}); | |
var hasShorthandPropertyBug = false; | |
var styleFloatAccessor = 'cssFloat'; | |
if (ExecutionEnvironment$13.canUseDOM) { | |
var tempStyle = document.createElement('div').style; | |
try { | |
// IE8 throws "Invalid argument." if resetting shorthand style properties. | |
tempStyle.font = ''; | |
} catch (e) { | |
hasShorthandPropertyBug = true; | |
} | |
// IE8 only supports accessing cssFloat (standard) as styleFloat | |
if (document.documentElement.style.cssFloat === undefined) { | |
styleFloatAccessor = 'styleFloat'; | |
} | |
} | |
if (__DEV__) { | |
// 'msTransform' is correct, but the other prefixes should be capitalized | |
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; | |
// style values shouldn't contain a semicolon | |
var badStyleValueWithSemicolonPattern = /;\s*$/; | |
var warnedStyleNames = {}; | |
var warnedStyleValues = {}; | |
var warnedForNaNValue = false; | |
var warnHyphenatedStyleName = function (name, owner) { | |
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
return; | |
} | |
warnedStyleNames[name] = true; | |
warning$8(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName$1(name), checkRenderMessage(owner)); | |
}; | |
var warnBadVendoredStyleName = function (name, owner) { | |
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
return; | |
} | |
warnedStyleNames[name] = true; | |
warning$8(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)); | |
}; | |
var warnStyleValueWithSemicolon = function (name, value, owner) { | |
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { | |
return; | |
} | |
warnedStyleValues[value] = true; | |
warning$8(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')); | |
}; | |
var warnStyleValueIsNaN = function (name, value, owner) { | |
if (warnedForNaNValue) { | |
return; | |
} | |
warnedForNaNValue = true; | |
warning$8(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)); | |
}; | |
var checkRenderMessage = function (owner) { | |
var ownerName; | |
if (owner != null) { | |
// Stack passes the owner manually all the way to CSSPropertyOperations. | |
ownerName = getComponentName$2(owner); | |
} else { | |
// Fiber doesn't pass it but uses ReactDebugCurrentFiber to track it. | |
// It is only enabled in development and tracks host components too. | |
ownerName = getCurrentFiberOwnerName(); | |
// TODO: also report the stack. | |
} | |
if (ownerName) { | |
return '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
return ''; | |
}; | |
/** | |
* @param {string} name | |
* @param {*} value | |
* @param {ReactDOMComponent} component | |
*/ | |
var warnValidStyle = function (name, value, component) { | |
var owner; | |
if (component) { | |
owner = component._currentElement._owner; | |
} | |
if (name.indexOf('-') > -1) { | |
warnHyphenatedStyleName(name, owner); | |
} else if (badVendoredStyleNamePattern.test(name)) { | |
warnBadVendoredStyleName(name, owner); | |
} else if (badStyleValueWithSemicolonPattern.test(value)) { | |
warnStyleValueWithSemicolon(name, value, owner); | |
} | |
if (typeof value === 'number' && isNaN(value)) { | |
warnStyleValueIsNaN(name, value, owner); | |
} | |
}; | |
} | |
/** | |
* Operations for dealing with CSS properties. | |
*/ | |
var CSSPropertyOperations$1 = { | |
/** | |
* Serializes a mapping of style properties for use as inline styles: | |
* | |
* > createMarkupForStyles({width: '200px', height: 0}) | |
* "width:200px;height:0;" | |
* | |
* Undefined values are ignored so that declarative programming is easier. | |
* The result should be HTML-escaped before insertion into the DOM. | |
* | |
* @param {object} styles | |
* @param {ReactDOMComponent} component | |
* @return {?string} | |
*/ | |
createMarkupForStyles: function (styles, component) { | |
var serialized = ''; | |
for (var styleName in styles) { | |
if (!styles.hasOwnProperty(styleName)) { | |
continue; | |
} | |
var styleValue = styles[styleName]; | |
if (__DEV__) { | |
warnValidStyle(styleName, styleValue, component); | |
} | |
if (styleValue != null) { | |
serialized += processStyleName(styleName) + ':'; | |
serialized += dangerousStyleValue(styleName, styleValue, component) + ';'; | |
} | |
} | |
return serialized || null; | |
}, | |
/** | |
* Sets the value for multiple styles on a node. If a value is specified as | |
* '' (empty string), the corresponding style property will be unset. | |
* | |
* @param {DOMElement} node | |
* @param {object} styles | |
* @param {ReactDOMComponent} component | |
*/ | |
setValueForStyles: function (node, styles, component) { | |
var style = node.style; | |
for (var styleName in styles) { | |
if (!styles.hasOwnProperty(styleName)) { | |
continue; | |
} | |
if (__DEV__) { | |
warnValidStyle(styleName, styles[styleName], component); | |
} | |
var styleValue = dangerousStyleValue(styleName, styles[styleName], component); | |
if (styleName === 'float' || styleName === 'cssFloat') { | |
styleName = styleFloatAccessor; | |
} | |
if (styleValue) { | |
style[styleName] = styleValue; | |
} else { | |
var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName]; | |
if (expansion) { | |
// Shorthand property that IE8 won't like unsetting, so unset each | |
// component to placate it | |
for (var individualStyleName in expansion) { | |
style[individualStyleName] = ''; | |
} | |
} else { | |
style[styleName] = ''; | |
} | |
} | |
} | |
} | |
}; | |
var CSSPropertyOperations_1 = CSSPropertyOperations$1; | |
var escapeTextContentForBrowser$3 = escapeTextContentForBrowser_1; | |
/** | |
* Escapes attribute value to prevent scripting attacks. | |
* | |
* @param {*} value Value to escape. | |
* @return {string} An escaped string. | |
*/ | |
function quoteAttributeValueForBrowser$1(value) { | |
return '"' + escapeTextContentForBrowser$3(value) + '"'; | |
} | |
var quoteAttributeValueForBrowser_1 = quoteAttributeValueForBrowser$1; | |
var DOMProperty$5 = DOMProperty_1; | |
var ReactDOMComponentTree$13 = ReactDOMComponentTree_1; | |
var ReactInstrumentation$5 = ReactInstrumentation$2; | |
var quoteAttributeValueForBrowser = quoteAttributeValueForBrowser_1; | |
var warning$9 = warning; | |
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty$5.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty$5.ATTRIBUTE_NAME_CHAR + ']*$'); | |
var illegalAttributeNameCache = {}; | |
var validatedAttributeNameCache = {}; | |
function isAttributeNameSafe(attributeName) { | |
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { | |
return true; | |
} | |
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { | |
return false; | |
} | |
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { | |
validatedAttributeNameCache[attributeName] = true; | |
return true; | |
} | |
illegalAttributeNameCache[attributeName] = true; | |
warning$9(false, 'Invalid attribute name: `%s`', attributeName); | |
return false; | |
} | |
function shouldIgnoreValue(propertyInfo, value) { | |
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false; | |
} | |
/** | |
* Operations for dealing with DOM properties. | |
*/ | |
var DOMPropertyOperations$1 = { | |
/** | |
* Creates markup for the ID property. | |
* | |
* @param {string} id Unescaped ID. | |
* @return {string} Markup string. | |
*/ | |
createMarkupForID: function (id) { | |
return DOMProperty$5.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id); | |
}, | |
setAttributeForID: function (node, id) { | |
node.setAttribute(DOMProperty$5.ID_ATTRIBUTE_NAME, id); | |
}, | |
createMarkupForRoot: function () { | |
return DOMProperty$5.ROOT_ATTRIBUTE_NAME + '=""'; | |
}, | |
setAttributeForRoot: function (node) { | |
node.setAttribute(DOMProperty$5.ROOT_ATTRIBUTE_NAME, ''); | |
}, | |
/** | |
* Creates markup for a property. | |
* | |
* @param {string} name | |
* @param {*} value | |
* @return {?string} Markup string, or null if the property was invalid. | |
*/ | |
createMarkupForProperty: function (name, value) { | |
var propertyInfo = DOMProperty$5.properties.hasOwnProperty(name) ? DOMProperty$5.properties[name] : null; | |
if (propertyInfo) { | |
if (shouldIgnoreValue(propertyInfo, value)) { | |
return ''; | |
} | |
var attributeName = propertyInfo.attributeName; | |
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | |
return attributeName + '=""'; | |
} | |
return attributeName + '=' + quoteAttributeValueForBrowser(value); | |
} else if (DOMProperty$5.isCustomAttribute(name)) { | |
if (value == null) { | |
return ''; | |
} | |
return name + '=' + quoteAttributeValueForBrowser(value); | |
} | |
return null; | |
}, | |
/** | |
* Creates markup for a custom property. | |
* | |
* @param {string} name | |
* @param {*} value | |
* @return {string} Markup string, or empty string if the property was invalid. | |
*/ | |
createMarkupForCustomAttribute: function (name, value) { | |
if (!isAttributeNameSafe(name) || value == null) { | |
return ''; | |
} | |
return name + '=' + quoteAttributeValueForBrowser(value); | |
}, | |
/** | |
* Sets the value for a property on a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
* @param {*} value | |
*/ | |
setValueForProperty: function (node, name, value) { | |
var propertyInfo = DOMProperty$5.properties.hasOwnProperty(name) ? DOMProperty$5.properties[name] : null; | |
if (propertyInfo) { | |
var mutationMethod = propertyInfo.mutationMethod; | |
if (mutationMethod) { | |
mutationMethod(node, value); | |
} else if (shouldIgnoreValue(propertyInfo, value)) { | |
DOMPropertyOperations$1.deleteValueForProperty(node, name); | |
return; | |
} else if (propertyInfo.mustUseProperty) { | |
// Contrary to `setAttribute`, object properties are properly | |
// `toString`ed by IE8/9. | |
node[propertyInfo.propertyName] = value; | |
} else { | |
var attributeName = propertyInfo.attributeName; | |
var namespace = propertyInfo.attributeNamespace; | |
// `setAttribute` with objects becomes only `[object]` in IE8/9, | |
// ('' + value) makes it output the correct toString()-value. | |
if (namespace) { | |
node.setAttributeNS(namespace, attributeName, '' + value); | |
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | |
node.setAttribute(attributeName, ''); | |
} else { | |
node.setAttribute(attributeName, '' + value); | |
} | |
} | |
} else if (DOMProperty$5.isCustomAttribute(name)) { | |
DOMPropertyOperations$1.setValueForAttribute(node, name, value); | |
return; | |
} | |
if (__DEV__) { | |
var payload = {}; | |
payload[name] = value; | |
ReactInstrumentation$5.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$13.getInstanceFromNode(node)._debugID, | |
type: 'update attribute', | |
payload: payload | |
}); | |
} | |
}, | |
setValueForAttribute: function (node, name, value) { | |
if (!isAttributeNameSafe(name)) { | |
return; | |
} | |
if (value == null) { | |
node.removeAttribute(name); | |
} else { | |
node.setAttribute(name, '' + value); | |
} | |
if (__DEV__) { | |
var payload = {}; | |
payload[name] = value; | |
ReactInstrumentation$5.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$13.getInstanceFromNode(node)._debugID, | |
type: 'update attribute', | |
payload: payload | |
}); | |
} | |
}, | |
/** | |
* Deletes an attributes from a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
*/ | |
deleteValueForAttribute: function (node, name) { | |
node.removeAttribute(name); | |
if (__DEV__) { | |
ReactInstrumentation$5.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$13.getInstanceFromNode(node)._debugID, | |
type: 'remove attribute', | |
payload: name | |
}); | |
} | |
}, | |
/** | |
* Deletes the value for a property on a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
*/ | |
deleteValueForProperty: function (node, name) { | |
var propertyInfo = DOMProperty$5.properties.hasOwnProperty(name) ? DOMProperty$5.properties[name] : null; | |
if (propertyInfo) { | |
var mutationMethod = propertyInfo.mutationMethod; | |
if (mutationMethod) { | |
mutationMethod(node, undefined); | |
} else if (propertyInfo.mustUseProperty) { | |
var propName = propertyInfo.propertyName; | |
if (propertyInfo.hasBooleanValue) { | |
node[propName] = false; | |
} else { | |
node[propName] = ''; | |
} | |
} else { | |
node.removeAttribute(propertyInfo.attributeName); | |
} | |
} else if (DOMProperty$5.isCustomAttribute(name)) { | |
node.removeAttribute(name); | |
} | |
if (__DEV__) { | |
ReactInstrumentation$5.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$13.getInstanceFromNode(node)._debugID, | |
type: 'remove attribute', | |
payload: name | |
}); | |
} | |
} | |
}; | |
var DOMPropertyOperations_1 = DOMPropertyOperations$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule ReactPropTypesSecret | |
*/ | |
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | |
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; | |
var React$1 = React; | |
var ReactPropTypesSecret = ReactPropTypesSecret_1; | |
var warning$11 = warning; | |
var hasReadOnlyValue = { | |
'button': true, | |
'checkbox': true, | |
'image': true, | |
'hidden': true, | |
'radio': true, | |
'reset': true, | |
'submit': true | |
}; | |
var propTypes = { | |
value: function (props, propName, componentName) { | |
if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) { | |
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) { | |
if (!props[propName] || props.onChange || props.readOnly || props.disabled) { | |
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`.'); | |
}, | |
onChange: React$1.PropTypes.func | |
}; | |
var loggedTypeFailures = {}; | |
function getDeclarationErrorAddendum$1(ownerName) { | |
if (ownerName) { | |
return '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
return ''; | |
} | |
/** | |
* Provide a linked `value` attribute for controlled forms. You should not use | |
* this outside of the ReactDOM controlled form components. | |
*/ | |
var ReactControlledValuePropTypes$1 = { | |
checkPropTypes: function (tagName, props, ownerName) { | |
for (var propName in propTypes) { | |
if (propTypes.hasOwnProperty(propName)) { | |
var error = propTypes[propName](props, propName, tagName, 'prop', null, ReactPropTypesSecret); | |
} | |
if (error instanceof Error && !(error.message in loggedTypeFailures)) { | |
// Only monitor this failure once because there tends to be a lot of the | |
// same error. | |
loggedTypeFailures[error.message] = true; | |
var addendum = getDeclarationErrorAddendum$1(ownerName); | |
warning$11(false, 'Failed form propType: %s%s', error.message, addendum); | |
} | |
} | |
} | |
}; | |
var ReactControlledValuePropTypes_1 = ReactControlledValuePropTypes$1; | |
var DOMPropertyOperations$2 = DOMPropertyOperations_1; | |
var ReactControlledValuePropTypes = ReactControlledValuePropTypes_1; | |
var ReactDOMComponentTree$14 = ReactDOMComponentTree_1; | |
var invariant$13 = invariant; | |
var warning$10 = warning; | |
var didWarnValueDefaultValue = false; | |
var didWarnCheckedDefaultChecked = false; | |
var didWarnControlledToUncontrolled = false; | |
var didWarnUncontrolledToControlled = false; | |
function isControlled(props) { | |
var usesChecked = props.type === 'checkbox' || props.type === 'radio'; | |
return usesChecked ? props.checked != null : props.value != null; | |
} | |
/** | |
* Implements an <input> host component that allows setting these optional | |
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`. | |
* | |
* If `checked` or `value` are not supplied (or null/undefined), user actions | |
* that affect the checked state or value will trigger updates to the element. | |
* | |
* If they are supplied (and not null/undefined), the rendered element will not | |
* trigger updates to the element. Instead, the props must change in order for | |
* the rendered element to be updated. | |
* | |
* The rendered element will be initialized as unchecked (or `defaultChecked`) | |
* with an empty value (or `defaultValue`). | |
* | |
* @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | |
*/ | |
var ReactDOMInput$1 = { | |
getHostProps: function (inst, props) { | |
var value = props.value; | |
var checked = props.checked; | |
var hostProps = Object.assign({ | |
// Make sure we set .type before any other properties (setting .value | |
// before .type means .value is lost in IE11 and below) | |
type: undefined, | |
// Make sure we set .step before .value (setting .value before .step | |
// means .value is rounded on mount, based upon step precision) | |
step: undefined, | |
// Make sure we set .min & .max before .value (to ensure proper order | |
// in corner cases such as min or max deriving from value, e.g. Issue #7170) | |
min: undefined, | |
max: undefined | |
}, props, { | |
defaultChecked: undefined, | |
defaultValue: undefined, | |
value: value != null ? value : inst._wrapperState.initialValue, | |
checked: checked != null ? checked : inst._wrapperState.initialChecked | |
}); | |
return hostProps; | |
}, | |
mountWrapper: function (inst, props) { | |
if (__DEV__) { | |
var owner = inst._currentElement._owner; | |
ReactControlledValuePropTypes.checkPropTypes('input', props, owner ? owner.getName() : null); | |
if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { | |
warning$10(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', owner && owner.getName() || 'A component', props.type); | |
didWarnCheckedDefaultChecked = true; | |
} | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { | |
warning$10(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', owner && owner.getName() || 'A component', props.type); | |
didWarnValueDefaultValue = true; | |
} | |
} | |
var defaultValue = props.defaultValue; | |
inst._wrapperState = { | |
initialChecked: props.checked != null ? props.checked : props.defaultChecked, | |
initialValue: props.value != null ? props.value : defaultValue, | |
listeners: null | |
}; | |
if (__DEV__) { | |
inst._wrapperState.controlled = isControlled(props); | |
} | |
}, | |
updateWrapper: function (inst) { | |
var props = inst._currentElement.props; | |
if (__DEV__) { | |
var controlled = isControlled(props); | |
var owner = inst._currentElement._owner; | |
if (!inst._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { | |
warning$10(false, '%s is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type); | |
didWarnUncontrolledToControlled = true; | |
} | |
if (inst._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { | |
warning$10(false, '%s is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type); | |
didWarnControlledToUncontrolled = true; | |
} | |
} | |
var checked = props.checked; | |
if (checked != null) { | |
DOMPropertyOperations$2.setValueForProperty(ReactDOMComponentTree$14.getNodeFromInstance(inst), 'checked', checked || false); | |
} | |
var node = ReactDOMComponentTree$14.getNodeFromInstance(inst); | |
var value = props.value; | |
if (value != null) { | |
// Cast `value` to a string to ensure the value is set correctly. While | |
// browsers typically do this as necessary, jsdom doesn't. | |
var newValue = '' + value; | |
// To avoid side effects (such as losing text selection), only set value if changed | |
if (newValue !== node.value) { | |
node.value = newValue; | |
} | |
} else { | |
if (props.value == null && props.defaultValue != null) { | |
// In Chrome, assigning defaultValue to certain input types triggers input validation. | |
// For number inputs, the display value loses trailing decimal points. For email inputs, | |
// Chrome raises "The specified value <x> is not a valid email address". | |
// | |
// Here we check to see if the defaultValue has actually changed, avoiding these problems | |
// when the user is inputting text | |
// | |
// https://github.com/facebook/react/issues/7253 | |
if (node.defaultValue !== '' + props.defaultValue) { | |
node.defaultValue = '' + props.defaultValue; | |
} | |
} | |
if (props.checked == null && props.defaultChecked != null) { | |
node.defaultChecked = !!props.defaultChecked; | |
} | |
} | |
}, | |
postMountWrapper: function (inst) { | |
var props = inst._currentElement.props; | |
// This is in postMount because we need access to the DOM node, which is not | |
// available until after the component has mounted. | |
var node = ReactDOMComponentTree$14.getNodeFromInstance(inst); | |
// Detach value from defaultValue. We won't do anything if we're working on | |
// submit or reset inputs as those values & defaultValues are linked. They | |
// are not resetable nodes so this operation doesn't matter and actually | |
// removes browser-default values (eg "Submit Query") when no value is | |
// provided. | |
switch (props.type) { | |
case 'submit': | |
case 'reset': | |
break; | |
case 'color': | |
case 'date': | |
case 'datetime': | |
case 'datetime-local': | |
case 'month': | |
case 'time': | |
case 'week': | |
// This fixes the no-show issue on iOS Safari and Android Chrome: | |
// https://github.com/facebook/react/issues/7233 | |
node.value = ''; | |
node.value = node.defaultValue; | |
break; | |
default: | |
node.value = node.value; | |
break; | |
} | |
// Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug | |
// this is needed to work around a chrome bug where setting defaultChecked | |
// will sometimes influence the value of checked (even after detachment). | |
// Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 | |
// We need to temporarily unset name to avoid disrupting radio button groups. | |
var name = node.name; | |
if (name !== '') { | |
node.name = ''; | |
} | |
node.defaultChecked = !node.defaultChecked; | |
node.defaultChecked = !node.defaultChecked; | |
if (name !== '') { | |
node.name = name; | |
} | |
}, | |
restoreControlledState: function (inst) { | |
if (inst._rootNodeID) { | |
// DOM component is still mounted; update | |
ReactDOMInput$1.updateWrapper(inst); | |
} | |
var props = inst._currentElement.props; | |
updateNamedCousins(inst, props); | |
} | |
}; | |
function updateNamedCousins(thisInstance, props) { | |
var name = props.name; | |
if (props.type === 'radio' && name != null) { | |
var rootNode = ReactDOMComponentTree$14.getNodeFromInstance(thisInstance); | |
var queryRoot = rootNode; | |
while (queryRoot.parentNode) { | |
queryRoot = queryRoot.parentNode; | |
} | |
// If `rootNode.form` was non-null, then we could try `form.elements`, | |
// but that sometimes behaves strangely in IE8. We could also try using | |
// `form.getElementsByName`, but that will only return direct children | |
// and won't include inputs that use the HTML5 `form=` attribute. Since | |
// the input might not even be in a form. It might not even be in the | |
// document. Let's just use the local `querySelectorAll` to ensure we don't | |
// miss anything. | |
var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); | |
for (var i = 0; i < group.length; i++) { | |
var otherNode = group[i]; | |
if (otherNode === rootNode || otherNode.form !== rootNode.form) { | |
continue; | |
} | |
// This will throw if radio buttons rendered by different copies of React | |
// and the same name are rendered into the same form (same as #1939). | |
// That's probably okay; we don't support it just as we don't support | |
// mixing React radio buttons with non-React ones. | |
var otherInstance = ReactDOMComponentTree$14.getInstanceFromNode(otherNode); | |
invariant$13(otherInstance, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.'); | |
// If this is a controlled radio button group, forcing the input that | |
// was previously checked to update will cause it to be come re-checked | |
// as appropriate. | |
if (otherInstance._rootNodeID) { | |
ReactDOMInput$1.updateWrapper(otherInstance); | |
} | |
} | |
} | |
} | |
var ReactDOMInput_1 = ReactDOMInput$1; | |
var ReactControlledValuePropTypes$2 = ReactControlledValuePropTypes_1; | |
var ReactDOMComponentTree$16 = ReactDOMComponentTree_1; | |
var warning$13 = warning; | |
var didWarnValueDefaultValue$1 = false; | |
function getDeclarationErrorAddendum$2(owner) { | |
if (owner) { | |
var name = owner.getName(); | |
if (name) { | |
return '\n\nCheck the render method of `' + name + '`.'; | |
} | |
} | |
return ''; | |
} | |
var valuePropNames = ['value', 'defaultValue']; | |
/** | |
* Validation function for `value` and `defaultValue`. | |
* @private | |
*/ | |
function checkSelectPropTypes(inst, props) { | |
var owner = inst._currentElement._owner; | |
ReactControlledValuePropTypes$2.checkPropTypes('select', props, owner ? owner.getName() : null); | |
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) { | |
warning$13(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum$2(owner)); | |
} else if (!props.multiple && isArray) { | |
warning$13(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum$2(owner)); | |
} | |
} | |
} | |
/** | |
* @param {ReactDOMComponent} inst | |
* @param {boolean} multiple | |
* @param {*} propValue A stringable (with `multiple`, a list of stringables). | |
* @private | |
*/ | |
function updateOptions(inst, multiple, propValue) { | |
var options = ReactDOMComponentTree$16.getNodeFromInstance(inst).options; | |
if (multiple) { | |
var selectedValue = {}; | |
for (var i = 0; i < propValue.length; i++) { | |
selectedValue['' + propValue[i]] = true; | |
} | |
for (var _i = 0; _i < options.length; _i++) { | |
var selected = selectedValue.hasOwnProperty(options[_i].value); | |
if (options[_i].selected !== selected) { | |
options[_i].selected = selected; | |
} | |
} | |
} else { | |
// Do not set `select.value` as exact behavior isn't consistent across all | |
// browsers for all cases. | |
var _selectedValue = '' + propValue; | |
for (var _i2 = 0; _i2 < options.length; _i2++) { | |
if (options[_i2].value === _selectedValue) { | |
options[_i2].selected = true; | |
return; | |
} | |
} | |
if (options.length) { | |
options[0].selected = true; | |
} | |
} | |
} | |
/** | |
* Implements a <select> host component that allows optionally setting the | |
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a | |
* stringable. If `multiple` is true, the prop must be an array of stringables. | |
* | |
* If `value` is not supplied (or null/undefined), user actions that change the | |
* selected option will trigger updates to the rendered options. | |
* | |
* If it is supplied (and not null/undefined), the rendered options will not | |
* update in response to user actions. Instead, the `value` prop must change in | |
* order for the rendered options to update. | |
* | |
* If `defaultValue` is provided, any options with the supplied values will be | |
* selected. | |
*/ | |
var ReactDOMSelect$2 = { | |
getHostProps: function (inst, props) { | |
return Object.assign({}, props, { | |
value: undefined | |
}); | |
}, | |
mountWrapper: function (inst, props) { | |
if (__DEV__) { | |
checkSelectPropTypes(inst, props); | |
} | |
var value = props.value; | |
inst._wrapperState = { | |
initialValue: value != null ? value : props.defaultValue, | |
listeners: null, | |
wasMultiple: !!props.multiple | |
}; | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { | |
warning$13(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'); | |
didWarnValueDefaultValue$1 = true; | |
} | |
}, | |
getSelectValueContext: function (inst) { | |
// ReactDOMOption looks at this initial value so the initial generated | |
// markup has correct `selected` attributes | |
return inst._wrapperState.initialValue; | |
}, | |
postUpdateWrapper: function (inst) { | |
var props = inst._currentElement.props; | |
// After the initial mount, we control selected-ness manually so don't pass | |
// this value down | |
inst._wrapperState.initialValue = undefined; | |
var wasMultiple = inst._wrapperState.wasMultiple; | |
inst._wrapperState.wasMultiple = !!props.multiple; | |
var value = props.value; | |
if (value != null) { | |
updateOptions(inst, !!props.multiple, value); | |
} else if (wasMultiple !== !!props.multiple) { | |
// For simplicity, reapply `defaultValue` if `multiple` is toggled. | |
if (props.defaultValue != null) { | |
updateOptions(inst, !!props.multiple, props.defaultValue); | |
} else { | |
// Revert the select back to its default unselected state. | |
updateOptions(inst, !!props.multiple, props.multiple ? [] : ''); | |
} | |
} | |
}, | |
restoreControlledState: function (inst) { | |
if (inst._rootNodeID) { | |
var props = inst._currentElement.props; | |
var value = props.value; | |
if (value != null) { | |
updateOptions(inst, !!props.multiple, value); | |
} | |
} | |
} | |
}; | |
var ReactDOMSelect_1 = ReactDOMSelect$2; | |
var React$2 = React; | |
var ReactDOMComponentTree$15 = ReactDOMComponentTree_1; | |
var ReactDOMSelect$1 = ReactDOMSelect_1; | |
var warning$12 = warning; | |
var didWarnInvalidOptionChildren = false; | |
function flattenChildren(children) { | |
var content = ''; | |
// Flatten children and warn if they aren't strings or numbers; | |
// invalid types are ignored. | |
React$2.Children.forEach(children, function (child) { | |
if (child == null) { | |
return; | |
} | |
if (typeof child === 'string' || typeof child === 'number') { | |
content += child; | |
} else if (!didWarnInvalidOptionChildren) { | |
didWarnInvalidOptionChildren = true; | |
warning$12(false, 'Only strings and numbers are supported as <option> children.'); | |
} | |
}); | |
return content; | |
} | |
/** | |
* Implements an <option> host component that warns when `selected` is set. | |
*/ | |
var ReactDOMOption$1 = { | |
mountWrapper: function (inst, props, hostParent) { | |
// TODO (yungsters): Remove support for `selected` in <option>. | |
if (__DEV__) { | |
warning$12(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); | |
} | |
// Look up whether this option is 'selected' | |
var selectValue = null; | |
if (hostParent != null) { | |
var selectParent = hostParent; | |
if (selectParent._tag === 'optgroup') { | |
selectParent = selectParent._hostParent; | |
} | |
if (selectParent != null && selectParent._tag === 'select') { | |
selectValue = ReactDOMSelect$1.getSelectValueContext(selectParent); | |
} | |
} | |
// If the value is null (e.g., no specified value or after initial mount) | |
// or missing (e.g., for <datalist>), we don't change props.selected | |
var selected = null; | |
if (selectValue != null) { | |
var value; | |
if (props.value != null) { | |
value = props.value + ''; | |
} else { | |
value = flattenChildren(props.children); | |
} | |
selected = false; | |
if (Array.isArray(selectValue)) { | |
// multiple | |
for (var i = 0; i < selectValue.length; i++) { | |
if ('' + selectValue[i] === value) { | |
selected = true; | |
break; | |
} | |
} | |
} else { | |
selected = '' + selectValue === value; | |
} | |
} | |
inst._wrapperState = { selected: selected }; | |
}, | |
postMountWrapper: function (inst) { | |
// value="" should make a value attribute (#6219) | |
var props = inst._currentElement.props; | |
if (props.value != null) { | |
var node = ReactDOMComponentTree$15.getNodeFromInstance(inst); | |
node.setAttribute('value', props.value); | |
} | |
}, | |
getHostProps: function (inst, props) { | |
var hostProps = Object.assign({ selected: undefined, children: undefined }, props); | |
// Read state only from initial mount because <select> updates value | |
// manually; we need the initial state only for server rendering | |
if (inst._wrapperState.selected != null) { | |
hostProps.selected = inst._wrapperState.selected; | |
} | |
var content = flattenChildren(props.children); | |
if (content) { | |
hostProps.children = content; | |
} | |
return hostProps; | |
} | |
}; | |
var ReactDOMOption_1 = ReactDOMOption$1; | |
var ReactControlledValuePropTypes$3 = ReactControlledValuePropTypes_1; | |
var ReactDOMComponentTree$17 = ReactDOMComponentTree_1; | |
var invariant$14 = invariant; | |
var warning$14 = warning; | |
var didWarnValDefaultVal = false; | |
/** | |
* Implements a <textarea> host component that allows setting `value`, and | |
* `defaultValue`. This differs from the traditional DOM API because value is | |
* usually set as PCDATA children. | |
* | |
* If `value` is not supplied (or null/undefined), user actions that affect the | |
* value will trigger updates to the element. | |
* | |
* If `value` is supplied (and not null/undefined), the rendered element will | |
* not trigger updates to the element. Instead, the `value` prop must change in | |
* order for the rendered element to be updated. | |
* | |
* The rendered element will be initialized with an empty value, the prop | |
* `defaultValue` if specified, or the children content (deprecated). | |
*/ | |
var ReactDOMTextarea$1 = { | |
getHostProps: function (inst, props) { | |
invariant$14(props.dangerouslySetInnerHTML == null, '`dangerouslySetInnerHTML` does not make sense on <textarea>.'); | |
// Always set children to the same thing. In IE9, the selection range will | |
// get reset if `textContent` is mutated. We could add a check in setTextContent | |
// to only set the value if/when the value differs from the node value (which would | |
// completely solve this IE9 bug), but Sebastian+Ben seemed to like this solution. | |
// The value can be a boolean or object so that's why it's forced to be a string. | |
var hostProps = Object.assign({}, props, { | |
value: undefined, | |
defaultValue: undefined, | |
children: '' + inst._wrapperState.initialValue | |
}); | |
return hostProps; | |
}, | |
mountWrapper: function (inst, props) { | |
if (__DEV__) { | |
var owner = inst._currentElement._owner; | |
ReactControlledValuePropTypes$3.checkPropTypes('textarea', props, owner ? owner.getName() : null); | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { | |
warning$14(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'); | |
didWarnValDefaultVal = true; | |
} | |
} | |
var value = props.value; | |
var initialValue = value; | |
// Only bother fetching default value if we're going to use it | |
if (value == null) { | |
var defaultValue = props.defaultValue; | |
// TODO (yungsters): Remove support for children content in <textarea>. | |
var children = props.children; | |
if (children != null) { | |
if (__DEV__) { | |
warning$14(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); | |
} | |
invariant$14(defaultValue == null, 'If you supply `defaultValue` on a <textarea>, do not pass children.'); | |
if (Array.isArray(children)) { | |
invariant$14(children.length <= 1, '<textarea> can only have at most one child.'); | |
children = children[0]; | |
} | |
defaultValue = '' + children; | |
} | |
if (defaultValue == null) { | |
defaultValue = ''; | |
} | |
initialValue = defaultValue; | |
} | |
inst._wrapperState = { | |
initialValue: '' + initialValue, | |
listeners: null | |
}; | |
}, | |
updateWrapper: function (inst) { | |
var props = inst._currentElement.props; | |
var node = ReactDOMComponentTree$17.getNodeFromInstance(inst); | |
var value = props.value; | |
if (value != null) { | |
// Cast `value` to a string to ensure the value is set correctly. While | |
// browsers typically do this as necessary, jsdom doesn't. | |
var newValue = '' + value; | |
// To avoid side effects (such as losing text selection), only set value if changed | |
if (newValue !== node.value) { | |
node.value = newValue; | |
} | |
if (props.defaultValue == null) { | |
node.defaultValue = newValue; | |
} | |
} | |
if (props.defaultValue != null) { | |
node.defaultValue = props.defaultValue; | |
} | |
}, | |
postMountWrapper: function (inst) { | |
// This is in postMount because we need access to the DOM node, which is not | |
// available until after the component has mounted. | |
var node = ReactDOMComponentTree$17.getNodeFromInstance(inst); | |
var textContent = node.textContent; | |
// Only set node.value if textContent is equal to the expected | |
// initial value. In IE10/IE11 there is a bug where the placeholder attribute | |
// will populate textContent as well. | |
// https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ | |
if (textContent === inst._wrapperState.initialValue) { | |
node.value = textContent; | |
} | |
}, | |
restoreControlledState: function (inst) { | |
if (inst._rootNodeID) { | |
// DOM component is still mounted; update | |
ReactDOMTextarea$1.updateWrapper(inst); | |
} | |
} | |
}; | |
var ReactDOMTextarea_1 = ReactDOMTextarea$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactInstanceMap | |
*/ | |
/** | |
* `ReactInstanceMap` maintains a mapping from a public facing stateful | |
* instance (key) and the internal representation (value). This allows public | |
* methods to accept the user facing instance as an argument and map them back | |
* to internal methods. | |
*/ | |
// TODO: Replace this with ES6: var ReactInstanceMap = new Map(); | |
var ReactInstanceMap$1 = { | |
/** | |
* This API should be called `delete` but we'd have to make sure to always | |
* transform these to strings for IE support. When this transform is fully | |
* supported we can rename it. | |
*/ | |
remove: function (key) { | |
key._reactInternalInstance = undefined; | |
}, | |
get: function (key) { | |
return key._reactInternalInstance; | |
}, | |
has: function (key) { | |
return key._reactInternalInstance !== undefined; | |
}, | |
set: function (key, value) { | |
key._reactInternalInstance = value; | |
} | |
}; | |
var ReactInstanceMap_1 = ReactInstanceMap$1; | |
var _require$4 = ReactTypeOfWork; | |
var ClassComponent$1 = _require$4.ClassComponent; | |
var emptyObject$1 = emptyObject; | |
var invariant$16 = invariant; | |
/** | |
* @param {?object} object | |
* @return {boolean} True if `object` is a valid owner. | |
* @final | |
*/ | |
function isValidOwner(object) { | |
return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function'); | |
} | |
/** | |
* ReactOwners are capable of storing references to owned components. | |
* | |
* All components are capable of //being// referenced by owner components, but | |
* only ReactOwner components are capable of //referencing// owned components. | |
* The named reference is known as a "ref". | |
* | |
* Refs are available when mounted and updated during reconciliation. | |
* | |
* var MyComponent = React.createClass({ | |
* render: function() { | |
* return ( | |
* <div onClick={this.handleClick}> | |
* <CustomComponent ref="custom" /> | |
* </div> | |
* ); | |
* }, | |
* handleClick: function() { | |
* this.refs.custom.handleClick(); | |
* }, | |
* componentDidMount: function() { | |
* this.refs.custom.initialize(); | |
* } | |
* }); | |
* | |
* Refs should rarely be used. When refs are used, they should only be done to | |
* control data that is not handled by React's data flow. | |
* | |
* @class ReactOwner | |
*/ | |
var ReactOwner$1 = { | |
/** | |
* Adds a component by ref to an owner component. | |
* | |
* @param {ReactComponent} component Component to reference. | |
* @param {string} ref Name by which to refer to the component. | |
* @param {ReactOwner} owner Component on which to record the ref. | |
* @final | |
* @internal | |
*/ | |
addComponentAsRefTo: function (component, ref, owner) { | |
if (owner && owner.tag === ClassComponent$1) { | |
var inst = owner.stateNode; | |
var refs = inst.refs === emptyObject$1 ? inst.refs = {} : inst.refs; | |
refs[ref] = component.getPublicInstance(); | |
} else { | |
invariant$16(isValidOwner(owner), 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).'); | |
owner.attachRef(ref, component); | |
} | |
}, | |
/** | |
* Removes a component by ref from an owner component. | |
* | |
* @param {ReactComponent} component Component to dereference. | |
* @param {string} ref Name of the ref to remove. | |
* @param {ReactOwner} owner Component on which the ref is recorded. | |
* @final | |
* @internal | |
*/ | |
removeComponentAsRefFrom: function (component, ref, owner) { | |
if (owner && owner.tag === ClassComponent$1) { | |
var inst = owner.stateNode; | |
if (inst && inst.refs[ref] === component.getPublicInstance()) { | |
delete inst.refs[ref]; | |
} | |
} else { | |
invariant$16(isValidOwner(owner), 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).'); | |
var ownerPublicInstance = owner.getPublicInstance(); | |
// Check that `component`'s owner is still alive and that `component` is still the current ref | |
// because we do not want to detach the ref if another component stole it. | |
if (ownerPublicInstance && ownerPublicInstance.refs[ref] === component.getPublicInstance()) { | |
owner.detachRef(ref); | |
} | |
} | |
} | |
}; | |
var ReactOwner_1 = ReactOwner$1; | |
var ReactCompositeComponentTypes$1 = { | |
ImpureClass: 0, | |
PureClass: 1, | |
StatelessFunctional: 2 | |
}; /** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactCompositeComponentTypes | |
* | |
*/ | |
var ReactOwner = ReactOwner_1; | |
var ReactRef$1 = {}; | |
if (__DEV__) { | |
var ReactCompositeComponentTypes = ReactCompositeComponentTypes$1; | |
var ReactComponentTreeHook$2 = ReactComponentTreeHook_1; | |
var warning$16 = warning; | |
var warnedAboutStatelessRefs = {}; | |
} | |
function attachRef(ref, component, owner) { | |
if (__DEV__) { | |
if (component._compositeType === ReactCompositeComponentTypes.StatelessFunctional) { | |
var info = ''; | |
var ownerName = void 0; | |
if (owner) { | |
if (typeof owner.getName === 'function') { | |
ownerName = owner.getName(); | |
} | |
if (ownerName) { | |
info += '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
} | |
var warningKey = ownerName || component._debugID; | |
var element = component._currentElement; | |
if (element && element._source) { | |
warningKey = element._source.fileName + ':' + element._source.lineNumber; | |
} | |
if (!warnedAboutStatelessRefs[warningKey]) { | |
warnedAboutStatelessRefs[warningKey] = true; | |
warning$16(false, 'Stateless function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s%s', info, ReactComponentTreeHook$2.getStackAddendumByID(component._debugID)); | |
} | |
} | |
} | |
if (typeof ref === 'function') { | |
ref(component.getPublicInstance()); | |
} else { | |
// Legacy ref | |
ReactOwner.addComponentAsRefTo(component, ref, owner); | |
} | |
} | |
function detachRef(ref, component, owner) { | |
if (typeof ref === 'function') { | |
ref(null); | |
} else { | |
// Legacy ref | |
ReactOwner.removeComponentAsRefFrom(component, ref, owner); | |
} | |
} | |
ReactRef$1.attachRefs = function (instance, element) { | |
if (element === null || typeof element !== 'object') { | |
return; | |
} | |
var ref = element.ref; | |
if (ref != null) { | |
attachRef(ref, instance, element._owner); | |
} | |
}; | |
ReactRef$1.shouldUpdateRefs = function (prevElement, nextElement) { | |
// If either the owner or a `ref` has changed, make sure the newest owner | |
// has stored a reference to `this`, and the previous owner (if different) | |
// has forgotten the reference to `this`. We use the element instead | |
// of the public this.props because the post processing cannot determine | |
// a ref. The ref conceptually lives on the element. | |
// TODO: Should this even be possible? The owner cannot change because | |
// it's forbidden by shouldUpdateReactComponent. The ref can change | |
// if you swap the keys of but not the refs. Reconsider where this check | |
// is made. It probably belongs where the key checking and | |
// instantiateReactComponent is done. | |
var prevRef = null; | |
var prevOwner = null; | |
if (prevElement !== null && typeof prevElement === 'object') { | |
prevRef = prevElement.ref; | |
prevOwner = prevElement._owner; | |
} | |
var nextRef = null; | |
var nextOwner = null; | |
if (nextElement !== null && typeof nextElement === 'object') { | |
nextRef = nextElement.ref; | |
nextOwner = nextElement._owner; | |
} | |
return prevRef !== nextRef || | |
// If owner changes but we have an unchanged function ref, don't update refs | |
typeof nextRef === 'string' && nextOwner !== prevOwner; | |
}; | |
ReactRef$1.detachRefs = function (instance, element) { | |
if (element === null || typeof element !== 'object') { | |
return; | |
} | |
var ref = element.ref; | |
if (ref != null) { | |
detachRef(ref, instance, element._owner); | |
} | |
}; | |
var ReactRef_1 = ReactRef$1; | |
var ReactRef = ReactRef_1; | |
var ReactInstrumentation$7 = ReactInstrumentation$2; | |
var warning$15 = warning; | |
/** | |
* Helper to call ReactRef.attachRefs with this composite component, split out | |
* to avoid allocations in the transaction mount-ready queue. | |
*/ | |
function attachRefs() { | |
ReactRef.attachRefs(this, this._currentElement); | |
} | |
var ReactReconciler$2 = { | |
/** | |
* Initializes the component, renders markup, and registers event listeners. | |
* | |
* @param {ReactComponent} internalInstance | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {?object} the containing host component instance | |
* @param {?object} info about the host container | |
* @return {?string} Rendered markup to be inserted into the DOM. | |
* @final | |
* @internal | |
*/ | |
mountComponent: function (internalInstance, transaction, hostParent, hostContainerInfo, context, parentDebugID // 0 in production and for roots | |
) { | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID); | |
} | |
} | |
var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID); | |
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) { | |
transaction.getReactMountReady().enqueue(attachRefs, internalInstance); | |
} | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onMountComponent(internalInstance._debugID); | |
} | |
} | |
return markup; | |
}, | |
/** | |
* Returns a value that can be passed to | |
* ReactComponentEnvironment.replaceNodeWithMarkup. | |
*/ | |
getHostNode: function (internalInstance) { | |
return internalInstance.getHostNode(); | |
}, | |
/** | |
* Releases any resources allocated by `mountComponent`. | |
* | |
* @final | |
* @internal | |
*/ | |
unmountComponent: function (internalInstance, safely, skipLifecycle) { | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onBeforeUnmountComponent(internalInstance._debugID); | |
} | |
} | |
ReactRef.detachRefs(internalInstance, internalInstance._currentElement); | |
internalInstance.unmountComponent(safely, skipLifecycle); | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onUnmountComponent(internalInstance._debugID); | |
} | |
} | |
}, | |
/** | |
* Update a component using a new element. | |
* | |
* @param {ReactComponent} internalInstance | |
* @param {ReactElement} nextElement | |
* @param {ReactReconcileTransaction} transaction | |
* @param {object} context | |
* @internal | |
*/ | |
receiveComponent: function (internalInstance, nextElement, transaction, context) { | |
var prevElement = internalInstance._currentElement; | |
if (nextElement === prevElement && context === internalInstance._context) { | |
// Since elements are immutable after the owner is rendered, | |
// we can do a cheap identity compare here to determine if this is a | |
// superfluous reconcile. It's possible for state to be mutable but such | |
// change should trigger an update of the owner which would recreate | |
// the element. We explicitly check for the existence of an owner since | |
// it's possible for an element created outside a composite to be | |
// deeply mutated and reused. | |
// TODO: Bailing out early is just a perf optimization right? | |
// TODO: Removing the return statement should affect correctness? | |
return; | |
} | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onBeforeUpdateComponent(internalInstance._debugID, nextElement); | |
} | |
} | |
var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement); | |
if (refsChanged) { | |
ReactRef.detachRefs(internalInstance, prevElement); | |
} | |
internalInstance.receiveComponent(nextElement, transaction, context); | |
if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) { | |
transaction.getReactMountReady().enqueue(attachRefs, internalInstance); | |
} | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onUpdateComponent(internalInstance._debugID); | |
} | |
} | |
}, | |
/** | |
* Flush any dirty changes in a component. | |
* | |
* @param {ReactComponent} internalInstance | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
performUpdateIfNecessary: function (internalInstance, transaction, updateBatchNumber) { | |
if (internalInstance._updateBatchNumber !== updateBatchNumber) { | |
// The component's enqueued batch number should always be the current | |
// batch or the following one. | |
warning$15(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber); | |
return; | |
} | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement); | |
} | |
} | |
internalInstance.performUpdateIfNecessary(transaction); | |
if (__DEV__) { | |
if (internalInstance._debugID !== 0) { | |
ReactInstrumentation$7.debugTool.onUpdateComponent(internalInstance._debugID); | |
} | |
} | |
} | |
}; | |
var ReactReconciler_1 = ReactReconciler$2; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule KeyEscapeUtils | |
* | |
*/ | |
/** | |
* Escape and wrap key so it is safe to use as a reactid | |
* | |
* @param {string} key to be escaped. | |
* @return {string} the escaped key. | |
*/ | |
function escape(key) { | |
var escapeRegex = /[=:]/g; | |
var escaperLookup = { | |
'=': '=0', | |
':': '=2' | |
}; | |
var escapedString = ('' + key).replace(escapeRegex, function (match) { | |
return escaperLookup[match]; | |
}); | |
return '$' + escapedString; | |
} | |
/** | |
* Unescape and unwrap key for human-readable display | |
* | |
* @param {string} key to unescape. | |
* @return {string} the unescaped key. | |
*/ | |
function unescape(key) { | |
var unescapeRegex = /(=0|=2)/g; | |
var unescaperLookup = { | |
'=0': '=', | |
'=2': ':' | |
}; | |
var keySubstring = key[0] === '.' && key[1] === '$' ? key.substring(2) : key.substring(1); | |
return ('' + keySubstring).replace(unescapeRegex, function (match) { | |
return unescaperLookup[match]; | |
}); | |
} | |
var KeyEscapeUtils$1 = { | |
escape: escape, | |
unescape: unescape | |
}; | |
var KeyEscapeUtils_1 = KeyEscapeUtils$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactFeatureFlags | |
* | |
*/ | |
var ReactFeatureFlags$1 = { | |
// When true, call console.time() before and .timeEnd() after each top-level | |
// render (both initial renders and updates). Useful when looking at prod-mode | |
// timeline profiles in Chrome, for example. | |
logTopLevelRenders: false, | |
prepareNewChildrenBeforeUnmountInStack: true, | |
disableNewFiberFeatures: false | |
}; | |
var ReactFeatureFlags_1 = ReactFeatureFlags$1; | |
var React$4 = React; | |
var invariant$19 = invariant; | |
var ReactNodeTypes$1 = { | |
HOST: 0, | |
COMPOSITE: 1, | |
EMPTY: 2, | |
getType: function (node) { | |
if (node === null || node === false) { | |
return ReactNodeTypes$1.EMPTY; | |
} else if (React$4.isValidElement(node)) { | |
if (typeof node.type === 'function') { | |
return ReactNodeTypes$1.COMPOSITE; | |
} else { | |
return ReactNodeTypes$1.HOST; | |
} | |
} | |
invariant$19(false, 'Unexpected node: %s', node); | |
} | |
}; | |
var ReactNodeTypes_1 = ReactNodeTypes$1; | |
var ReactPropTypesSecret$2 = ReactPropTypesSecret_1; | |
var invariant$20 = invariant; | |
var warning$20 = warning; | |
var loggedTypeFailures$1 = {}; | |
/** | |
* Assert that the values match with the type specs. | |
* Error messages are memorized and will only be shown once. | |
* | |
* @param {object} typeSpecs Map of name to a ReactPropType | |
* @param {object} values Runtime values that need to be type-checked | |
* @param {string} location e.g. "prop", "context", "child context" | |
* @param {string} componentName Name of the component for error messages. | |
* @param {?Function} getStack Returns the component stack. | |
* @private | |
*/ | |
function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) { | |
if (__DEV__) { | |
for (var typeSpecName in typeSpecs) { | |
if (typeSpecs.hasOwnProperty(typeSpecName)) { | |
var error; | |
// Prop type validation may throw. In case they do, we don't want to | |
// fail the render phase where it didn't fail before. So we log it. | |
// After these have been cleaned up, we'll let them throw. | |
try { | |
// This is intentionally an invariant that gets caught. It's the same | |
// behavior as without this statement except with a better message. | |
invariant$20(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName); | |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$2); | |
} catch (ex) { | |
error = ex; | |
} | |
warning$20(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); | |
if (error instanceof Error && !(error.message in loggedTypeFailures$1)) { | |
// Only monitor this failure once because there tends to be a lot of the | |
// same error. | |
loggedTypeFailures$1[error.message] = true; | |
var stack = getStack ? getStack() : ''; | |
warning$20(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); | |
} | |
} | |
} | |
} | |
} | |
var checkPropTypes_1 = checkPropTypes$1; | |
var ReactDebugCurrentFrame$1 = {}; | |
if (__DEV__) { | |
var _require$6 = ReactComponentTreeHook_1, | |
getStackAddendumByID = _require$6.getStackAddendumByID, | |
getStackAddendumByWorkInProgressFiber$1 = _require$6.getStackAddendumByWorkInProgressFiber, | |
getCurrentStackAddendum = _require$6.getCurrentStackAddendum; | |
// Component that is being worked on | |
ReactDebugCurrentFrame$1.current = null; | |
// Element that is being cloned or created | |
ReactDebugCurrentFrame$1.element = null; | |
ReactDebugCurrentFrame$1.getStackAddendum = function () { | |
var stack = null; | |
var current = ReactDebugCurrentFrame$1.current; | |
var element = ReactDebugCurrentFrame$1.element; | |
if (current !== null) { | |
if (typeof current === 'number') { | |
// DebugID from Stack. | |
var debugID = current; | |
stack = getStackAddendumByID(debugID); | |
} else if (typeof current.tag === 'number') { | |
// This is a Fiber. | |
// The stack will only be correct if this is a work in progress | |
// version and we're calling it during reconciliation. | |
var workInProgress = current; | |
stack = getStackAddendumByWorkInProgressFiber$1(workInProgress); | |
} | |
} else if (element !== null) { | |
stack = getCurrentStackAddendum(element); | |
} | |
return stack; | |
}; | |
} | |
var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1; | |
var checkPropTypes = checkPropTypes_1; | |
var _require$5 = ReactDebugCurrentFrame_1; | |
var getStackAddendum = _require$5.getStackAddendum; | |
function checkReactTypeSpec$1(typeSpecs, values, location, componentName) { | |
checkPropTypes(typeSpecs, values, location, componentName, getStackAddendum); | |
} | |
var checkReactTypeSpec_1 = checkReactTypeSpec$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule shouldUpdateReactComponent | |
*/ | |
/** | |
* Given a `prevElement` and `nextElement`, determines if the existing | |
* instance should be updated as opposed to being destroyed or replaced by a new | |
* instance. Both arguments are elements. This ensures that this logic can | |
* operate on stateless trees without any backing instance. | |
* | |
* @param {?object} prevElement | |
* @param {?object} nextElement | |
* @return {boolean} True if the existing instance should be updated. | |
* @protected | |
*/ | |
function shouldUpdateReactComponent$2(prevElement, nextElement) { | |
var prevEmpty = prevElement === null || prevElement === false; | |
var nextEmpty = nextElement === null || nextElement === false; | |
if (prevEmpty || nextEmpty) { | |
return prevEmpty === nextEmpty; | |
} | |
var prevType = typeof prevElement; | |
var nextType = typeof nextElement; | |
if (prevType === 'string' || prevType === 'number') { | |
return nextType === 'string' || nextType === 'number'; | |
} else { | |
return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key; | |
} | |
} | |
var shouldUpdateReactComponent_1 = shouldUpdateReactComponent$2; | |
var React$3 = React; | |
var ReactComponentEnvironment$3 = ReactComponentEnvironment_1; | |
var ReactCompositeComponentTypes$3 = ReactCompositeComponentTypes$1; | |
var ReactCurrentOwner$3 = ReactCurrentOwner_1; | |
var ReactErrorUtils$3 = ReactErrorUtils_1; | |
var ReactFeatureFlags$2 = ReactFeatureFlags_1; | |
var ReactInstanceMap$2 = ReactInstanceMap_1; | |
var ReactInstrumentation$8 = ReactInstrumentation$2; | |
var ReactNodeTypes = ReactNodeTypes_1; | |
var ReactReconciler$4 = ReactReconciler_1; | |
if (__DEV__) { | |
var checkReactTypeSpec = checkReactTypeSpec_1; | |
var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1; | |
var warningAboutMissingGetChildContext = {}; | |
} | |
var emptyObject$2 = emptyObject; | |
var invariant$18 = invariant; | |
var shallowEqual$2 = shallowEqual; | |
var shouldUpdateReactComponent$1 = shouldUpdateReactComponent_1; | |
var warning$19 = warning; | |
function StatelessComponent(Component) {} | |
StatelessComponent.prototype.render = function () { | |
var Component = ReactInstanceMap$2.get(this)._currentElement.type; | |
var element = Component(this.props, this.context, this.updater); | |
return element; | |
}; | |
function shouldConstruct(Component) { | |
return !!(Component.prototype && Component.prototype.isReactComponent); | |
} | |
function isPureComponent(Component) { | |
return !!(Component.prototype && Component.prototype.isPureReactComponent); | |
} | |
// Separated into a function to contain deoptimizations caused by try/finally. | |
function measureLifeCyclePerf(fn, debugID, timerType) { | |
if (debugID === 0) { | |
// Top-level wrappers (see ReactMount) and empty components (see | |
// ReactDOMEmptyComponent) are invisible to hooks and devtools. | |
// Both are implementation details that should go away in the future. | |
return fn(); | |
} | |
ReactInstrumentation$8.debugTool.onBeginLifeCycleTimer(debugID, timerType); | |
try { | |
return fn(); | |
} finally { | |
ReactInstrumentation$8.debugTool.onEndLifeCycleTimer(debugID, timerType); | |
} | |
} | |
/** | |
* ------------------ The Life-Cycle of a Composite Component ------------------ | |
* | |
* - constructor: Initialization of state. The instance is now retained. | |
* - componentWillMount | |
* - render | |
* - [children's constructors] | |
* - [children's componentWillMount and render] | |
* - [children's componentDidMount] | |
* - componentDidMount | |
* | |
* Update Phases: | |
* - componentWillReceiveProps (only called if parent updated) | |
* - shouldComponentUpdate | |
* - componentWillUpdate | |
* - render | |
* - [children's constructors or receive props phases] | |
* - componentDidUpdate | |
* | |
* - componentWillUnmount | |
* - [children's componentWillUnmount] | |
* - [children destroyed] | |
* - (destroyed): The instance is now blank, released by React and ready for GC. | |
* | |
* ----------------------------------------------------------------------------- | |
*/ | |
/** | |
* An incrementing ID assigned to each component when it is mounted. This is | |
* used to enforce the order in which `ReactUpdates` updates dirty components. | |
* | |
* @private | |
*/ | |
var nextMountID = 1; | |
/** | |
* @lends {ReactCompositeComponent.prototype} | |
*/ | |
var ReactCompositeComponent$1 = { | |
/** | |
* Base constructor for all composite component. | |
* | |
* @param {ReactElement} element | |
* @final | |
* @internal | |
*/ | |
construct: function (element) { | |
this._currentElement = element; | |
this._rootNodeID = 0; | |
this._compositeType = null; | |
this._instance = null; | |
this._hostParent = null; | |
this._hostContainerInfo = null; | |
// See ReactUpdateQueue | |
this._updateBatchNumber = null; | |
this._pendingElement = null; | |
this._pendingStateQueue = null; | |
this._pendingReplaceState = false; | |
this._pendingForceUpdate = false; | |
this._renderedNodeType = null; | |
this._renderedComponent = null; | |
this._context = null; | |
this._mountOrder = 0; | |
this._topLevelWrapper = null; | |
// See ReactUpdates and ReactUpdateQueue. | |
this._pendingCallbacks = null; | |
// ComponentWillUnmount shall only be called once | |
this._calledComponentWillUnmount = false; | |
if (__DEV__) { | |
this._warnedAboutRefsInRender = false; | |
} | |
}, | |
/** | |
* Initializes the component, renders markup, and registers event listeners. | |
* | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {?object} hostParent | |
* @param {?object} hostContainerInfo | |
* @param {?object} context | |
* @return {?string} Rendered markup to be inserted into the DOM. | |
* @final | |
* @internal | |
*/ | |
mountComponent: function (transaction, hostParent, hostContainerInfo, context) { | |
var _this = this; | |
this._context = context; | |
this._mountOrder = nextMountID++; | |
this._hostParent = hostParent; | |
this._hostContainerInfo = hostContainerInfo; | |
var publicProps = this._currentElement.props; | |
var publicContext = this._processContext(context); | |
var Component = this._currentElement.type; | |
var updateQueue = transaction.getUpdateQueue(); | |
// Initialize the public class | |
var doConstruct = shouldConstruct(Component); | |
var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue); | |
var renderedElement; | |
// Support functional components | |
if (!doConstruct && (inst == null || inst.render == null)) { | |
renderedElement = inst; | |
if (__DEV__) { | |
warning$19(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component'); | |
} | |
invariant$18(inst === null || inst === false || React$3.isValidElement(inst), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component'); | |
inst = new StatelessComponent(Component); | |
this._compositeType = ReactCompositeComponentTypes$3.StatelessFunctional; | |
} else { | |
if (isPureComponent(Component)) { | |
this._compositeType = ReactCompositeComponentTypes$3.PureClass; | |
} else { | |
this._compositeType = ReactCompositeComponentTypes$3.ImpureClass; | |
} | |
} | |
if (__DEV__) { | |
// This will throw later in _renderValidatedComponent, but add an early | |
// warning now to help debugging | |
if (inst.render == null) { | |
warning$19(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', Component.displayName || Component.name || 'Component'); | |
} | |
var propsMutated = inst.props !== publicProps; | |
var componentName = Component.displayName || Component.name || 'Component'; | |
warning$19(inst.props === undefined || !propsMutated, '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component\'s constructor was passed.', componentName, componentName); | |
} | |
// These should be set up in the constructor, but as a convenience for | |
// simpler class abstractions, we set them up after the fact. | |
inst.props = publicProps; | |
inst.context = publicContext; | |
inst.refs = emptyObject$2; | |
inst.updater = updateQueue; | |
this._instance = inst; | |
// Store a reference from the instance back to the internal representation | |
ReactInstanceMap$2.set(inst, this); | |
if (__DEV__) { | |
// Since plain JS classes are defined without any special initialization | |
// logic, we can not catch common errors early. Therefore, we have to | |
// catch them here, at initialization time, instead. | |
warning$19(!inst.getInitialState || inst.getInitialState.isReactClassApproved || inst.state, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component'); | |
warning$19(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component'); | |
warning$19(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component'); | |
warning$19(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component'); | |
warning$19(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component'); | |
warning$19(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component'); | |
warning$19(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component'); | |
} | |
var initialState = inst.state; | |
if (initialState === undefined) { | |
inst.state = initialState = null; | |
} | |
invariant$18(typeof initialState === 'object' && !Array.isArray(initialState), '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent'); | |
this._pendingStateQueue = null; | |
this._pendingReplaceState = false; | |
this._pendingForceUpdate = false; | |
if (inst.componentWillMount) { | |
if (__DEV__) { | |
measureLifeCyclePerf(function () { | |
return inst.componentWillMount(); | |
}, this._debugID, 'componentWillMount'); | |
} else { | |
inst.componentWillMount(); | |
} | |
// When mounting, calls to `setState` by `componentWillMount` will set | |
// `this._pendingStateQueue` without triggering a re-render. | |
if (this._pendingStateQueue) { | |
inst.state = this._processPendingState(inst.props, inst.context); | |
} | |
} | |
var markup; | |
if (inst.unstable_handleError) { | |
markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context); | |
} else { | |
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context); | |
} | |
if (inst.componentDidMount) { | |
if (__DEV__) { | |
transaction.getReactMountReady().enqueue(function () { | |
measureLifeCyclePerf(function () { | |
return inst.componentDidMount(); | |
}, _this._debugID, 'componentDidMount'); | |
}); | |
} else { | |
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst); | |
} | |
} | |
// setState callbacks during willMount should end up here | |
var callbacks = this._pendingCallbacks; | |
if (callbacks) { | |
this._pendingCallbacks = null; | |
for (var i = 0; i < callbacks.length; i++) { | |
transaction.getReactMountReady().enqueue(callbacks[i], inst); | |
} | |
} | |
return markup; | |
}, | |
_constructComponent: function (doConstruct, publicProps, publicContext, updateQueue) { | |
if (__DEV__) { | |
ReactCurrentOwner$3.current = this; | |
try { | |
return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue); | |
} finally { | |
ReactCurrentOwner$3.current = null; | |
} | |
} else { | |
return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue); | |
} | |
}, | |
_constructComponentWithoutOwner: function (doConstruct, publicProps, publicContext, updateQueue) { | |
var Component = this._currentElement.type; | |
if (doConstruct) { | |
if (__DEV__) { | |
return measureLifeCyclePerf(function () { | |
return new Component(publicProps, publicContext, updateQueue); | |
}, this._debugID, 'ctor'); | |
} else { | |
return new Component(publicProps, publicContext, updateQueue); | |
} | |
} | |
// This can still be an instance in case of factory components | |
// but we'll count this as time spent rendering as the more common case. | |
if (__DEV__) { | |
return measureLifeCyclePerf(function () { | |
return Component(publicProps, publicContext, updateQueue); | |
}, this._debugID, 'render'); | |
} else { | |
return Component(publicProps, publicContext, updateQueue); | |
} | |
}, | |
performInitialMountWithErrorHandling: function (renderedElement, hostParent, hostContainerInfo, transaction, context) { | |
var markup; | |
var checkpoint = transaction.checkpoint(); | |
try { | |
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context); | |
} catch (e) { | |
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint | |
transaction.rollback(checkpoint); | |
this._instance.unstable_handleError(e); | |
if (this._pendingStateQueue) { | |
this._instance.state = this._processPendingState(this._instance.props, this._instance.context); | |
} | |
checkpoint = transaction.checkpoint(); | |
this._renderedComponent.unmountComponent(true, /* safely */ | |
// Don't call componentWillUnmount() because they never fully mounted: | |
true /* skipLifecyle */ | |
); | |
transaction.rollback(checkpoint); | |
// Try again - we've informed the component about the error, so they can render an error message this time. | |
// If this throws again, the error will bubble up (and can be caught by a higher error boundary). | |
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context); | |
} | |
return markup; | |
}, | |
performInitialMount: function (renderedElement, hostParent, hostContainerInfo, transaction, context) { | |
// If not a stateless component, we now render | |
if (renderedElement === undefined) { | |
renderedElement = this._renderValidatedComponent(); | |
} | |
var nodeType = ReactNodeTypes.getType(renderedElement); | |
this._renderedNodeType = nodeType; | |
var child = this._instantiateReactComponent(renderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */ | |
); | |
this._renderedComponent = child; | |
var debugID = 0; | |
if (__DEV__) { | |
debugID = this._debugID; | |
} | |
var markup = ReactReconciler$4.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID); | |
if (__DEV__) { | |
if (debugID !== 0) { | |
var childDebugIDs = child._debugID !== 0 ? [child._debugID] : []; | |
ReactInstrumentation$8.debugTool.onSetChildren(debugID, childDebugIDs); | |
} | |
} | |
return markup; | |
}, | |
getHostNode: function () { | |
return ReactReconciler$4.getHostNode(this._renderedComponent); | |
}, | |
/** | |
* Releases any resources allocated by `mountComponent`. | |
* | |
* @final | |
* @internal | |
*/ | |
unmountComponent: function (safely, skipLifecycle) { | |
if (!this._renderedComponent) { | |
return; | |
} | |
var inst = this._instance; | |
if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) { | |
inst._calledComponentWillUnmount = true; | |
if (safely) { | |
if (!skipLifecycle) { | |
var name = this.getName() + '.componentWillUnmount()'; | |
ReactErrorUtils$3.invokeGuardedCallbackAndCatchFirstError(name, inst.componentWillUnmount, inst); | |
} | |
} else { | |
if (__DEV__) { | |
measureLifeCyclePerf(function () { | |
return inst.componentWillUnmount(); | |
}, this._debugID, 'componentWillUnmount'); | |
} else { | |
inst.componentWillUnmount(); | |
} | |
} | |
} | |
if (this._renderedComponent) { | |
ReactReconciler$4.unmountComponent(this._renderedComponent, safely, skipLifecycle); | |
this._renderedNodeType = null; | |
this._renderedComponent = null; | |
this._instance = null; | |
} | |
// Reset pending fields | |
// Even if this component is scheduled for another update in ReactUpdates, | |
// it would still be ignored because these fields are reset. | |
this._pendingStateQueue = null; | |
this._pendingReplaceState = false; | |
this._pendingForceUpdate = false; | |
this._pendingCallbacks = null; | |
this._pendingElement = null; | |
// These fields do not really need to be reset since this object is no | |
// longer accessible. | |
this._context = null; | |
this._rootNodeID = 0; | |
this._topLevelWrapper = null; | |
// Delete the reference from the instance to this internal representation | |
// which allow the internals to be properly cleaned up even if the user | |
// leaks a reference to the public instance. | |
ReactInstanceMap$2.remove(inst); | |
// Some existing components rely on inst.props even after they've been | |
// destroyed (in event handlers). | |
// TODO: inst.props = null; | |
// TODO: inst.state = null; | |
// TODO: inst.context = null; | |
}, | |
/** | |
* Filters the context object to only contain keys specified in | |
* `contextTypes` | |
* | |
* @param {object} context | |
* @return {?object} | |
* @private | |
*/ | |
_maskContext: function (context) { | |
var Component = this._currentElement.type; | |
var contextTypes = Component.contextTypes; | |
if (!contextTypes) { | |
return emptyObject$2; | |
} | |
var maskedContext = {}; | |
for (var contextName in contextTypes) { | |
maskedContext[contextName] = context[contextName]; | |
} | |
return maskedContext; | |
}, | |
/** | |
* Filters the context object to only contain keys specified in | |
* `contextTypes`, and asserts that they are valid. | |
* | |
* @param {object} context | |
* @return {?object} | |
* @private | |
*/ | |
_processContext: function (context) { | |
var maskedContext = this._maskContext(context); | |
if (__DEV__) { | |
var Component = this._currentElement.type; | |
if (Component.contextTypes) { | |
this._checkContextTypes(Component.contextTypes, maskedContext, 'context'); | |
} | |
} | |
return maskedContext; | |
}, | |
/** | |
* @param {object} currentContext | |
* @return {object} | |
* @private | |
*/ | |
_processChildContext: function (currentContext) { | |
var Component = this._currentElement.type; | |
var inst = this._instance; | |
var childContext; | |
if (typeof inst.getChildContext === 'function') { | |
if (__DEV__) { | |
ReactInstrumentation$8.debugTool.onBeginProcessingChildContext(); | |
try { | |
childContext = inst.getChildContext(); | |
} finally { | |
ReactInstrumentation$8.debugTool.onEndProcessingChildContext(); | |
} | |
} else { | |
childContext = inst.getChildContext(); | |
} | |
invariant$18(typeof Component.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent'); | |
if (__DEV__) { | |
this._checkContextTypes(Component.childContextTypes, childContext, 'child context'); | |
} | |
for (var name in childContext) { | |
invariant$18(name in Component.childContextTypes, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name); | |
} | |
return Object.assign({}, currentContext, childContext); | |
} else { | |
if (__DEV__) { | |
var componentName = this.getName(); | |
if (!warningAboutMissingGetChildContext[componentName]) { | |
warningAboutMissingGetChildContext[componentName] = true; | |
warning$19(!Component.childContextTypes, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName); | |
} | |
} | |
} | |
return currentContext; | |
}, | |
/** | |
* Assert that the context types are valid | |
* | |
* @param {object} typeSpecs Map of context field to a ReactPropType | |
* @param {object} values Runtime values that need to be type-checked | |
* @param {string} location e.g. "prop", "context", "child context" | |
* @private | |
*/ | |
_checkContextTypes: function (typeSpecs, values, location) { | |
if (__DEV__) { | |
ReactDebugCurrentFrame.current = this._debugID; | |
checkReactTypeSpec(typeSpecs, values, location, this.getName()); | |
ReactDebugCurrentFrame.current = null; | |
} | |
}, | |
receiveComponent: function (nextElement, transaction, nextContext) { | |
var prevElement = this._currentElement; | |
var prevContext = this._context; | |
this._pendingElement = null; | |
this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext); | |
}, | |
/** | |
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate` | |
* is set, update the component. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
performUpdateIfNecessary: function (transaction) { | |
if (this._pendingElement != null) { | |
ReactReconciler$4.receiveComponent(this, this._pendingElement, transaction, this._context); | |
} else if (this._pendingStateQueue !== null || this._pendingForceUpdate) { | |
this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context); | |
} else { | |
var callbacks = this._pendingCallbacks; | |
this._pendingCallbacks = null; | |
if (callbacks) { | |
for (var j = 0; j < callbacks.length; j++) { | |
transaction.getReactMountReady().enqueue(callbacks[j], this.getPublicInstance()); | |
} | |
} | |
this._updateBatchNumber = null; | |
} | |
}, | |
/** | |
* Perform an update to a mounted component. The componentWillReceiveProps and | |
* shouldComponentUpdate methods are called, then (assuming the update isn't | |
* skipped) the remaining update lifecycle methods are called and the DOM | |
* representation is updated. | |
* | |
* By default, this implements React's rendering and reconciliation algorithm. | |
* Sophisticated clients may wish to override this. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @param {ReactElement} prevParentElement | |
* @param {ReactElement} nextParentElement | |
* @internal | |
* @overridable | |
*/ | |
updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) { | |
var inst = this._instance; | |
invariant$18(inst != null, 'Attempted to update component `%s` that has already been unmounted ' + '(or failed to mount).', this.getName() || 'ReactCompositeComponent'); | |
var willReceive = false; | |
var nextContext; | |
// Determine if the context has changed or not | |
if (this._context === nextUnmaskedContext) { | |
nextContext = inst.context; | |
} else { | |
nextContext = this._processContext(nextUnmaskedContext); | |
willReceive = true; | |
} | |
var prevProps = prevParentElement.props; | |
var nextProps = nextParentElement.props; | |
// Not a simple state update but a props update | |
if (prevParentElement !== nextParentElement) { | |
willReceive = true; | |
} | |
// An update here will schedule an update but immediately set | |
// _pendingStateQueue which will ensure that any state updates gets | |
// immediately reconciled instead of waiting for the next batch. | |
if (willReceive && inst.componentWillReceiveProps) { | |
var beforeState = inst.state; | |
if (__DEV__) { | |
measureLifeCyclePerf(function () { | |
return inst.componentWillReceiveProps(nextProps, nextContext); | |
}, this._debugID, 'componentWillReceiveProps'); | |
} else { | |
inst.componentWillReceiveProps(nextProps, nextContext); | |
} | |
var afterState = inst.state; | |
if (beforeState !== afterState) { | |
inst.state = beforeState; | |
inst.updater.enqueueReplaceState(inst, afterState); | |
if (__DEV__) { | |
warning$19(false, '%s.componentWillReceiveProps(): Assigning directly to ' + 'this.state is deprecated (except inside a component\'s ' + 'constructor). Use setState instead.', this.getName() || 'ReactCompositeComponent'); | |
} | |
} | |
} | |
// If updating happens to enqueue any new updates, we shouldn't execute new | |
// callbacks until the next render happens, so stash the callbacks first. | |
var callbacks = this._pendingCallbacks; | |
this._pendingCallbacks = null; | |
var nextState = this._processPendingState(nextProps, nextContext); | |
var shouldUpdate = true; | |
if (!this._pendingForceUpdate) { | |
var prevState = inst.state; | |
shouldUpdate = willReceive || nextState !== prevState; | |
if (inst.shouldComponentUpdate) { | |
if (__DEV__) { | |
shouldUpdate = measureLifeCyclePerf(function () { | |
return inst.shouldComponentUpdate(nextProps, nextState, nextContext); | |
}, this._debugID, 'shouldComponentUpdate'); | |
} else { | |
shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext); | |
} | |
} else { | |
if (this._compositeType === ReactCompositeComponentTypes$3.PureClass) { | |
shouldUpdate = !shallowEqual$2(prevProps, nextProps) || !shallowEqual$2(inst.state, nextState); | |
} | |
} | |
} | |
if (__DEV__) { | |
warning$19(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent'); | |
} | |
this._updateBatchNumber = null; | |
if (shouldUpdate) { | |
this._pendingForceUpdate = false; | |
// Will set `this.props`, `this.state` and `this.context`. | |
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext); | |
} else { | |
// If it's determined that a component should not update, we still want | |
// to set props and state but we shortcut the rest of the update. | |
this._currentElement = nextParentElement; | |
this._context = nextUnmaskedContext; | |
inst.props = nextProps; | |
inst.state = nextState; | |
inst.context = nextContext; | |
} | |
if (callbacks) { | |
for (var j = 0; j < callbacks.length; j++) { | |
transaction.getReactMountReady().enqueue(callbacks[j], this.getPublicInstance()); | |
} | |
} | |
}, | |
_processPendingState: function (props, context) { | |
var inst = this._instance; | |
var queue = this._pendingStateQueue; | |
var replace = this._pendingReplaceState; | |
this._pendingReplaceState = false; | |
this._pendingStateQueue = null; | |
if (!queue) { | |
return inst.state; | |
} | |
if (replace && queue.length === 1) { | |
return queue[0]; | |
} | |
var nextState = replace ? queue[0] : inst.state; | |
var dontMutate = true; | |
for (var i = replace ? 1 : 0; i < queue.length; i++) { | |
var partial = queue[i]; | |
var partialState = typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial; | |
if (partialState) { | |
if (dontMutate) { | |
dontMutate = false; | |
nextState = Object.assign({}, nextState, partialState); | |
} else { | |
Object.assign(nextState, partialState); | |
} | |
} | |
} | |
return nextState; | |
}, | |
/** | |
* Merges new props and state, notifies delegate methods of update and | |
* performs update. | |
* | |
* @param {ReactElement} nextElement Next element | |
* @param {object} nextProps Next public object to set as properties. | |
* @param {?object} nextState Next object to set as state. | |
* @param {?object} nextContext Next public object to set as context. | |
* @param {ReactReconcileTransaction} transaction | |
* @param {?object} unmaskedContext | |
* @private | |
*/ | |
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) { | |
var _this2 = this; | |
var inst = this._instance; | |
var hasComponentDidUpdate = !!inst.componentDidUpdate; | |
var prevProps; | |
var prevState; | |
var prevContext; | |
if (hasComponentDidUpdate) { | |
prevProps = inst.props; | |
prevState = inst.state; | |
prevContext = inst.context; | |
} | |
if (inst.componentWillUpdate) { | |
if (__DEV__) { | |
measureLifeCyclePerf(function () { | |
return inst.componentWillUpdate(nextProps, nextState, nextContext); | |
}, this._debugID, 'componentWillUpdate'); | |
} else { | |
inst.componentWillUpdate(nextProps, nextState, nextContext); | |
} | |
} | |
this._currentElement = nextElement; | |
this._context = unmaskedContext; | |
inst.props = nextProps; | |
inst.state = nextState; | |
inst.context = nextContext; | |
if (inst.unstable_handleError) { | |
this._updateRenderedComponentWithErrorHandling(transaction, unmaskedContext); | |
} else { | |
this._updateRenderedComponent(transaction, unmaskedContext); | |
} | |
if (hasComponentDidUpdate) { | |
if (__DEV__) { | |
transaction.getReactMountReady().enqueue(function () { | |
measureLifeCyclePerf(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), _this2._debugID, 'componentDidUpdate'); | |
}); | |
} else { | |
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst); | |
} | |
} | |
}, | |
/** | |
* Call the component's `render` method and update the DOM accordingly. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
_updateRenderedComponentWithErrorHandling: function (transaction, context) { | |
var checkpoint = transaction.checkpoint(); | |
try { | |
this._updateRenderedComponent(transaction, context); | |
} catch (e) { | |
// Roll back to checkpoint, handle error (which may add items to the transaction), | |
// and take a new checkpoint | |
transaction.rollback(checkpoint); | |
this._instance.unstable_handleError(e); | |
if (this._pendingStateQueue) { | |
this._instance.state = this._processPendingState(this._instance.props, this._instance.context); | |
} | |
checkpoint = transaction.checkpoint(); | |
// Gracefully update to a clean state | |
this._updateRenderedComponentWithNextElement(transaction, context, null, true /* safely */ | |
); | |
// Try again - we've informed the component about the error, so they can render an error message this time. | |
// If this throws again, the error will bubble up (and can be caught by a higher error boundary). | |
this._updateRenderedComponent(transaction, context); | |
} | |
}, | |
/** | |
* Call the component's `render` method and update the DOM accordingly. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
_updateRenderedComponent: function (transaction, context) { | |
var nextRenderedElement = this._renderValidatedComponent(); | |
this._updateRenderedComponentWithNextElement(transaction, context, nextRenderedElement, false /* safely */ | |
); | |
}, | |
/** | |
* Call the component's `render` method and update the DOM accordingly. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
_updateRenderedComponentWithNextElement: function (transaction, context, nextRenderedElement, safely) { | |
var prevComponentInstance = this._renderedComponent; | |
var prevRenderedElement = prevComponentInstance._currentElement; | |
var debugID = 0; | |
if (__DEV__) { | |
debugID = this._debugID; | |
} | |
if (shouldUpdateReactComponent$1(prevRenderedElement, nextRenderedElement)) { | |
ReactReconciler$4.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context)); | |
} else { | |
var oldHostNode = ReactReconciler$4.getHostNode(prevComponentInstance); | |
if (!ReactFeatureFlags$2.prepareNewChildrenBeforeUnmountInStack) { | |
ReactReconciler$4.unmountComponent(prevComponentInstance, safely, false /* skipLifecycle */ | |
); | |
} | |
var nodeType = ReactNodeTypes.getType(nextRenderedElement); | |
this._renderedNodeType = nodeType; | |
var child = this._instantiateReactComponent(nextRenderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */ | |
); | |
this._renderedComponent = child; | |
var nextMarkup = ReactReconciler$4.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context), debugID); | |
if (ReactFeatureFlags$2.prepareNewChildrenBeforeUnmountInStack) { | |
ReactReconciler$4.unmountComponent(prevComponentInstance, safely, false /* skipLifecycle */ | |
); | |
} | |
if (__DEV__) { | |
if (debugID !== 0) { | |
var childDebugIDs = child._debugID !== 0 ? [child._debugID] : []; | |
ReactInstrumentation$8.debugTool.onSetChildren(debugID, childDebugIDs); | |
} | |
} | |
this._replaceNodeWithMarkup(oldHostNode, nextMarkup, prevComponentInstance); | |
} | |
}, | |
/** | |
* Overridden in shallow rendering. | |
* | |
* @protected | |
*/ | |
_replaceNodeWithMarkup: function (oldHostNode, nextMarkup, prevInstance) { | |
ReactComponentEnvironment$3.replaceNodeWithMarkup(oldHostNode, nextMarkup, prevInstance); | |
}, | |
/** | |
* @protected | |
*/ | |
_renderValidatedComponentWithoutOwnerOrContext: function () { | |
var inst = this._instance; | |
var renderedElement; | |
if (__DEV__) { | |
renderedElement = measureLifeCyclePerf(function () { | |
return inst.render(); | |
}, this._debugID, 'render'); | |
} else { | |
renderedElement = inst.render(); | |
} | |
if (__DEV__) { | |
// We allow auto-mocks to proceed as if they're returning null. | |
if (renderedElement === undefined && inst.render._isMockFunction) { | |
// This is probably bad practice. Consider warning here and | |
// deprecating this convenience. | |
renderedElement = null; | |
} | |
} | |
return renderedElement; | |
}, | |
/** | |
* @private | |
*/ | |
_renderValidatedComponent: function () { | |
var renderedElement; | |
if (__DEV__ || this._compositeType !== ReactCompositeComponentTypes$3.StatelessFunctional) { | |
ReactCurrentOwner$3.current = this; | |
try { | |
renderedElement = this._renderValidatedComponentWithoutOwnerOrContext(); | |
} finally { | |
ReactCurrentOwner$3.current = null; | |
} | |
} else { | |
renderedElement = this._renderValidatedComponentWithoutOwnerOrContext(); | |
} | |
invariant$18( | |
// TODO: An `isValidNode` function would probably be more appropriate | |
renderedElement === null || renderedElement === false || React$3.isValidElement(renderedElement), '%s.render(): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent'); | |
return renderedElement; | |
}, | |
/** | |
* Lazily allocates the refs object and stores `component` as `ref`. | |
* | |
* @param {string} ref Reference name. | |
* @param {component} component Component to store as `ref`. | |
* @final | |
* @private | |
*/ | |
attachRef: function (ref, component) { | |
var inst = this.getPublicInstance(); | |
invariant$18(inst != null, 'Stateless function components cannot have refs.'); | |
var publicComponentInstance = component.getPublicInstance(); | |
var refs = inst.refs === emptyObject$2 ? inst.refs = {} : inst.refs; | |
refs[ref] = publicComponentInstance; | |
}, | |
/** | |
* Detaches a reference name. | |
* | |
* @param {string} ref Name to dereference. | |
* @final | |
* @private | |
*/ | |
detachRef: function (ref) { | |
var refs = this.getPublicInstance().refs; | |
delete refs[ref]; | |
}, | |
/** | |
* Get a text description of the component that can be used to identify it | |
* in error messages. | |
* @return {string} The name or null. | |
* @internal | |
*/ | |
getName: function () { | |
var type = this._currentElement.type; | |
var constructor = this._instance && this._instance.constructor; | |
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null; | |
}, | |
/** | |
* Get the publicly accessible representation of this component - i.e. what | |
* is exposed by refs and returned by render. Can be null for stateless | |
* components. | |
* | |
* @return {ReactComponent} the public component instance. | |
* @internal | |
*/ | |
getPublicInstance: function () { | |
var inst = this._instance; | |
if (this._compositeType === ReactCompositeComponentTypes$3.StatelessFunctional) { | |
return null; | |
} | |
return inst; | |
}, | |
// Stub | |
_instantiateReactComponent: null | |
}; | |
var ReactCompositeComponent_1 = ReactCompositeComponent$1; | |
/** | |
* Copyright 2014-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactEmptyComponent | |
*/ | |
var emptyComponentFactory; | |
var ReactEmptyComponentInjection = { | |
injectEmptyComponentFactory: function (factory) { | |
emptyComponentFactory = factory; | |
} | |
}; | |
var ReactEmptyComponent$2 = { | |
create: function (instantiate) { | |
return emptyComponentFactory(instantiate); | |
} | |
}; | |
ReactEmptyComponent$2.injection = ReactEmptyComponentInjection; | |
var ReactEmptyComponent_1 = ReactEmptyComponent$2; | |
var invariant$21 = invariant; | |
var genericComponentClass = null; | |
var textComponentClass = null; | |
var ReactHostComponentInjection = { | |
// This accepts a class that receives the tag string. This is a catch all | |
// that can render any kind of tag. | |
injectGenericComponentClass: function (componentClass) { | |
genericComponentClass = componentClass; | |
}, | |
// This accepts a text component class that takes the text string to be | |
// rendered as props. | |
injectTextComponentClass: function (componentClass) { | |
textComponentClass = componentClass; | |
} | |
}; | |
/** | |
* Get a host internal component class for a specific tag. | |
* | |
* @param {ReactElement} element The element to create. | |
* @return {function} The internal class constructor function. | |
*/ | |
function createInternalComponent(element) { | |
invariant$21(genericComponentClass, 'There is no registered component for the tag %s', element.type); | |
return new genericComponentClass(element); | |
} | |
/** | |
* @param {ReactText} text | |
* @return {ReactComponent} | |
*/ | |
function createInstanceForText(text) { | |
return new textComponentClass(text); | |
} | |
/** | |
* @param {ReactComponent} component | |
* @return {boolean} | |
*/ | |
function isTextComponent(component) { | |
return component instanceof textComponentClass; | |
} | |
var ReactHostComponent$2 = { | |
createInternalComponent: createInternalComponent, | |
createInstanceForText: createInstanceForText, | |
isTextComponent: isTextComponent, | |
injection: ReactHostComponentInjection | |
}; | |
var ReactHostComponent_1 = ReactHostComponent$2; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getNextDebugID | |
* | |
*/ | |
var nextDebugID = 1; | |
function getNextDebugID$1() { | |
return nextDebugID++; | |
} | |
var getNextDebugID_1 = getNextDebugID$1; | |
var ReactCompositeComponent = ReactCompositeComponent_1; | |
var ReactEmptyComponent$1 = ReactEmptyComponent_1; | |
var ReactHostComponent$1 = ReactHostComponent_1; | |
var getNextDebugID = getNextDebugID_1; | |
var invariant$17 = invariant; | |
var warning$18 = warning; | |
// To avoid a cyclic dependency, we create the final class in this module | |
var ReactCompositeComponentWrapper = function (element) { | |
this.construct(element); | |
}; | |
function getDeclarationErrorAddendum$3(owner) { | |
if (owner) { | |
var name = owner.getName(); | |
if (name) { | |
return '\n\nCheck the render method of `' + name + '`.'; | |
} | |
} | |
return ''; | |
} | |
/** | |
* Check if the type reference is a known internal type. I.e. not a user | |
* provided composite type. | |
* | |
* @param {function} type | |
* @return {boolean} Returns true if this is a valid internal type. | |
*/ | |
function isInternalComponentType(type) { | |
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function'; | |
} | |
/** | |
* Given a ReactNode, create an instance that will actually be mounted. | |
* | |
* @param {ReactNode} node | |
* @param {boolean} shouldHaveDebugID | |
* @return {object} A new instance of the element's constructor. | |
* @protected | |
*/ | |
function instantiateReactComponent$1(node, shouldHaveDebugID) { | |
var instance; | |
if (node === null || node === false) { | |
instance = ReactEmptyComponent$1.create(instantiateReactComponent$1); | |
} else if (typeof node === 'object') { | |
var element = node; | |
var type = element.type; | |
if (typeof type !== 'function' && typeof type !== 'string') { | |
var info = ''; | |
if (__DEV__) { | |
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { | |
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.'; | |
} | |
} | |
info += getDeclarationErrorAddendum$3(element._owner); | |
invariant$17(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info); | |
} | |
// Special case string values | |
if (typeof element.type === 'string') { | |
instance = ReactHostComponent$1.createInternalComponent(element); | |
} else if (isInternalComponentType(element.type)) { | |
// This is temporarily available for custom components that are not string | |
// representations. I.e. ART. Once those are updated to use the string | |
// representation, we can drop this code path. | |
instance = new element.type(element); | |
// We renamed this. Allow the old name for compat. :( | |
if (!instance.getHostNode) { | |
instance.getHostNode = instance.getNativeNode; | |
} | |
} else { | |
instance = new ReactCompositeComponentWrapper(element); | |
} | |
} else if (typeof node === 'string' || typeof node === 'number') { | |
instance = ReactHostComponent$1.createInstanceForText(node); | |
} else { | |
invariant$17(false, 'Encountered invalid React node of type %s', typeof node); | |
} | |
if (__DEV__) { | |
warning$18(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.'); | |
} | |
// These two fields are used by the DOM and ART diffing algorithms | |
// respectively. Instead of using expandos on components, we should be | |
// storing the state needed by the diffing algorithms elsewhere. | |
instance._mountIndex = 0; | |
instance._mountImage = null; | |
if (__DEV__) { | |
instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0; | |
} | |
// Internal instances should fully constructed at this point, so they should | |
// not get any new fields added to them at this point. | |
if (__DEV__) { | |
if (Object.preventExtensions) { | |
Object.preventExtensions(instance); | |
} | |
} | |
return instance; | |
} | |
Object.assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, { | |
_instantiateReactComponent: instantiateReactComponent$1 | |
}); | |
var instantiateReactComponent_1 = instantiateReactComponent$1; | |
/** | |
* Copyright 2014-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactElementSymbol | |
* | |
*/ | |
// The Symbol used to tag the ReactElement type. If there is no native Symbol | |
// nor polyfill, then a plain number is used for performance. | |
var REACT_ELEMENT_TYPE$1 = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7; | |
var ReactElementSymbol = REACT_ELEMENT_TYPE$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getIteratorFn | |
* | |
*/ | |
/* global Symbol */ | |
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; | |
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. | |
/** | |
* Returns the iterator method function contained on the iterable object. | |
* | |
* Be sure to invoke the function with the iterable as context: | |
* | |
* var iteratorFn = getIteratorFn(myIterable); | |
* if (iteratorFn) { | |
* var iterator = iteratorFn.call(myIterable); | |
* ... | |
* } | |
* | |
* @param {?object} maybeIterable | |
* @return {?function} | |
*/ | |
function getIteratorFn$1(maybeIterable) { | |
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); | |
if (typeof iteratorFn === 'function') { | |
return iteratorFn; | |
} | |
} | |
var getIteratorFn_1 = getIteratorFn$1; | |
var ReactCurrentOwner$4 = ReactCurrentOwner_1; | |
var REACT_ELEMENT_TYPE = ReactElementSymbol; | |
var getIteratorFn = getIteratorFn_1; | |
var invariant$22 = invariant; | |
var KeyEscapeUtils$2 = KeyEscapeUtils_1; | |
var warning$21 = warning; | |
var SEPARATOR = '.'; | |
var SUBSEPARATOR = ':'; | |
/** | |
* This is inlined from ReactElement since this file is shared between | |
* isomorphic and renderers. We could extract this to a | |
* | |
*/ | |
/** | |
* TODO: Test that a single child and an array with one item have the same key | |
* pattern. | |
*/ | |
var didWarnAboutMaps = false; | |
/** | |
* Generate a key string that identifies a component within a set. | |
* | |
* @param {*} component A component that could contain a manual key. | |
* @param {number} index Index that is used if a manual key is not provided. | |
* @return {string} | |
*/ | |
function getComponentKey(component, index) { | |
// Do some typechecking here since we call this blindly. We want to ensure | |
// that we don't block potential future ES APIs. | |
if (component && typeof component === 'object' && component.key != null) { | |
// Explicit key | |
return KeyEscapeUtils$2.escape(component.key); | |
} | |
// Implicit key determined by the index in the set | |
return index.toString(36); | |
} | |
/** | |
* @param {?*} children Children tree container. | |
* @param {!string} nameSoFar Name of the key path so far. | |
* @param {!function} callback Callback to invoke with each child found. | |
* @param {?*} traverseContext Used to pass information throughout the traversal | |
* process. | |
* @return {!number} The number of children in this subtree. | |
*/ | |
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { | |
var type = typeof children; | |
if (type === 'undefined' || type === 'boolean') { | |
// All of the above are perceived as null. | |
children = null; | |
} | |
if (children === null || type === 'string' || type === 'number' || | |
// The following is inlined from ReactElement. This means we can optimize | |
// some checks. React Fiber also inlines this logic for similar purposes. | |
type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) { | |
callback(traverseContext, children, | |
// If it's the only child, treat the name as if it was wrapped in an array | |
// so that it's consistent if the number of children grows. | |
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); | |
return 1; | |
} | |
var child; | |
var nextName; | |
var subtreeCount = 0; // Count of children found in the current subtree. | |
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; | |
if (Array.isArray(children)) { | |
for (var i = 0; i < children.length; i++) { | |
child = children[i]; | |
nextName = nextNamePrefix + getComponentKey(child, i); | |
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | |
} | |
} else { | |
var iteratorFn = getIteratorFn(children); | |
if (iteratorFn) { | |
if (__DEV__) { | |
// Warn about using Maps as children | |
if (iteratorFn === children.entries) { | |
var mapsAsChildrenAddendum = ''; | |
if (ReactCurrentOwner$4.current) { | |
var mapsAsChildrenOwnerName = ReactCurrentOwner$4.current.getName(); | |
if (mapsAsChildrenOwnerName) { | |
mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.'; | |
} | |
} | |
warning$21(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum); | |
didWarnAboutMaps = true; | |
} | |
} | |
var iterator = iteratorFn.call(children); | |
var step; | |
var ii = 0; | |
while (!(step = iterator.next()).done) { | |
child = step.value; | |
nextName = nextNamePrefix + getComponentKey(child, ii++); | |
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); | |
} | |
} else if (type === 'object') { | |
var addendum = ''; | |
if (__DEV__) { | |
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.'; | |
if (ReactCurrentOwner$4.current) { | |
var name = ReactCurrentOwner$4.current.getName(); | |
if (name) { | |
addendum += '\n\nCheck the render method of `' + name + '`.'; | |
} | |
} | |
} | |
var childrenString = '' + children; | |
invariant$22(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); | |
} | |
} | |
return subtreeCount; | |
} | |
/** | |
* Traverses children that are typically specified as `props.children`, but | |
* might also be specified through attributes: | |
* | |
* - `traverseAllChildren(this.props.children, ...)` | |
* - `traverseAllChildren(this.props.leftPanelChildren, ...)` | |
* | |
* The `traverseContext` is an optional argument that is passed through the | |
* entire traversal. It can be used to store accumulations or anything else that | |
* the callback might find relevant. | |
* | |
* @param {?*} children Children tree object. | |
* @param {!function} callback To invoke upon traversing each child. | |
* @param {?*} traverseContext Context for traversal. | |
* @return {!number} The number of children in this subtree. | |
*/ | |
function traverseAllChildren$1(children, callback, traverseContext) { | |
if (children == null) { | |
return 0; | |
} | |
return traverseAllChildrenImpl(children, '', callback, traverseContext); | |
} | |
var traverseAllChildren_1 = traverseAllChildren$1; | |
var KeyEscapeUtils = KeyEscapeUtils_1; | |
var ReactFeatureFlags = ReactFeatureFlags_1; | |
var ReactReconciler$3 = ReactReconciler_1; | |
var instantiateReactComponent = instantiateReactComponent_1; | |
var shouldUpdateReactComponent = shouldUpdateReactComponent_1; | |
var traverseAllChildren = traverseAllChildren_1; | |
var warning$17 = warning; | |
var ReactComponentTreeHook$3; | |
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') { | |
// Temporary hack. | |
// Inline requires don't work well with Jest: | |
// https://github.com/facebook/react/issues/7240 | |
// Remove the inline requires when we don't need them anymore: | |
// https://github.com/facebook/react/pull/7178 | |
ReactComponentTreeHook$3 = ReactComponentTreeHook_1; | |
} | |
function instantiateChild(childInstances, child, name, selfDebugID) { | |
// We found a component instance. | |
var keyUnique = childInstances[name] === undefined; | |
if (__DEV__) { | |
if (!ReactComponentTreeHook$3) { | |
ReactComponentTreeHook$3 = ReactComponentTreeHook_1; | |
} | |
if (!keyUnique) { | |
warning$17(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook$3.getStackAddendumByID(selfDebugID)); | |
} | |
} | |
if (child != null && keyUnique) { | |
childInstances[name] = instantiateReactComponent(child, true); | |
} | |
} | |
/** | |
* ReactChildReconciler provides helpers for initializing or updating a set of | |
* children. Its output is suitable for passing it onto ReactMultiChild which | |
* does diffed reordering and insertion. | |
*/ | |
var ReactChildReconciler$1 = { | |
/** | |
* Generates a "mount image" for each of the supplied children. In the case | |
* of `ReactDOMComponent`, a mount image is a string of markup. | |
* | |
* @param {?object} nestedChildNodes Nested child maps. | |
* @return {?object} A set of child instances. | |
* @internal | |
*/ | |
instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // 0 in production and for roots | |
) { | |
if (nestedChildNodes == null) { | |
return null; | |
} | |
var childInstances = {}; | |
if (__DEV__) { | |
traverseAllChildren(nestedChildNodes, function (childInsts, child, name) { | |
return instantiateChild(childInsts, child, name, selfDebugID); | |
}, childInstances); | |
} else { | |
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances); | |
} | |
return childInstances; | |
}, | |
/** | |
* Updates the rendered children and returns a new set of children. | |
* | |
* @param {?object} prevChildren Previously initialized set of children. | |
* @param {?object} nextChildren Flat child element maps. | |
* @param {ReactReconcileTransaction} transaction | |
* @param {object} context | |
* @return {?object} A new set of child instances. | |
* @internal | |
*/ | |
updateChildren: function (prevChildren, nextChildren, mountImages, removedNodes, transaction, hostParent, hostContainerInfo, context, selfDebugID // 0 in production and for roots | |
) { | |
// We currently don't have a way to track moves here but if we use iterators | |
// instead of for..in we can zip the iterators and check if an item has | |
// moved. | |
// TODO: If nothing has changed, return the prevChildren object so that we | |
// can quickly bailout if nothing has changed. | |
if (!nextChildren && !prevChildren) { | |
return; | |
} | |
var name; | |
var prevChild; | |
for (name in nextChildren) { | |
if (!nextChildren.hasOwnProperty(name)) { | |
continue; | |
} | |
prevChild = prevChildren && prevChildren[name]; | |
var prevElement = prevChild && prevChild._currentElement; | |
var nextElement = nextChildren[name]; | |
if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) { | |
ReactReconciler$3.receiveComponent(prevChild, nextElement, transaction, context); | |
nextChildren[name] = prevChild; | |
} else { | |
if (!ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack && prevChild) { | |
removedNodes[name] = ReactReconciler$3.getHostNode(prevChild); | |
ReactReconciler$3.unmountComponent(prevChild, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
} | |
// The child must be instantiated before it's mounted. | |
var nextChildInstance = instantiateReactComponent(nextElement, true); | |
nextChildren[name] = nextChildInstance; | |
// Creating mount image now ensures refs are resolved in right order | |
// (see https://github.com/facebook/react/pull/7101 for explanation). | |
var nextChildMountImage = ReactReconciler$3.mountComponent(nextChildInstance, transaction, hostParent, hostContainerInfo, context, selfDebugID); | |
mountImages.push(nextChildMountImage); | |
if (ReactFeatureFlags.prepareNewChildrenBeforeUnmountInStack && prevChild) { | |
removedNodes[name] = ReactReconciler$3.getHostNode(prevChild); | |
ReactReconciler$3.unmountComponent(prevChild, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
} | |
} | |
} | |
// Unmount children that are no longer present. | |
for (name in prevChildren) { | |
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) { | |
prevChild = prevChildren[name]; | |
removedNodes[name] = ReactReconciler$3.getHostNode(prevChild); | |
ReactReconciler$3.unmountComponent(prevChild, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
} | |
} | |
}, | |
/** | |
* Unmounts all rendered children. This should be used to clean up children | |
* when this component is unmounted. | |
* | |
* @param {?object} renderedChildren Previously initialized set of children. | |
* @internal | |
*/ | |
unmountChildren: function (renderedChildren, safely, skipLifecycle) { | |
for (var name in renderedChildren) { | |
if (renderedChildren.hasOwnProperty(name)) { | |
var renderedChild = renderedChildren[name]; | |
ReactReconciler$3.unmountComponent(renderedChild, safely, skipLifecycle); | |
} | |
} | |
} | |
}; | |
var ReactChildReconciler_1 = ReactChildReconciler$1; | |
var KeyEscapeUtils$3 = KeyEscapeUtils_1; | |
var traverseAllChildren$2 = traverseAllChildren_1; | |
var warning$22 = warning; | |
var ReactComponentTreeHook$4; | |
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') { | |
// Temporary hack. | |
// Inline requires don't work well with Jest: | |
// https://github.com/facebook/react/issues/7240 | |
// Remove the inline requires when we don't need them anymore: | |
// https://github.com/facebook/react/pull/7178 | |
ReactComponentTreeHook$4 = ReactComponentTreeHook_1; | |
} | |
/** | |
* @param {function} traverseContext Context passed through traversal. | |
* @param {?ReactComponent} child React child component. | |
* @param {!string} name String name of key path to child. | |
* @param {number=} selfDebugID Optional debugID of the current internal instance. | |
*/ | |
function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID) { | |
// We found a component instance. | |
if (traverseContext && typeof traverseContext === 'object') { | |
var result = traverseContext; | |
var keyUnique = result[name] === undefined; | |
if (__DEV__) { | |
if (!ReactComponentTreeHook$4) { | |
ReactComponentTreeHook$4 = ReactComponentTreeHook_1; | |
} | |
if (!keyUnique) { | |
warning$22(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils$3.unescape(name), ReactComponentTreeHook$4.getStackAddendumByID(selfDebugID)); | |
} | |
} | |
if (keyUnique && child != null) { | |
result[name] = child; | |
} | |
} | |
} | |
/** | |
* Flattens children that are typically specified as `props.children`. Any null | |
* children will not be included in the resulting object. | |
* @return {!object} flattened children keyed by name. | |
*/ | |
function flattenChildren$2(children, selfDebugID) { | |
if (children == null) { | |
return children; | |
} | |
var result = {}; | |
if (__DEV__) { | |
traverseAllChildren$2(children, function (traverseContext, child, name) { | |
return flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID); | |
}, result); | |
} else { | |
traverseAllChildren$2(children, flattenSingleChildIntoContext, result); | |
} | |
return result; | |
} | |
var flattenChildren_1 = flattenChildren$2; | |
var ReactComponentEnvironment$2 = ReactComponentEnvironment_1; | |
var ReactInstanceMap = ReactInstanceMap_1; | |
var ReactInstrumentation$6 = ReactInstrumentation$2; | |
var ReactCurrentOwner$2 = ReactCurrentOwner_1; | |
var ReactReconciler$1 = ReactReconciler_1; | |
var ReactChildReconciler = ReactChildReconciler_1; | |
var emptyFunction$4 = emptyFunction; | |
var flattenChildren$1 = flattenChildren_1; | |
var invariant$15 = invariant; | |
/** | |
* Make an update for markup to be rendered and inserted at a supplied index. | |
* | |
* @param {string} markup Markup that renders into an element. | |
* @param {number} toIndex Destination index. | |
* @private | |
*/ | |
function makeInsertMarkup(markup, afterNode, toIndex) { | |
// NOTE: Null values reduce hidden classes. | |
return { | |
type: 'INSERT_MARKUP', | |
content: markup, | |
fromIndex: null, | |
fromNode: null, | |
toIndex: toIndex, | |
afterNode: afterNode | |
}; | |
} | |
/** | |
* Make an update for moving an existing element to another index. | |
* | |
* @param {number} fromIndex Source index of the existing element. | |
* @param {number} toIndex Destination index of the element. | |
* @private | |
*/ | |
function makeMove(child, afterNode, toIndex) { | |
// NOTE: Null values reduce hidden classes. | |
return { | |
type: 'MOVE_EXISTING', | |
content: null, | |
fromIndex: child._mountIndex, | |
fromNode: ReactReconciler$1.getHostNode(child), | |
toIndex: toIndex, | |
afterNode: afterNode | |
}; | |
} | |
/** | |
* Make an update for removing an element at an index. | |
* | |
* @param {number} fromIndex Index of the element to remove. | |
* @private | |
*/ | |
function makeRemove(child, node) { | |
// NOTE: Null values reduce hidden classes. | |
return { | |
type: 'REMOVE_NODE', | |
content: null, | |
fromIndex: child._mountIndex, | |
fromNode: node, | |
toIndex: null, | |
afterNode: null | |
}; | |
} | |
/** | |
* Make an update for setting the markup of a node. | |
* | |
* @param {string} markup Markup that renders into an element. | |
* @private | |
*/ | |
function makeSetMarkup(markup) { | |
// NOTE: Null values reduce hidden classes. | |
return { | |
type: 'SET_MARKUP', | |
content: markup, | |
fromIndex: null, | |
fromNode: null, | |
toIndex: null, | |
afterNode: null | |
}; | |
} | |
/** | |
* Make an update for setting the text content. | |
* | |
* @param {string} textContent Text content to set. | |
* @private | |
*/ | |
function makeTextContent(textContent) { | |
// NOTE: Null values reduce hidden classes. | |
return { | |
type: 'TEXT_CONTENT', | |
content: textContent, | |
fromIndex: null, | |
fromNode: null, | |
toIndex: null, | |
afterNode: null | |
}; | |
} | |
/** | |
* Push an update, if any, onto the queue. Creates a new queue if none is | |
* passed and always returns the queue. Mutative. | |
*/ | |
function enqueue(queue, update) { | |
if (update) { | |
queue = queue || []; | |
queue.push(update); | |
} | |
return queue; | |
} | |
/** | |
* Processes any enqueued updates. | |
* | |
* @private | |
*/ | |
function processQueue(inst, updateQueue) { | |
ReactComponentEnvironment$2.processChildrenUpdates(inst, updateQueue); | |
} | |
var setChildrenForInstrumentation = emptyFunction$4; | |
if (__DEV__) { | |
var getDebugID = function (inst) { | |
if (!inst._debugID) { | |
// Check for ART-like instances. TODO: This is silly/gross. | |
var internal; | |
if (internal = ReactInstanceMap.get(inst)) { | |
inst = internal; | |
} | |
} | |
return inst._debugID; | |
}; | |
setChildrenForInstrumentation = function (children) { | |
var debugID = getDebugID(this); | |
// TODO: React Native empty components are also multichild. | |
// This means they still get into this method but don't have _debugID. | |
if (debugID !== 0) { | |
ReactInstrumentation$6.debugTool.onSetChildren(debugID, children ? Object.keys(children).map(function (key) { | |
return children[key]._debugID; | |
}) : []); | |
} | |
}; | |
} | |
/** | |
* Provides common functionality for components that must reconcile multiple | |
* children. This is used by `ReactDOMComponent` to mount, update, and | |
* unmount child components. | |
*/ | |
var ReactMultiChild$1 = { | |
_reconcilerInstantiateChildren: function (nestedChildren, transaction, context) { | |
if (__DEV__) { | |
var selfDebugID = getDebugID(this); | |
if (this._currentElement) { | |
try { | |
ReactCurrentOwner$2.current = this._currentElement._owner; | |
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, selfDebugID); | |
} finally { | |
ReactCurrentOwner$2.current = null; | |
} | |
} | |
} | |
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context); | |
}, | |
_reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) { | |
var nextChildren; | |
var selfDebugID = 0; | |
if (__DEV__) { | |
selfDebugID = getDebugID(this); | |
if (this._currentElement) { | |
try { | |
ReactCurrentOwner$2.current = this._currentElement._owner; | |
nextChildren = flattenChildren$1(nextNestedChildrenElements, selfDebugID); | |
} finally { | |
ReactCurrentOwner$2.current = null; | |
} | |
ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID); | |
return nextChildren; | |
} | |
} | |
nextChildren = flattenChildren$1(nextNestedChildrenElements, selfDebugID); | |
ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID); | |
return nextChildren; | |
}, | |
/** | |
* Generates a "mount image" for each of the supplied children. In the case | |
* of `ReactDOMComponent`, a mount image is a string of markup. | |
* | |
* @param {?object} nestedChildren Nested child maps. | |
* @return {array} An array of mounted representations. | |
* @internal | |
*/ | |
mountChildren: function (nestedChildren, transaction, context) { | |
var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context); | |
this._renderedChildren = children; | |
var mountImages = []; | |
var index = 0; | |
for (var name in children) { | |
if (children.hasOwnProperty(name)) { | |
var child = children[name]; | |
var selfDebugID = 0; | |
if (__DEV__) { | |
selfDebugID = getDebugID(this); | |
} | |
var mountImage = ReactReconciler$1.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID); | |
child._mountIndex = index++; | |
mountImages.push(mountImage); | |
} | |
} | |
if (__DEV__) { | |
setChildrenForInstrumentation.call(this, children); | |
} | |
return mountImages; | |
}, | |
/** | |
* Replaces any rendered children with a text content string. | |
* | |
* @param {string} nextContent String of content. | |
* @internal | |
*/ | |
updateTextContent: function (nextContent) { | |
var prevChildren = this._renderedChildren; | |
// Remove any rendered children. | |
ReactChildReconciler.unmountChildren(prevChildren, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
for (var name in prevChildren) { | |
if (prevChildren.hasOwnProperty(name)) { | |
invariant$15(false, 'updateTextContent called on non-empty component.'); | |
} | |
} | |
// Set new text content. | |
var updates = [makeTextContent(nextContent)]; | |
processQueue(this, updates); | |
}, | |
/** | |
* Replaces any rendered children with a markup string. | |
* | |
* @param {string} nextMarkup String of markup. | |
* @internal | |
*/ | |
updateMarkup: function (nextMarkup) { | |
var prevChildren = this._renderedChildren; | |
// Remove any rendered children. | |
ReactChildReconciler.unmountChildren(prevChildren, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
for (var name in prevChildren) { | |
if (prevChildren.hasOwnProperty(name)) { | |
invariant$15(false, 'updateTextContent called on non-empty component.'); | |
} | |
} | |
var updates = [makeSetMarkup(nextMarkup)]; | |
processQueue(this, updates); | |
}, | |
/** | |
* Updates the rendered children with new children. | |
* | |
* @param {?object} nextNestedChildrenElements Nested child element maps. | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
updateChildren: function (nextNestedChildrenElements, transaction, context) { | |
// Hook used by React ART | |
this._updateChildren(nextNestedChildrenElements, transaction, context); | |
}, | |
/** | |
* @param {?object} nextNestedChildrenElements Nested child element maps. | |
* @param {ReactReconcileTransaction} transaction | |
* @final | |
* @protected | |
*/ | |
_updateChildren: function (nextNestedChildrenElements, transaction, context) { | |
var prevChildren = this._renderedChildren; | |
var removedNodes = {}; | |
var mountImages = []; | |
var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context); | |
if (!nextChildren && !prevChildren) { | |
return; | |
} | |
var updates = null; | |
var name; | |
// `nextIndex` will increment for each child in `nextChildren`, but | |
// `lastIndex` will be the last index visited in `prevChildren`. | |
var nextIndex = 0; | |
var lastIndex = 0; | |
// `nextMountIndex` will increment for each newly mounted child. | |
var nextMountIndex = 0; | |
var lastPlacedNode = null; | |
for (name in nextChildren) { | |
if (!nextChildren.hasOwnProperty(name)) { | |
continue; | |
} | |
var prevChild = prevChildren && prevChildren[name]; | |
var nextChild = nextChildren[name]; | |
if (prevChild === nextChild) { | |
updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex)); | |
lastIndex = Math.max(prevChild._mountIndex, lastIndex); | |
prevChild._mountIndex = nextIndex; | |
} else { | |
if (prevChild) { | |
// Update `lastIndex` before `_mountIndex` gets unset by unmounting. | |
lastIndex = Math.max(prevChild._mountIndex, lastIndex); | |
// The `removedNodes` loop below will actually remove the child. | |
} | |
// The child must be instantiated before it's mounted. | |
updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context)); | |
nextMountIndex++; | |
} | |
nextIndex++; | |
lastPlacedNode = ReactReconciler$1.getHostNode(nextChild); | |
} | |
// Remove children that are no longer present. | |
for (name in removedNodes) { | |
if (removedNodes.hasOwnProperty(name)) { | |
updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name])); | |
} | |
} | |
if (updates) { | |
processQueue(this, updates); | |
} | |
this._renderedChildren = nextChildren; | |
if (__DEV__) { | |
setChildrenForInstrumentation.call(this, nextChildren); | |
} | |
}, | |
/** | |
* Unmounts all rendered children. This should be used to clean up children | |
* when this component is unmounted. It does not actually perform any | |
* backend operations. | |
* | |
* @internal | |
*/ | |
unmountChildren: function (safely, skipLifecycle) { | |
var renderedChildren = this._renderedChildren; | |
ReactChildReconciler.unmountChildren(renderedChildren, safely, skipLifecycle); | |
this._renderedChildren = null; | |
}, | |
/** | |
* Moves a child component to the supplied index. | |
* | |
* @param {ReactComponent} child Component to move. | |
* @param {number} toIndex Destination index of the element. | |
* @param {number} lastIndex Last index visited of the siblings of `child`. | |
* @protected | |
*/ | |
moveChild: function (child, afterNode, toIndex, lastIndex) { | |
// If the index of `child` is less than `lastIndex`, then it needs to | |
// be moved. Otherwise, we do not need to move it because a child will be | |
// inserted or moved before `child`. | |
if (child._mountIndex < lastIndex) { | |
return makeMove(child, afterNode, toIndex); | |
} | |
}, | |
/** | |
* Creates a child component. | |
* | |
* @param {ReactComponent} child Component to create. | |
* @param {string} mountImage Markup to insert. | |
* @protected | |
*/ | |
createChild: function (child, afterNode, mountImage) { | |
return makeInsertMarkup(mountImage, afterNode, child._mountIndex); | |
}, | |
/** | |
* Removes a child component. | |
* | |
* @param {ReactComponent} child Child to remove. | |
* @protected | |
*/ | |
removeChild: function (child, node) { | |
return makeRemove(child, node); | |
}, | |
/** | |
* Mounts a child with the supplied name. | |
* | |
* NOTE: This is part of `updateChildren` and is here for readability. | |
* | |
* @param {ReactComponent} child Component to mount. | |
* @param {string} name Name of the child. | |
* @param {number} index Index at which to insert the child. | |
* @param {ReactReconcileTransaction} transaction | |
* @private | |
*/ | |
_mountChildAtIndex: function (child, mountImage, afterNode, index, transaction, context) { | |
child._mountIndex = index; | |
return this.createChild(child, afterNode, mountImage); | |
}, | |
/** | |
* Unmounts a rendered child. | |
* | |
* NOTE: This is part of `updateChildren` and is here for readability. | |
* | |
* @param {ReactComponent} child Component to unmount. | |
* @private | |
*/ | |
_unmountChild: function (child, node) { | |
var update = this.removeChild(child, node); | |
child._mountIndex = null; | |
return update; | |
} | |
}; | |
var ReactMultiChild_1 = ReactMultiChild$1; | |
var invariant$23 = invariant; | |
var OBSERVED_ERROR = {}; | |
/** | |
* `Transaction` creates a black box that is able to wrap any method such that | |
* certain invariants are maintained before and after the method is invoked | |
* (Even if an exception is thrown while invoking the wrapped method). Whoever | |
* instantiates a transaction can provide enforcers of the invariants at | |
* creation time. The `Transaction` class itself will supply one additional | |
* automatic invariant for you - the invariant that any transaction instance | |
* should not be run while it is already being run. You would typically create a | |
* single instance of a `Transaction` for reuse multiple times, that potentially | |
* is used to wrap several different methods. Wrappers are extremely simple - | |
* they only require implementing two methods. | |
* | |
* <pre> | |
* wrappers (injected at creation time) | |
* + + | |
* | | | |
* +-----------------|--------|--------------+ | |
* | v | | | |
* | +---------------+ | | | |
* | +--| wrapper1 |---|----+ | | |
* | | +---------------+ v | | | |
* | | +-------------+ | | | |
* | | +----| wrapper2 |--------+ | | |
* | | | +-------------+ | | | | |
* | | | | | | | |
* | v v v v | wrapper | |
* | +---+ +---+ +---------+ +---+ +---+ | invariants | |
* perform(anyMethod) | | | | | | | | | | | | maintained | |
* +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|--------> | |
* | | | | | | | | | | | | | |
* | | | | | | | | | | | | | |
* | | | | | | | | | | | | | |
* | +---+ +---+ +---------+ +---+ +---+ | | |
* | initialize close | | |
* +-----------------------------------------+ | |
* </pre> | |
* | |
* Use cases: | |
* - Preserving the input selection ranges before/after reconciliation. | |
* Restoring selection even in the event of an unexpected error. | |
* - Deactivating events while rearranging the DOM, preventing blurs/focuses, | |
* while guaranteeing that afterwards, the event system is reactivated. | |
* - Flushing a queue of collected DOM mutations to the main UI thread after a | |
* reconciliation takes place in a worker thread. | |
* - Invoking any collected `componentDidUpdate` callbacks after rendering new | |
* content. | |
* - (Future use case): Wrapping particular flushes of the `ReactWorker` queue | |
* to preserve the `scrollTop` (an automatic scroll aware DOM). | |
* - (Future use case): Layout calculations before and after DOM updates. | |
* | |
* Transactional plugin API: | |
* - A module that has an `initialize` method that returns any precomputation. | |
* - and a `close` method that accepts the precomputation. `close` is invoked | |
* when the wrapped process is completed, or has failed. | |
* | |
* @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules | |
* that implement `initialize` and `close`. | |
* @return {Transaction} Single transaction for reuse in thread. | |
* | |
* @class Transaction | |
*/ | |
var TransactionImpl = { | |
/** | |
* Sets up this instance so that it is prepared for collecting metrics. Does | |
* so such that this setup method may be used on an instance that is already | |
* initialized, in a way that does not consume additional memory upon reuse. | |
* That can be useful if you decide to make your subclass of this mixin a | |
* "PooledClass". | |
*/ | |
reinitializeTransaction: function () { | |
this.transactionWrappers = this.getTransactionWrappers(); | |
if (this.wrapperInitData) { | |
this.wrapperInitData.length = 0; | |
} else { | |
this.wrapperInitData = []; | |
} | |
this._isInTransaction = false; | |
}, | |
_isInTransaction: false, | |
/** | |
* @abstract | |
* @return {Array<TransactionWrapper>} Array of transaction wrappers. | |
*/ | |
getTransactionWrappers: null, | |
isInTransaction: function () { | |
return !!this._isInTransaction; | |
}, | |
/** | |
* Executes the function within a safety window. Use this for the top level | |
* methods that result in large amounts of computation/mutations that would | |
* need to be safety checked. The optional arguments helps prevent the need | |
* to bind in many cases. | |
* | |
* @param {function} method Member of scope to call. | |
* @param {Object} scope Scope to invoke from. | |
* @param {Object?=} a Argument to pass to the method. | |
* @param {Object?=} b Argument to pass to the method. | |
* @param {Object?=} c Argument to pass to the method. | |
* @param {Object?=} d Argument to pass to the method. | |
* @param {Object?=} e Argument to pass to the method. | |
* @param {Object?=} f Argument to pass to the method. | |
* | |
* @return {*} Return value from `method`. | |
*/ | |
perform: function (method, scope, a, b, c, d, e, f) { | |
invariant$23(!this.isInTransaction(), 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.'); | |
var errorThrown; | |
var ret; | |
try { | |
this._isInTransaction = true; | |
// Catching errors makes debugging more difficult, so we start with | |
// errorThrown set to true before setting it to false after calling | |
// close -- if it's still set to true in the finally block, it means | |
// one of these calls threw. | |
errorThrown = true; | |
this.initializeAll(0); | |
ret = method.call(scope, a, b, c, d, e, f); | |
errorThrown = false; | |
} finally { | |
try { | |
if (errorThrown) { | |
// If `method` throws, prefer to show that stack trace over any thrown | |
// by invoking `closeAll`. | |
try { | |
this.closeAll(0); | |
} catch (err) {} | |
} else { | |
// Since `method` didn't throw, we don't want to silence the exception | |
// here. | |
this.closeAll(0); | |
} | |
} finally { | |
this._isInTransaction = false; | |
} | |
} | |
return ret; | |
}, | |
initializeAll: function (startIndex) { | |
var transactionWrappers = this.transactionWrappers; | |
for (var i = startIndex; i < transactionWrappers.length; i++) { | |
var wrapper = transactionWrappers[i]; | |
try { | |
// Catching errors makes debugging more difficult, so we start with the | |
// OBSERVED_ERROR state before overwriting it with the real return value | |
// of initialize -- if it's still set to OBSERVED_ERROR in the finally | |
// block, it means wrapper.initialize threw. | |
this.wrapperInitData[i] = OBSERVED_ERROR; | |
this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null; | |
} finally { | |
if (this.wrapperInitData[i] === OBSERVED_ERROR) { | |
// The initializer for wrapper i threw an error; initialize the | |
// remaining wrappers but silence any exceptions from them to ensure | |
// that the first error is the one to bubble up. | |
try { | |
this.initializeAll(i + 1); | |
} catch (err) {} | |
} | |
} | |
} | |
}, | |
/** | |
* Invokes each of `this.transactionWrappers.close[i]` functions, passing into | |
* them the respective return values of `this.transactionWrappers.init[i]` | |
* (`close`rs that correspond to initializers that failed will not be | |
* invoked). | |
*/ | |
closeAll: function (startIndex) { | |
invariant$23(this.isInTransaction(), 'Transaction.closeAll(): Cannot close transaction when none are open.'); | |
var transactionWrappers = this.transactionWrappers; | |
for (var i = startIndex; i < transactionWrappers.length; i++) { | |
var wrapper = transactionWrappers[i]; | |
var initData = this.wrapperInitData[i]; | |
var errorThrown; | |
try { | |
// Catching errors makes debugging more difficult, so we start with | |
// errorThrown set to true before setting it to false after calling | |
// close -- if it's still set to true in the finally block, it means | |
// wrapper.close threw. | |
errorThrown = true; | |
if (initData !== OBSERVED_ERROR && wrapper.close) { | |
wrapper.close.call(this, initData); | |
} | |
errorThrown = false; | |
} finally { | |
if (errorThrown) { | |
// The closer for wrapper i threw an error; close the remaining | |
// wrappers but silence any exceptions from them to ensure that the | |
// first error is the one to bubble up. | |
try { | |
this.closeAll(i + 1); | |
} catch (e) {} | |
} | |
} | |
} | |
this.wrapperInitData.length = 0; | |
} | |
}; | |
var Transaction$1 = TransactionImpl; | |
var PooledClass$5 = PooledClass_1; | |
var ReactFeatureFlags$3 = ReactFeatureFlags_1; | |
var ReactReconciler$5 = ReactReconciler_1; | |
var Transaction$3 = Transaction$1; | |
var invariant$24 = invariant; | |
var dirtyComponents = []; | |
var updateBatchNumber = 0; | |
var batchingStrategy = null; | |
function ensureInjected() { | |
invariant$24(ReactUpdates$2.ReactReconcileTransaction && batchingStrategy, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy'); | |
} | |
var NESTED_UPDATES = { | |
initialize: function () { | |
this.dirtyComponentsLength = dirtyComponents.length; | |
}, | |
close: function () { | |
if (this.dirtyComponentsLength !== dirtyComponents.length) { | |
// Additional updates were enqueued by componentDidUpdate handlers or | |
// similar; before our own UPDATE_QUEUEING wrapper closes, we want to run | |
// these new updates so that if A's componentDidUpdate calls setState on | |
// B, B will update before the callback A's updater provided when calling | |
// setState. | |
dirtyComponents.splice(0, this.dirtyComponentsLength); | |
flushBatchedUpdates(); | |
} else { | |
dirtyComponents.length = 0; | |
} | |
} | |
}; | |
var TRANSACTION_WRAPPERS$1 = [NESTED_UPDATES]; | |
function ReactUpdatesFlushTransaction() { | |
this.reinitializeTransaction(); | |
this.dirtyComponentsLength = null; | |
this.reconcileTransaction = ReactUpdates$2.ReactReconcileTransaction.getPooled( | |
/* useCreateElement */true); | |
} | |
Object.assign(ReactUpdatesFlushTransaction.prototype, Transaction$3, { | |
getTransactionWrappers: function () { | |
return TRANSACTION_WRAPPERS$1; | |
}, | |
destructor: function () { | |
this.dirtyComponentsLength = null; | |
ReactUpdates$2.ReactReconcileTransaction.release(this.reconcileTransaction); | |
this.reconcileTransaction = null; | |
}, | |
perform: function (method, scope, a) { | |
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)` | |
// with this transaction's wrappers around it. | |
return Transaction$3.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a); | |
} | |
}); | |
PooledClass$5.addPoolingTo(ReactUpdatesFlushTransaction); | |
function batchedUpdates$1(callback, a, b, c, d, e) { | |
ensureInjected(); | |
return batchingStrategy.batchedUpdates(callback, a, b, c, d, e); | |
} | |
/** | |
* Array comparator for ReactComponents by mount ordering. | |
* | |
* @param {ReactComponent} c1 first component you're comparing | |
* @param {ReactComponent} c2 second component you're comparing | |
* @return {number} Return value usable by Array.prototype.sort(). | |
*/ | |
function mountOrderComparator(c1, c2) { | |
return c1._mountOrder - c2._mountOrder; | |
} | |
function runBatchedUpdates(transaction) { | |
var len = transaction.dirtyComponentsLength; | |
invariant$24(len === dirtyComponents.length, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length); | |
// Since reconciling a component higher in the owner hierarchy usually (not | |
// always -- see shouldComponentUpdate()) will reconcile children, reconcile | |
// them before their children by sorting the array. | |
dirtyComponents.sort(mountOrderComparator); | |
// Any updates enqueued while reconciling must be performed after this entire | |
// batch. Otherwise, if dirtyComponents is [A, B] where A has children B and | |
// C, B could update twice in a single batch if C's render enqueues an update | |
// to B (since B would have already updated, we should skip it, and the only | |
// way we can know to do so is by checking the batch counter). | |
updateBatchNumber++; | |
for (var i = 0; i < len; i++) { | |
// If a component is unmounted before pending changes apply, it will still | |
// be here, but we assume that it has cleared its _pendingCallbacks and | |
// that performUpdateIfNecessary is a noop. | |
var component = dirtyComponents[i]; | |
var markerName; | |
if (ReactFeatureFlags$3.logTopLevelRenders) { | |
var namedComponent = component; | |
// Duck type TopLevelWrapper. This is probably always true. | |
if (component._currentElement.type.isReactTopLevelWrapper) { | |
namedComponent = component._renderedComponent; | |
} | |
markerName = 'React update: ' + namedComponent.getName(); | |
console.time(markerName); | |
} | |
ReactReconciler$5.performUpdateIfNecessary(component, transaction.reconcileTransaction, updateBatchNumber); | |
if (markerName) { | |
console.timeEnd(markerName); | |
} | |
} | |
} | |
var flushBatchedUpdates = function () { | |
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents | |
// array and perform any updates enqueued by mount-ready handlers (i.e., | |
// componentDidUpdate) but we need to check here too in order to catch | |
// updates enqueued by setState callbacks. | |
while (dirtyComponents.length) { | |
var transaction = ReactUpdatesFlushTransaction.getPooled(); | |
transaction.perform(runBatchedUpdates, null, transaction); | |
ReactUpdatesFlushTransaction.release(transaction); | |
} | |
}; | |
/** | |
* Mark a component as needing a rerender, adding an optional callback to a | |
* list of functions which will be executed once the rerender occurs. | |
*/ | |
function enqueueUpdate$1(component) { | |
ensureInjected(); | |
// Various parts of our code (such as ReactCompositeComponent's | |
// _renderValidatedComponent) assume that calls to render aren't nested; | |
// verify that that's the case. (This is called by each top-level update | |
// function, like setState, forceUpdate, etc.; creation and | |
// destruction of top-level components is guarded in ReactMount.) | |
if (!batchingStrategy.isBatchingUpdates) { | |
batchingStrategy.batchedUpdates(enqueueUpdate$1, component); | |
return; | |
} | |
dirtyComponents.push(component); | |
if (component._updateBatchNumber == null) { | |
component._updateBatchNumber = updateBatchNumber + 1; | |
} | |
} | |
var ReactUpdatesInjection = { | |
injectReconcileTransaction: function (ReconcileTransaction) { | |
invariant$24(ReconcileTransaction, 'ReactUpdates: must provide a reconcile transaction class'); | |
ReactUpdates$2.ReactReconcileTransaction = ReconcileTransaction; | |
}, | |
injectBatchingStrategy: function (_batchingStrategy) { | |
invariant$24(_batchingStrategy, 'ReactUpdates: must provide a batching strategy'); | |
invariant$24(typeof _batchingStrategy.batchedUpdates === 'function', 'ReactUpdates: must provide a batchedUpdates() function'); | |
invariant$24(typeof _batchingStrategy.isBatchingUpdates === 'boolean', 'ReactUpdates: must provide an isBatchingUpdates boolean attribute'); | |
batchingStrategy = _batchingStrategy; | |
}, | |
getBatchingStrategy: function () { | |
return batchingStrategy; | |
} | |
}; | |
var ReactUpdates$2 = { | |
/** | |
* React references `ReactReconcileTransaction` using this property in order | |
* to allow dependency injection. | |
* | |
* @internal | |
*/ | |
ReactReconcileTransaction: null, | |
batchedUpdates: batchedUpdates$1, | |
enqueueUpdate: enqueueUpdate$1, | |
flushBatchedUpdates: flushBatchedUpdates, | |
injection: ReactUpdatesInjection | |
}; | |
var ReactUpdates_1 = ReactUpdates$2; | |
var ReactCurrentOwner$5 = ReactCurrentOwner_1; | |
var ReactInstanceMap$3 = ReactInstanceMap_1; | |
var ReactInstrumentation$10 = ReactInstrumentation$2; | |
var ReactUpdates$1 = ReactUpdates_1; | |
if (__DEV__) { | |
var warning$24 = warning; | |
var warnOnInvalidCallback = function (callback, callerName) { | |
warning$24(callback === null || typeof callback === 'function', '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, '' + callback); | |
}; | |
} | |
function enqueueUpdate(internalInstance) { | |
ReactUpdates$1.enqueueUpdate(internalInstance); | |
} | |
function getInternalInstanceReadyForUpdate(publicInstance, callerName) { | |
var internalInstance = ReactInstanceMap$3.get(publicInstance); | |
if (!internalInstance) { | |
if (__DEV__) { | |
var ctor = publicInstance.constructor; | |
warning$24(false, 'Can only update a mounted or mounting component. This usually means ' + 'you called setState, replaceState, or forceUpdate on an unmounted ' + 'component. This is a no-op.\n\nPlease check the code for the ' + '%s component.', ctor && (ctor.displayName || ctor.name) || 'ReactClass'); | |
} | |
return null; | |
} | |
if (__DEV__) { | |
warning$24(ReactCurrentOwner$5.current == null, 'Cannot update during an existing state transition (such as within ' + '`render` or another component\'s constructor). Render methods should ' + 'be a pure function of props and state; constructor side-effects are ' + 'an anti-pattern, but can be moved to `componentWillMount`.'); | |
} | |
return internalInstance; | |
} | |
/** | |
* ReactUpdateQueue allows for state updates to be scheduled into a later | |
* reconciliation step. | |
*/ | |
var ReactUpdateQueue$1 = { | |
/** | |
* Checks whether or not this composite component is mounted. | |
* @param {ReactClass} publicInstance The instance we want to test. | |
* @return {boolean} True if mounted, false otherwise. | |
* @protected | |
* @final | |
*/ | |
isMounted: function (publicInstance) { | |
if (__DEV__) { | |
var owner = ReactCurrentOwner$5.current; | |
if (owner !== null) { | |
warning$24(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component'); | |
owner._warnedAboutRefsInRender = true; | |
} | |
} | |
var internalInstance = ReactInstanceMap$3.get(publicInstance); | |
if (internalInstance) { | |
// During componentWillMount and render this will still be null but after | |
// that will always render to something. At least for now. So we can use | |
// this hack. | |
return !!internalInstance._renderedComponent; | |
} else { | |
return false; | |
} | |
}, | |
enqueueCallbackInternal: function (internalInstance, callback) { | |
if (internalInstance._pendingCallbacks) { | |
internalInstance._pendingCallbacks.push(callback); | |
} else { | |
internalInstance._pendingCallbacks = [callback]; | |
} | |
enqueueUpdate(internalInstance); | |
}, | |
/** | |
* Forces an update. This should only be invoked when it is known with | |
* certainty that we are **not** in a DOM transaction. | |
* | |
* You may want to call this when you know that some deeper aspect of the | |
* component's state has changed but `setState` was not called. | |
* | |
* This will not invoke `shouldComponentUpdate`, but it will invoke | |
* `componentWillUpdate` and `componentDidUpdate`. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueForceUpdate: function (publicInstance, callback, callerName) { | |
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance); | |
if (!internalInstance) { | |
return; | |
} | |
if (callback) { | |
callback = callback === undefined ? null : callback; | |
if (__DEV__) { | |
warnOnInvalidCallback(callback, callerName); | |
} | |
if (internalInstance._pendingCallbacks) { | |
internalInstance._pendingCallbacks.push(callback); | |
} else { | |
internalInstance._pendingCallbacks = [callback]; | |
} | |
} | |
internalInstance._pendingForceUpdate = true; | |
enqueueUpdate(internalInstance); | |
}, | |
/** | |
* Replaces all of the state. Always use this or `setState` to mutate state. | |
* You should treat `this.state` as immutable. | |
* | |
* There is no guarantee that `this.state` will be immediately updated, so | |
* accessing `this.state` after calling this method may return the old value. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object} completeState Next state. | |
* @param {?function} callback Called after state is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueReplaceState: function (publicInstance, completeState, callback, callerName) { | |
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance); | |
if (!internalInstance) { | |
return; | |
} | |
internalInstance._pendingStateQueue = [completeState]; | |
internalInstance._pendingReplaceState = true; | |
if (callback) { | |
callback = callback === undefined ? null : callback; | |
if (__DEV__) { | |
warnOnInvalidCallback(callback, callerName); | |
} | |
if (internalInstance._pendingCallbacks) { | |
internalInstance._pendingCallbacks.push(callback); | |
} else { | |
internalInstance._pendingCallbacks = [callback]; | |
} | |
} | |
enqueueUpdate(internalInstance); | |
}, | |
/** | |
* Sets a subset of the state. This only exists because _pendingState is | |
* internal. This provides a merging strategy that is not available to deep | |
* properties which is confusing. TODO: Expose pendingState or don't use it | |
* during the merge. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object} partialState Next partial state to be merged with state. | |
* @param {?function} callback Called after state is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
enqueueSetState: function (publicInstance, partialState, callback, callerName) { | |
if (__DEV__) { | |
ReactInstrumentation$10.debugTool.onSetState(); | |
warning$24(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().'); | |
} | |
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance); | |
if (!internalInstance) { | |
return; | |
} | |
var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []); | |
queue.push(partialState); | |
if (callback) { | |
callback = callback === undefined ? null : callback; | |
if (__DEV__) { | |
warnOnInvalidCallback(callback, callerName); | |
} | |
if (internalInstance._pendingCallbacks) { | |
internalInstance._pendingCallbacks.push(callback); | |
} else { | |
internalInstance._pendingCallbacks = [callback]; | |
} | |
} | |
enqueueUpdate(internalInstance); | |
}, | |
enqueueElementInternal: function (internalInstance, nextElement, nextContext) { | |
internalInstance._pendingElement = nextElement; | |
// TODO: introduce _pendingContext instead of setting it directly. | |
internalInstance._context = nextContext; | |
enqueueUpdate(internalInstance); | |
} | |
}; | |
var ReactUpdateQueue_1 = ReactUpdateQueue$1; | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var ReactUpdateQueue = ReactUpdateQueue_1; | |
var warning$23 = warning; | |
function warnNoop(publicInstance, callerName) { | |
if (__DEV__) { | |
var constructor = publicInstance.constructor; | |
warning$23(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, constructor && (constructor.displayName || constructor.name) || 'ReactClass'); | |
} | |
} | |
/** | |
* This is the update queue used for server rendering. | |
* It delegates to ReactUpdateQueue while server rendering is in progress and | |
* switches to ReactNoopUpdateQueue after the transaction has completed. | |
* @class ReactServerUpdateQueue | |
* @param {Transaction} transaction | |
*/ | |
var ReactServerUpdateQueue$1 = function () { | |
function ReactServerUpdateQueue(transaction) { | |
_classCallCheck(this, ReactServerUpdateQueue); | |
this.transaction = transaction; | |
} | |
/** | |
* Checks whether or not this composite component is mounted. | |
* @param {ReactClass} publicInstance The instance we want to test. | |
* @return {boolean} True if mounted, false otherwise. | |
* @protected | |
* @final | |
*/ | |
ReactServerUpdateQueue.prototype.isMounted = function isMounted(publicInstance) { | |
return false; | |
}; | |
/** | |
* Forces an update. This should only be invoked when it is known with | |
* certainty that we are **not** in a DOM transaction. | |
* | |
* You may want to call this when you know that some deeper aspect of the | |
* component's state has changed but `setState` was not called. | |
* | |
* This will not invoke `shouldComponentUpdate`, but it will invoke | |
* `componentWillUpdate` and `componentDidUpdate`. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
ReactServerUpdateQueue.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance, callback, callerName) { | |
if (this.transaction.isInTransaction()) { | |
ReactUpdateQueue.enqueueForceUpdate(publicInstance, callback, callerName); | |
} else { | |
warnNoop(publicInstance, 'forceUpdate'); | |
} | |
}; | |
/** | |
* Replaces all of the state. Always use this or `setState` to mutate state. | |
* You should treat `this.state` as immutable. | |
* | |
* There is no guarantee that `this.state` will be immediately updated, so | |
* accessing `this.state` after calling this method may return the old value. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object|function} completeState Next state. | |
* @param {?function} callback Called after component is updated. | |
* @param {?string} Name of the calling function in the public API. | |
* @internal | |
*/ | |
ReactServerUpdateQueue.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState, callback, callerName) { | |
if (this.transaction.isInTransaction()) { | |
ReactUpdateQueue.enqueueReplaceState(publicInstance, completeState, callback, callerName); | |
} else { | |
warnNoop(publicInstance, 'replaceState'); | |
} | |
}; | |
/** | |
* Sets a subset of the state. This only exists because _pendingState is | |
* internal. This provides a merging strategy that is not available to deep | |
* properties which is confusing. TODO: Expose pendingState or don't use it | |
* during the merge. | |
* | |
* @param {ReactClass} publicInstance The instance that should rerender. | |
* @param {object|function} partialState Next partial state to be merged with state. | |
* @internal | |
*/ | |
ReactServerUpdateQueue.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState, callback, callerName) { | |
if (this.transaction.isInTransaction()) { | |
ReactUpdateQueue.enqueueSetState(publicInstance, partialState, callback, callerName); | |
} else { | |
warnNoop(publicInstance, 'setState'); | |
} | |
}; | |
return ReactServerUpdateQueue; | |
}(); | |
var ReactServerUpdateQueue_1 = ReactServerUpdateQueue$1; | |
var PooledClass$4 = PooledClass_1; | |
var Transaction = Transaction$1; | |
var ReactInstrumentation$9 = ReactInstrumentation$2; | |
var ReactServerUpdateQueue = ReactServerUpdateQueue_1; | |
/** | |
* Executed within the scope of the `Transaction` instance. Consider these as | |
* being member methods, but with an implied ordering while being isolated from | |
* each other. | |
*/ | |
var TRANSACTION_WRAPPERS = []; | |
if (__DEV__) { | |
TRANSACTION_WRAPPERS.push({ | |
initialize: ReactInstrumentation$9.debugTool.onBeginFlush, | |
close: ReactInstrumentation$9.debugTool.onEndFlush | |
}); | |
} | |
var noopCallbackQueue = { | |
enqueue: function () {} | |
}; | |
/** | |
* @class ReactServerRenderingTransaction | |
* @param {boolean} renderToStaticMarkup | |
*/ | |
function ReactServerRenderingTransaction$1(renderToStaticMarkup) { | |
this.reinitializeTransaction(); | |
this.renderToStaticMarkup = renderToStaticMarkup; | |
this.useCreateElement = false; | |
this.updateQueue = new ReactServerUpdateQueue(this); | |
} | |
var Mixin = { | |
/** | |
* @see Transaction | |
* @abstract | |
* @final | |
* @return {array} Empty list of operation wrap procedures. | |
*/ | |
getTransactionWrappers: function () { | |
return TRANSACTION_WRAPPERS; | |
}, | |
/** | |
* @return {object} The queue to collect `onDOMReady` callbacks with. | |
*/ | |
getReactMountReady: function () { | |
return noopCallbackQueue; | |
}, | |
/** | |
* @return {object} The queue to collect React async events. | |
*/ | |
getUpdateQueue: function () { | |
return this.updateQueue; | |
}, | |
/** | |
* `PooledClass` looks for this, and will invoke this before allowing this | |
* instance to be reused. | |
*/ | |
destructor: function () {}, | |
checkpoint: function () {}, | |
rollback: function () {} | |
}; | |
Object.assign(ReactServerRenderingTransaction$1.prototype, Transaction, Mixin); | |
PooledClass$4.addPoolingTo(ReactServerRenderingTransaction$1); | |
var ReactServerRenderingTransaction_1 = ReactServerRenderingTransaction$1; | |
var emptyFunction$5 = emptyFunction; | |
var getComponentName$4 = getComponentName_1; | |
var warning$25 = warning; | |
var validateDOMNesting$1 = emptyFunction$5; | |
if (__DEV__) { | |
var _require$7 = ReactDebugCurrentFiber_1, | |
getCurrentFiberStackAddendum$1 = _require$7.getCurrentFiberStackAddendum; | |
// This validation code was written based on the HTML5 parsing spec: | |
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | |
// | |
// Note: this does not catch all invalid nesting, nor does it try to (as it's | |
// not clear what practical benefit doing so provides); instead, we warn only | |
// for cases where the parser will give a parse tree differing from what React | |
// intended. For example, <b><div></div></b> is invalid but we don't warn | |
// because it still parses correctly; we do warn for other cases like nested | |
// <p> tags where the beginning of the second element implicitly closes the | |
// first, causing a confusing mess. | |
// https://html.spec.whatwg.org/multipage/syntax.html#special | |
var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; | |
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope | |
var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', | |
// https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point | |
// TODO: Distinguish by namespace here -- for <title>, including it here | |
// errs on the side of fewer warnings | |
'foreignObject', 'desc', 'title']; | |
// https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope | |
var buttonScopeTags = inScopeTags.concat(['button']); | |
// https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags | |
var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt']; | |
var emptyAncestorInfo = { | |
current: null, | |
formTag: null, | |
aTagInScope: null, | |
buttonTagInScope: null, | |
nobrTagInScope: null, | |
pTagInButtonScope: null, | |
listItemTagAutoclosing: null, | |
dlItemTagAutoclosing: null | |
}; | |
var updatedAncestorInfo = function (oldInfo, tag, instance) { | |
var ancestorInfo = Object.assign({}, oldInfo || emptyAncestorInfo); | |
var info = { tag: tag, instance: instance }; | |
if (inScopeTags.indexOf(tag) !== -1) { | |
ancestorInfo.aTagInScope = null; | |
ancestorInfo.buttonTagInScope = null; | |
ancestorInfo.nobrTagInScope = null; | |
} | |
if (buttonScopeTags.indexOf(tag) !== -1) { | |
ancestorInfo.pTagInButtonScope = null; | |
} | |
// See rules for 'li', 'dd', 'dt' start tags in | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | |
if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') { | |
ancestorInfo.listItemTagAutoclosing = null; | |
ancestorInfo.dlItemTagAutoclosing = null; | |
} | |
ancestorInfo.current = info; | |
if (tag === 'form') { | |
ancestorInfo.formTag = info; | |
} | |
if (tag === 'a') { | |
ancestorInfo.aTagInScope = info; | |
} | |
if (tag === 'button') { | |
ancestorInfo.buttonTagInScope = info; | |
} | |
if (tag === 'nobr') { | |
ancestorInfo.nobrTagInScope = info; | |
} | |
if (tag === 'p') { | |
ancestorInfo.pTagInButtonScope = info; | |
} | |
if (tag === 'li') { | |
ancestorInfo.listItemTagAutoclosing = info; | |
} | |
if (tag === 'dd' || tag === 'dt') { | |
ancestorInfo.dlItemTagAutoclosing = info; | |
} | |
return ancestorInfo; | |
}; | |
/** | |
* Returns whether | |
*/ | |
var isTagValidWithParent = function (tag, parentTag) { | |
// First, let's check if we're in an unusual parsing mode... | |
switch (parentTag) { | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect | |
case 'select': | |
return tag === 'option' || tag === 'optgroup' || tag === '#text'; | |
case 'optgroup': | |
return tag === 'option' || tag === '#text'; | |
// Strictly speaking, seeing an <option> doesn't mean we're in a <select> | |
// but | |
case 'option': | |
return tag === '#text'; | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption | |
// No special behavior since these rules fall back to "in body" mode for | |
// all except special table nodes which cause bad parsing behavior anyway. | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr | |
case 'tr': | |
return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template'; | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody | |
case 'tbody': | |
case 'thead': | |
case 'tfoot': | |
return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template'; | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup | |
case 'colgroup': | |
return tag === 'col' || tag === 'template'; | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable | |
case 'table': | |
return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template'; | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead | |
case 'head': | |
return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template'; | |
// https://html.spec.whatwg.org/multipage/semantics.html#the-html-element | |
case 'html': | |
return tag === 'head' || tag === 'body'; | |
case '#document': | |
return tag === 'html'; | |
} | |
// Probably in the "in body" parsing mode, so we outlaw only tag combos | |
// where the parsing rules cause implicit opens or closes to be added. | |
// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody | |
switch (tag) { | |
case 'h1': | |
case 'h2': | |
case 'h3': | |
case 'h4': | |
case 'h5': | |
case 'h6': | |
return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6'; | |
case 'rp': | |
case 'rt': | |
return impliedEndTags.indexOf(parentTag) === -1; | |
case 'body': | |
case 'caption': | |
case 'col': | |
case 'colgroup': | |
case 'frame': | |
case 'head': | |
case 'html': | |
case 'tbody': | |
case 'td': | |
case 'tfoot': | |
case 'th': | |
case 'thead': | |
case 'tr': | |
// These tags are only valid with a few parents that have special child | |
// parsing rules -- if we're down here, then none of those matched and | |
// so we allow it only if we don't know what the parent is, as all other | |
// cases are invalid. | |
return parentTag == null; | |
} | |
return true; | |
}; | |
/** | |
* Returns whether | |
*/ | |
var findInvalidAncestorForTag = function (tag, ancestorInfo) { | |
switch (tag) { | |
case 'address': | |
case 'article': | |
case 'aside': | |
case 'blockquote': | |
case 'center': | |
case 'details': | |
case 'dialog': | |
case 'dir': | |
case 'div': | |
case 'dl': | |
case 'fieldset': | |
case 'figcaption': | |
case 'figure': | |
case 'footer': | |
case 'header': | |
case 'hgroup': | |
case 'main': | |
case 'menu': | |
case 'nav': | |
case 'ol': | |
case 'p': | |
case 'section': | |
case 'summary': | |
case 'ul': | |
case 'pre': | |
case 'listing': | |
case 'table': | |
case 'hr': | |
case 'xmp': | |
case 'h1': | |
case 'h2': | |
case 'h3': | |
case 'h4': | |
case 'h5': | |
case 'h6': | |
return ancestorInfo.pTagInButtonScope; | |
case 'form': | |
return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope; | |
case 'li': | |
return ancestorInfo.listItemTagAutoclosing; | |
case 'dd': | |
case 'dt': | |
return ancestorInfo.dlItemTagAutoclosing; | |
case 'button': | |
return ancestorInfo.buttonTagInScope; | |
case 'a': | |
// Spec says something about storing a list of markers, but it sounds | |
// equivalent to this check. | |
return ancestorInfo.aTagInScope; | |
case 'nobr': | |
return ancestorInfo.nobrTagInScope; | |
} | |
return null; | |
}; | |
/** | |
* Given a ReactCompositeComponent instance, return a list of its recursive | |
* owners, starting at the root and ending with the instance itself. | |
*/ | |
var findOwnerStack = function (instance) { | |
if (!instance) { | |
return []; | |
} | |
var stack = []; | |
do { | |
stack.push(instance); | |
} while (instance = instance._currentElement._owner); | |
stack.reverse(); | |
return stack; | |
}; | |
var getOwnerInfo = function (childInstance, childTag, ancestorInstance, ancestorTag, isParent) { | |
var childOwner = childInstance && childInstance._currentElement._owner; | |
var ancestorOwner = ancestorInstance && ancestorInstance._currentElement._owner; | |
var childOwners = findOwnerStack(childOwner); | |
var ancestorOwners = findOwnerStack(ancestorOwner); | |
var minStackLen = Math.min(childOwners.length, ancestorOwners.length); | |
var i; | |
var deepestCommon = -1; | |
for (i = 0; i < minStackLen; i++) { | |
if (childOwners[i] === ancestorOwners[i]) { | |
deepestCommon = i; | |
} else { | |
break; | |
} | |
} | |
var UNKNOWN = '(unknown)'; | |
var childOwnerNames = childOwners.slice(deepestCommon + 1).map(function (inst) { | |
return getComponentName$4(inst) || UNKNOWN; | |
}); | |
var ancestorOwnerNames = ancestorOwners.slice(deepestCommon + 1).map(function (inst) { | |
return getComponentName$4(inst) || UNKNOWN; | |
}); | |
var ownerInfo = [].concat( | |
// If the parent and child instances have a common owner ancestor, start | |
// with that -- otherwise we just start with the parent's owners. | |
deepestCommon !== -1 ? getComponentName$4(childOwners[deepestCommon]) || UNKNOWN : [], ancestorOwnerNames, ancestorTag, | |
// If we're warning about an invalid (non-parent) ancestry, add '...' | |
isParent ? [] : ['...'], childOwnerNames, childTag).join(' > '); | |
return ownerInfo; | |
}; | |
var didWarn = {}; | |
validateDOMNesting$1 = function (childTag, childText, childInstance, ancestorInfo) { | |
ancestorInfo = ancestorInfo || emptyAncestorInfo; | |
var parentInfo = ancestorInfo.current; | |
var parentTag = parentInfo && parentInfo.tag; | |
if (childText != null) { | |
warning$25(childTag == null, 'validateDOMNesting: when childText is passed, childTag should be null'); | |
childTag = '#text'; | |
} | |
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo; | |
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); | |
var invalidParentOrAncestor = invalidParent || invalidAncestor; | |
if (!invalidParentOrAncestor) { | |
return; | |
} | |
var ancestorInstance = invalidParentOrAncestor.instance; | |
var ancestorTag = invalidParentOrAncestor.tag; | |
var addendum; | |
if (childInstance != null) { | |
addendum = ' See ' + getOwnerInfo(childInstance, childTag, ancestorInstance, ancestorTag, !!invalidParent) + '.'; | |
} else { | |
addendum = getCurrentFiberStackAddendum$1(); | |
} | |
var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum; | |
if (didWarn[warnKey]) { | |
return; | |
} | |
didWarn[warnKey] = true; | |
var tagDisplayName = childTag; | |
var whitespaceInfo = ''; | |
if (childTag === '#text') { | |
if (/\S/.test(childText)) { | |
tagDisplayName = 'Text nodes'; | |
} else { | |
tagDisplayName = 'Whitespace text nodes'; | |
whitespaceInfo = ' Make sure you don\'t have any extra whitespace between tags on ' + 'each line of your source code.'; | |
} | |
} else { | |
tagDisplayName = '<' + childTag + '>'; | |
} | |
if (invalidParent) { | |
var info = ''; | |
if (ancestorTag === 'table' && childTag === 'tr') { | |
info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.'; | |
} | |
warning$25(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum); | |
} else { | |
warning$25(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum); | |
} | |
}; | |
validateDOMNesting$1.updatedAncestorInfo = updatedAncestorInfo; | |
// For testing | |
validateDOMNesting$1.isTagValidInContext = function (tag, ancestorInfo) { | |
ancestorInfo = ancestorInfo || emptyAncestorInfo; | |
var parentInfo = ancestorInfo.current; | |
var parentTag = parentInfo && parentInfo.tag; | |
return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo); | |
}; | |
} | |
var validateDOMNesting_1 = validateDOMNesting$1; | |
var AutoFocusUtils = AutoFocusUtils_1; | |
var CSSPropertyOperations = CSSPropertyOperations_1; | |
var DOMLazyTree$3 = DOMLazyTree_1; | |
var DOMNamespaces$3 = DOMNamespaces_1; | |
var DOMProperty$4 = DOMProperty_1; | |
var DOMPropertyOperations = DOMPropertyOperations_1; | |
var EventPluginRegistry$3 = EventPluginRegistry_1; | |
var ReactBrowserEventEmitter$3 = ReactBrowserEventEmitter_1; | |
var ReactDOMComponentFlags$2 = ReactDOMComponentFlags_1; | |
var ReactDOMComponentTree$11 = ReactDOMComponentTree_1; | |
var ReactDOMInput = ReactDOMInput_1; | |
var ReactDOMOption = ReactDOMOption_1; | |
var ReactDOMSelect = ReactDOMSelect_1; | |
var ReactDOMTextarea = ReactDOMTextarea_1; | |
var ReactInstrumentation$4 = ReactInstrumentation$2; | |
var ReactMultiChild = ReactMultiChild_1; | |
var ReactServerRenderingTransaction = ReactServerRenderingTransaction_1; | |
var emptyFunction$3 = emptyFunction; | |
var escapeTextContentForBrowser$2 = escapeTextContentForBrowser_1; | |
var invariant$12 = invariant; | |
var isEventSupported$3 = isEventSupported_1; | |
var inputValueTracking$2 = inputValueTracking_1; | |
var validateDOMNesting = validateDOMNesting_1; | |
var warning$7 = warning; | |
var didWarnShadyDOM = false; | |
var Flags$1 = ReactDOMComponentFlags$2; | |
var getNode = ReactDOMComponentTree$11.getNodeFromInstance; | |
var listenTo = ReactBrowserEventEmitter$3.listenTo; | |
var registrationNameModules = EventPluginRegistry$3.registrationNameModules; | |
// For quickly matching children type, to test if can be treated as content. | |
var CONTENT_TYPES = { 'string': true, 'number': true }; | |
var STYLE = 'style'; | |
var HTML = '__html'; | |
var RESERVED_PROPS = { | |
children: null, | |
dangerouslySetInnerHTML: null, | |
suppressContentEditableWarning: null | |
}; | |
// Node type for document fragments (Node.DOCUMENT_FRAGMENT_NODE). | |
var DOC_FRAGMENT_TYPE = 11; | |
function getDeclarationErrorAddendum(internalInstance) { | |
if (internalInstance) { | |
var owner = internalInstance._currentElement._owner || null; | |
if (owner) { | |
var name = owner.getName(); | |
if (name) { | |
return '\n\nThis DOM node was rendered by `' + name + '`.'; | |
} | |
} | |
} | |
return ''; | |
} | |
/** | |
* @param {object} component | |
* @param {?object} props | |
*/ | |
function assertValidProps(component, props) { | |
if (!props) { | |
return; | |
} | |
// Note the use of `==` which checks for null or undefined. | |
if (voidElementTags[component._tag]) { | |
invariant$12(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must neither have `children` nor ' + 'use `dangerouslySetInnerHTML`.%s', component._tag, getDeclarationErrorAddendum(component)); | |
} | |
if (props.dangerouslySetInnerHTML != null) { | |
invariant$12(props.children == null, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'); | |
invariant$12(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.'); | |
} | |
if (__DEV__) { | |
warning$7(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); | |
warning$7(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, '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.'); | |
warning$7(props.onFocusIn == null && props.onFocusOut == null, '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.'); | |
} | |
invariant$12(props.style == null || typeof props.style === 'object', 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)); | |
} | |
function ensureListeningTo(inst, registrationName, transaction) { | |
if (transaction instanceof ReactServerRenderingTransaction) { | |
return; | |
} | |
if (__DEV__) { | |
// IE8 has no API for event capturing and the `onScroll` event doesn't | |
// bubble. | |
warning$7(registrationName !== 'onScroll' || isEventSupported$3('scroll', true), 'This browser doesn\'t support the `onScroll` event'); | |
} | |
var containerInfo = inst._hostContainerInfo; | |
var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE; | |
var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument; | |
listenTo(registrationName, doc); | |
} | |
function inputPostMount() { | |
var inst = this; | |
ReactDOMInput.postMountWrapper(inst); | |
} | |
function textareaPostMount() { | |
var inst = this; | |
ReactDOMTextarea.postMountWrapper(inst); | |
} | |
function optionPostMount() { | |
var inst = this; | |
ReactDOMOption.postMountWrapper(inst); | |
} | |
var setAndValidateContentChildDev = emptyFunction$3; | |
if (__DEV__) { | |
setAndValidateContentChildDev = function (content) { | |
var hasExistingContent = this._contentDebugID != null; | |
var debugID = this._debugID; | |
// This ID represents the inlined child that has no backing instance: | |
var contentDebugID = -debugID; | |
if (content == null) { | |
if (hasExistingContent) { | |
ReactInstrumentation$4.debugTool.onUnmountComponent(this._contentDebugID); | |
} | |
this._contentDebugID = null; | |
return; | |
} | |
validateDOMNesting(null, '' + content, this, this._ancestorInfo); | |
this._contentDebugID = contentDebugID; | |
if (hasExistingContent) { | |
ReactInstrumentation$4.debugTool.onBeforeUpdateComponent(contentDebugID, content); | |
ReactInstrumentation$4.debugTool.onUpdateComponent(contentDebugID); | |
} else { | |
ReactInstrumentation$4.debugTool.onBeforeMountComponent(contentDebugID, content, debugID); | |
ReactInstrumentation$4.debugTool.onMountComponent(contentDebugID); | |
ReactInstrumentation$4.debugTool.onSetChildren(debugID, [contentDebugID]); | |
} | |
}; | |
} | |
// There are so many media events, it makes sense to just | |
// maintain a list rather than create a `trapBubbledEvent` for each | |
var mediaEvents = { | |
topAbort: 'abort', | |
topCanPlay: 'canplay', | |
topCanPlayThrough: 'canplaythrough', | |
topDurationChange: 'durationchange', | |
topEmptied: 'emptied', | |
topEncrypted: 'encrypted', | |
topEnded: 'ended', | |
topError: 'error', | |
topLoadedData: 'loadeddata', | |
topLoadedMetadata: 'loadedmetadata', | |
topLoadStart: 'loadstart', | |
topPause: 'pause', | |
topPlay: 'play', | |
topPlaying: 'playing', | |
topProgress: 'progress', | |
topRateChange: 'ratechange', | |
topSeeked: 'seeked', | |
topSeeking: 'seeking', | |
topStalled: 'stalled', | |
topSuspend: 'suspend', | |
topTimeUpdate: 'timeupdate', | |
topVolumeChange: 'volumechange', | |
topWaiting: 'waiting' | |
}; | |
function trackInputValue() { | |
inputValueTracking$2.track(this); | |
} | |
function trapClickOnNonInteractiveElement() { | |
// Mobile Safari does not fire properly bubble click events on | |
// non-interactive elements, which means delegated click listeners do not | |
// fire. The workaround for this bug involves attaching an empty click | |
// listener on the target node. | |
// http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
// Just set it using the onclick property so that we don't have to manage any | |
// bookkeeping for it. Not sure if we need to clear it when the listener is | |
// removed. | |
// TODO: Only do this for the relevant Safaris maybe? | |
var node = getNode(this); | |
node.onclick = emptyFunction$3; | |
} | |
function trapBubbledEventsLocal() { | |
var inst = this; | |
// If a component renders to null or if another component fatals and causes | |
// the state of the tree to be corrupted, `node` here can be null. | |
invariant$12(inst._rootNodeID, 'Must be mounted to trap events'); | |
var node = getNode(inst); | |
invariant$12(node, 'trapBubbledEvent(...): Requires node to be rendered.'); | |
switch (inst._tag) { | |
case 'iframe': | |
case 'object': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topLoad', 'load', node)]; | |
break; | |
case 'video': | |
case 'audio': | |
inst._wrapperState.listeners = []; | |
// Create listener for each media event | |
for (var event in mediaEvents) { | |
if (mediaEvents.hasOwnProperty(event)) { | |
inst._wrapperState.listeners.push(ReactBrowserEventEmitter$3.trapBubbledEvent(event, mediaEvents[event], node)); | |
} | |
} | |
break; | |
case 'source': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topError', 'error', node)]; | |
break; | |
case 'img': | |
case 'image': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topError', 'error', node), ReactBrowserEventEmitter$3.trapBubbledEvent('topLoad', 'load', node)]; | |
break; | |
case 'form': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topReset', 'reset', node), ReactBrowserEventEmitter$3.trapBubbledEvent('topSubmit', 'submit', node)]; | |
break; | |
case 'input': | |
case 'select': | |
case 'textarea': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topInvalid', 'invalid', node)]; | |
break; | |
case 'details': | |
inst._wrapperState.listeners = [ReactBrowserEventEmitter$3.trapBubbledEvent('topToggle', 'toggle', node)]; | |
break; | |
} | |
} | |
function postUpdateSelectWrapper() { | |
ReactDOMSelect.postUpdateWrapper(this); | |
} | |
// 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 | |
}; | |
var newlineEatingTags = { | |
'listing': true, | |
'pre': true, | |
'textarea': true | |
}; | |
// For HTML, certain tags cannot have children. This has the same purpose as | |
// `omittedCloseTags` except that `menuitem` should still have its closing tag. | |
var voidElementTags = Object.assign({ | |
'menuitem': true | |
}, omittedCloseTags); | |
// 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 = {}; | |
var hasOwnProperty = {}.hasOwnProperty; | |
function validateDangerousTag(tag) { | |
if (!hasOwnProperty.call(validatedTagCache, tag)) { | |
invariant$12(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag); | |
validatedTagCache[tag] = true; | |
} | |
} | |
function isCustomComponent(tagName, props) { | |
return tagName.indexOf('-') >= 0 || props.is != null; | |
} | |
var globalIdCounter = 1; | |
/** | |
* Creates a new React class that is idempotent and capable of containing other | |
* React components. It accepts event listeners and DOM properties that are | |
* valid according to `DOMProperty`. | |
* | |
* - Event listeners: `onClick`, `onMouseDown`, etc. | |
* - DOM properties: `className`, `name`, `title`, etc. | |
* | |
* The `style` property functions differently from the DOM API. It accepts an | |
* object mapping of style properties to values. | |
* | |
* @constructor ReactDOMComponent | |
* @extends ReactMultiChild | |
*/ | |
function ReactDOMComponent$1(element) { | |
var tag = element.type; | |
this._currentElement = element; | |
this._tag = tag.toLowerCase(); | |
this._namespaceURI = null; | |
this._renderedChildren = null; | |
this._hostNode = null; | |
this._hostParent = null; | |
this._rootNodeID = 0; | |
this._domID = 0; | |
this._hostContainerInfo = null; | |
this._wrapperState = null; | |
this._topLevelWrapper = null; | |
this._flags = 0; | |
if (__DEV__) { | |
this._ancestorInfo = null; | |
setAndValidateContentChildDev.call(this, null); | |
} | |
} | |
ReactDOMComponent$1.displayName = 'ReactDOMComponent'; | |
ReactDOMComponent$1.Mixin = { | |
/** | |
* Generates root tag markup then recurses. This method has side effects and | |
* is not idempotent. | |
* | |
* @internal | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {?ReactDOMComponent} the parent component instance | |
* @param {?object} info about the host container | |
* @param {object} context | |
* @return {string} The computed markup. | |
*/ | |
mountComponent: function (transaction, hostParent, hostContainerInfo, context) { | |
this._rootNodeID = globalIdCounter++; | |
this._domID = hostContainerInfo._idCounter++; | |
this._hostParent = hostParent; | |
this._hostContainerInfo = hostContainerInfo; | |
var props = this._currentElement.props; | |
switch (this._tag) { | |
case 'audio': | |
case 'form': | |
case 'iframe': | |
case 'img': | |
case 'image': | |
case 'link': | |
case 'object': | |
case 'source': | |
case 'video': | |
case 'details': | |
this._wrapperState = { | |
listeners: null | |
}; | |
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | |
break; | |
case 'input': | |
ReactDOMInput.mountWrapper(this, props, hostParent); | |
props = ReactDOMInput.getHostProps(this, props); | |
transaction.getReactMountReady().enqueue(trackInputValue, this); | |
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(this, 'onChange', transaction); | |
break; | |
case 'option': | |
ReactDOMOption.mountWrapper(this, props, hostParent); | |
props = ReactDOMOption.getHostProps(this, props); | |
break; | |
case 'select': | |
ReactDOMSelect.mountWrapper(this, props, hostParent); | |
props = ReactDOMSelect.getHostProps(this, props); | |
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(this, 'onChange', transaction); | |
break; | |
case 'textarea': | |
ReactDOMTextarea.mountWrapper(this, props, hostParent); | |
props = ReactDOMTextarea.getHostProps(this, props); | |
transaction.getReactMountReady().enqueue(trackInputValue, this); | |
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(this, 'onChange', transaction); | |
break; | |
} | |
assertValidProps(this, props); | |
// We create tags in the namespace of their parent container, except HTML | |
// tags get no namespace. | |
var namespaceURI; | |
var parentTag; | |
if (hostParent != null) { | |
namespaceURI = hostParent._namespaceURI; | |
parentTag = hostParent._tag; | |
} else if (hostContainerInfo._tag) { | |
namespaceURI = hostContainerInfo._namespaceURI; | |
parentTag = hostContainerInfo._tag; | |
} | |
if (namespaceURI == null || namespaceURI === DOMNamespaces$3.svg && parentTag === 'foreignobject') { | |
namespaceURI = DOMNamespaces$3.html; | |
} | |
if (namespaceURI === DOMNamespaces$3.html) { | |
if (__DEV__) { | |
warning$7(isCustomComponent(this._tag, props) || this._tag === this._currentElement.type, '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', this._currentElement.type); | |
} | |
if (this._tag === 'svg') { | |
namespaceURI = DOMNamespaces$3.svg; | |
} else if (this._tag === 'math') { | |
namespaceURI = DOMNamespaces$3.mathml; | |
} | |
} | |
this._namespaceURI = namespaceURI; | |
if (__DEV__) { | |
var parentInfo; | |
if (hostParent != null) { | |
parentInfo = hostParent._ancestorInfo; | |
} else if (hostContainerInfo._tag) { | |
parentInfo = hostContainerInfo._ancestorInfo; | |
} | |
if (parentInfo) { | |
// parentInfo should always be present except for the top-level | |
// component when server rendering | |
validateDOMNesting(this._tag, null, this, parentInfo); | |
} | |
this._ancestorInfo = validateDOMNesting.updatedAncestorInfo(parentInfo, this._tag, this); | |
} | |
var mountImage; | |
var type = this._currentElement.type; | |
if (transaction.useCreateElement) { | |
var ownerDocument = hostContainerInfo._ownerDocument; | |
var el; | |
if (namespaceURI === DOMNamespaces$3.html) { | |
if (this._tag === 'script') { | |
// Create the script via .innerHTML so its "parser-inserted" flag is | |
// set to true and it does not execute | |
var div = ownerDocument.createElement('div'); | |
div.innerHTML = '<' + type + '></' + type + '>'; | |
el = div.removeChild(div.firstChild); | |
} else if (props.is) { | |
el = ownerDocument.createElement(type, props.is); | |
} else { | |
// Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. | |
// See discussion in https://github.com/facebook/react/pull/6896 | |
// and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 | |
el = ownerDocument.createElement(type); | |
} | |
} else { | |
el = ownerDocument.createElementNS(namespaceURI, type); | |
} | |
var isCustomComponentTag = isCustomComponent(this._tag, props); | |
if (__DEV__ && isCustomComponentTag && !didWarnShadyDOM && el.shadyRoot) { | |
var owner = this._currentElement._owner; | |
var name = owner && owner.getName() || 'A component'; | |
warning$7(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', name); | |
didWarnShadyDOM = true; | |
} | |
ReactDOMComponentTree$11.precacheNode(this, el); | |
this._flags |= Flags$1.hasCachedChildNodes; | |
if (!this._hostParent) { | |
DOMPropertyOperations.setAttributeForRoot(el); | |
} | |
this._updateDOMProperties(null, props, transaction, isCustomComponentTag); | |
var lazyTree = DOMLazyTree$3(el); | |
this._createInitialChildren(transaction, props, context, lazyTree); | |
mountImage = lazyTree; | |
} else { | |
validateDangerousTag(this._tag); | |
var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props); | |
var tagContent = this._createContentMarkup(transaction, props, context); | |
if (!tagContent && omittedCloseTags[this._tag]) { | |
mountImage = tagOpen + '/>'; | |
} else { | |
mountImage = tagOpen + '>' + tagContent + '</' + type + '>'; | |
} | |
} | |
switch (this._tag) { | |
case 'input': | |
transaction.getReactMountReady().enqueue(inputPostMount, this); | |
if (props.autoFocus) { | |
transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this); | |
} | |
break; | |
case 'textarea': | |
transaction.getReactMountReady().enqueue(textareaPostMount, this); | |
if (props.autoFocus) { | |
transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this); | |
} | |
break; | |
case 'select': | |
if (props.autoFocus) { | |
transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this); | |
} | |
break; | |
case 'button': | |
if (props.autoFocus) { | |
transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this); | |
} | |
break; | |
case 'option': | |
transaction.getReactMountReady().enqueue(optionPostMount, this); | |
break; | |
default: | |
if (typeof props.onClick === 'function') { | |
transaction.getReactMountReady().enqueue(trapClickOnNonInteractiveElement, this); | |
} | |
break; | |
} | |
return mountImage; | |
}, | |
/** | |
* Creates markup for the open tag and all attributes. | |
* | |
* This method has side effects because events get registered. | |
* | |
* Iterating over object properties is faster than iterating over arrays. | |
* @see http://jsperf.com/obj-vs-arr-iteration | |
* | |
* @private | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {object} props | |
* @return {string} Markup of opening tag. | |
*/ | |
_createOpenTagMarkupAndPutListeners: function (transaction, props) { | |
var ret = '<' + this._currentElement.type; | |
for (var propKey in props) { | |
if (!props.hasOwnProperty(propKey)) { | |
continue; | |
} | |
var propValue = props[propKey]; | |
if (propValue == null) { | |
continue; | |
} | |
if (registrationNameModules.hasOwnProperty(propKey)) { | |
if (propValue) { | |
ensureListeningTo(this, propKey, transaction); | |
} | |
} else { | |
if (propKey === STYLE) { | |
if (propValue) { | |
if (__DEV__) { | |
Object.freeze(propValue); | |
} | |
} | |
propValue = CSSPropertyOperations.createMarkupForStyles(propValue, this); | |
} | |
var markup = null; | |
if (this._tag != null && isCustomComponent(this._tag, props)) { | |
if (!RESERVED_PROPS.hasOwnProperty(propKey)) { | |
markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue); | |
} | |
} else { | |
markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue); | |
} | |
if (markup) { | |
ret += ' ' + markup; | |
} | |
} | |
} | |
// For static pages, no need to put React ID and checksum. Saves lots of | |
// bytes. | |
if (transaction.renderToStaticMarkup) { | |
return ret; | |
} | |
if (!this._hostParent) { | |
ret += ' ' + DOMPropertyOperations.createMarkupForRoot(); | |
} | |
ret += ' ' + DOMPropertyOperations.createMarkupForID(this._domID); | |
return ret; | |
}, | |
/** | |
* Creates markup for the content between the tags. | |
* | |
* @private | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {object} props | |
* @param {object} context | |
* @return {string} Content markup. | |
*/ | |
_createContentMarkup: function (transaction, props, context) { | |
var ret = ''; | |
// Intentional use of != to avoid catching zero/false. | |
var innerHTML = props.dangerouslySetInnerHTML; | |
if (innerHTML != null) { | |
if (innerHTML.__html != null) { | |
ret = innerHTML.__html; | |
} | |
} else { | |
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null; | |
var childrenToUse = contentToUse != null ? null : props.children; | |
if (contentToUse != null) { | |
// TODO: Validate that text is allowed as a child of this node | |
ret = escapeTextContentForBrowser$2(contentToUse); | |
if (__DEV__) { | |
setAndValidateContentChildDev.call(this, contentToUse); | |
} | |
} else if (childrenToUse != null) { | |
var mountImages = this.mountChildren(childrenToUse, transaction, context); | |
ret = mountImages.join(''); | |
} | |
} | |
if (newlineEatingTags[this._tag] && ret.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> | |
return '\n' + ret; | |
} else { | |
return ret; | |
} | |
}, | |
_createInitialChildren: function (transaction, props, context, lazyTree) { | |
// Intentional use of != to avoid catching zero/false. | |
var innerHTML = props.dangerouslySetInnerHTML; | |
if (innerHTML != null) { | |
var innerHTMLContent = innerHTML.__html; | |
if (innerHTMLContent != null && innerHTMLContent !== '') { | |
DOMLazyTree$3.queueHTML(lazyTree, innerHTMLContent); | |
} | |
} else { | |
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null; | |
var childrenToUse = contentToUse != null ? null : props.children; | |
// TODO: Validate that text is allowed as a child of this node | |
if (contentToUse != null) { | |
// Avoid setting textContent when the text is empty. In IE11 setting | |
// textContent on a text area will cause the placeholder to not | |
// show within the textarea until it has been focused and blurred again. | |
// https://github.com/facebook/react/issues/6731#issuecomment-254874553 | |
if (contentToUse !== '') { | |
if (__DEV__) { | |
setAndValidateContentChildDev.call(this, contentToUse); | |
} | |
DOMLazyTree$3.queueText(lazyTree, contentToUse); | |
} | |
} else if (childrenToUse != null) { | |
var mountImages = this.mountChildren(childrenToUse, transaction, context); | |
for (var i = 0; i < mountImages.length; i++) { | |
DOMLazyTree$3.queueChild(lazyTree, mountImages[i]); | |
} | |
} | |
} | |
}, | |
/** | |
* Receives a next element and updates the component. | |
* | |
* @internal | |
* @param {ReactElement} nextElement | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @param {object} context | |
*/ | |
receiveComponent: function (nextElement, transaction, context) { | |
var prevElement = this._currentElement; | |
this._currentElement = nextElement; | |
this.updateComponent(transaction, prevElement, nextElement, context); | |
}, | |
/** | |
* Updates a DOM component after it has already been allocated and | |
* attached to the DOM. Reconciles the root DOM node, then recurses. | |
* | |
* @param {ReactReconcileTransaction} transaction | |
* @param {ReactElement} prevElement | |
* @param {ReactElement} nextElement | |
* @internal | |
* @overridable | |
*/ | |
updateComponent: function (transaction, prevElement, nextElement, context) { | |
var lastProps = prevElement.props; | |
var nextProps = this._currentElement.props; | |
switch (this._tag) { | |
case 'input': | |
lastProps = ReactDOMInput.getHostProps(this, lastProps); | |
nextProps = ReactDOMInput.getHostProps(this, nextProps); | |
break; | |
case 'option': | |
lastProps = ReactDOMOption.getHostProps(this, lastProps); | |
nextProps = ReactDOMOption.getHostProps(this, nextProps); | |
break; | |
case 'select': | |
lastProps = ReactDOMSelect.getHostProps(this, lastProps); | |
nextProps = ReactDOMSelect.getHostProps(this, nextProps); | |
break; | |
case 'textarea': | |
lastProps = ReactDOMTextarea.getHostProps(this, lastProps); | |
nextProps = ReactDOMTextarea.getHostProps(this, nextProps); | |
break; | |
default: | |
if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { | |
transaction.getReactMountReady().enqueue(trapClickOnNonInteractiveElement, this); | |
} | |
break; | |
} | |
assertValidProps(this, nextProps); | |
var isCustomComponentTag = isCustomComponent(this._tag, nextProps); | |
this._updateDOMProperties(lastProps, nextProps, transaction, isCustomComponentTag); | |
this._updateDOMChildren(lastProps, nextProps, transaction, context); | |
switch (this._tag) { | |
case 'input': | |
// Update the wrapper around inputs *after* updating props. This has to | |
// happen after `_updateDOMProperties`. Otherwise HTML5 input validations | |
// raise warnings and prevent the new value from being assigned. | |
ReactDOMInput.updateWrapper(this); | |
break; | |
case 'textarea': | |
ReactDOMTextarea.updateWrapper(this); | |
break; | |
case 'select': | |
// <select> value update needs to occur after <option> children | |
// reconciliation | |
transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this); | |
break; | |
} | |
}, | |
/** | |
* Reconciles the properties by detecting differences in property values and | |
* updating the DOM as necessary. This function is probably the single most | |
* critical path for performance optimization. | |
* | |
* TODO: Benchmark whether checking for changed values in memory actually | |
* improves performance (especially statically positioned elements). | |
* TODO: Benchmark the effects of putting this at the top since 99% of props | |
* do not change for a given reconciliation. | |
* TODO: Benchmark areas that can be improved with caching. | |
* | |
* @private | |
* @param {object} lastProps | |
* @param {object} nextProps | |
* @param {?DOMElement} node | |
*/ | |
_updateDOMProperties: function (lastProps, nextProps, transaction, isCustomComponentTag) { | |
var propKey; | |
var styleName; | |
var styleUpdates; | |
for (propKey in lastProps) { | |
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { | |
continue; | |
} | |
if (propKey === STYLE) { | |
var lastStyle = lastProps[STYLE]; | |
for (styleName in lastStyle) { | |
if (lastStyle.hasOwnProperty(styleName)) { | |
styleUpdates = styleUpdates || {}; | |
styleUpdates[styleName] = ''; | |
} | |
} | |
} else if (registrationNameModules.hasOwnProperty(propKey)) { | |
// Do nothing for event names. | |
} else if (isCustomComponent(this._tag, lastProps)) { | |
if (!RESERVED_PROPS.hasOwnProperty(propKey)) { | |
DOMPropertyOperations.deleteValueForAttribute(getNode(this), propKey); | |
} | |
} else if (DOMProperty$4.properties[propKey] || DOMProperty$4.isCustomAttribute(propKey)) { | |
DOMPropertyOperations.deleteValueForProperty(getNode(this), propKey); | |
} | |
} | |
for (propKey in nextProps) { | |
var nextProp = nextProps[propKey]; | |
var lastProp = lastProps != null ? lastProps[propKey] : undefined; | |
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { | |
continue; | |
} | |
if (propKey === STYLE) { | |
if (nextProp) { | |
if (__DEV__) { | |
Object.freeze(nextProp); | |
} | |
} | |
if (lastProp) { | |
// Unset styles on `lastProp` but not on `nextProp`. | |
for (styleName in lastProp) { | |
if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { | |
styleUpdates = styleUpdates || {}; | |
styleUpdates[styleName] = ''; | |
} | |
} | |
// Update styles that changed since `lastProp`. | |
for (styleName in nextProp) { | |
if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { | |
styleUpdates = styleUpdates || {}; | |
styleUpdates[styleName] = nextProp[styleName]; | |
} | |
} | |
} else { | |
// Relies on `updateStylesByID` not mutating `styleUpdates`. | |
styleUpdates = nextProp; | |
} | |
} else if (registrationNameModules.hasOwnProperty(propKey)) { | |
if (nextProp) { | |
ensureListeningTo(this, propKey, transaction); | |
} | |
} else if (isCustomComponentTag) { | |
if (!RESERVED_PROPS.hasOwnProperty(propKey)) { | |
DOMPropertyOperations.setValueForAttribute(getNode(this), propKey, nextProp); | |
} | |
} else if (DOMProperty$4.properties[propKey] || DOMProperty$4.isCustomAttribute(propKey)) { | |
var node = getNode(this); | |
// If we're updating to null or undefined, we should remove the property | |
// from the DOM node instead of inadvertently setting to a string. This | |
// brings us in line with the same behavior we have on initial render. | |
if (nextProp != null) { | |
DOMPropertyOperations.setValueForProperty(node, propKey, nextProp); | |
} else { | |
DOMPropertyOperations.deleteValueForProperty(node, propKey); | |
} | |
} | |
} | |
if (styleUpdates) { | |
if (__DEV__) { | |
ReactInstrumentation$4.debugTool.onHostOperation({ | |
instanceID: this._debugID, | |
type: 'update styles', | |
payload: styleUpdates | |
}); | |
} | |
CSSPropertyOperations.setValueForStyles(getNode(this), styleUpdates, this); | |
} | |
}, | |
/** | |
* Reconciles the children with the various properties that affect the | |
* children content. | |
* | |
* @param {object} lastProps | |
* @param {object} nextProps | |
* @param {ReactReconcileTransaction} transaction | |
* @param {object} context | |
*/ | |
_updateDOMChildren: function (lastProps, nextProps, transaction, context) { | |
var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null; | |
var nextContent = CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null; | |
var lastHtml = lastProps.dangerouslySetInnerHTML && lastProps.dangerouslySetInnerHTML.__html; | |
var nextHtml = nextProps.dangerouslySetInnerHTML && nextProps.dangerouslySetInnerHTML.__html; | |
// Note the use of `!=` which checks for null or undefined. | |
var lastChildren = lastContent != null ? null : lastProps.children; | |
var nextChildren = nextContent != null ? null : nextProps.children; | |
// If we're switching from children to content/html or vice versa, remove | |
// the old content | |
var lastHasContentOrHtml = lastContent != null || lastHtml != null; | |
var nextHasContentOrHtml = nextContent != null || nextHtml != null; | |
if (lastChildren != null && nextChildren == null) { | |
this.updateChildren(null, transaction, context); | |
} else if (lastHasContentOrHtml && !nextHasContentOrHtml) { | |
this.updateTextContent(''); | |
if (__DEV__) { | |
ReactInstrumentation$4.debugTool.onSetChildren(this._debugID, []); | |
} | |
} | |
if (nextContent != null) { | |
if (lastContent !== nextContent) { | |
this.updateTextContent('' + nextContent); | |
if (__DEV__) { | |
setAndValidateContentChildDev.call(this, nextContent); | |
} | |
} | |
} else if (nextHtml != null) { | |
if (lastHtml !== nextHtml) { | |
this.updateMarkup('' + nextHtml); | |
} | |
if (__DEV__) { | |
ReactInstrumentation$4.debugTool.onSetChildren(this._debugID, []); | |
} | |
} else if (nextChildren != null) { | |
if (__DEV__) { | |
setAndValidateContentChildDev.call(this, null); | |
} | |
this.updateChildren(nextChildren, transaction, context); | |
} | |
}, | |
getHostNode: function () { | |
return getNode(this); | |
}, | |
/** | |
* Destroys all event registrations for this instance. Does not remove from | |
* the DOM. That must be done by the parent. | |
* | |
* @internal | |
*/ | |
unmountComponent: function (safely, skipLifecycle) { | |
switch (this._tag) { | |
case 'audio': | |
case 'form': | |
case 'iframe': | |
case 'img': | |
case 'image': | |
case 'link': | |
case 'object': | |
case 'source': | |
case 'video': | |
var listeners = this._wrapperState.listeners; | |
if (listeners) { | |
for (var i = 0; i < listeners.length; i++) { | |
listeners[i].remove(); | |
} | |
} | |
break; | |
case 'input': | |
case 'textarea': | |
inputValueTracking$2.stopTracking(this); | |
break; | |
case 'html': | |
case 'head': | |
case 'body': | |
/** | |
* Components like <html> <head> and <body> can't be removed or added | |
* easily in a cross-browser way, however it's valuable to be able to | |
* take advantage of React's reconciliation for styling and <title> | |
* management. So we just document it and throw in dangerous cases. | |
*/ | |
invariant$12(false, '<%s> tried to unmount. Because of cross-browser quirks it is ' + 'impossible to unmount some top-level components (eg <html>, ' + '<head>, and <body>) reliably and efficiently. To fix this, have a ' + 'single top-level component that never unmounts render these ' + 'elements.', this._tag); | |
break; | |
} | |
this.unmountChildren(safely, skipLifecycle); | |
ReactDOMComponentTree$11.uncacheNode(this); | |
this._rootNodeID = 0; | |
this._domID = 0; | |
this._wrapperState = null; | |
if (__DEV__) { | |
setAndValidateContentChildDev.call(this, null); | |
} | |
}, | |
restoreControlledState: function () { | |
switch (this._tag) { | |
case 'input': | |
ReactDOMInput.restoreControlledState(this); | |
return; | |
case 'textarea': | |
ReactDOMTextarea.restoreControlledState(this); | |
return; | |
case 'select': | |
ReactDOMSelect.restoreControlledState(this); | |
return; | |
} | |
}, | |
getPublicInstance: function () { | |
return getNode(this); | |
} | |
}; | |
Object.assign(ReactDOMComponent$1.prototype, ReactDOMComponent$1.Mixin, ReactMultiChild); | |
var ReactDOMComponent_1 = ReactDOMComponent$1; | |
var DOMLazyTree$4 = DOMLazyTree_1; | |
var ReactDOMComponentTree$18 = ReactDOMComponentTree_1; | |
var ReactDOMEmptyComponent$1 = function (instantiate) { | |
// ReactCompositeComponent uses this: | |
this._currentElement = null; | |
// ReactDOMComponentTree uses these: | |
this._hostNode = null; | |
this._hostParent = null; | |
this._hostContainerInfo = null; | |
this._domID = 0; | |
}; | |
Object.assign(ReactDOMEmptyComponent$1.prototype, { | |
mountComponent: function (transaction, hostParent, hostContainerInfo, context) { | |
var domID = hostContainerInfo._idCounter++; | |
this._domID = domID; | |
this._hostParent = hostParent; | |
this._hostContainerInfo = hostContainerInfo; | |
var nodeValue = ' react-empty: ' + this._domID + ' '; | |
if (transaction.useCreateElement) { | |
var ownerDocument = hostContainerInfo._ownerDocument; | |
var node = ownerDocument.createComment(nodeValue); | |
ReactDOMComponentTree$18.precacheNode(this, node); | |
return DOMLazyTree$4(node); | |
} else { | |
if (transaction.renderToStaticMarkup) { | |
// Normally we'd insert a comment node, but since this is a situation | |
// where React won't take over (static pages), we can simply return | |
// nothing. | |
return ''; | |
} | |
return '<!--' + nodeValue + '-->'; | |
} | |
}, | |
receiveComponent: function () {}, | |
getHostNode: function () { | |
return ReactDOMComponentTree$18.getNodeFromInstance(this); | |
}, | |
unmountComponent: function () { | |
ReactDOMComponentTree$18.uncacheNode(this); | |
} | |
}); | |
var ReactDOMEmptyComponent_1 = ReactDOMEmptyComponent$1; | |
var DOMChildrenOperations$3 = DOMChildrenOperations_1; | |
var DOMLazyTree$5 = DOMLazyTree_1; | |
var ReactDOMComponentTree$19 = ReactDOMComponentTree_1; | |
var escapeTextContentForBrowser$4 = escapeTextContentForBrowser_1; | |
var invariant$25 = invariant; | |
var validateDOMNesting$2 = validateDOMNesting_1; | |
/** | |
* Text nodes violate a couple assumptions that React makes about components: | |
* | |
* - When mounting text into the DOM, adjacent text nodes are merged. | |
* - Text nodes cannot be assigned a React root ID. | |
* | |
* This component is used to wrap strings between comment nodes so that they | |
* can undergo the same reconciliation that is applied to elements. | |
* | |
* TODO: Investigate representing React components in the DOM with text nodes. | |
* | |
* @class ReactDOMTextComponent | |
* @extends ReactComponent | |
* @internal | |
*/ | |
var ReactDOMTextComponent$1 = function (text) { | |
// TODO: This is really a ReactText (ReactNode), not a ReactElement | |
this._currentElement = text; | |
this._stringText = '' + text; | |
// ReactDOMComponentTree uses these: | |
this._hostNode = null; | |
this._hostParent = null; | |
// Properties | |
this._domID = 0; | |
this._mountIndex = 0; | |
this._closingComment = null; | |
this._commentNodes = null; | |
}; | |
Object.assign(ReactDOMTextComponent$1.prototype, { | |
/** | |
* Creates the markup for this text node. This node is not intended to have | |
* any features besides containing text content. | |
* | |
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | |
* @return {string} Markup for this text node. | |
* @internal | |
*/ | |
mountComponent: function (transaction, hostParent, hostContainerInfo, context) { | |
if (__DEV__) { | |
var parentInfo; | |
if (hostParent != null) { | |
parentInfo = hostParent._ancestorInfo; | |
} else if (hostContainerInfo != null) { | |
parentInfo = hostContainerInfo._ancestorInfo; | |
} | |
if (parentInfo) { | |
// parentInfo should always be present except for the top-level | |
// component when server rendering | |
validateDOMNesting$2(null, this._stringText, this, parentInfo); | |
} | |
} | |
var domID = hostContainerInfo._idCounter++; | |
var openingValue = ' react-text: ' + domID + ' '; | |
var closingValue = ' /react-text '; | |
this._domID = domID; | |
this._hostParent = hostParent; | |
if (transaction.useCreateElement) { | |
var ownerDocument = hostContainerInfo._ownerDocument; | |
var openingComment = ownerDocument.createComment(openingValue); | |
var closingComment = ownerDocument.createComment(closingValue); | |
var lazyTree = DOMLazyTree$5(ownerDocument.createDocumentFragment()); | |
DOMLazyTree$5.queueChild(lazyTree, DOMLazyTree$5(openingComment)); | |
if (this._stringText) { | |
DOMLazyTree$5.queueChild(lazyTree, DOMLazyTree$5(ownerDocument.createTextNode(this._stringText))); | |
} | |
DOMLazyTree$5.queueChild(lazyTree, DOMLazyTree$5(closingComment)); | |
ReactDOMComponentTree$19.precacheNode(this, openingComment); | |
this._closingComment = closingComment; | |
return lazyTree; | |
} else { | |
var escapedText = escapeTextContentForBrowser$4(this._stringText); | |
if (transaction.renderToStaticMarkup) { | |
// Normally we'd wrap this between comment nodes for the reasons stated | |
// above, but since this is a situation where React won't take over | |
// (static pages), we can simply return the text as it is. | |
return escapedText; | |
} | |
return '<!--' + openingValue + '-->' + escapedText + '<!--' + closingValue + '-->'; | |
} | |
}, | |
/** | |
* Updates this component by updating the text content. | |
* | |
* @param {ReactText} nextText The next text content | |
* @param {ReactReconcileTransaction} transaction | |
* @internal | |
*/ | |
receiveComponent: function (nextText, transaction) { | |
if (nextText !== this._currentElement) { | |
this._currentElement = nextText; | |
var nextStringText = '' + nextText; | |
if (nextStringText !== this._stringText) { | |
// TODO: Save this as pending props and use performUpdateIfNecessary | |
// and/or updateComponent to do the actual update for consistency with | |
// other component types? | |
this._stringText = nextStringText; | |
var commentNodes = this.getHostNode(); | |
DOMChildrenOperations$3.replaceDelimitedText(commentNodes[0], commentNodes[1], nextStringText); | |
} | |
} | |
}, | |
getHostNode: function () { | |
var hostNode = this._commentNodes; | |
if (hostNode) { | |
return hostNode; | |
} | |
if (!this._closingComment) { | |
var openingComment = ReactDOMComponentTree$19.getNodeFromInstance(this); | |
var node = openingComment.nextSibling; | |
while (true) { | |
invariant$25(node != null, 'Missing closing comment for text component %s', this._domID); | |
if (node.nodeType === 8 && node.nodeValue === ' /react-text ') { | |
this._closingComment = node; | |
break; | |
} | |
node = node.nextSibling; | |
} | |
} | |
hostNode = [this._hostNode, this._closingComment]; | |
this._commentNodes = hostNode; | |
return hostNode; | |
}, | |
unmountComponent: function () { | |
this._closingComment = null; | |
this._commentNodes = null; | |
ReactDOMComponentTree$19.uncacheNode(this); | |
} | |
}); | |
var ReactDOMTextComponent_1 = ReactDOMTextComponent$1; | |
var ReactUpdates$3 = ReactUpdates_1; | |
var Transaction$4 = Transaction$1; | |
var emptyFunction$6 = emptyFunction; | |
var RESET_BATCHED_UPDATES = { | |
initialize: emptyFunction$6, | |
close: function () { | |
ReactDefaultBatchingStrategy$1.isBatchingUpdates = false; | |
} | |
}; | |
var FLUSH_BATCHED_UPDATES = { | |
initialize: emptyFunction$6, | |
close: ReactUpdates$3.flushBatchedUpdates.bind(ReactUpdates$3) | |
}; | |
var TRANSACTION_WRAPPERS$2 = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES]; | |
function ReactDefaultBatchingStrategyTransaction() { | |
this.reinitializeTransaction(); | |
} | |
Object.assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction$4, { | |
getTransactionWrappers: function () { | |
return TRANSACTION_WRAPPERS$2; | |
} | |
}); | |
var transaction = new ReactDefaultBatchingStrategyTransaction(); | |
var ReactDefaultBatchingStrategy$1 = { | |
isBatchingUpdates: false, | |
/** | |
* Call the provided function in a context within which calls to `setState` | |
* and friends are batched such that components aren't updated unnecessarily. | |
*/ | |
batchedUpdates: function (callback, a, b, c, d, e) { | |
var alreadyBatchingUpdates = ReactDefaultBatchingStrategy$1.isBatchingUpdates; | |
ReactDefaultBatchingStrategy$1.isBatchingUpdates = true; | |
// The code is written this way to avoid extra allocations | |
if (alreadyBatchingUpdates) { | |
return callback(a, b, c, d, e); | |
} else { | |
return transaction.perform(callback, null, a, b, c, d, e); | |
} | |
} | |
}; | |
var ReactDefaultBatchingStrategy_1 = ReactDefaultBatchingStrategy$1; | |
var invariant$27 = invariant; | |
function validateCallback$1(callback) { | |
invariant$27(!callback || typeof callback === 'function', 'Invalid argument passed as callback. Expected a function. Instead ' + 'received: %s', callback); | |
} | |
var validateCallback_1 = validateCallback$1; | |
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var PooledClass$7 = PooledClass_1; | |
var invariant$26 = invariant; | |
var validateCallback = validateCallback_1; | |
/** | |
* A specialized pseudo-event module to help keep track of components waiting to | |
* be notified when their DOM representations are available for use. | |
* | |
* This implements `PooledClass`, so you should never need to instantiate this. | |
* Instead, use `CallbackQueue.getPooled()`. | |
* | |
* @class CallbackQueue | |
* @implements PooledClass | |
* @internal | |
*/ | |
var CallbackQueue$1 = function () { | |
function CallbackQueue(arg) { | |
_classCallCheck$1(this, CallbackQueue); | |
this._callbacks = null; | |
this._contexts = null; | |
this._arg = arg; | |
} | |
/** | |
* Enqueues a callback to be invoked when `notifyAll` is invoked. | |
* | |
* @param {function} callback Invoked when `notifyAll` is invoked. | |
* @param {?object} context Context to call `callback` with. | |
* @internal | |
*/ | |
CallbackQueue.prototype.enqueue = function enqueue(callback, context) { | |
this._callbacks = this._callbacks || []; | |
this._callbacks.push(callback); | |
this._contexts = this._contexts || []; | |
this._contexts.push(context); | |
}; | |
/** | |
* Invokes all enqueued callbacks and clears the queue. This is invoked after | |
* the DOM representation of a component has been created or updated. | |
* | |
* @internal | |
*/ | |
CallbackQueue.prototype.notifyAll = function notifyAll() { | |
var callbacks = this._callbacks; | |
var contexts = this._contexts; | |
var arg = this._arg; | |
if (callbacks && contexts) { | |
invariant$26(callbacks.length === contexts.length, 'Mismatched list of contexts in callback queue'); | |
this._callbacks = null; | |
this._contexts = null; | |
for (var i = 0; i < callbacks.length; i++) { | |
validateCallback(callbacks[i]); | |
callbacks[i].call(contexts[i], arg); | |
} | |
callbacks.length = 0; | |
contexts.length = 0; | |
} | |
}; | |
CallbackQueue.prototype.checkpoint = function checkpoint() { | |
return this._callbacks ? this._callbacks.length : 0; | |
}; | |
CallbackQueue.prototype.rollback = function rollback(len) { | |
if (this._callbacks && this._contexts) { | |
this._callbacks.length = len; | |
this._contexts.length = len; | |
} | |
}; | |
/** | |
* Resets the internal queue. | |
* | |
* @internal | |
*/ | |
CallbackQueue.prototype.reset = function reset() { | |
this._callbacks = null; | |
this._contexts = null; | |
}; | |
/** | |
* `PooledClass` looks for this. | |
*/ | |
CallbackQueue.prototype.destructor = function destructor() { | |
this.reset(); | |
}; | |
return CallbackQueue; | |
}(); | |
var CallbackQueue_1 = PooledClass$7.addPoolingTo(CallbackQueue$1); | |
var CallbackQueue = CallbackQueue_1; | |
var PooledClass$6 = PooledClass_1; | |
var ReactBrowserEventEmitter$4 = ReactBrowserEventEmitter_1; | |
var ReactInputSelection$2 = ReactInputSelection_1; | |
var ReactInstrumentation$11 = ReactInstrumentation$2; | |
var Transaction$5 = Transaction$1; | |
var ReactUpdateQueue$2 = ReactUpdateQueue_1; | |
/** | |
* Ensures that, when possible, the selection range (currently selected text | |
* input) is not disturbed by performing the transaction. | |
*/ | |
var SELECTION_RESTORATION = { | |
/** | |
* @return {Selection} Selection information. | |
*/ | |
initialize: ReactInputSelection$2.getSelectionInformation, | |
/** | |
* @param {Selection} sel Selection information returned from `initialize`. | |
*/ | |
close: ReactInputSelection$2.restoreSelection | |
}; | |
/** | |
* Suppresses events (blur/focus) that could be inadvertently dispatched due to | |
* high level DOM manipulations (like temporarily removing a text input from the | |
* DOM). | |
*/ | |
var EVENT_SUPPRESSION = { | |
/** | |
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before | |
* the reconciliation. | |
*/ | |
initialize: function () { | |
var currentlyEnabled = ReactBrowserEventEmitter$4.isEnabled(); | |
ReactBrowserEventEmitter$4.setEnabled(false); | |
return currentlyEnabled; | |
}, | |
/** | |
* @param {boolean} previouslyEnabled Enabled status of | |
* `ReactBrowserEventEmitter` before the reconciliation occurred. `close` | |
* restores the previous value. | |
*/ | |
close: function (previouslyEnabled) { | |
ReactBrowserEventEmitter$4.setEnabled(previouslyEnabled); | |
} | |
}; | |
/** | |
* Provides a queue for collecting `componentDidMount` and | |
* `componentDidUpdate` callbacks during the transaction. | |
*/ | |
var ON_DOM_READY_QUEUEING = { | |
/** | |
* Initializes the internal `onDOMReady` queue. | |
*/ | |
initialize: function () { | |
this.reactMountReady.reset(); | |
}, | |
/** | |
* After DOM is flushed, invoke all registered `onDOMReady` callbacks. | |
*/ | |
close: function () { | |
this.reactMountReady.notifyAll(); | |
} | |
}; | |
/** | |
* Executed within the scope of the `Transaction` instance. Consider these as | |
* being member methods, but with an implied ordering while being isolated from | |
* each other. | |
*/ | |
var TRANSACTION_WRAPPERS$3 = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING]; | |
if (__DEV__) { | |
TRANSACTION_WRAPPERS$3.push({ | |
initialize: ReactInstrumentation$11.debugTool.onBeginFlush, | |
close: ReactInstrumentation$11.debugTool.onEndFlush | |
}); | |
} | |
/** | |
* Currently: | |
* - The order that these are listed in the transaction is critical: | |
* - Suppresses events. | |
* - Restores selection range. | |
* | |
* Future: | |
* - Restore document/overflow scroll positions that were unintentionally | |
* modified via DOM insertions above the top viewport boundary. | |
* - Implement/integrate with customized constraint based layout system and keep | |
* track of which dimensions must be remeasured. | |
* | |
* @class ReactReconcileTransaction | |
*/ | |
function ReactReconcileTransaction$1(useCreateElement) { | |
this.reinitializeTransaction(); | |
// Only server-side rendering really needs this option (see | |
// `ReactServerRendering`), but server-side uses | |
// `ReactServerRenderingTransaction` instead. This option is here so that it's | |
// accessible and defaults to false when `ReactDOMComponent` and | |
// `ReactDOMTextComponent` checks it in `mountComponent`.` | |
this.renderToStaticMarkup = false; | |
this.reactMountReady = CallbackQueue.getPooled(null); | |
this.useCreateElement = useCreateElement; | |
} | |
var Mixin$1 = { | |
/** | |
* @see Transaction | |
* @abstract | |
* @final | |
* @return {array<object>} List of operation wrap procedures. | |
* TODO: convert to array<TransactionWrapper> | |
*/ | |
getTransactionWrappers: function () { | |
return TRANSACTION_WRAPPERS$3; | |
}, | |
/** | |
* @return {object} The queue to collect `onDOMReady` callbacks with. | |
*/ | |
getReactMountReady: function () { | |
return this.reactMountReady; | |
}, | |
/** | |
* @return {object} The queue to collect React async events. | |
*/ | |
getUpdateQueue: function () { | |
return ReactUpdateQueue$2; | |
}, | |
/** | |
* Save current transaction state -- if the return value from this method is | |
* passed to `rollback`, the transaction will be reset to that state. | |
*/ | |
checkpoint: function () { | |
// reactMountReady is the our only stateful wrapper | |
return this.reactMountReady.checkpoint(); | |
}, | |
rollback: function (checkpoint) { | |
this.reactMountReady.rollback(checkpoint); | |
}, | |
/** | |
* `PooledClass` looks for this, and will invoke this before allowing this | |
* instance to be reused. | |
*/ | |
destructor: function () { | |
CallbackQueue.release(this.reactMountReady); | |
this.reactMountReady = null; | |
} | |
}; | |
Object.assign(ReactReconcileTransaction$1.prototype, Transaction$5, Mixin$1); | |
PooledClass$6.addPoolingTo(ReactReconcileTransaction$1); | |
var ReactReconcileTransaction_1 = ReactReconcileTransaction$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule findDOMNode | |
* | |
*/ | |
var ReactCurrentOwner$6 = ReactCurrentOwner_1; | |
var ReactInstanceMap$4 = ReactInstanceMap_1; | |
var getComponentName$5 = getComponentName_1; | |
var invariant$28 = invariant; | |
var warning$26 = warning; | |
var findFiber = function (arg) { | |
invariant$28(false, 'Missing injection for fiber findDOMNode'); | |
}; | |
var findStack = function (arg) { | |
invariant$28(false, 'Missing injection for stack findDOMNode'); | |
}; | |
var findDOMNode$2 = function (componentOrElement) { | |
if (__DEV__) { | |
var owner = ReactCurrentOwner$6.current; | |
if (owner !== null) { | |
var isFiber = typeof owner.tag === 'number'; | |
var warnedAboutRefsInRender = isFiber ? owner.stateNode._warnedAboutRefsInRender : owner._warnedAboutRefsInRender; | |
warning$26(warnedAboutRefsInRender, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName$5(owner) || 'A component'); | |
if (isFiber) { | |
owner.stateNode._warnedAboutRefsInRender = true; | |
} else { | |
owner._warnedAboutRefsInRender = true; | |
} | |
} | |
} | |
if (componentOrElement == null) { | |
return null; | |
} | |
if (componentOrElement.nodeType === 1) { | |
return componentOrElement; | |
} | |
var inst = ReactInstanceMap$4.get(componentOrElement); | |
if (inst) { | |
if (typeof inst.tag === 'number') { | |
return findFiber(inst); | |
} else { | |
return findStack(inst); | |
} | |
} | |
if (typeof componentOrElement.render === 'function') { | |
invariant$28(false, 'Unable to find node on an unmounted component.'); | |
} else { | |
invariant$28(false, 'Element appears to be neither ReactComponent nor DOMNode. Keys: %s', Object.keys(componentOrElement)); | |
} | |
}; | |
findDOMNode$2._injectFiber = function (fn) { | |
findFiber = fn; | |
}; | |
findDOMNode$2._injectStack = function (fn) { | |
findStack = fn; | |
}; | |
var findDOMNode_1 = findDOMNode$2; | |
var ReactNodeTypes$2 = ReactNodeTypes_1; | |
function getHostComponentFromComposite$2(inst) { | |
var type; | |
while ((type = inst._renderedNodeType) === ReactNodeTypes$2.COMPOSITE) { | |
inst = inst._renderedComponent; | |
} | |
if (type === ReactNodeTypes$2.HOST) { | |
return inst._renderedComponent; | |
} else if (type === ReactNodeTypes$2.EMPTY) { | |
return null; | |
} | |
} | |
var getHostComponentFromComposite_1 = getHostComponentFromComposite$2; | |
var ReactComponentEnvironment = ReactComponentEnvironment_1; | |
var ReactComponentBrowserEnvironment = ReactComponentBrowserEnvironment_1; | |
var ReactDOMComponent = ReactDOMComponent_1; | |
var ReactDOMComponentTree$8 = ReactDOMComponentTree_1; | |
var ReactDOMEmptyComponent = ReactDOMEmptyComponent_1; | |
var ReactDOMTextComponent = ReactDOMTextComponent_1; | |
var ReactDefaultBatchingStrategy = ReactDefaultBatchingStrategy_1; | |
var ReactEmptyComponent = ReactEmptyComponent_1; | |
var ReactGenericBatching$4 = ReactGenericBatching_1; | |
var ReactHostComponent = ReactHostComponent_1; | |
var ReactReconcileTransaction = ReactReconcileTransaction_1; | |
var ReactUpdates = ReactUpdates_1; | |
var findDOMNode$1 = findDOMNode_1; | |
var getHostComponentFromComposite$1 = getHostComponentFromComposite_1; | |
var alreadyInjected$1 = false; | |
function inject$1() { | |
if (alreadyInjected$1) { | |
// TODO: This is currently true because these injections are shared between | |
// the client and the server package. They should be built independently | |
// and not share any injection state. Then this problem will be solved. | |
return; | |
} | |
alreadyInjected$1 = true; | |
ReactGenericBatching$4.injection.injectStackBatchedUpdates(ReactUpdates.batchedUpdates); | |
ReactHostComponent.injection.injectGenericComponentClass(ReactDOMComponent); | |
ReactHostComponent.injection.injectTextComponentClass(ReactDOMTextComponent); | |
ReactEmptyComponent.injection.injectEmptyComponentFactory(function (instantiate) { | |
return new ReactDOMEmptyComponent(instantiate); | |
}); | |
ReactUpdates.injection.injectReconcileTransaction(ReactReconcileTransaction); | |
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy); | |
ReactComponentEnvironment.injection.injectEnvironment(ReactComponentBrowserEnvironment); | |
findDOMNode$1._injectStack(function (inst) { | |
inst = getHostComponentFromComposite$1(inst); | |
return inst ? ReactDOMComponentTree$8.getNodeFromInstance(inst) : null; | |
}); | |
} | |
var ReactDOMStackInjection$1 = { | |
inject: inject$1 | |
}; | |
var validateDOMNesting$3 = validateDOMNesting_1; | |
var DOC_NODE_TYPE$1 = 9; | |
function ReactDOMContainerInfo$1(topLevelWrapper, node) { | |
var info = { | |
_topLevelWrapper: topLevelWrapper, | |
_idCounter: 1, | |
_ownerDocument: node ? node.nodeType === DOC_NODE_TYPE$1 ? node : node.ownerDocument : null, | |
_node: node, | |
_tag: node ? node.nodeName.toLowerCase() : null, | |
_namespaceURI: node ? node.namespaceURI : null | |
}; | |
if (__DEV__) { | |
info._ancestorInfo = node ? validateDOMNesting$3.updatedAncestorInfo(null, info._tag, null) : null; | |
} | |
return info; | |
} | |
var ReactDOMContainerInfo_1 = ReactDOMContainerInfo$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOMFeatureFlags | |
*/ | |
var ReactDOMFeatureFlags$1 = { | |
useCreateElement: true, | |
useFiber: false | |
}; | |
var ReactDOMFeatureFlags_1 = ReactDOMFeatureFlags$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule adler32 | |
* | |
*/ | |
var MOD = 65521; | |
// adler32 is not cryptographically strong, and is only used to sanity check that | |
// markup generated on the server matches the markup generated on the client. | |
// This implementation (a modified version of the SheetJS version) has been optimized | |
// for our use case, at the expense of conforming to the adler32 specification | |
// for non-ascii inputs. | |
function adler32$1(data) { | |
var a = 1; | |
var b = 0; | |
var i = 0; | |
var l = data.length; | |
var m = l & ~0x3; | |
while (i < m) { | |
var n = Math.min(i + 4096, m); | |
for (; i < n; i += 4) { | |
b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3)); | |
} | |
a %= MOD; | |
b %= MOD; | |
} | |
for (; i < l; i++) { | |
b += a += data.charCodeAt(i); | |
} | |
a %= MOD; | |
b %= MOD; | |
return a | b << 16; | |
} | |
var adler32_1 = adler32$1; | |
var adler32 = adler32_1; | |
var TAG_END = /\/?>/; | |
var COMMENT_START = /^<\!\-\-/; | |
var ReactMarkupChecksum$1 = { | |
CHECKSUM_ATTR_NAME: 'data-react-checksum', | |
/** | |
* @param {string} markup Markup string | |
* @return {string} Markup string with checksum attribute attached | |
*/ | |
addChecksumToMarkup: function (markup) { | |
var checksum = adler32(markup); | |
// Add checksum (handle both parent tags, comments and self-closing tags) | |
if (COMMENT_START.test(markup)) { | |
return markup; | |
} else { | |
return markup.replace(TAG_END, ' ' + ReactMarkupChecksum$1.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&'); | |
} | |
}, | |
/** | |
* @param {string} markup to use | |
* @param {DOMElement} element root React element | |
* @returns {boolean} whether or not the markup is the same | |
*/ | |
canReuseMarkup: function (markup, element) { | |
var existingChecksum = element.getAttribute(ReactMarkupChecksum$1.CHECKSUM_ATTR_NAME); | |
existingChecksum = existingChecksum && parseInt(existingChecksum, 10); | |
var markupChecksum = adler32(markup); | |
return markupChecksum === existingChecksum; | |
} | |
}; | |
var ReactMarkupChecksum_1 = ReactMarkupChecksum$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getContextForSubtree | |
* | |
*/ | |
var ReactInstanceMap$6 = ReactInstanceMap_1; | |
var emptyObject$3 = emptyObject; | |
var invariant$30 = invariant; | |
var getContextFiber = function (arg) { | |
invariant$30(false, 'Missing injection for fiber getContextForSubtree'); | |
}; | |
function getContextForSubtree$1(parentComponent) { | |
if (!parentComponent) { | |
return emptyObject$3; | |
} | |
var instance = ReactInstanceMap$6.get(parentComponent); | |
if (typeof instance.tag === 'number') { | |
return getContextFiber(instance); | |
} else { | |
return instance._processChildContext(instance._context); | |
} | |
} | |
getContextForSubtree$1._injectFiber = function (fn) { | |
getContextFiber = fn; | |
}; | |
var getContextForSubtree_1 = getContextForSubtree$1; | |
var DOMLazyTree$6 = DOMLazyTree_1; | |
var DOMProperty$6 = DOMProperty_1; | |
var React$5 = React; | |
var ReactBrowserEventEmitter$5 = ReactBrowserEventEmitter_1; | |
var ReactCurrentOwner$7 = ReactCurrentOwner_1; | |
var ReactDOMComponentTree$20 = ReactDOMComponentTree_1; | |
var ReactDOMContainerInfo = ReactDOMContainerInfo_1; | |
var ReactDOMFeatureFlags = ReactDOMFeatureFlags_1; | |
var ReactFeatureFlags$4 = ReactFeatureFlags_1; | |
var ReactInstanceMap$5 = ReactInstanceMap_1; | |
var ReactInstrumentation$12 = ReactInstrumentation$2; | |
var ReactMarkupChecksum = ReactMarkupChecksum_1; | |
var ReactReconciler$6 = ReactReconciler_1; | |
var ReactUpdateQueue$3 = ReactUpdateQueue_1; | |
var ReactUpdates$4 = ReactUpdates_1; | |
var getContextForSubtree = getContextForSubtree_1; | |
var instantiateReactComponent$2 = instantiateReactComponent_1; | |
var invariant$29 = invariant; | |
var setInnerHTML$4 = setInnerHTML_1; | |
var shouldUpdateReactComponent$3 = shouldUpdateReactComponent_1; | |
var warning$27 = warning; | |
var validateCallback$2 = validateCallback_1; | |
var ATTR_NAME$1 = DOMProperty$6.ID_ATTRIBUTE_NAME; | |
var ROOT_ATTR_NAME = DOMProperty$6.ROOT_ATTRIBUTE_NAME; | |
var ELEMENT_NODE_TYPE$1 = 1; | |
var DOC_NODE_TYPE = 9; | |
var DOCUMENT_FRAGMENT_NODE_TYPE$1 = 11; | |
var instancesByReactRootID = {}; | |
/** | |
* Finds the index of the first character | |
* that's not common between the two given strings. | |
* | |
* @return {number} the index of the character where the strings diverge | |
*/ | |
function firstDifferenceIndex(string1, string2) { | |
var minLen = Math.min(string1.length, string2.length); | |
for (var i = 0; i < minLen; i++) { | |
if (string1.charAt(i) !== string2.charAt(i)) { | |
return i; | |
} | |
} | |
return string1.length === string2.length ? -1 : minLen; | |
} | |
/** | |
* @param {DOMElement|DOMDocument} container DOM element that may contain | |
* a React component | |
* @return {?*} DOM element that may have the reactRoot ID, or null. | |
*/ | |
function getReactRootElementInContainer(container) { | |
if (!container) { | |
return null; | |
} | |
if (container.nodeType === DOC_NODE_TYPE) { | |
return container.documentElement; | |
} else { | |
return container.firstChild; | |
} | |
} | |
function internalGetID(node) { | |
// If node is something like a window, document, or text node, none of | |
// which support attributes or a .getAttribute method, gracefully return | |
// the empty string, as if the attribute were missing. | |
return node.getAttribute && node.getAttribute(ATTR_NAME$1) || ''; | |
} | |
/** | |
* Mounts this component and inserts it into the DOM. | |
* | |
* @param {ReactComponent} componentInstance The instance to mount. | |
* @param {DOMElement} container DOM element to mount into. | |
* @param {ReactReconcileTransaction} transaction | |
* @param {boolean} shouldReuseMarkup If true, do not insert markup | |
*/ | |
function mountComponentIntoNode(wrapperInstance, container, transaction, shouldReuseMarkup, context) { | |
var markerName; | |
if (ReactFeatureFlags$4.logTopLevelRenders) { | |
var wrappedElement = wrapperInstance._currentElement.props.child; | |
var type = wrappedElement.type; | |
markerName = 'React mount: ' + (typeof type === 'string' ? type : type.displayName || type.name); | |
console.time(markerName); | |
} | |
var markup = ReactReconciler$6.mountComponent(wrapperInstance, transaction, null, ReactDOMContainerInfo(wrapperInstance, container), context, 0 /* parentDebugID */ | |
); | |
if (markerName) { | |
console.timeEnd(markerName); | |
} | |
wrapperInstance._renderedComponent._topLevelWrapper = wrapperInstance; | |
ReactMount$1._mountImageIntoNode(markup, container, wrapperInstance, shouldReuseMarkup, transaction); | |
} | |
/** | |
* Batched mount. | |
* | |
* @param {ReactComponent} componentInstance The instance to mount. | |
* @param {DOMElement} container DOM element to mount into. | |
* @param {boolean} shouldReuseMarkup If true, do not insert markup | |
*/ | |
function batchedMountComponentIntoNode(componentInstance, container, shouldReuseMarkup, context) { | |
var transaction = ReactUpdates$4.ReactReconcileTransaction.getPooled( | |
/* useCreateElement */ | |
!shouldReuseMarkup && ReactDOMFeatureFlags.useCreateElement); | |
transaction.perform(mountComponentIntoNode, null, componentInstance, container, transaction, shouldReuseMarkup, context); | |
ReactUpdates$4.ReactReconcileTransaction.release(transaction); | |
} | |
/** | |
* Unmounts a component and removes it from the DOM. | |
* | |
* @param {ReactComponent} instance React component instance. | |
* @param {DOMElement} container DOM element to unmount from. | |
* @final | |
* @internal | |
* @see {ReactMount.unmountComponentAtNode} | |
*/ | |
function unmountComponentFromNode(instance, container) { | |
if (__DEV__) { | |
ReactInstrumentation$12.debugTool.onBeginFlush(); | |
} | |
ReactReconciler$6.unmountComponent(instance, false /* safely */ | |
, false /* skipLifecycle */ | |
); | |
if (__DEV__) { | |
ReactInstrumentation$12.debugTool.onEndFlush(); | |
} | |
if (container.nodeType === DOC_NODE_TYPE) { | |
container = container.documentElement; | |
} | |
// http://jsperf.com/emptying-a-node | |
while (container.lastChild) { | |
container.removeChild(container.lastChild); | |
} | |
} | |
/** | |
* True if the supplied DOM node has a direct React-rendered child that is | |
* not a React root element. Useful for warning in `render`, | |
* `unmountComponentAtNode`, etc. | |
* | |
* @param {?DOMElement} node The candidate DOM node. | |
* @return {boolean} True if the DOM element contains a direct child that was | |
* rendered by React but is not a root element. | |
* @internal | |
*/ | |
function hasNonRootReactChild(container) { | |
var rootEl = getReactRootElementInContainer(container); | |
if (rootEl) { | |
var inst = ReactDOMComponentTree$20.getInstanceFromNode(rootEl); | |
return !!(inst && inst._hostParent); | |
} | |
} | |
/** | |
* True if the supplied DOM node is a React DOM element and | |
* it has been rendered by another copy of React. | |
* | |
* @param {?DOMElement} node The candidate DOM node. | |
* @return {boolean} True if the DOM has been rendered by another copy of React | |
* @internal | |
*/ | |
function nodeIsRenderedByOtherInstance(container) { | |
var rootEl = getReactRootElementInContainer(container); | |
return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree$20.getInstanceFromNode(rootEl)); | |
} | |
/** | |
* True if the supplied DOM node is a valid node element. | |
* | |
* @param {?DOMElement} node The candidate DOM node. | |
* @return {boolean} True if the DOM is a valid DOM node. | |
* @internal | |
*/ | |
function isValidContainer(node) { | |
return !!(node && (node.nodeType === ELEMENT_NODE_TYPE$1 || node.nodeType === DOC_NODE_TYPE || node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE$1)); | |
} | |
/** | |
* True if the supplied DOM node is a valid React node element. | |
* | |
* @param {?DOMElement} node The candidate DOM node. | |
* @return {boolean} True if the DOM is a valid React DOM node. | |
* @internal | |
*/ | |
function isReactNode(node) { | |
return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME$1)); | |
} | |
function getHostRootInstanceInContainer(container) { | |
var rootEl = getReactRootElementInContainer(container); | |
var prevHostInstance = rootEl && ReactDOMComponentTree$20.getInstanceFromNode(rootEl); | |
return prevHostInstance && !prevHostInstance._hostParent ? prevHostInstance : null; | |
} | |
function getTopLevelWrapperInContainer(container) { | |
var root = getHostRootInstanceInContainer(container); | |
return root ? root._hostContainerInfo._topLevelWrapper : null; | |
} | |
/** | |
* Temporary (?) hack so that we can store all top-level pending updates on | |
* composites instead of having to worry about different types of components | |
* here. | |
*/ | |
var topLevelRootCounter = 1; | |
var TopLevelWrapper = function () { | |
this.rootID = topLevelRootCounter++; | |
}; | |
TopLevelWrapper.prototype.isReactComponent = {}; | |
if (__DEV__) { | |
TopLevelWrapper.displayName = 'TopLevelWrapper'; | |
} | |
TopLevelWrapper.prototype.render = function () { | |
return this.props.child; | |
}; | |
TopLevelWrapper.isReactTopLevelWrapper = true; | |
/** | |
* Mounting is the process of initializing a React component by creating its | |
* representative DOM elements and inserting them into a supplied `container`. | |
* Any prior content inside `container` is destroyed in the process. | |
* | |
* ReactMount.render( | |
* component, | |
* document.getElementById('container') | |
* ); | |
* | |
* <div id="container"> <-- Supplied `container`. | |
* <div data-reactid=".3"> <-- Rendered reactRoot of React | |
* // ... component. | |
* </div> | |
* </div> | |
* | |
* Inside of `container`, the first element rendered is the "reactRoot". | |
*/ | |
var ReactMount$1 = { | |
TopLevelWrapper: TopLevelWrapper, | |
/** | |
* Used by devtools. The keys are not important. | |
*/ | |
_instancesByReactRootID: instancesByReactRootID, | |
/** | |
* This is a hook provided to support rendering React components while | |
* ensuring that the apparent scroll position of its `container` does not | |
* change. | |
* | |
* @param {DOMElement} container The `container` being rendered into. | |
* @param {function} renderCallback This must be called once to do the render. | |
*/ | |
scrollMonitor: function (container, renderCallback) { | |
renderCallback(); | |
}, | |
/** | |
* Take a component that's already mounted into the DOM and replace its props | |
* @param {ReactComponent} prevComponent component instance already in the DOM | |
* @param {ReactElement} nextElement component instance to render | |
* @param {DOMElement} container container to render into | |
* @param {?function} callback function triggered on completion | |
*/ | |
_updateRootComponent: function (prevComponent, nextElement, nextContext, container, callback) { | |
ReactMount$1.scrollMonitor(container, function () { | |
ReactUpdateQueue$3.enqueueElementInternal(prevComponent, nextElement, nextContext); | |
if (callback) { | |
ReactUpdateQueue$3.enqueueCallbackInternal(prevComponent, callback); | |
} | |
}); | |
return prevComponent; | |
}, | |
/** | |
* Render a new component into the DOM. Hooked by hooks! | |
* | |
* @param {ReactElement} nextElement element to render | |
* @param {DOMElement} container container to render into | |
* @param {boolean} shouldReuseMarkup if we should skip the markup insertion | |
* @return {ReactComponent} nextComponent | |
*/ | |
_renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context, callback) { | |
// Various parts of our code (such as ReactCompositeComponent's | |
// _renderValidatedComponent) assume that calls to render aren't nested; | |
// verify that that's the case. | |
warning$27(ReactCurrentOwner$7.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate.\n\nCheck the render method of %s.', ReactCurrentOwner$7.current && ReactCurrentOwner$7.current.getName() || 'ReactCompositeComponent'); | |
invariant$29(isValidContainer(container), '_registerComponent(...): Target container is not a DOM element.'); | |
ReactBrowserEventEmitter$5.ensureScrollValueMonitoring(); | |
var componentInstance = instantiateReactComponent$2(nextElement, false); | |
if (callback) { | |
componentInstance._pendingCallbacks = [function () { | |
validateCallback$2(callback); | |
callback.call(componentInstance._renderedComponent.getPublicInstance()); | |
}]; | |
} | |
// The initial render is synchronous but any updates that happen during | |
// rendering, in componentWillMount or componentDidMount, will be batched | |
// according to the current batching strategy. | |
ReactUpdates$4.batchedUpdates(batchedMountComponentIntoNode, componentInstance, container, shouldReuseMarkup, context); | |
var wrapperID = componentInstance._instance.rootID; | |
instancesByReactRootID[wrapperID] = componentInstance; | |
return componentInstance; | |
}, | |
/** | |
* Renders a React component into the DOM in the supplied `container`. | |
* | |
* If the React component was previously rendered into `container`, this will | |
* perform an update on it and only mutate the DOM as necessary to reflect the | |
* latest React component. | |
* | |
* @param {ReactComponent} parentComponent The conceptual parent of this render tree. | |
* @param {ReactElement} nextElement Component element to render. | |
* @param {DOMElement} container DOM element to render into. | |
* @param {?function} callback function triggered on completion | |
* @return {ReactComponent} Component instance rendered in `container`. | |
*/ | |
renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) { | |
invariant$29(parentComponent != null && ReactInstanceMap$5.has(parentComponent), 'parentComponent must be a valid React Component'); | |
return ReactMount$1._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback); | |
}, | |
_renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) { | |
callback = callback === undefined ? null : callback; | |
if (__DEV__) { | |
warning$27(callback === null || typeof callback === 'function', 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', '' + callback); | |
} | |
if (!React$5.isValidElement(nextElement)) { | |
if (typeof nextElement === 'string') { | |
invariant$29(false, 'ReactDOM.render(): Invalid component element. Instead of ' + 'passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.'); | |
} else if (typeof nextElement === 'function') { | |
invariant$29(false, 'ReactDOM.render(): Invalid component element. Instead of ' + 'passing a class like Foo, pass React.createElement(Foo) ' + 'or <Foo />.'); | |
} else if (nextElement != null && typeof nextElement.props !== 'undefined') { | |
// Check if it quacks like an element | |
invariant$29(false, 'ReactDOM.render(): Invalid component element. This may be ' + 'caused by unintentionally loading two independent copies ' + 'of React.'); | |
} else { | |
invariant$29(false, 'ReactDOM.render(): Invalid component element.'); | |
} | |
} | |
warning$27(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.'); | |
var nextWrappedElement = React$5.createElement(TopLevelWrapper, { child: nextElement }); | |
var nextContext = getContextForSubtree(parentComponent); | |
var prevComponent = getTopLevelWrapperInContainer(container); | |
if (prevComponent) { | |
var prevWrappedElement = prevComponent._currentElement; | |
var prevElement = prevWrappedElement.props.child; | |
if (shouldUpdateReactComponent$3(prevElement, nextElement)) { | |
var publicInst = prevComponent._renderedComponent.getPublicInstance(); | |
var updatedCallback = callback && function () { | |
validateCallback$2(callback); | |
callback.call(publicInst); | |
}; | |
ReactMount$1._updateRootComponent(prevComponent, nextWrappedElement, nextContext, container, updatedCallback); | |
return publicInst; | |
} else { | |
ReactMount$1.unmountComponentAtNode(container); | |
} | |
} | |
var reactRootElement = getReactRootElementInContainer(container); | |
var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement); | |
var containerHasNonRootReactChild = hasNonRootReactChild(container); | |
if (__DEV__) { | |
warning$27(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.'); | |
if (!containerHasReactMarkup || reactRootElement.nextSibling) { | |
var rootElementSibling = reactRootElement; | |
while (rootElementSibling) { | |
if (internalGetID(rootElementSibling)) { | |
warning$27(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.'); | |
break; | |
} | |
rootElementSibling = rootElementSibling.nextSibling; | |
} | |
} | |
} | |
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild; | |
var component = ReactMount$1._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, nextContext, callback)._renderedComponent.getPublicInstance(); | |
return component; | |
}, | |
/** | |
* Renders a React component into the DOM in the supplied `container`. | |
* See https://facebook.github.io/react/docs//Users/gaearon/p/react/src/renderers/dom/ReactDOM.js.html#render | |
* | |
* If the React component was previously rendered into `container`, this will | |
* perform an update on it and only mutate the DOM as necessary to reflect the | |
* latest React component. | |
* | |
* @param {ReactElement} nextElement Component element to render. | |
* @param {DOMElement} container DOM element to render into. | |
* @param {?function} callback function triggered on completion | |
* @return {ReactComponent} Component instance rendered in `container`. | |
*/ | |
render: function (nextElement, container, callback) { | |
return ReactMount$1._renderSubtreeIntoContainer(null, nextElement, container, callback); | |
}, | |
/** | |
* Unmounts and destroys the React component rendered in the `container`. | |
* See https://facebook.github.io/react/docs//Users/gaearon/p/react/src/renderers/dom/ReactDOM.js.html#unmountcomponentatnode | |
* | |
* @param {DOMElement} container DOM element containing a React component. | |
* @return {boolean} True if a component was found in and unmounted from | |
* `container` | |
*/ | |
unmountComponentAtNode: function (container) { | |
// Various parts of our code (such as ReactCompositeComponent's | |
// _renderValidatedComponent) assume that calls to render aren't nested; | |
// verify that that's the case. (Strictly speaking, unmounting won't cause a | |
// render but we still don't expect to be in a render call here.) | |
warning$27(ReactCurrentOwner$7.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate.\n\nCheck the render method of %s.', ReactCurrentOwner$7.current && ReactCurrentOwner$7.current.getName() || 'ReactCompositeComponent'); | |
invariant$29(isValidContainer(container), 'unmountComponentAtNode(...): Target container is not a DOM element.'); | |
if (__DEV__) { | |
warning$27(!nodeIsRenderedByOtherInstance(container), 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by another copy of React.'); | |
} | |
var prevComponent = getTopLevelWrapperInContainer(container); | |
if (!prevComponent) { | |
// Check if the node being unmounted was rendered by React, but isn't a | |
// root node. | |
var containerHasNonRootReactChild = hasNonRootReactChild(container); | |
// Check if the container itself is a React root node. | |
var isContainerReactRoot = container.nodeType === 1 && container.hasAttribute(ROOT_ATTR_NAME); | |
if (__DEV__) { | |
warning$27(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.'); | |
} | |
return false; | |
} | |
delete instancesByReactRootID[prevComponent._instance.rootID]; | |
ReactUpdates$4.batchedUpdates(unmountComponentFromNode, prevComponent, container); | |
return true; | |
}, | |
_mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) { | |
invariant$29(isValidContainer(container), 'mountComponentIntoNode(...): Target container is not valid.'); | |
if (shouldReuseMarkup) { | |
var rootElement = getReactRootElementInContainer(container); | |
if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) { | |
ReactDOMComponentTree$20.precacheNode(instance, rootElement); | |
return; | |
} else { | |
var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME); | |
rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME); | |
var rootMarkup = rootElement.outerHTML; | |
rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum); | |
var normalizedMarkup = markup; | |
if (__DEV__) { | |
// because rootMarkup is retrieved from the DOM, various normalizations | |
// will have occurred which will not be present in `markup`. Here, | |
// insert markup into a <div> or <iframe> depending on the container | |
// type to perform the same normalizations before comparing. | |
var normalizer; | |
if (container.nodeType === ELEMENT_NODE_TYPE$1) { | |
normalizer = document.createElement('div'); | |
normalizer.innerHTML = markup; | |
normalizedMarkup = normalizer.innerHTML; | |
} else { | |
normalizer = document.createElement('iframe'); | |
document.body.appendChild(normalizer); | |
normalizer.contentDocument.write(markup); | |
normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML; | |
document.body.removeChild(normalizer); | |
} | |
} | |
var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup); | |
var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20); | |
invariant$29(container.nodeType !== DOC_NODE_TYPE, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference); | |
if (__DEV__) { | |
warning$27(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference); | |
} | |
} | |
} | |
invariant$29(container.nodeType !== DOC_NODE_TYPE, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See ReactDOMServer.renderToString() for server rendering.'); | |
if (transaction.useCreateElement) { | |
while (container.lastChild) { | |
container.removeChild(container.lastChild); | |
} | |
DOMLazyTree$6.insertTreeBefore(container, markup, null); | |
} else { | |
setInnerHTML$4(container, markup); | |
ReactDOMComponentTree$20.precacheNode(instance, container.firstChild); | |
} | |
if (__DEV__) { | |
var hostNode = ReactDOMComponentTree$20.getInstanceFromNode(container.firstChild); | |
if (hostNode._debugID !== 0) { | |
ReactInstrumentation$12.debugTool.onHostOperation({ | |
instanceID: hostNode._debugID, | |
type: 'mount', | |
payload: markup.toString() | |
}); | |
} | |
} | |
} | |
}; | |
var ReactMount_1 = ReactMount$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactVersion | |
*/ | |
var ReactVersion$1 = '16.0.0-alpha.3'; | |
var DOMProperty$7 = DOMProperty_1; | |
var EventPluginRegistry$4 = EventPluginRegistry_1; | |
var ReactComponentTreeHook$5 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$1 = ReactDebugCurrentFiber_1; | |
var warning$28 = warning; | |
function getStackAddendum$1(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$5.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$1.getCurrentFiberStackAddendum(); | |
} | |
} | |
if (__DEV__) { | |
var reactProps = { | |
children: true, | |
dangerouslySetInnerHTML: true, | |
key: true, | |
ref: true, | |
autoFocus: true, | |
defaultValue: true, | |
defaultChecked: true, | |
innerHTML: true, | |
suppressContentEditableWarning: true, | |
onFocusIn: true, | |
onFocusOut: true | |
}; | |
var warnedProperties = {}; | |
var validateProperty = function (tagName, name, debugID) { | |
if (DOMProperty$7.properties.hasOwnProperty(name) || DOMProperty$7.isCustomAttribute(name)) { | |
return true; | |
} | |
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) { | |
return true; | |
} | |
if (EventPluginRegistry$4.registrationNameModules.hasOwnProperty(name)) { | |
return true; | |
} | |
warnedProperties[name] = true; | |
var lowerCasedName = name.toLowerCase(); | |
// data-* attributes should be lowercase; suggest the lowercase version | |
var standardName = DOMProperty$7.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty$7.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty$7.getPossibleStandardName[lowerCasedName] : null; | |
var registrationName = EventPluginRegistry$4.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry$4.possibleRegistrationNames[lowerCasedName] : null; | |
if (standardName != null) { | |
warning$28(false, 'Unknown DOM property %s. Did you mean %s?%s', name, standardName, getStackAddendum$1(debugID)); | |
return true; | |
} else if (registrationName != null) { | |
warning$28(false, 'Unknown event handler property %s. Did you mean `%s`?%s', name, registrationName, getStackAddendum$1(debugID)); | |
return true; | |
} else { | |
// We were unable to guess which prop the user intended. | |
// It is likely that the user was just blindly spreading/forwarding props | |
// Components should be careful to only render valid props/attributes. | |
// Warning will be invoked in warnUnknownProperties to allow grouping. | |
return false; | |
} | |
}; | |
} | |
var warnUnknownProperties = function (type, props, debugID) { | |
var unknownProps = []; | |
for (var key in props) { | |
var isValid = validateProperty(type, key, debugID); | |
if (!isValid) { | |
unknownProps.push(key); | |
} | |
} | |
var unknownPropString = unknownProps.map(function (prop) { | |
return '`' + prop + '`'; | |
}).join(', '); | |
if (unknownProps.length === 1) { | |
warning$28(false, 'Unknown prop %s on <%s> tag. Remove this prop from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, type, getStackAddendum$1(debugID)); | |
} else if (unknownProps.length > 1) { | |
warning$28(false, 'Unknown props %s on <%s> tag. Remove these props from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, type, getStackAddendum$1(debugID)); | |
} | |
}; | |
function validateProperties(type, props, debugID /* Stack only */) { | |
if (type.indexOf('-') >= 0 || props.is) { | |
return; | |
} | |
warnUnknownProperties(type, props, debugID); | |
} | |
var ReactDOMUnknownPropertyHook$1 = { | |
// Fiber | |
validateProperties: validateProperties, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMUnknownPropertyHook_1 = ReactDOMUnknownPropertyHook$1; | |
var ReactComponentTreeHook$6 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$2 = ReactDebugCurrentFiber_1; | |
var warning$29 = warning; | |
var didWarnValueNull = false; | |
function getStackAddendum$2(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$6.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$2.getCurrentFiberStackAddendum(); | |
} | |
} | |
function validateProperties$1(type, props, debugID /* Stack only */) { | |
if (type !== 'input' && type !== 'textarea' && type !== 'select') { | |
return; | |
} | |
if (props != null && props.value === null && !didWarnValueNull) { | |
warning$29(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$2(debugID)); | |
didWarnValueNull = true; | |
} | |
} | |
var ReactDOMNullInputValuePropHook$1 = { | |
// Fiber | |
validateProperties: validateProperties$1, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$1(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$1(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMNullInputValuePropHook_1 = ReactDOMNullInputValuePropHook$1; | |
var DOMProperty$8 = DOMProperty_1; | |
var ReactComponentTreeHook$7 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$3 = ReactDebugCurrentFiber_1; | |
var warning$30 = warning; | |
var warnedProperties$1 = {}; | |
var rARIA = new RegExp('^(aria)-[' + DOMProperty$8.ATTRIBUTE_NAME_CHAR + ']*$'); | |
function getStackAddendum$3(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$7.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$3.getCurrentFiberStackAddendum(); | |
} | |
} | |
function validateProperty$1(tagName, name, debugID) { | |
if (warnedProperties$1.hasOwnProperty(name) && warnedProperties$1[name]) { | |
return true; | |
} | |
if (rARIA.test(name)) { | |
var lowerCasedName = name.toLowerCase(); | |
var standardName = DOMProperty$8.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty$8.getPossibleStandardName[lowerCasedName] : null; | |
// If this is an aria-* attribute, but is not listed in the known DOM | |
// DOM properties, then it is an invalid aria-* attribute. | |
if (standardName == null) { | |
warnedProperties$1[name] = true; | |
return false; | |
} | |
// aria-* attributes should be lowercase; suggest the lowercase version. | |
if (name !== standardName) { | |
warning$30(false, 'Unknown ARIA attribute %s. Did you mean %s?%s', name, standardName, getStackAddendum$3(debugID)); | |
warnedProperties$1[name] = true; | |
return true; | |
} | |
} | |
return true; | |
} | |
function warnInvalidARIAProps(type, props, debugID) { | |
var invalidProps = []; | |
for (var key in props) { | |
var isValid = validateProperty$1(type, key, debugID); | |
if (!isValid) { | |
invalidProps.push(key); | |
} | |
} | |
var unknownPropString = invalidProps.map(function (prop) { | |
return '`' + prop + '`'; | |
}).join(', '); | |
if (invalidProps.length === 1) { | |
warning$30(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum$3(debugID)); | |
} else if (invalidProps.length > 1) { | |
warning$30(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum$3(debugID)); | |
} | |
} | |
function validateProperties$2(type, props, debugID /* Stack only */) { | |
if (type.indexOf('-') >= 0 || props.is) { | |
return; | |
} | |
warnInvalidARIAProps(type, props, debugID); | |
} | |
var ReactDOMInvalidARIAHook$1 = { | |
// Fiber | |
validateProperties: validateProperties$2, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$2(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$2(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMInvalidARIAHook_1 = ReactDOMInvalidARIAHook$1; | |
var ReactDOMComponentTree = ReactDOMComponentTree_1; | |
var ReactDOMInjection = ReactDOMInjection$1; | |
var ReactDOMStackInjection = ReactDOMStackInjection$1; | |
var ReactGenericBatching = ReactGenericBatching_1; | |
var ReactMount = ReactMount_1; | |
var ReactReconciler = ReactReconciler_1; | |
var ReactVersion = ReactVersion$1; | |
var findDOMNode = findDOMNode_1; | |
var getHostComponentFromComposite = getHostComponentFromComposite_1; | |
var warning2 = warning; | |
ReactDOMInjection.inject(); | |
ReactDOMStackInjection.inject(); | |
var ReactDOM$1 = { | |
findDOMNode: findDOMNode, | |
render: ReactMount.render, | |
unmountComponentAtNode: ReactMount.unmountComponentAtNode, | |
version: ReactVersion, | |
/* eslint-disable camelcase */ | |
unstable_batchedUpdates: ReactGenericBatching.batchedUpdates, | |
unstable_renderSubtreeIntoContainer: ReactMount.renderSubtreeIntoContainer | |
}; | |
// Inject the runtime into a devtools global hook regardless of browser. | |
// Allows for debugging when the hook is injected on the page. | |
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { | |
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ | |
ComponentTree: { | |
getClosestInstanceFromNode: ReactDOMComponentTree.getClosestInstanceFromNode, | |
getNodeFromInstance: function (inst) { | |
// inst is an internal instance (but could be a composite) | |
if (inst._renderedComponent) { | |
inst = getHostComponentFromComposite(inst); | |
} | |
if (inst) { | |
return ReactDOMComponentTree.getNodeFromInstance(inst); | |
} else { | |
return null; | |
} | |
} | |
}, | |
Mount: ReactMount, | |
Reconciler: ReactReconciler | |
}); | |
} | |
if (__DEV__) { | |
var ExecutionEnvironment2 = ExecutionEnvironment; | |
if (ExecutionEnvironment2.canUseDOM && window.top === window.self) { | |
// First check if devtools is not installed | |
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { | |
// If we're in Chrome or Firefox, provide a download link if not installed. | |
if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { | |
// Firefox does not have the issue with devtools loaded over file:// | |
var showFileUrlMessage = window.location.protocol.indexOf('http') === -1 && navigator.userAgent.indexOf('Firefox') === -1; | |
console.debug('Download the React DevTools ' + (showFileUrlMessage ? 'and use an HTTP server (instead of a file: URL) ' : '') + 'for a better development experience: ' + 'https://fb.me/react-devtools'); | |
} | |
} | |
var testFunc = function testFn() {}; | |
warning2((testFunc.name || testFunc.toString()).indexOf('testFn') !== -1, 'It looks like you\'re using a minified copy of the development build ' + 'of React. When deploying React apps to production, make sure to use ' + 'the production build which skips development warning2s and is faster. ' + 'See https://fb.me/react-minification for more details.'); | |
// If we're in IE8, check to see if we are in compatibility mode and provide | |
// information on preventing compatibility mode | |
var ieCompatibilityMode = document.documentMode && document.documentMode < 8; | |
warning2(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'); | |
var expectedFeatures = [ | |
// shims | |
Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.trim]; | |
for (var i = 0; i < expectedFeatures.length; i++) { | |
if (!expectedFeatures[i]) { | |
warning2(false, 'One or more ES5 shims expected by React are not available: ' + 'https://fb.me/react-warning2-polyfills'); | |
break; | |
} | |
} | |
} | |
} | |
if (__DEV__) { | |
var ReactInstrumentation = ReactInstrumentation$2; | |
var ReactDOMUnknownPropertyHook = ReactDOMUnknownPropertyHook_1; | |
var ReactDOMNullInputValuePropHook = ReactDOMNullInputValuePropHook_1; | |
var ReactDOMInvalidARIAHook = ReactDOMInvalidARIAHook_1; | |
ReactInstrumentation.debugTool.addHook(ReactDOMUnknownPropertyHook); | |
ReactInstrumentation.debugTool.addHook(ReactDOMNullInputValuePropHook); | |
ReactInstrumentation.debugTool.addHook(ReactDOMInvalidARIAHook); | |
} | |
var ReactDOM_1 = ReactDOM$1; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var ReactDebugTool$2 = ReactDebugTool_1; | |
var warning$31 = warning; | |
var alreadyWarned = false; | |
function roundFloat(val) { | |
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; | |
var n = Math.pow(10, base); | |
return Math.floor(val * n) / n; | |
} | |
// Flow type definition of console.table is too strict right now, see | |
// https://github.com/facebook/flow/pull/2353 for updates | |
function consoleTable(table) { | |
console.table(table); | |
} | |
function warnInProduction() { | |
if (alreadyWarned) { | |
return; | |
} | |
alreadyWarned = true; | |
if (typeof console !== 'undefined') { | |
console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.'); | |
} | |
} | |
function getLastMeasurements() { | |
if (!__DEV__) { | |
warnInProduction(); | |
return []; | |
} | |
return ReactDebugTool$2.getFlushHistory(); | |
} | |
function getExclusive() { | |
var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements(); | |
if (!__DEV__) { | |
warnInProduction(); | |
return []; | |
} | |
var aggregatedStats = {}; | |
var affectedIDs = {}; | |
function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) { | |
var displayName = treeSnapshot[instanceID].displayName; | |
var key = displayName; | |
var stats = aggregatedStats[key]; | |
if (!stats) { | |
affectedIDs[key] = {}; | |
stats = aggregatedStats[key] = { | |
key: key, | |
instanceCount: 0, | |
counts: {}, | |
durations: {}, | |
totalDuration: 0 | |
}; | |
} | |
if (!stats.durations[timerType]) { | |
stats.durations[timerType] = 0; | |
} | |
if (!stats.counts[timerType]) { | |
stats.counts[timerType] = 0; | |
} | |
affectedIDs[key][instanceID] = true; | |
applyUpdate(stats); | |
} | |
flushHistory.forEach(function (flush) { | |
var measurements = flush.measurements, | |
treeSnapshot = flush.treeSnapshot; | |
measurements.forEach(function (measurement) { | |
var duration = measurement.duration, | |
instanceID = measurement.instanceID, | |
timerType = measurement.timerType; | |
updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) { | |
stats.totalDuration += duration; | |
stats.durations[timerType] += duration; | |
stats.counts[timerType]++; | |
}); | |
}); | |
}); | |
return Object.keys(aggregatedStats).map(function (key) { | |
return _extends({}, aggregatedStats[key], { | |
instanceCount: Object.keys(affectedIDs[key]).length | |
}); | |
}).sort(function (a, b) { | |
return b.totalDuration - a.totalDuration; | |
}); | |
} | |
function getInclusive() { | |
var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements(); | |
if (!__DEV__) { | |
warnInProduction(); | |
return []; | |
} | |
var aggregatedStats = {}; | |
var affectedIDs = {}; | |
function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) { | |
var _treeSnapshot$instanc = treeSnapshot[instanceID], | |
displayName = _treeSnapshot$instanc.displayName, | |
ownerID = _treeSnapshot$instanc.ownerID; | |
var owner = treeSnapshot[ownerID]; | |
var key = (owner ? owner.displayName + ' > ' : '') + displayName; | |
var stats = aggregatedStats[key]; | |
if (!stats) { | |
affectedIDs[key] = {}; | |
stats = aggregatedStats[key] = { | |
key: key, | |
instanceCount: 0, | |
inclusiveRenderDuration: 0, | |
renderCount: 0 | |
}; | |
} | |
affectedIDs[key][instanceID] = true; | |
applyUpdate(stats); | |
} | |
var isCompositeByID = {}; | |
flushHistory.forEach(function (flush) { | |
var measurements = flush.measurements; | |
measurements.forEach(function (measurement) { | |
var instanceID = measurement.instanceID, | |
timerType = measurement.timerType; | |
if (timerType !== 'render') { | |
return; | |
} | |
isCompositeByID[instanceID] = true; | |
}); | |
}); | |
flushHistory.forEach(function (flush) { | |
var measurements = flush.measurements, | |
treeSnapshot = flush.treeSnapshot; | |
measurements.forEach(function (measurement) { | |
var duration = measurement.duration, | |
instanceID = measurement.instanceID, | |
timerType = measurement.timerType; | |
if (timerType !== 'render') { | |
return; | |
} | |
updateAggregatedStats(treeSnapshot, instanceID, function (stats) { | |
stats.renderCount++; | |
}); | |
var nextParentID = instanceID; | |
while (nextParentID) { | |
// As we traverse parents, only count inclusive time towards composites. | |
// We know something is a composite if its render() was called. | |
if (isCompositeByID[nextParentID]) { | |
updateAggregatedStats(treeSnapshot, nextParentID, function (stats) { | |
stats.inclusiveRenderDuration += duration; | |
}); | |
} | |
nextParentID = treeSnapshot[nextParentID].parentID; | |
} | |
}); | |
}); | |
return Object.keys(aggregatedStats).map(function (key) { | |
return _extends({}, aggregatedStats[key], { | |
instanceCount: Object.keys(affectedIDs[key]).length | |
}); | |
}).sort(function (a, b) { | |
return b.inclusiveRenderDuration - a.inclusiveRenderDuration; | |
}); | |
} | |
function getWasted() { | |
var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements(); | |
if (!__DEV__) { | |
warnInProduction(); | |
return []; | |
} | |
var aggregatedStats = {}; | |
var affectedIDs = {}; | |
function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) { | |
var _treeSnapshot$instanc2 = treeSnapshot[instanceID], | |
displayName = _treeSnapshot$instanc2.displayName, | |
ownerID = _treeSnapshot$instanc2.ownerID; | |
var owner = treeSnapshot[ownerID]; | |
var key = (owner ? owner.displayName + ' > ' : '') + displayName; | |
var stats = aggregatedStats[key]; | |
if (!stats) { | |
affectedIDs[key] = {}; | |
stats = aggregatedStats[key] = { | |
key: key, | |
instanceCount: 0, | |
inclusiveRenderDuration: 0, | |
renderCount: 0 | |
}; | |
} | |
affectedIDs[key][instanceID] = true; | |
applyUpdate(stats); | |
} | |
flushHistory.forEach(function (flush) { | |
var measurements = flush.measurements, | |
treeSnapshot = flush.treeSnapshot, | |
operations = flush.operations; | |
var isDefinitelyNotWastedByID = {}; | |
// Find host components associated with an operation in this batch. | |
// Mark all components in their parent tree as definitely not wasted. | |
operations.forEach(function (operation) { | |
var instanceID = operation.instanceID; | |
var nextParentID = instanceID; | |
while (nextParentID) { | |
isDefinitelyNotWastedByID[nextParentID] = true; | |
nextParentID = treeSnapshot[nextParentID].parentID; | |
} | |
}); | |
// Find composite components that rendered in this batch. | |
// These are potential candidates for being wasted renders. | |
var renderedCompositeIDs = {}; | |
measurements.forEach(function (measurement) { | |
var instanceID = measurement.instanceID, | |
timerType = measurement.timerType; | |
if (timerType !== 'render') { | |
return; | |
} | |
renderedCompositeIDs[instanceID] = true; | |
}); | |
measurements.forEach(function (measurement) { | |
var duration = measurement.duration, | |
instanceID = measurement.instanceID, | |
timerType = measurement.timerType; | |
if (timerType !== 'render') { | |
return; | |
} | |
// If there was a DOM update below this component, or it has just been | |
// mounted, its render() is not considered wasted. | |
var updateCount = treeSnapshot[instanceID].updateCount; | |
if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) { | |
return; | |
} | |
// We consider this render() wasted. | |
updateAggregatedStats(treeSnapshot, instanceID, function (stats) { | |
stats.renderCount++; | |
}); | |
var nextParentID = instanceID; | |
while (nextParentID) { | |
// Any parents rendered during this batch are considered wasted | |
// unless we previously marked them as dirty. | |
var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID]; | |
if (isWasted) { | |
updateAggregatedStats(treeSnapshot, nextParentID, function (stats) { | |
stats.inclusiveRenderDuration += duration; | |
}); | |
} | |
nextParentID = treeSnapshot[nextParentID].parentID; | |
} | |
}); | |
}); | |
return Object.keys(aggregatedStats).map(function (key) { | |
return _extends({}, aggregatedStats[key], { | |
instanceCount: Object.keys(affectedIDs[key]).length | |
}); | |
}).sort(function (a, b) { | |
return b.inclusiveRenderDuration - a.inclusiveRenderDuration; | |
}); | |
} | |
function getOperations() { | |
var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements(); | |
if (!__DEV__) { | |
warnInProduction(); | |
return []; | |
} | |
var stats = []; | |
flushHistory.forEach(function (flush, flushIndex) { | |
var operations = flush.operations, | |
treeSnapshot = flush.treeSnapshot; | |
operations.forEach(function (operation) { | |
var instanceID = operation.instanceID, | |
type = operation.type, | |
payload = operation.payload; | |
var _treeSnapshot$instanc3 = treeSnapshot[instanceID], | |
displayName = _treeSnapshot$instanc3.displayName, | |
ownerID = _treeSnapshot$instanc3.ownerID; | |
var owner = treeSnapshot[ownerID]; | |
var key = (owner ? owner.displayName + ' > ' : '') + displayName; | |
stats.push({ | |
flushIndex: flushIndex, | |
instanceID: instanceID, | |
key: key, | |
type: type, | |
ownerID: ownerID, | |
payload: payload | |
}); | |
}); | |
}); | |
return stats; | |
} | |
function printExclusive(flushHistory) { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
var stats = getExclusive(flushHistory); | |
var table = stats.map(function (item) { | |
var key = item.key, | |
instanceCount = item.instanceCount, | |
totalDuration = item.totalDuration; | |
var renderCount = item.counts.render || 0; | |
var renderDuration = item.durations.render || 0; | |
return { | |
'Component': key, | |
'Total time (ms)': roundFloat(totalDuration), | |
'Instance count': instanceCount, | |
'Total render time (ms)': roundFloat(renderDuration), | |
'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined, | |
'Render count': renderCount, | |
'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration) | |
}; | |
}); | |
consoleTable(table); | |
} | |
function printInclusive(flushHistory) { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
var stats = getInclusive(flushHistory); | |
var table = stats.map(function (item) { | |
var key = item.key, | |
instanceCount = item.instanceCount, | |
inclusiveRenderDuration = item.inclusiveRenderDuration, | |
renderCount = item.renderCount; | |
return { | |
'Owner > Component': key, | |
'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration), | |
'Instance count': instanceCount, | |
'Render count': renderCount | |
}; | |
}); | |
consoleTable(table); | |
} | |
function printWasted(flushHistory) { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
var stats = getWasted(flushHistory); | |
var table = stats.map(function (item) { | |
var key = item.key, | |
instanceCount = item.instanceCount, | |
inclusiveRenderDuration = item.inclusiveRenderDuration, | |
renderCount = item.renderCount; | |
return { | |
'Owner > Component': key, | |
'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration), | |
'Instance count': instanceCount, | |
'Render count': renderCount | |
}; | |
}); | |
consoleTable(table); | |
} | |
function printOperations(flushHistory) { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
var stats = getOperations(flushHistory); | |
var table = stats.map(function (stat) { | |
return { | |
'Owner > Node': stat.key, | |
'Operation': stat.type, | |
'Payload': typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload, | |
'Flush index': stat.flushIndex, | |
'Owner Component ID': stat.ownerID, | |
'DOM Component ID': stat.instanceID | |
}; | |
}); | |
consoleTable(table); | |
} | |
var warnedAboutPrintDOM = false; | |
function printDOM(measurements) { | |
warning$31(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.'); | |
warnedAboutPrintDOM = true; | |
return printOperations(measurements); | |
} | |
var warnedAboutGetMeasurementsSummaryMap = false; | |
function getMeasurementsSummaryMap(measurements) { | |
warning$31(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.'); | |
warnedAboutGetMeasurementsSummaryMap = true; | |
return getWasted(measurements); | |
} | |
function start() { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
ReactDebugTool$2.beginProfiling(); | |
} | |
function stop() { | |
if (!__DEV__) { | |
warnInProduction(); | |
return; | |
} | |
ReactDebugTool$2.endProfiling(); | |
} | |
function isRunning() { | |
if (!__DEV__) { | |
warnInProduction(); | |
return false; | |
} | |
return ReactDebugTool$2.isProfiling(); | |
} | |
var ReactPerfAnalysis = { | |
getLastMeasurements: getLastMeasurements, | |
getExclusive: getExclusive, | |
getInclusive: getInclusive, | |
getWasted: getWasted, | |
getOperations: getOperations, | |
printExclusive: printExclusive, | |
printInclusive: printInclusive, | |
printWasted: printWasted, | |
printOperations: printOperations, | |
start: start, | |
stop: stop, | |
isRunning: isRunning, | |
// Deprecated: | |
printDOM: printDOM, | |
getMeasurementsSummaryMap: getMeasurementsSummaryMap | |
}; | |
var ReactPerf = ReactPerfAnalysis; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule EventConstants | |
*/ | |
/** | |
* Types of raw signals from the browser caught at the top level. | |
*/ | |
var topLevelTypes$1 = { | |
topAbort: null, | |
topAnimationEnd: null, | |
topAnimationIteration: null, | |
topAnimationStart: null, | |
topBlur: null, | |
topCancel: null, | |
topCanPlay: null, | |
topCanPlayThrough: null, | |
topChange: null, | |
topClick: null, | |
topClose: null, | |
topCompositionEnd: null, | |
topCompositionStart: null, | |
topCompositionUpdate: null, | |
topContextMenu: null, | |
topCopy: null, | |
topCut: null, | |
topDoubleClick: null, | |
topDrag: null, | |
topDragEnd: null, | |
topDragEnter: null, | |
topDragExit: null, | |
topDragLeave: null, | |
topDragOver: null, | |
topDragStart: null, | |
topDrop: null, | |
topDurationChange: null, | |
topEmptied: null, | |
topEncrypted: null, | |
topEnded: null, | |
topError: null, | |
topFocus: null, | |
topInput: null, | |
topInvalid: null, | |
topKeyDown: null, | |
topKeyPress: null, | |
topKeyUp: null, | |
topLoad: null, | |
topLoadedData: null, | |
topLoadedMetadata: null, | |
topLoadStart: null, | |
topMouseDown: null, | |
topMouseMove: null, | |
topMouseOut: null, | |
topMouseOver: null, | |
topMouseUp: null, | |
topPaste: null, | |
topPause: null, | |
topPlay: null, | |
topPlaying: null, | |
topProgress: null, | |
topRateChange: null, | |
topReset: null, | |
topScroll: null, | |
topSeeked: null, | |
topSeeking: null, | |
topSelectionChange: null, | |
topStalled: null, | |
topSubmit: null, | |
topSuspend: null, | |
topTextInput: null, | |
topTimeUpdate: null, | |
topToggle: null, | |
topTouchCancel: null, | |
topTouchEnd: null, | |
topTouchMove: null, | |
topTouchStart: null, | |
topTransitionEnd: null, | |
topVolumeChange: null, | |
topWaiting: null, | |
topWheel: null | |
}; | |
var EventConstants$1 = { | |
topLevelTypes: topLevelTypes$1 | |
}; | |
var EventConstants_1 = EventConstants$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactTypeOfSideEffect | |
* | |
*/ | |
var ReactTypeOfSideEffect = { | |
NoEffect: 0, // 0b0000000 | |
Placement: 1, // 0b0000001 | |
Update: 2, // 0b0000010 | |
PlacementAndUpdate: 3, // 0b0000011 | |
Deletion: 4, // 0b0000100 | |
ContentReset: 8, // 0b0001000 | |
Callback: 16, // 0b0010000 | |
Err: 32, // 0b0100000 | |
Ref: 64 }; | |
var ReactInstanceMap$8 = ReactInstanceMap_1; | |
var ReactCurrentOwner$8 = ReactCurrentOwner_1; | |
var invariant$32 = invariant; | |
if (__DEV__) { | |
var warning$32 = warning; | |
} | |
var _require$8 = ReactTypeOfWork; | |
var HostRoot$1 = _require$8.HostRoot; | |
var HostComponent$4 = _require$8.HostComponent; | |
var HostText$2 = _require$8.HostText; | |
var ClassComponent$3 = _require$8.ClassComponent; | |
var _require2 = ReactTypeOfSideEffect; | |
var NoEffect = _require2.NoEffect; | |
var Placement = _require2.Placement; | |
var MOUNTING = 1; | |
var MOUNTED = 2; | |
var UNMOUNTED = 3; | |
function isFiberMountedImpl(fiber) { | |
var node = fiber; | |
if (!fiber.alternate) { | |
// If there is no alternate, this might be a new tree that isn't inserted | |
// yet. If it is, then it will have a pending insertion effect on it. | |
if ((node.effectTag & Placement) !== NoEffect) { | |
return MOUNTING; | |
} | |
while (node['return']) { | |
node = node['return']; | |
if ((node.effectTag & Placement) !== NoEffect) { | |
return MOUNTING; | |
} | |
} | |
} else { | |
while (node['return']) { | |
node = node['return']; | |
} | |
} | |
if (node.tag === HostRoot$1) { | |
// TODO: Check if this was a nested HostRoot when used with | |
// renderContainerIntoSubtree. | |
return MOUNTED; | |
} | |
// If we didn't hit the root, that means that we're in an disconnected tree | |
// that has been unmounted. | |
return UNMOUNTED; | |
} | |
var isFiberMounted = function (fiber) { | |
return isFiberMountedImpl(fiber) === MOUNTED; | |
}; | |
var isMounted = function (component) { | |
if (__DEV__) { | |
var owner = ReactCurrentOwner$8.current; | |
if (owner !== null && owner.tag === ClassComponent$3) { | |
var ownerFiber = owner; | |
var instance = ownerFiber.stateNode; | |
warning$32(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName$6(ownerFiber)); | |
instance._warnedAboutRefsInRender = true; | |
} | |
} | |
var fiber = ReactInstanceMap$8.get(component); | |
if (!fiber) { | |
return false; | |
} | |
return isFiberMountedImpl(fiber) === MOUNTED; | |
}; | |
function assertIsMounted(fiber) { | |
invariant$32(isFiberMountedImpl(fiber) === MOUNTED, 'Unable to find node on an unmounted component.'); | |
} | |
function findCurrentFiberUsingSlowPath(fiber) { | |
var alternate = fiber.alternate; | |
if (!alternate) { | |
// If there is no alternate, then we only need to check if it is mounted. | |
var state = isFiberMountedImpl(fiber); | |
invariant$32(state !== UNMOUNTED, 'Unable to find node on an unmounted component.'); | |
if (state === MOUNTING) { | |
return null; | |
} | |
return fiber; | |
} | |
// If we have two possible branches, we'll walk backwards up to the root | |
// to see what path the root points to. On the way we may hit one of the | |
// special cases and we'll deal with them. | |
var a = fiber; | |
var b = alternate; | |
while (true) { | |
var parentA = a['return']; | |
var parentB = parentA ? parentA.alternate : null; | |
if (!parentA || !parentB) { | |
// We're at the root. | |
break; | |
} | |
// If both copies of the parent fiber point to the same child, we can | |
// assume that the child is current. This happens when we bailout on low | |
// priority: the bailed out fiber's child reuses the current child. | |
if (parentA.child === parentB.child) { | |
var child = parentA.child; | |
while (child) { | |
if (child === a) { | |
// We've determined that A is the current branch. | |
assertIsMounted(parentA); | |
return fiber; | |
} | |
if (child === b) { | |
// We've determined that B is the current branch. | |
assertIsMounted(parentA); | |
return alternate; | |
} | |
child = child.sibling; | |
} | |
// We should never have an alternate for any mounting node. So the only | |
// way this could possibly happen is if this was unmounted, if at all. | |
invariant$32(false, 'Unable to find node on an unmounted component.'); | |
} | |
if (a['return'] !== b['return']) { | |
// The return pointer of A and the return pointer of B point to different | |
// fibers. We assume that return pointers never criss-cross, so A must | |
// belong to the child set of A.return, and B must belong to the child | |
// set of B.return. | |
a = parentA; | |
b = parentB; | |
} else { | |
// The return pointers pointer to the same fiber. We'll have to use the | |
// default, slow path: scan the child sets of each parent alternate to see | |
// which child belongs to which set. | |
// | |
// Search parent A's child set | |
var didFindChild = false; | |
var _child = parentA.child; | |
while (_child) { | |
if (_child === a) { | |
didFindChild = true; | |
a = parentA; | |
b = parentB; | |
break; | |
} | |
if (_child === b) { | |
didFindChild = true; | |
b = parentA; | |
a = parentB; | |
break; | |
} | |
_child = _child.sibling; | |
} | |
if (!didFindChild) { | |
// Search parent B's child set | |
_child = parentB.child; | |
while (_child) { | |
if (_child === a) { | |
didFindChild = true; | |
a = parentB; | |
b = parentA; | |
break; | |
} | |
if (_child === b) { | |
didFindChild = true; | |
b = parentB; | |
a = parentA; | |
break; | |
} | |
_child = _child.sibling; | |
} | |
invariant$32(didFindChild, 'Child was not found in either parent set. This indicates a bug ' + 'related to the return pointer.'); | |
} | |
} | |
invariant$32(a.alternate === b, 'Return fibers should always be each others\' alternates.'); | |
} | |
// If the root is not a host container, we're in a disconnected tree. I.e. | |
// unmounted. | |
invariant$32(a.tag === HostRoot$1, 'Unable to find node on an unmounted component.'); | |
if (a.stateNode.current === a) { | |
// We've determined that A is the current branch. | |
return fiber; | |
} | |
// Otherwise B has to be current branch. | |
return alternate; | |
} | |
var findCurrentFiberUsingSlowPath_1 = findCurrentFiberUsingSlowPath; | |
var findCurrentHostFiber = function (parent) { | |
var currentParent = findCurrentFiberUsingSlowPath(parent); | |
if (!currentParent) { | |
return null; | |
} | |
// Next we'll drill down this component to find the first HostComponent/Text. | |
var node = currentParent; | |
while (true) { | |
if (node.tag === HostComponent$4 || node.tag === HostText$2) { | |
return node; | |
} else if (node.child) { | |
// TODO: If we hit a Portal, we're supposed to skip it. | |
node.child['return'] = node; | |
node = node.child; | |
continue; | |
} | |
if (node === currentParent) { | |
return null; | |
} | |
while (!node.sibling) { | |
if (!node['return'] || node['return'] === currentParent) { | |
return null; | |
} | |
node = node['return']; | |
} | |
node.sibling['return'] = node['return']; | |
node = node.sibling; | |
} | |
// Flow needs the return null here, but ESLint complains about it. | |
// eslint-disable-next-line no-unreachable | |
return null; | |
}; | |
function getComponentName$6(fiber) { | |
var type = fiber.type; | |
var instance = fiber.stateNode; | |
var constructor = instance && instance.constructor; | |
return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || 'A Component'; | |
} | |
var getComponentName_1$2 = getComponentName$6; | |
var ReactFiberTreeReflection$1 = { | |
isFiberMounted: isFiberMounted, | |
isMounted: isMounted, | |
findCurrentFiberUsingSlowPath: findCurrentFiberUsingSlowPath_1, | |
findCurrentHostFiber: findCurrentHostFiber, | |
getComponentName: getComponentName_1$2 | |
}; | |
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var React$7 = React; | |
var ReactDOMInjection$3 = ReactDOMInjection$1; | |
var ReactDOMStackInjection$3 = ReactDOMStackInjection$1; | |
var ReactCompositeComponent$2 = ReactCompositeComponent_1; | |
var ReactReconciler$7 = ReactReconciler_1; | |
var ReactUpdates$5 = ReactUpdates_1; | |
var emptyObject$4 = emptyObject; | |
var getNextDebugID$2 = getNextDebugID_1; | |
var invariant$33 = invariant; | |
var NoopInternalComponent = function () { | |
function NoopInternalComponent(element) { | |
_classCallCheck$2(this, NoopInternalComponent); | |
this._renderedOutput = element; | |
this._currentElement = element; | |
if (__DEV__) { | |
this._debugID = getNextDebugID$2(); | |
} | |
} | |
NoopInternalComponent.prototype.mountComponent = function mountComponent() {}; | |
NoopInternalComponent.prototype.receiveComponent = function receiveComponent(element) { | |
this._renderedOutput = element; | |
this._currentElement = element; | |
}; | |
NoopInternalComponent.prototype.unmountComponent = function unmountComponent() {}; | |
NoopInternalComponent.prototype.getHostNode = function getHostNode() { | |
return undefined; | |
}; | |
NoopInternalComponent.prototype.getPublicInstance = function getPublicInstance() { | |
return null; | |
}; | |
return NoopInternalComponent; | |
}(); | |
var ShallowComponentWrapper = function (element) { | |
// TODO: Consolidate with instantiateReactComponent | |
if (__DEV__) { | |
this._debugID = getNextDebugID$2(); | |
} | |
this.construct(element); | |
}; | |
Object.assign(ShallowComponentWrapper.prototype, ReactCompositeComponent$2, { | |
_constructComponent: ReactCompositeComponent$2._constructComponentWithoutOwner, | |
_instantiateReactComponent: function (element) { | |
return new NoopInternalComponent(element); | |
}, | |
_replaceNodeWithMarkup: function () {}, | |
_renderValidatedComponent: ReactCompositeComponent$2._renderValidatedComponentWithoutOwnerOrContext | |
}); | |
function _batchedRender(renderer, element, context) { | |
var transaction = ReactUpdates$5.ReactReconcileTransaction.getPooled(true); | |
renderer._render(element, transaction, context); | |
ReactUpdates$5.ReactReconcileTransaction.release(transaction); | |
} | |
var ReactShallowRenderer$1 = function () { | |
function ReactShallowRenderer() { | |
_classCallCheck$2(this, ReactShallowRenderer); | |
this._instance = null; | |
} | |
ReactShallowRenderer.prototype.getMountedInstance = function getMountedInstance() { | |
return this._instance ? this._instance._instance : null; | |
}; | |
ReactShallowRenderer.prototype.render = function render(element, context) { | |
// Ensure we've done the default injections. This might not be true in the | |
// case of a simple test that only requires React and the TestUtils in | |
// conjunction with an inline-requires transform. | |
ReactDOMInjection$3.inject(); | |
ReactDOMStackInjection$3.inject(); | |
invariant$33(React$7.isValidElement(element), 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : ''); | |
invariant$33(typeof element.type !== 'string', 'ReactShallowRenderer render(): Shallow rendering works only with custom ' + 'components, not primitives (%s). Instead of calling `.render(el)` and ' + 'inspecting the rendered output, look at `el.props` directly instead.', element.type); | |
if (!context) { | |
context = emptyObject$4; | |
} | |
ReactUpdates$5.batchedUpdates(_batchedRender, this, element, context); | |
return this.getRenderOutput(); | |
}; | |
ReactShallowRenderer.prototype.getRenderOutput = function getRenderOutput() { | |
return this._instance && this._instance._renderedComponent && this._instance._renderedComponent._renderedOutput || null; | |
}; | |
ReactShallowRenderer.prototype.unmount = function unmount() { | |
if (this._instance) { | |
ReactReconciler$7.unmountComponent(this._instance, false, /* safely */ | |
false /* skipLifecycle */ | |
); | |
} | |
}; | |
ReactShallowRenderer.prototype._render = function _render(element, transaction, context) { | |
if (this._instance) { | |
ReactReconciler$7.receiveComponent(this._instance, element, transaction, context); | |
} else { | |
var instance = new ShallowComponentWrapper(element); | |
ReactReconciler$7.mountComponent(instance, transaction, null, null, context, 0); | |
this._instance = instance; | |
} | |
}; | |
return ReactShallowRenderer; | |
}(); | |
var ReactShallowRenderer_1 = ReactShallowRenderer$1; | |
var EventConstants = EventConstants_1; | |
var EventPluginHub$5 = EventPluginHub_1; | |
var EventPluginRegistry$5 = EventPluginRegistry_1; | |
var EventPropagators$6 = EventPropagators_1; | |
var React$6 = React; | |
var ReactControlledComponent$3 = ReactControlledComponent_1; | |
var ReactDOM$2 = ReactDOM_1; | |
var ReactDOMComponentTree$21 = ReactDOMComponentTree_1; | |
var ReactBrowserEventEmitter$6 = ReactBrowserEventEmitter_1; | |
var ReactFiberTreeReflection = ReactFiberTreeReflection$1; | |
var ReactInstanceMap$7 = ReactInstanceMap_1; | |
var ReactTypeOfWork$4 = ReactTypeOfWork; | |
var ReactGenericBatching$5 = ReactGenericBatching_1; | |
var SyntheticEvent$10 = SyntheticEvent_1; | |
var ReactShallowRenderer = ReactShallowRenderer_1; | |
var findDOMNode$3 = findDOMNode_1; | |
var invariant$31 = invariant; | |
var topLevelTypes = EventConstants.topLevelTypes; | |
var ClassComponent$2 = ReactTypeOfWork$4.ClassComponent; | |
var FunctionalComponent$1 = ReactTypeOfWork$4.FunctionalComponent; | |
var HostComponent$3 = ReactTypeOfWork$4.HostComponent; | |
var HostText$1 = ReactTypeOfWork$4.HostText; | |
function Event(suffix) {} | |
/** | |
* @class ReactTestUtils | |
*/ | |
function findAllInRenderedStackTreeInternal(inst, test) { | |
if (!inst || !inst.getPublicInstance) { | |
return []; | |
} | |
var publicInst = inst.getPublicInstance(); | |
var ret = test(publicInst) ? [publicInst] : []; | |
var currentElement = inst._currentElement; | |
if (ReactTestUtils.isDOMComponent(publicInst)) { | |
var renderedChildren = inst._renderedChildren; | |
var key; | |
for (key in renderedChildren) { | |
if (!renderedChildren.hasOwnProperty(key)) { | |
continue; | |
} | |
ret = ret.concat(findAllInRenderedStackTreeInternal(renderedChildren[key], test)); | |
} | |
} else if (React$6.isValidElement(currentElement) && typeof currentElement.type === 'function') { | |
ret = ret.concat(findAllInRenderedStackTreeInternal(inst._renderedComponent, test)); | |
} | |
return ret; | |
} | |
function findAllInRenderedFiberTreeInternal(fiber, test) { | |
if (!fiber) { | |
return []; | |
} | |
var currentParent = ReactFiberTreeReflection.findCurrentFiberUsingSlowPath(fiber); | |
if (!currentParent) { | |
return []; | |
} | |
var node = currentParent; | |
var ret = []; | |
while (true) { | |
if (node.tag === HostComponent$3 || node.tag === HostText$1 || node.tag === ClassComponent$2 || node.tag === FunctionalComponent$1) { | |
var publicInst = node.stateNode; | |
if (test(publicInst)) { | |
ret.push(publicInst); | |
} | |
} | |
if (node.child) { | |
node.child['return'] = node; | |
node = node.child; | |
continue; | |
} | |
if (node === currentParent) { | |
return ret; | |
} | |
while (!node.sibling) { | |
if (!node['return'] || node['return'] === currentParent) { | |
return ret; | |
} | |
node = node['return']; | |
} | |
node.sibling['return'] = node['return']; | |
node = node.sibling; | |
} | |
} | |
/** | |
* Utilities for making it easy to test React components. | |
* | |
* See https://facebook.github.io/react/docs/test-utils.html | |
* | |
* Todo: Support the entire DOM.scry query syntax. For now, these simple | |
* utilities will suffice for testing purposes. | |
* @lends ReactTestUtils | |
*/ | |
var ReactTestUtils = { | |
renderIntoDocument: function (element) { | |
var div = document.createElement('div'); | |
// None of our tests actually require attaching the container to the | |
// DOM, and doing so creates a mess that we rely on test isolation to | |
// clean up, so we're going to stop honoring the name of this method | |
// (and probably rename it eventually) if no problems arise. | |
// document.documentElement.appendChild(div); | |
return ReactDOM$2.render(element, div); | |
}, | |
isElement: function (element) { | |
return React$6.isValidElement(element); | |
}, | |
isElementOfType: function (inst, convenienceConstructor) { | |
return React$6.isValidElement(inst) && inst.type === convenienceConstructor; | |
}, | |
isDOMComponent: function (inst) { | |
return !!(inst && inst.nodeType === 1 && inst.tagName); | |
}, | |
isDOMComponentElement: function (inst) { | |
return !!(inst && React$6.isValidElement(inst) && !!inst.tagName); | |
}, | |
isCompositeComponent: function (inst) { | |
if (ReactTestUtils.isDOMComponent(inst)) { | |
// Accessing inst.setState warns; just return false as that'll be what | |
// this returns when we have DOM nodes as refs directly | |
return false; | |
} | |
return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function'; | |
}, | |
isCompositeComponentWithType: function (inst, type) { | |
if (!ReactTestUtils.isCompositeComponent(inst)) { | |
return false; | |
} | |
var internalInstance = ReactInstanceMap$7.get(inst); | |
var constructor = typeof internalInstance.tag === 'number' ? internalInstance.type : // Fiber reconciler | |
internalInstance._currentElement.type; // Stack reconciler | |
return constructor === type; | |
}, | |
// TODO: deprecate? It's undocumented and unused. | |
isCompositeComponentElement: function (inst) { | |
if (!React$6.isValidElement(inst)) { | |
return false; | |
} | |
// We check the prototype of the type that will get mounted, not the | |
// instance itself. This is a future proof way of duck typing. | |
var prototype = inst.type.prototype; | |
return typeof prototype.render === 'function' && typeof prototype.setState === 'function'; | |
}, | |
// TODO: deprecate? It's undocumented and unused. | |
isCompositeComponentElementWithType: function (inst, type) { | |
var internalInstance = ReactInstanceMap$7.get(inst); | |
var constructor = internalInstance._currentElement.type; | |
return !!(ReactTestUtils.isCompositeComponentElement(inst) && constructor === type); | |
}, | |
// TODO: deprecate? It's undocumented and unused. | |
getRenderedChildOfCompositeComponent: function (inst) { | |
if (!ReactTestUtils.isCompositeComponent(inst)) { | |
return null; | |
} | |
var internalInstance = ReactInstanceMap$7.get(inst); | |
return internalInstance._renderedComponent.getPublicInstance(); | |
}, | |
findAllInRenderedTree: function (inst, test) { | |
if (!inst) { | |
return []; | |
} | |
invariant$31(ReactTestUtils.isCompositeComponent(inst), 'findAllInRenderedTree(...): instance must be a composite component'); | |
var internalInstance = ReactInstanceMap$7.get(inst); | |
if (internalInstance && typeof internalInstance.tag === 'number') { | |
return findAllInRenderedFiberTreeInternal(internalInstance, test); | |
} else { | |
return findAllInRenderedStackTreeInternal(internalInstance, test); | |
} | |
}, | |
/** | |
* Finds all instance of components in the rendered tree that are DOM | |
* components with the class name matching `className`. | |
* @return {array} an array of all the matches. | |
*/ | |
scryRenderedDOMComponentsWithClass: function (root, classNames) { | |
return ReactTestUtils.findAllInRenderedTree(root, function (inst) { | |
if (ReactTestUtils.isDOMComponent(inst)) { | |
var className = inst.className; | |
if (typeof className !== 'string') { | |
// SVG, probably. | |
className = inst.getAttribute('class') || ''; | |
} | |
var classList = className.split(/\s+/); | |
if (!Array.isArray(classNames)) { | |
invariant$31(classNames !== undefined, 'TestUtils.scryRenderedDOMComponentsWithClass expects a ' + 'className as a second argument.'); | |
classNames = classNames.split(/\s+/); | |
} | |
return classNames.every(function (name) { | |
return classList.indexOf(name) !== -1; | |
}); | |
} | |
return false; | |
}); | |
}, | |
/** | |
* Like scryRenderedDOMComponentsWithClass but expects there to be one result, | |
* and returns that one result, or throws exception if there is any other | |
* number of matches besides one. | |
* @return {!ReactDOMComponent} The one match. | |
*/ | |
findRenderedDOMComponentWithClass: function (root, className) { | |
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className); | |
if (all.length !== 1) { | |
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className); | |
} | |
return all[0]; | |
}, | |
/** | |
* Finds all instance of components in the rendered tree that are DOM | |
* components with the tag name matching `tagName`. | |
* @return {array} an array of all the matches. | |
*/ | |
scryRenderedDOMComponentsWithTag: function (root, tagName) { | |
return ReactTestUtils.findAllInRenderedTree(root, function (inst) { | |
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase(); | |
}); | |
}, | |
/** | |
* Like scryRenderedDOMComponentsWithTag but expects there to be one result, | |
* and returns that one result, or throws exception if there is any other | |
* number of matches besides one. | |
* @return {!ReactDOMComponent} The one match. | |
*/ | |
findRenderedDOMComponentWithTag: function (root, tagName) { | |
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName); | |
if (all.length !== 1) { | |
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName); | |
} | |
return all[0]; | |
}, | |
/** | |
* Finds all instances of components with type equal to `componentType`. | |
* @return {array} an array of all the matches. | |
*/ | |
scryRenderedComponentsWithType: function (root, componentType) { | |
return ReactTestUtils.findAllInRenderedTree(root, function (inst) { | |
return ReactTestUtils.isCompositeComponentWithType(inst, componentType); | |
}); | |
}, | |
/** | |
* Same as `scryRenderedComponentsWithType` but expects there to be one result | |
* and returns that one result, or throws exception if there is any other | |
* number of matches besides one. | |
* @return {!ReactComponent} The one match. | |
*/ | |
findRenderedComponentWithType: function (root, componentType) { | |
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType); | |
if (all.length !== 1) { | |
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType); | |
} | |
return all[0]; | |
}, | |
/** | |
* Pass a mocked component module to this method to augment it with | |
* useful methods that allow it to be used as a dummy React component. | |
* Instead of rendering as usual, the component will become a simple | |
* <div> containing any provided children. | |
* | |
* @param {object} module the mock function object exported from a | |
* module that defines the component to be mocked | |
* @param {?string} mockTagName optional dummy root tag name to return | |
* from render method (overrides | |
* module.mockTagName if provided) | |
* @return {object} the ReactTestUtils object (for chaining) | |
*/ | |
mockComponent: function (module, mockTagName) { | |
mockTagName = mockTagName || module.mockTagName || 'div'; | |
module.prototype.render.mockImplementation(function () { | |
return React$6.createElement(mockTagName, null, this.props.children); | |
}); | |
return this; | |
}, | |
/** | |
* Simulates a top level event being dispatched from a raw event that occurred | |
* on an `Element` node. | |
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes` | |
* @param {!Element} node The dom to simulate an event occurring on. | |
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. | |
*/ | |
simulateNativeEventOnNode: function (topLevelType, node, fakeNativeEvent) { | |
fakeNativeEvent.target = node; | |
ReactBrowserEventEmitter$6.ReactEventListener.dispatchEvent(topLevelType, fakeNativeEvent); | |
}, | |
/** | |
* Simulates a top level event being dispatched from a raw event that occurred | |
* on the `ReactDOMComponent` `comp`. | |
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`. | |
* @param {!ReactDOMComponent} comp | |
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. | |
*/ | |
simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) { | |
ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode$3(comp), fakeNativeEvent); | |
}, | |
nativeTouchData: function (x, y) { | |
return { | |
touches: [{ pageX: x, pageY: y }] | |
}; | |
}, | |
createRenderer: function () { | |
return new ReactShallowRenderer(); | |
}, | |
Simulate: null, | |
SimulateNative: {} | |
}; | |
/** | |
* Exports: | |
* | |
* - `ReactTestUtils.Simulate.click(Element/ReactDOMComponent)` | |
* - `ReactTestUtils.Simulate.mouseMove(Element/ReactDOMComponent)` | |
* - `ReactTestUtils.Simulate.change(Element/ReactDOMComponent)` | |
* - ... (All keys from event plugin `eventTypes` objects) | |
*/ | |
function makeSimulator(eventType) { | |
return function (domComponentOrNode, eventData) { | |
var node; | |
invariant$31(!React$6.isValidElement(domComponentOrNode), 'TestUtils.Simulate expects a component instance and not a ReactElement.' + 'TestUtils.Simulate will not work if you are using shallow rendering.'); | |
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { | |
node = findDOMNode$3(domComponentOrNode); | |
} else if (domComponentOrNode.tagName) { | |
node = domComponentOrNode; | |
} | |
var dispatchConfig = EventPluginRegistry$5.eventNameDispatchConfigs[eventType]; | |
var fakeNativeEvent = new Event(); | |
fakeNativeEvent.target = node; | |
fakeNativeEvent.type = eventType.toLowerCase(); | |
// We don't use SyntheticEvent.getPooled in order to not have to worry about | |
// properly destroying any properties assigned from `eventData` upon release | |
var targetInst = ReactDOMComponentTree$21.getInstanceFromNode(node); | |
var event = new SyntheticEvent$10(dispatchConfig, targetInst, fakeNativeEvent, node); | |
// Since we aren't using pooling, always persist the event. This will make | |
// sure it's marked and won't warn when setting additional properties. | |
event.persist(); | |
Object.assign(event, eventData); | |
if (dispatchConfig.phasedRegistrationNames) { | |
EventPropagators$6.accumulateTwoPhaseDispatches(event); | |
} else { | |
EventPropagators$6.accumulateDirectDispatches(event); | |
} | |
ReactGenericBatching$5.batchedUpdates(function () { | |
// Normally extractEvent enqueues a state restore, but we'll just always | |
// do that since we we're by-passing it here. | |
ReactControlledComponent$3.enqueueStateRestore(node); | |
EventPluginHub$5.enqueueEvents(event); | |
EventPluginHub$5.processEventQueue(true); | |
}); | |
}; | |
} | |
function buildSimulators() { | |
ReactTestUtils.Simulate = {}; | |
var eventType; | |
for (eventType in EventPluginRegistry$5.eventNameDispatchConfigs) { | |
/** | |
* @param {!Element|ReactDOMComponent} domComponentOrNode | |
* @param {?object} eventData Fake event data to use in SyntheticEvent. | |
*/ | |
ReactTestUtils.Simulate[eventType] = makeSimulator(eventType); | |
} | |
} | |
// Rebuild ReactTestUtils.Simulate whenever event plugins are injected | |
var oldInjectEventPluginOrder = EventPluginHub$5.injection.injectEventPluginOrder; | |
EventPluginHub$5.injection.injectEventPluginOrder = function () { | |
oldInjectEventPluginOrder.apply(this, arguments); | |
buildSimulators(); | |
}; | |
var oldInjectEventPlugins = EventPluginHub$5.injection.injectEventPluginsByName; | |
EventPluginHub$5.injection.injectEventPluginsByName = function () { | |
oldInjectEventPlugins.apply(this, arguments); | |
buildSimulators(); | |
}; | |
buildSimulators(); | |
/** | |
* Exports: | |
* | |
* - `ReactTestUtils.SimulateNative.click(Element/ReactDOMComponent)` | |
* - `ReactTestUtils.SimulateNative.mouseMove(Element/ReactDOMComponent)` | |
* - `ReactTestUtils.SimulateNative.mouseIn/ReactDOMComponent)` | |
* - `ReactTestUtils.SimulateNative.mouseOut(Element/ReactDOMComponent)` | |
* - ... (All keys from `EventConstants.topLevelTypes`) | |
* | |
* Note: Top level event types are a subset of the entire set of handler types | |
* (which include a broader set of "synthetic" events). For example, onDragDone | |
* is a synthetic event. Except when testing an event plugin or React's event | |
* handling code specifically, you probably want to use ReactTestUtils.Simulate | |
* to dispatch synthetic events. | |
*/ | |
function makeNativeSimulator(eventType) { | |
return function (domComponentOrNode, nativeEventData) { | |
var fakeNativeEvent = new Event(eventType); | |
Object.assign(fakeNativeEvent, nativeEventData); | |
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { | |
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent); | |
} else if (domComponentOrNode.tagName) { | |
// Will allow on actual dom nodes. | |
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent); | |
} | |
}; | |
} | |
Object.keys(topLevelTypes).forEach(function (eventType) { | |
// Event type is stored as 'topClick' - we transform that to 'click' | |
var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType; | |
/** | |
* @param {!Element|ReactDOMComponent} domComponentOrNode | |
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. | |
*/ | |
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType); | |
}); | |
var ReactTestUtils_1 = ReactTestUtils; | |
var React2 = React; | |
var ReactDOM = ReactDOM_1; | |
if (__DEV__) { | |
ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { | |
// ReactPerf and ReactTestUtils currently only work with the DOM renderer | |
// so we expose them from here, but only in DEV mode. | |
ReactPerf: ReactPerf, | |
ReactTestUtils: ReactTestUtils_1 | |
}; | |
} | |
// Inject ReactDOM into React for the addons UMD build that depends on ReactDOM (TransitionGroup). | |
// We can remove this after we deprecate and remove the addons UMD build. | |
if (React2.addons) { | |
React2.__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; | |
} | |
var ReactDOMFBEntry = ReactDOM; | |
module.exports = ReactDOMFBEntry; |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOMFiber-core | |
*/ | |
'use strict'; | |
var invariant = require('invariant'); | |
var warning = require('warning'); | |
var ExecutionEnvironment = require('ExecutionEnvironment'); | |
var camelizeStyleName = require('camelizeStyleName'); | |
var hyphenateStyleName = require('hyphenateStyleName'); | |
var memoizeStringOnly = require('memoizeStringOnly'); | |
var performanceNow = require('performanceNow'); | |
var React = require('React'); | |
var emptyFunction = require('emptyFunction'); | |
var EventListener = require('EventListener'); | |
var getUnboundedScrollPosition = require('getUnboundedScrollPosition'); | |
var containsNode = require('containsNode'); | |
var focusNode = require('focusNode'); | |
var getActiveElement = require('getActiveElement'); | |
var shallowEqual = require('shallowEqual'); | |
var emptyObject = require('emptyObject'); | |
var createNodesFromMarkup = require('createNodesFromMarkup'); | |
var invariant$1 = invariant; | |
/** | |
* Injectable ordering of event plugins. | |
*/ | |
var eventPluginOrder = null; | |
/** | |
* Injectable mapping from names to event plugin modules. | |
*/ | |
var namesToPlugins = {}; | |
/** | |
* Recomputes the plugin list using the injected plugins and plugin ordering. | |
* | |
* @private | |
*/ | |
function recomputePluginOrdering() { | |
if (!eventPluginOrder) { | |
// Wait until an `eventPluginOrder` is injected. | |
return; | |
} | |
for (var pluginName in namesToPlugins) { | |
var pluginModule = namesToPlugins[pluginName]; | |
var pluginIndex = eventPluginOrder.indexOf(pluginName); | |
invariant$1(pluginIndex > -1, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName); | |
if (EventPluginRegistry$1.plugins[pluginIndex]) { | |
continue; | |
} | |
invariant$1(pluginModule.extractEvents, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName); | |
EventPluginRegistry$1.plugins[pluginIndex] = pluginModule; | |
var publishedEvents = pluginModule.eventTypes; | |
for (var eventName in publishedEvents) { | |
invariant$1(publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName), 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName); | |
} | |
} | |
} | |
/** | |
* Publishes an event so that it can be dispatched by the supplied plugin. | |
* | |
* @param {object} dispatchConfig Dispatch configuration for the event. | |
* @param {object} PluginModule Plugin publishing the event. | |
* @return {boolean} True if the event was successfully published. | |
* @private | |
*/ | |
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { | |
invariant$1(!EventPluginRegistry$1.eventNameDispatchConfigs.hasOwnProperty(eventName), 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName); | |
EventPluginRegistry$1.eventNameDispatchConfigs[eventName] = dispatchConfig; | |
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | |
if (phasedRegistrationNames) { | |
for (var phaseName in phasedRegistrationNames) { | |
if (phasedRegistrationNames.hasOwnProperty(phaseName)) { | |
var phasedRegistrationName = phasedRegistrationNames[phaseName]; | |
publishRegistrationName(phasedRegistrationName, pluginModule, eventName); | |
} | |
} | |
return true; | |
} else if (dispatchConfig.registrationName) { | |
publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName); | |
return true; | |
} | |
return false; | |
} | |
/** | |
* Publishes a registration name that is used to identify dispatched events. | |
* | |
* @param {string} registrationName Registration name to add. | |
* @param {object} PluginModule Plugin publishing the event. | |
* @private | |
*/ | |
function publishRegistrationName(registrationName, pluginModule, eventName) { | |
invariant$1(!EventPluginRegistry$1.registrationNameModules[registrationName], 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName); | |
EventPluginRegistry$1.registrationNameModules[registrationName] = pluginModule; | |
EventPluginRegistry$1.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies; | |
if (__DEV__) { | |
var lowerCasedName = registrationName.toLowerCase(); | |
EventPluginRegistry$1.possibleRegistrationNames[lowerCasedName] = registrationName; | |
if (registrationName === 'onDoubleClick') { | |
EventPluginRegistry$1.possibleRegistrationNames.ondblclick = registrationName; | |
} | |
} | |
} | |
/** | |
* Registers plugins so that they can extract and dispatch events. | |
* | |
* @see {EventPluginHub} | |
*/ | |
var EventPluginRegistry$1 = { | |
/** | |
* Ordered list of injected plugins. | |
*/ | |
plugins: [], | |
/** | |
* Mapping from event name to dispatch config | |
*/ | |
eventNameDispatchConfigs: {}, | |
/** | |
* Mapping from registration name to plugin module | |
*/ | |
registrationNameModules: {}, | |
/** | |
* Mapping from registration name to event name | |
*/ | |
registrationNameDependencies: {}, | |
/** | |
* Mapping from lowercase registration names to the properly cased version, | |
* used to warn in the case of missing event handlers. Available | |
* only in __DEV__. | |
* @type {Object} | |
*/ | |
possibleRegistrationNames: __DEV__ ? {} : null, | |
// Trust the developer to only use possibleRegistrationNames in __DEV__ | |
/** | |
* 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. | |
* | |
* @param {array} InjectedEventPluginOrder | |
* @internal | |
* @see {EventPluginHub.injection.injectEventPluginOrder} | |
*/ | |
injectEventPluginOrder: function (injectedEventPluginOrder) { | |
invariant$1(!eventPluginOrder, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.'); | |
// Clone the ordering so it cannot be dynamically mutated. | |
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); | |
recomputePluginOrdering(); | |
}, | |
/** | |
* Injects plugins to be used by `EventPluginHub`. The plugin names must be | |
* in the ordering injected by `injectEventPluginOrder`. | |
* | |
* Plugins can be injected as part of page initialization or on-the-fly. | |
* | |
* @param {object} injectedNamesToPlugins Map from names to plugin modules. | |
* @internal | |
* @see {EventPluginHub.injection.injectEventPluginsByName} | |
*/ | |
injectEventPluginsByName: function (injectedNamesToPlugins) { | |
var isOrderingDirty = false; | |
for (var pluginName in injectedNamesToPlugins) { | |
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { | |
continue; | |
} | |
var pluginModule = injectedNamesToPlugins[pluginName]; | |
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) { | |
invariant$1(!namesToPlugins[pluginName], 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName); | |
namesToPlugins[pluginName] = pluginModule; | |
isOrderingDirty = true; | |
} | |
} | |
if (isOrderingDirty) { | |
recomputePluginOrdering(); | |
} | |
}, | |
/** | |
* Looks up the plugin for the supplied event. | |
* | |
* @param {object} event A synthetic event. | |
* @return {?object} The plugin that created the supplied event. | |
* @internal | |
*/ | |
getPluginModuleForEvent: function (event) { | |
var dispatchConfig = event.dispatchConfig; | |
if (dispatchConfig.registrationName) { | |
return EventPluginRegistry$1.registrationNameModules[dispatchConfig.registrationName] || null; | |
} | |
if (dispatchConfig.phasedRegistrationNames !== undefined) { | |
// pulling phasedRegistrationNames out of dispatchConfig helps Flow see | |
// that it is not undefined. | |
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; | |
for (var phase in phasedRegistrationNames) { | |
if (!phasedRegistrationNames.hasOwnProperty(phase)) { | |
continue; | |
} | |
var pluginModule = EventPluginRegistry$1.registrationNameModules[phasedRegistrationNames[phase]]; | |
if (pluginModule) { | |
return pluginModule; | |
} | |
} | |
} | |
return null; | |
}, | |
/** | |
* Exposed for unit testing. | |
* @private | |
*/ | |
_resetEventPlugins: function () { | |
eventPluginOrder = null; | |
for (var pluginName in namesToPlugins) { | |
if (namesToPlugins.hasOwnProperty(pluginName)) { | |
delete namesToPlugins[pluginName]; | |
} | |
} | |
EventPluginRegistry$1.plugins.length = 0; | |
var eventNameDispatchConfigs = EventPluginRegistry$1.eventNameDispatchConfigs; | |
for (var eventName in eventNameDispatchConfigs) { | |
if (eventNameDispatchConfigs.hasOwnProperty(eventName)) { | |
delete eventNameDispatchConfigs[eventName]; | |
} | |
} | |
var registrationNameModules = EventPluginRegistry$1.registrationNameModules; | |
for (var registrationName in registrationNameModules) { | |
if (registrationNameModules.hasOwnProperty(registrationName)) { | |
delete registrationNameModules[registrationName]; | |
} | |
} | |
if (__DEV__) { | |
var possibleRegistrationNames = EventPluginRegistry$1.possibleRegistrationNames; | |
for (var lowerCasedName in possibleRegistrationNames) { | |
if (possibleRegistrationNames.hasOwnProperty(lowerCasedName)) { | |
delete possibleRegistrationNames[lowerCasedName]; | |
} | |
} | |
} | |
} | |
}; | |
var EventPluginRegistry_1 = EventPluginRegistry$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactErrorUtils | |
* | |
*/ | |
var caughtError = null; | |
/** | |
* Call a function while guarding against errors that happens within it. | |
* Returns an error if it throws, otherwise null. | |
* | |
* @param {String} name of the guard to use for logging or debugging | |
* @param {Function} func The function to invoke | |
* @param {*} context The context to use when calling the function | |
* @param {...*} args Arguments for function | |
*/ | |
var ReactErrorUtils$2 = { | |
invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) { | |
var funcArgs = Array.prototype.slice.call(arguments, 3); | |
try { | |
func.apply(context, funcArgs); | |
} catch (error) { | |
return error; | |
} | |
return null; | |
}, | |
/** | |
* Same as invokeGuardedCallback, but instead of returning an error, it stores | |
* it in a global so it can be rethrown by `rethrowCaughtError` later. | |
* | |
* @param {String} name of the guard to use for logging or debugging | |
* @param {Function} func The function to invoke | |
* @param {*} context The context to use when calling the function | |
* @param {...*} args Arguments for function | |
*/ | |
invokeGuardedCallbackAndCatchFirstError: function (name, func, context, a, b, c, d, e, f) { | |
var error = ReactErrorUtils$2.invokeGuardedCallback.apply(this, arguments); | |
if (error !== null && caughtError === null) { | |
caughtError = error; | |
} | |
}, | |
/** | |
* During execution of guarded functions we will capture the first error which | |
* we will rethrow to be handled by the top level error handler. | |
*/ | |
rethrowCaughtError: function () { | |
if (caughtError) { | |
var error = caughtError; | |
caughtError = null; | |
throw error; | |
} | |
} | |
}; | |
if (__DEV__) { | |
/** | |
* To help development we can get better devtools integration by simulating a | |
* real browser event. | |
*/ | |
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') { | |
var fakeNode = document.createElement('React'); | |
var depth = 0; | |
ReactErrorUtils$2.invokeGuardedCallback = function (name, func, context, a, b, c, d, e, f) { | |
depth++; | |
var thisDepth = depth; | |
var funcArgs = Array.prototype.slice.call(arguments, 3); | |
var boundFunc = function () { | |
func.apply(context, funcArgs); | |
}; | |
var fakeEventError = null; | |
var onFakeEventError = function (event) { | |
// Don't capture nested errors | |
if (depth === thisDepth) { | |
fakeEventError = event.error; | |
} | |
}; | |
var evtType = 'react-' + (name ? name : 'invokeguardedcallback') + '-' + depth; | |
window.addEventListener('error', onFakeEventError); | |
fakeNode.addEventListener(evtType, boundFunc, false); | |
var evt = document.createEvent('Event'); | |
evt.initEvent(evtType, false, false); | |
fakeNode.dispatchEvent(evt); | |
fakeNode.removeEventListener(evtType, boundFunc, false); | |
window.removeEventListener('error', onFakeEventError); | |
depth--; | |
return fakeEventError; | |
}; | |
} | |
} | |
var ReactErrorUtils_1 = ReactErrorUtils$2; | |
var ReactErrorUtils$1 = ReactErrorUtils_1; | |
var invariant$3 = invariant; | |
var warning$1 = warning; | |
/** | |
* Injected dependencies: | |
*/ | |
/** | |
* - `ComponentTree`: [required] Module that can convert between React instances | |
* and actual node references. | |
*/ | |
var ComponentTree; | |
var injection = { | |
injectComponentTree: function (Injected) { | |
ComponentTree = Injected; | |
if (__DEV__) { | |
warning$1(Injected && Injected.getNodeFromInstance && Injected.getInstanceFromNode, 'EventPluginUtils.injection.injectComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.'); | |
} | |
} | |
}; | |
function isEndish(topLevelType) { | |
return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel'; | |
} | |
function isMoveish(topLevelType) { | |
return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove'; | |
} | |
function isStartish(topLevelType) { | |
return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart'; | |
} | |
var validateEventDispatches; | |
if (__DEV__) { | |
validateEventDispatches = function (event) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
var listenersIsArr = Array.isArray(dispatchListeners); | |
var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0; | |
var instancesIsArr = Array.isArray(dispatchInstances); | |
var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0; | |
warning$1(instancesIsArr === listenersIsArr && instancesLen === listenersLen, 'EventPluginUtils: Invalid `event`.'); | |
}; | |
} | |
/** | |
* Dispatch the event to the listener. | |
* @param {SyntheticEvent} event SyntheticEvent to handle | |
* @param {boolean} simulated If the event is simulated (changes exn behavior) | |
* @param {function} listener Application-level callback | |
* @param {*} inst Internal component instance | |
*/ | |
function executeDispatch(event, simulated, listener, inst) { | |
var type = event.type || 'unknown-event'; | |
event.currentTarget = EventPluginUtils$1.getNodeFromInstance(inst); | |
ReactErrorUtils$1.invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); | |
event.currentTarget = null; | |
} | |
/** | |
* Standard/simple iteration through an event's collected dispatches. | |
*/ | |
function executeDispatchesInOrder(event, simulated) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
if (Array.isArray(dispatchListeners)) { | |
for (var i = 0; i < dispatchListeners.length; i++) { | |
if (event.isPropagationStopped()) { | |
break; | |
} | |
// Listeners and Instances are two parallel arrays that are always in sync. | |
executeDispatch(event, simulated, dispatchListeners[i], dispatchInstances[i]); | |
} | |
} else if (dispatchListeners) { | |
executeDispatch(event, simulated, dispatchListeners, dispatchInstances); | |
} | |
event._dispatchListeners = null; | |
event._dispatchInstances = null; | |
} | |
/** | |
* Standard/simple iteration through an event's collected dispatches, but stops | |
* at the first dispatch execution returning true, and returns that id. | |
* | |
* @return {?string} id of the first dispatch execution who's listener returns | |
* true, or null if no listener returned true. | |
*/ | |
function executeDispatchesInOrderStopAtTrueImpl(event) { | |
var dispatchListeners = event._dispatchListeners; | |
var dispatchInstances = event._dispatchInstances; | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
if (Array.isArray(dispatchListeners)) { | |
for (var i = 0; i < dispatchListeners.length; i++) { | |
if (event.isPropagationStopped()) { | |
break; | |
} | |
// Listeners and Instances are two parallel arrays that are always in sync. | |
if (dispatchListeners[i](event, dispatchInstances[i])) { | |
return dispatchInstances[i]; | |
} | |
} | |
} else if (dispatchListeners) { | |
if (dispatchListeners(event, dispatchInstances)) { | |
return dispatchInstances; | |
} | |
} | |
return null; | |
} | |
/** | |
* @see executeDispatchesInOrderStopAtTrueImpl | |
*/ | |
function executeDispatchesInOrderStopAtTrue(event) { | |
var ret = executeDispatchesInOrderStopAtTrueImpl(event); | |
event._dispatchInstances = null; | |
event._dispatchListeners = null; | |
return ret; | |
} | |
/** | |
* Execution of a "direct" dispatch - there must be at most one dispatch | |
* accumulated on the event or it is considered an error. It doesn't really make | |
* sense for an event with multiple dispatches (bubbled) to keep track of the | |
* return values at each dispatch execution, but it does tend to make sense when | |
* dealing with "direct" dispatches. | |
* | |
* @return {*} The return value of executing the single dispatch. | |
*/ | |
function executeDirectDispatch(event) { | |
if (__DEV__) { | |
validateEventDispatches(event); | |
} | |
var dispatchListener = event._dispatchListeners; | |
var dispatchInstance = event._dispatchInstances; | |
invariant$3(!Array.isArray(dispatchListener), 'executeDirectDispatch(...): Invalid `event`.'); | |
event.currentTarget = dispatchListener ? EventPluginUtils$1.getNodeFromInstance(dispatchInstance) : null; | |
var res = dispatchListener ? dispatchListener(event) : null; | |
event.currentTarget = null; | |
event._dispatchListeners = null; | |
event._dispatchInstances = null; | |
return res; | |
} | |
/** | |
* @param {SyntheticEvent} event | |
* @return {boolean} True iff number of dispatches accumulated is greater than 0. | |
*/ | |
function hasDispatches(event) { | |
return !!event._dispatchListeners; | |
} | |
/** | |
* General utilities that are useful in creating custom Event Plugins. | |
*/ | |
var EventPluginUtils$1 = { | |
isEndish: isEndish, | |
isMoveish: isMoveish, | |
isStartish: isStartish, | |
executeDirectDispatch: executeDirectDispatch, | |
executeDispatchesInOrder: executeDispatchesInOrder, | |
executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue, | |
hasDispatches: hasDispatches, | |
getFiberCurrentPropsFromNode: function (node) { | |
return ComponentTree.getFiberCurrentPropsFromNode(node); | |
}, | |
getInstanceFromNode: function (node) { | |
return ComponentTree.getInstanceFromNode(node); | |
}, | |
getNodeFromInstance: function (node) { | |
return ComponentTree.getNodeFromInstance(node); | |
}, | |
injection: injection | |
}; | |
var EventPluginUtils_1 = EventPluginUtils$1; | |
var invariant$4 = invariant; | |
/** | |
* Accumulates items that must not be null or undefined into the first one. This | |
* is used to conserve memory by avoiding array allocations, and thus sacrifices | |
* API cleanness. Since `current` can be null before being passed in and not | |
* null after this function, make sure to assign it back to `current`: | |
* | |
* `a = accumulateInto(a, b);` | |
* | |
* This API should be sparingly used. Try `accumulate` for something cleaner. | |
* | |
* @return {*|array<*>} An accumulation of items. | |
*/ | |
function accumulateInto$1(current, next) { | |
invariant$4(next != null, 'accumulateInto(...): Accumulated items must not be null or undefined.'); | |
if (current == null) { | |
return next; | |
} | |
// Both are not empty. Warning: Never call x.concat(y) when you are not | |
// certain that x is an Array (x could be a string with concat method). | |
if (Array.isArray(current)) { | |
if (Array.isArray(next)) { | |
current.push.apply(current, next); | |
return current; | |
} | |
current.push(next); | |
return current; | |
} | |
if (Array.isArray(next)) { | |
// A bit too dangerous to mutate `next`. | |
return [current].concat(next); | |
} | |
return [current, next]; | |
} | |
var accumulateInto_1 = accumulateInto$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule forEachAccumulated | |
* | |
*/ | |
/** | |
* @param {array} arr an "accumulation" of items which is either an Array or | |
* a single item. Useful when paired with the `accumulate` module. This is a | |
* simple utility that allows us to reason about a collection of items, but | |
* handling the case when there is exactly one item (and we do not need to | |
* allocate an array). | |
* @param {function} cb Callback invoked with each element or a collection. | |
* @param {?} [scope] Scope used as `this` in a callback. | |
*/ | |
function forEachAccumulated$1(arr, cb, scope) { | |
if (Array.isArray(arr)) { | |
arr.forEach(cb, scope); | |
} else if (arr) { | |
cb.call(scope, arr); | |
} | |
} | |
var forEachAccumulated_1 = forEachAccumulated$1; | |
var EventPluginRegistry$2 = EventPluginRegistry_1; | |
var EventPluginUtils = EventPluginUtils_1; | |
var ReactErrorUtils = ReactErrorUtils_1; | |
var accumulateInto = accumulateInto_1; | |
var forEachAccumulated = forEachAccumulated_1; | |
var invariant$2 = invariant; | |
/** | |
* Internal queue of events that have accumulated their dispatches and are | |
* waiting to have their dispatches executed. | |
*/ | |
var eventQueue = null; | |
/** | |
* Dispatches an event and releases it back into the pool, unless persistent. | |
* | |
* @param {?object} event Synthetic event to be dispatched. | |
* @param {boolean} simulated If the event is simulated (changes exn behavior) | |
* @private | |
*/ | |
var executeDispatchesAndRelease = function (event, simulated) { | |
if (event) { | |
EventPluginUtils.executeDispatchesInOrder(event, simulated); | |
if (!event.isPersistent()) { | |
event.constructor.release(event); | |
} | |
} | |
}; | |
var executeDispatchesAndReleaseSimulated = function (e) { | |
return executeDispatchesAndRelease(e, true); | |
}; | |
var executeDispatchesAndReleaseTopLevel = function (e) { | |
return executeDispatchesAndRelease(e, false); | |
}; | |
function isInteractive(tag) { | |
return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea'; | |
} | |
function shouldPreventMouseEvent(name, type, props) { | |
switch (name) { | |
case 'onClick': | |
case 'onClickCapture': | |
case 'onDoubleClick': | |
case 'onDoubleClickCapture': | |
case 'onMouseDown': | |
case 'onMouseDownCapture': | |
case 'onMouseMove': | |
case 'onMouseMoveCapture': | |
case 'onMouseUp': | |
case 'onMouseUpCapture': | |
return !!(props.disabled && isInteractive(type)); | |
default: | |
return false; | |
} | |
} | |
/** | |
* This is a unified interface for event plugins to be installed and configured. | |
* | |
* Event plugins can implement the following properties: | |
* | |
* `extractEvents` {function(string, DOMEventTarget, string, object): *} | |
* Required. When a top-level event is fired, this method is expected to | |
* extract synthetic events that will in turn be queued and dispatched. | |
* | |
* `eventTypes` {object} | |
* Optional, plugins that fire events must publish a mapping of registration | |
* names that are used to register listeners. Values of this mapping must | |
* be objects that contain `registrationName` or `phasedRegistrationNames`. | |
* | |
* `executeDispatch` {function(object, function, string)} | |
* Optional, allows plugins to override how an event gets dispatched. By | |
* default, the listener is simply invoked. | |
* | |
* Each plugin that is injected into `EventsPluginHub` is immediately operable. | |
* | |
* @public | |
*/ | |
var EventPluginHub$1 = { | |
/** | |
* Methods for injecting dependencies. | |
*/ | |
injection: { | |
/** | |
* @param {array} InjectedEventPluginOrder | |
* @public | |
*/ | |
injectEventPluginOrder: EventPluginRegistry$2.injectEventPluginOrder, | |
/** | |
* @param {object} injectedNamesToPlugins Map from names to plugin modules. | |
*/ | |
injectEventPluginsByName: EventPluginRegistry$2.injectEventPluginsByName | |
}, | |
/** | |
* @param {object} inst The instance, which is the source of events. | |
* @param {string} registrationName Name of listener (e.g. `onClick`). | |
* @return {?function} The stored callback. | |
*/ | |
getListener: function (inst, registrationName) { | |
var listener; | |
// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not | |
// live here; needs to be moved to a better place soon | |
if (typeof inst.tag === 'number') { | |
var props = EventPluginUtils.getFiberCurrentPropsFromNode(inst.stateNode); | |
if (!props) { | |
// Work in progress. | |
return null; | |
} | |
listener = props[registrationName]; | |
if (shouldPreventMouseEvent(registrationName, inst.type, props)) { | |
return null; | |
} | |
} else { | |
if (typeof inst._currentElement === 'string') { | |
// Text node, let it bubble through. | |
return null; | |
} | |
if (!inst._rootNodeID) { | |
// If the instance is already unmounted, we have no listeners. | |
return null; | |
} | |
var _props = inst._currentElement.props; | |
listener = _props[registrationName]; | |
if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, _props)) { | |
return null; | |
} | |
} | |
invariant$2(!listener || typeof listener === 'function', 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener); | |
return listener; | |
}, | |
/** | |
* Allows registered plugins an opportunity to extract events from top-level | |
* native browser events. | |
* | |
* @return {*} An accumulation of synthetic events. | |
* @internal | |
*/ | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var events; | |
var plugins = EventPluginRegistry$2.plugins; | |
for (var i = 0; i < plugins.length; i++) { | |
// Not every plugin in the ordering may be loaded at runtime. | |
var possiblePlugin = plugins[i]; | |
if (possiblePlugin) { | |
var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
if (extractedEvents) { | |
events = accumulateInto(events, extractedEvents); | |
} | |
} | |
} | |
return events; | |
}, | |
/** | |
* Enqueues a synthetic event that should be dispatched when | |
* `processEventQueue` is invoked. | |
* | |
* @param {*} events An accumulation of synthetic events. | |
* @internal | |
*/ | |
enqueueEvents: function (events) { | |
if (events) { | |
eventQueue = accumulateInto(eventQueue, events); | |
} | |
}, | |
/** | |
* Dispatches all synthetic events on the event queue. | |
* | |
* @internal | |
*/ | |
processEventQueue: function (simulated) { | |
// Set `eventQueue` to null before processing it so that we can tell if more | |
// events get enqueued while processing. | |
var processingEventQueue = eventQueue; | |
eventQueue = null; | |
if (simulated) { | |
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated); | |
} else { | |
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); | |
} | |
invariant$2(!eventQueue, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.'); | |
// This would be a good time to rethrow if any of the event handlers threw. | |
ReactErrorUtils.rethrowCaughtError(); | |
} | |
}; | |
var EventPluginHub_1 = EventPluginHub$1; | |
var EventPluginHub = EventPluginHub_1; | |
function runEventQueueInBatch(events) { | |
EventPluginHub.enqueueEvents(events); | |
EventPluginHub.processEventQueue(false); | |
} | |
var ReactEventEmitterMixin$1 = { | |
/** | |
* Streams a fired top-level event to `EventPluginHub` where plugins have the | |
* opportunity to create `ReactEvent`s to be dispatched. | |
*/ | |
handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var events = EventPluginHub.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget); | |
runEventQueueInBatch(events); | |
} | |
}; | |
var ReactEventEmitterMixin_1 = ReactEventEmitterMixin$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ViewportMetrics | |
*/ | |
var ViewportMetrics$1 = { | |
currentScrollLeft: 0, | |
currentScrollTop: 0, | |
refreshScrollValues: function (scrollPosition) { | |
ViewportMetrics$1.currentScrollLeft = scrollPosition.x; | |
ViewportMetrics$1.currentScrollTop = scrollPosition.y; | |
} | |
}; | |
var ViewportMetrics_1 = ViewportMetrics$1; | |
var ExecutionEnvironment2 = ExecutionEnvironment; | |
/** | |
* Generate a mapping of standard vendor prefixes using the defined style property and event name. | |
* | |
* @param {string} styleProp | |
* @param {string} eventName | |
* @returns {object} | |
*/ | |
function makePrefixMap(styleProp, eventName) { | |
var prefixes = {}; | |
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); | |
prefixes['Webkit' + styleProp] = 'webkit' + eventName; | |
prefixes['Moz' + styleProp] = 'moz' + eventName; | |
prefixes['ms' + styleProp] = 'MS' + eventName; | |
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase(); | |
return prefixes; | |
} | |
/** | |
* A list of event names to a configurable list of vendor prefixes. | |
*/ | |
var vendorPrefixes = { | |
animationend: makePrefixMap('Animation', 'AnimationEnd'), | |
animationiteration: makePrefixMap('Animation', 'AnimationIteration'), | |
animationstart: makePrefixMap('Animation', 'AnimationStart'), | |
transitionend: makePrefixMap('Transition', 'TransitionEnd') | |
}; | |
/** | |
* Event names that have already been detected and prefixed (if applicable). | |
*/ | |
var prefixedEventNames = {}; | |
/** | |
* Element to check for prefixes on. | |
*/ | |
var style = {}; | |
/** | |
* Bootstrap if a DOM exists. | |
*/ | |
if (ExecutionEnvironment2.canUseDOM) { | |
style = document.createElement('div').style; | |
// On some platforms, in particular some releases of Android 4.x, | |
// the un-prefixed "animation" and "transition" properties are defined on the | |
// style object but the events that fire will still be prefixed, so we need | |
// to check if the un-prefixed events are usable, and if not remove them from the map. | |
if (!('AnimationEvent' in window)) { | |
delete vendorPrefixes.animationend.animation; | |
delete vendorPrefixes.animationiteration.animation; | |
delete vendorPrefixes.animationstart.animation; | |
} | |
// Same as above | |
if (!('TransitionEvent' in window)) { | |
delete vendorPrefixes.transitionend.transition; | |
} | |
} | |
/** | |
* Attempts to determine the correct vendor prefixed event name. | |
* | |
* @param {string} eventName | |
* @returns {string} | |
*/ | |
function getVendorPrefixedEventName$1(eventName) { | |
if (prefixedEventNames[eventName]) { | |
return prefixedEventNames[eventName]; | |
} else if (!vendorPrefixes[eventName]) { | |
return eventName; | |
} | |
var prefixMap = vendorPrefixes[eventName]; | |
for (var styleProp in prefixMap) { | |
if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) { | |
return prefixedEventNames[eventName] = prefixMap[styleProp]; | |
} | |
} | |
return ''; | |
} | |
var getVendorPrefixedEventName_1 = getVendorPrefixedEventName$1; | |
var ExecutionEnvironment$1 = ExecutionEnvironment; | |
var useHasFeature; | |
if (ExecutionEnvironment$1.canUseDOM) { | |
useHasFeature = document.implementation && document.implementation.hasFeature && | |
// always returns true in newer browsers as per the standard. | |
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature | |
document.implementation.hasFeature('', '') !== true; | |
} | |
/** | |
* Checks if an event is supported in the current execution environment. | |
* | |
* NOTE: This will not work correctly for non-generic events such as `change`, | |
* `reset`, `load`, `error`, and `select`. | |
* | |
* Borrows from Modernizr. | |
* | |
* @param {string} eventNameSuffix Event name, e.g. "click". | |
* @param {?boolean} capture Check if the capture phase is supported. | |
* @return {boolean} True if the event is supported. | |
* @internal | |
* @license Modernizr 3.0.0pre (Custom Build) | MIT | |
*/ | |
function isEventSupported$1(eventNameSuffix, capture) { | |
if (!ExecutionEnvironment$1.canUseDOM || capture && !('addEventListener' in document)) { | |
return false; | |
} | |
var eventName = 'on' + eventNameSuffix; | |
var isSupported = eventName in document; | |
if (!isSupported) { | |
var element = document.createElement('div'); | |
element.setAttribute(eventName, 'return;'); | |
isSupported = typeof element[eventName] === 'function'; | |
} | |
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { | |
// This is the only way to test support for the `wheel` event in IE9+. | |
isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); | |
} | |
return isSupported; | |
} | |
var isEventSupported_1 = isEventSupported$1; | |
var EventPluginRegistry = EventPluginRegistry_1; | |
var ReactEventEmitterMixin = ReactEventEmitterMixin_1; | |
var ViewportMetrics = ViewportMetrics_1; | |
var getVendorPrefixedEventName = getVendorPrefixedEventName_1; | |
var isEventSupported = isEventSupported_1; | |
/** | |
* Summary of `ReactBrowserEventEmitter` event handling: | |
* | |
* - Top-level delegation is used to trap most native browser events. This | |
* may only occur in the main thread and is the responsibility of | |
* ReactEventListener, which is injected and can therefore support pluggable | |
* event sources. This is the only work that occurs in the main thread. | |
* | |
* - We normalize and de-duplicate events to account for browser quirks. This | |
* may be done in the worker thread. | |
* | |
* - Forward these native events (with the associated top-level type used to | |
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want | |
* to extract any synthetic events. | |
* | |
* - The `EventPluginHub` will then process each event by annotating them with | |
* "dispatches", a sequence of listeners and IDs that care about that event. | |
* | |
* - The `EventPluginHub` then dispatches the events. | |
* | |
* Overview of React and the event system: | |
* | |
* +------------+ . | |
* | DOM | . | |
* +------------+ . | |
* | . | |
* v . | |
* +------------+ . | |
* | ReactEvent | . | |
* | Listener | . | |
* +------------+ . +-----------+ | |
* | . +--------+|SimpleEvent| | |
* | . | |Plugin | | |
* +-----|------+ . v +-----------+ | |
* | | | . +--------------+ +------------+ | |
* | +-----------.--->|EventPluginHub| | Event | | |
* | | . | | +-----------+ | Propagators| | |
* | ReactEvent | . | | |TapEvent | |------------| | |
* | Emitter | . | |<---+|Plugin | |other plugin| | |
* | | . | | +-----------+ | utilities | | |
* | +-----------.--->| | +------------+ | |
* | | | . +--------------+ | |
* +-----|------+ . ^ +-----------+ | |
* | . | |Enter/Leave| | |
* + . +-------+|Plugin | | |
* +-------------+ . +-----------+ | |
* | application | . | |
* |-------------| . | |
* | | . | |
* | | . | |
* +-------------+ . | |
* . | |
* React Core . General Purpose Event Plugin System | |
*/ | |
var hasEventPageXY; | |
var alreadyListeningTo = {}; | |
var isMonitoringScrollValue = false; | |
var reactTopListenersCounter = 0; | |
// For events like 'submit' which don't consistently bubble (which we trap at a | |
// lower node than `document`), binding at `document` would cause duplicate | |
// events so we don't include them here | |
var topEventMapping = { | |
topAbort: 'abort', | |
topAnimationEnd: getVendorPrefixedEventName('animationend') || 'animationend', | |
topAnimationIteration: getVendorPrefixedEventName('animationiteration') || 'animationiteration', | |
topAnimationStart: getVendorPrefixedEventName('animationstart') || 'animationstart', | |
topBlur: 'blur', | |
topCancel: 'cancel', | |
topCanPlay: 'canplay', | |
topCanPlayThrough: 'canplaythrough', | |
topChange: 'change', | |
topClick: 'click', | |
topClose: 'close', | |
topCompositionEnd: 'compositionend', | |
topCompositionStart: 'compositionstart', | |
topCompositionUpdate: 'compositionupdate', | |
topContextMenu: 'contextmenu', | |
topCopy: 'copy', | |
topCut: 'cut', | |
topDoubleClick: 'dblclick', | |
topDrag: 'drag', | |
topDragEnd: 'dragend', | |
topDragEnter: 'dragenter', | |
topDragExit: 'dragexit', | |
topDragLeave: 'dragleave', | |
topDragOver: 'dragover', | |
topDragStart: 'dragstart', | |
topDrop: 'drop', | |
topDurationChange: 'durationchange', | |
topEmptied: 'emptied', | |
topEncrypted: 'encrypted', | |
topEnded: 'ended', | |
topError: 'error', | |
topFocus: 'focus', | |
topInput: 'input', | |
topKeyDown: 'keydown', | |
topKeyPress: 'keypress', | |
topKeyUp: 'keyup', | |
topLoadedData: 'loadeddata', | |
topLoadedMetadata: 'loadedmetadata', | |
topLoadStart: 'loadstart', | |
topMouseDown: 'mousedown', | |
topMouseMove: 'mousemove', | |
topMouseOut: 'mouseout', | |
topMouseOver: 'mouseover', | |
topMouseUp: 'mouseup', | |
topPaste: 'paste', | |
topPause: 'pause', | |
topPlay: 'play', | |
topPlaying: 'playing', | |
topProgress: 'progress', | |
topRateChange: 'ratechange', | |
topScroll: 'scroll', | |
topSeeked: 'seeked', | |
topSeeking: 'seeking', | |
topSelectionChange: 'selectionchange', | |
topStalled: 'stalled', | |
topSuspend: 'suspend', | |
topTextInput: 'textInput', | |
topTimeUpdate: 'timeupdate', | |
topToggle: 'toggle', | |
topTouchCancel: 'touchcancel', | |
topTouchEnd: 'touchend', | |
topTouchMove: 'touchmove', | |
topTouchStart: 'touchstart', | |
topTransitionEnd: getVendorPrefixedEventName('transitionend') || 'transitionend', | |
topVolumeChange: 'volumechange', | |
topWaiting: 'waiting', | |
topWheel: 'wheel' | |
}; | |
/** | |
* To ensure no conflicts with other potential React instances on the page | |
*/ | |
var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); | |
function getListeningForDocument(mountAt) { | |
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` | |
// directly. | |
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { | |
mountAt[topListenersIDKey] = reactTopListenersCounter++; | |
alreadyListeningTo[mountAt[topListenersIDKey]] = {}; | |
} | |
return alreadyListeningTo[mountAt[topListenersIDKey]]; | |
} | |
var ReactBrowserEventEmitter$1 = Object.assign({}, ReactEventEmitterMixin, { | |
/** | |
* Injectable event backend | |
*/ | |
ReactEventListener: null, | |
injection: { | |
/** | |
* @param {object} ReactEventListener | |
*/ | |
injectReactEventListener: function (ReactEventListener) { | |
ReactEventListener.setHandleTopLevel(ReactBrowserEventEmitter$1.handleTopLevel); | |
ReactBrowserEventEmitter$1.ReactEventListener = ReactEventListener; | |
} | |
}, | |
/** | |
* Sets whether or not any created callbacks should be enabled. | |
* | |
* @param {boolean} enabled True if callbacks should be enabled. | |
*/ | |
setEnabled: function (enabled) { | |
if (ReactBrowserEventEmitter$1.ReactEventListener) { | |
ReactBrowserEventEmitter$1.ReactEventListener.setEnabled(enabled); | |
} | |
}, | |
/** | |
* @return {boolean} True if callbacks are enabled. | |
*/ | |
isEnabled: function () { | |
return !!(ReactBrowserEventEmitter$1.ReactEventListener && ReactBrowserEventEmitter$1.ReactEventListener.isEnabled()); | |
}, | |
/** | |
* We listen for bubbled touch events on the document object. | |
* | |
* Firefox v8.01 (and possibly others) exhibited strange behavior when | |
* mounting `onmousemove` events at some node that was not the document | |
* element. The symptoms were that if your mouse is not moving over something | |
* contained within that mount point (for example on the background) the | |
* top-level listeners for `onmousemove` won't be called. However, if you | |
* register the `mousemove` on the document object, then it will of course | |
* catch all `mousemove`s. This along with iOS quirks, justifies restricting | |
* top-level listeners to the document object only, at least for these | |
* movement types of events and possibly all events. | |
* | |
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
* | |
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but | |
* they bubble to document. | |
* | |
* @param {string} registrationName Name of listener (e.g. `onClick`). | |
* @param {object} contentDocumentHandle Document which owns the container | |
*/ | |
listenTo: function (registrationName, contentDocumentHandle) { | |
var mountAt = contentDocumentHandle; | |
var isListening = getListeningForDocument(mountAt); | |
var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName]; | |
for (var i = 0; i < dependencies.length; i++) { | |
var dependency = dependencies[i]; | |
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { | |
if (dependency === 'topWheel') { | |
if (isEventSupported('wheel')) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'wheel', mountAt); | |
} else if (isEventSupported('mousewheel')) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'mousewheel', mountAt); | |
} else { | |
// Firefox needs to capture a different mouse scroll event. | |
// @see http://www.quirksmode.org/dom/events/tests/scroll.html | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt); | |
} | |
} else if (dependency === 'topScroll') { | |
if (isEventSupported('scroll', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topScroll', 'scroll', mountAt); | |
} else { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topScroll', 'scroll', ReactBrowserEventEmitter$1.ReactEventListener.WINDOW_HANDLE); | |
} | |
} else if (dependency === 'topFocus' || dependency === 'topBlur') { | |
if (isEventSupported('focus', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topFocus', 'focus', mountAt); | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topBlur', 'blur', mountAt); | |
} else if (isEventSupported('focusin')) { | |
// IE has `focusin` and `focusout` events which bubble. | |
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topFocus', 'focusin', mountAt); | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent('topBlur', 'focusout', mountAt); | |
} | |
// to make sure blur and focus event listeners are only attached once | |
isListening.topBlur = true; | |
isListening.topFocus = true; | |
} else if (dependency === 'topCancel') { | |
if (isEventSupported('cancel', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topCancel', 'cancel', mountAt); | |
} | |
isListening.topCancel = true; | |
} else if (dependency === 'topClose') { | |
if (isEventSupported('close', true)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent('topClose', 'close', mountAt); | |
} | |
isListening.topClose = true; | |
} else if (topEventMapping.hasOwnProperty(dependency)) { | |
ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt); | |
} | |
isListening[dependency] = true; | |
} | |
} | |
}, | |
isListeningToAllDependencies: function (registrationName, mountAt) { | |
var isListening = getListeningForDocument(mountAt); | |
var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName]; | |
for (var i = 0; i < dependencies.length; i++) { | |
var dependency = dependencies[i]; | |
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { | |
return false; | |
} | |
} | |
return true; | |
}, | |
trapBubbledEvent: function (topLevelType, handlerBaseName, handle) { | |
return ReactBrowserEventEmitter$1.ReactEventListener.trapBubbledEvent(topLevelType, handlerBaseName, handle); | |
}, | |
trapCapturedEvent: function (topLevelType, handlerBaseName, handle) { | |
return ReactBrowserEventEmitter$1.ReactEventListener.trapCapturedEvent(topLevelType, handlerBaseName, handle); | |
}, | |
/** | |
* Protect against document.createEvent() returning null | |
* Some popup blocker extensions appear to do this: | |
* https://github.com/facebook/react/issues/6887 | |
*/ | |
supportsEventPageXY: function () { | |
if (!document.createEvent) { | |
return false; | |
} | |
var ev = document.createEvent('MouseEvent'); | |
return ev != null && 'pageX' in ev; | |
}, | |
/** | |
* Listens to window scroll and resize events. We cache scroll values so that | |
* application code can access them without triggering reflows. | |
* | |
* ViewportMetrics is only used by SyntheticMouse/TouchEvent and only when | |
* pageX/pageY isn't supported (legacy browsers). | |
* | |
* NOTE: Scroll events do not bubble. | |
* | |
* @see http://www.quirksmode.org/dom/events/scroll.html | |
*/ | |
ensureScrollValueMonitoring: function () { | |
if (hasEventPageXY === undefined) { | |
hasEventPageXY = ReactBrowserEventEmitter$1.supportsEventPageXY(); | |
} | |
if (!hasEventPageXY && !isMonitoringScrollValue) { | |
var refresh = ViewportMetrics.refreshScrollValues; | |
ReactBrowserEventEmitter$1.ReactEventListener.monitorScrollValue(refresh); | |
isMonitoringScrollValue = true; | |
} | |
} | |
}); | |
var ReactBrowserEventEmitter_1 = ReactBrowserEventEmitter$1; | |
var EventPluginUtils$2 = EventPluginUtils_1; | |
var invariant$5 = invariant; | |
// Use to restore controlled state after a change event has fired. | |
var fiberHostComponent = null; | |
var ReactControlledComponentInjection = { | |
injectFiberControlledHostComponent: function (hostComponentImpl) { | |
// The fiber implementation doesn't use dynamic dispatch so we need to | |
// inject the implementation. | |
fiberHostComponent = hostComponentImpl; | |
} | |
}; | |
var restoreTarget = null; | |
var restoreQueue = null; | |
function restoreStateOfTarget(target) { | |
// We perform this translation at the end of the event loop so that we | |
// always receive the correct fiber here | |
var internalInstance = EventPluginUtils$2.getInstanceFromNode(target); | |
if (!internalInstance) { | |
// Unmounted | |
return; | |
} | |
if (typeof internalInstance.tag === 'number') { | |
invariant$5(fiberHostComponent && typeof fiberHostComponent.restoreControlledState === 'function', 'Fiber needs to be injected to handle a fiber target for controlled ' + 'events.'); | |
var props = EventPluginUtils$2.getFiberCurrentPropsFromNode(internalInstance.stateNode); | |
fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props); | |
return; | |
} | |
invariant$5(typeof internalInstance.restoreControlledState === 'function', 'The internal instance must be a React host component.'); | |
// If it is not a Fiber, we can just use dynamic dispatch. | |
internalInstance.restoreControlledState(); | |
} | |
var ReactControlledComponent$1 = { | |
injection: ReactControlledComponentInjection, | |
enqueueStateRestore: function (target) { | |
if (restoreTarget) { | |
if (restoreQueue) { | |
restoreQueue.push(target); | |
} else { | |
restoreQueue = [target]; | |
} | |
} else { | |
restoreTarget = target; | |
} | |
}, | |
restoreStateIfNeeded: function () { | |
if (!restoreTarget) { | |
return; | |
} | |
var target = restoreTarget; | |
var queuedTargets = restoreQueue; | |
restoreTarget = null; | |
restoreQueue = null; | |
restoreStateOfTarget(target); | |
if (queuedTargets) { | |
for (var i = 0; i < queuedTargets.length; i++) { | |
restoreStateOfTarget(queuedTargets[i]); | |
} | |
} | |
} | |
}; | |
var ReactControlledComponent_1 = ReactControlledComponent$1; | |
var invariant$7 = invariant; | |
function checkMask(value, bitmask) { | |
return (value & bitmask) === bitmask; | |
} | |
var DOMPropertyInjection = { | |
/** | |
* Mapping from normalized, camelcased property names to a configuration that | |
* specifies how the associated DOM property should be accessed or rendered. | |
*/ | |
MUST_USE_PROPERTY: 0x1, | |
HAS_BOOLEAN_VALUE: 0x4, | |
HAS_NUMERIC_VALUE: 0x8, | |
HAS_POSITIVE_NUMERIC_VALUE: 0x10 | 0x8, | |
HAS_OVERLOADED_BOOLEAN_VALUE: 0x20, | |
/** | |
* Inject some specialized knowledge about the DOM. This takes a config object | |
* with the following properties: | |
* | |
* isCustomAttribute: function that given an attribute name will return true | |
* if it can be inserted into the DOM verbatim. Useful for data-* or aria-* | |
* attributes where it's impossible to enumerate all of the possible | |
* attribute names, | |
* | |
* Properties: object mapping DOM property name to one of the | |
* DOMPropertyInjection constants or null. If your attribute isn't in here, | |
* it won't get written to the DOM. | |
* | |
* DOMAttributeNames: object mapping React attribute name to the DOM | |
* attribute name. Attribute names not specified use the **lowercase** | |
* normalized name. | |
* | |
* DOMAttributeNamespaces: object mapping React attribute name to the DOM | |
* attribute namespace URL. (Attribute names not specified use no namespace.) | |
* | |
* DOMPropertyNames: similar to DOMAttributeNames but for DOM properties. | |
* Property names not specified use the normalized name. | |
* | |
* DOMMutationMethods: Properties that require special mutation methods. If | |
* `value` is undefined, the mutation method should unset the property. | |
* | |
* @param {object} domPropertyConfig the config as described above. | |
*/ | |
injectDOMPropertyConfig: function (domPropertyConfig) { | |
var Injection = DOMPropertyInjection; | |
var Properties = domPropertyConfig.Properties || {}; | |
var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {}; | |
var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {}; | |
var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {}; | |
var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {}; | |
if (domPropertyConfig.isCustomAttribute) { | |
DOMProperty$1._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute); | |
} | |
for (var propName in Properties) { | |
invariant$7(!DOMProperty$1.properties.hasOwnProperty(propName), 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName); | |
var lowerCased = propName.toLowerCase(); | |
var propConfig = Properties[propName]; | |
var propertyInfo = { | |
attributeName: lowerCased, | |
attributeNamespace: null, | |
propertyName: propName, | |
mutationMethod: null, | |
mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY), | |
hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE), | |
hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE), | |
hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE), | |
hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE) | |
}; | |
invariant$7(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName); | |
if (__DEV__) { | |
DOMProperty$1.getPossibleStandardName[lowerCased] = propName; | |
} | |
if (DOMAttributeNames.hasOwnProperty(propName)) { | |
var attributeName = DOMAttributeNames[propName]; | |
propertyInfo.attributeName = attributeName; | |
if (__DEV__) { | |
DOMProperty$1.getPossibleStandardName[attributeName] = propName; | |
} | |
} | |
if (DOMAttributeNamespaces.hasOwnProperty(propName)) { | |
propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName]; | |
} | |
if (DOMPropertyNames.hasOwnProperty(propName)) { | |
propertyInfo.propertyName = DOMPropertyNames[propName]; | |
} | |
if (DOMMutationMethods.hasOwnProperty(propName)) { | |
propertyInfo.mutationMethod = DOMMutationMethods[propName]; | |
} | |
DOMProperty$1.properties[propName] = propertyInfo; | |
} | |
} | |
}; | |
/* eslint-disable max-len */ | |
var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD'; | |
/* eslint-enable max-len */ | |
/** | |
* DOMProperty exports lookup objects that can be used like functions: | |
* | |
* > DOMProperty.isValid['id'] | |
* true | |
* > DOMProperty.isValid['foobar'] | |
* undefined | |
* | |
* Although this may be confusing, it performs better in general. | |
* | |
* @see http://jsperf.com/key-exists | |
* @see http://jsperf.com/key-missing | |
*/ | |
var DOMProperty$1 = { | |
ID_ATTRIBUTE_NAME: 'data-reactid', | |
ROOT_ATTRIBUTE_NAME: 'data-reactroot', | |
ATTRIBUTE_NAME_START_CHAR: ATTRIBUTE_NAME_START_CHAR, | |
ATTRIBUTE_NAME_CHAR: ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040', | |
/** | |
* Map from property "standard name" to an object with info about how to set | |
* the property in the DOM. Each object contains: | |
* | |
* attributeName: | |
* Used when rendering markup or with `*Attribute()`. | |
* attributeNamespace | |
* propertyName: | |
* Used on DOM node instances. (This includes properties that mutate due to | |
* external factors.) | |
* mutationMethod: | |
* If non-null, used instead of the property or `setAttribute()` after | |
* initial render. | |
* mustUseProperty: | |
* Whether the property must be accessed and mutated as an object property. | |
* hasBooleanValue: | |
* Whether the property should be removed when set to a falsey value. | |
* hasNumericValue: | |
* Whether the property must be numeric or parse as a numeric and should be | |
* removed when set to a falsey value. | |
* hasPositiveNumericValue: | |
* Whether the property must be positive numeric or parse as a positive | |
* numeric and should be removed when set to a falsey value. | |
* hasOverloadedBooleanValue: | |
* Whether the property can be used as a flag as well as with a value. | |
* Removed when strictly equal to false; present without a value when | |
* strictly equal to true; present with a value otherwise. | |
*/ | |
properties: {}, | |
/** | |
* Mapping from lowercase property names to the properly cased version, used | |
* to warn in the case of missing properties. Available only in __DEV__. | |
* | |
* autofocus is predefined, because adding it to the property whitelist | |
* causes unintended side effects. | |
* | |
* @type {Object} | |
*/ | |
getPossibleStandardName: __DEV__ ? { autofocus: 'autoFocus' } : null, | |
/** | |
* All of the isCustomAttribute() functions that have been injected. | |
*/ | |
_isCustomAttributeFunctions: [], | |
/** | |
* Checks whether a property name is a custom attribute. | |
* @method | |
*/ | |
isCustomAttribute: function (attributeName) { | |
for (var i = 0; i < DOMProperty$1._isCustomAttributeFunctions.length; i++) { | |
var isCustomAttributeFn = DOMProperty$1._isCustomAttributeFunctions[i]; | |
if (isCustomAttributeFn(attributeName)) { | |
return true; | |
} | |
} | |
return false; | |
}, | |
injection: DOMPropertyInjection | |
}; | |
var DOMProperty_1 = DOMProperty$1; | |
/** | |
* Copyright 2015-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOMComponentFlags | |
*/ | |
var ReactDOMComponentFlags$1 = { | |
hasCachedChildNodes: 1 << 0 | |
}; | |
var ReactDOMComponentFlags_1 = ReactDOMComponentFlags$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactTypeOfWork | |
* | |
*/ | |
var ReactTypeOfWork = { | |
IndeterminateComponent: 0, // Before we know whether it is functional or class | |
FunctionalComponent: 1, | |
ClassComponent: 2, | |
HostRoot: 3, // Root of a host tree. Could be nested inside another node. | |
HostPortal: 4, // A subtree. Could be an entry point to a different renderer. | |
HostComponent: 5, | |
HostText: 6, | |
CoroutineComponent: 7, | |
CoroutineHandlerPhase: 8, | |
YieldComponent: 9, | |
Fragment: 10 | |
}; | |
var DOMProperty = DOMProperty_1; | |
var ReactDOMComponentFlags = ReactDOMComponentFlags_1; | |
var _require$1 = ReactTypeOfWork; | |
var HostComponent = _require$1.HostComponent; | |
var HostText = _require$1.HostText; | |
var invariant$6 = invariant; | |
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME; | |
var Flags = ReactDOMComponentFlags; | |
var randomKey = Math.random().toString(36).slice(2); | |
var internalInstanceKey = '__reactInternalInstance$' + randomKey; | |
var internalEventHandlersKey = '__reactEventHandlers$' + randomKey; | |
/** | |
* Check if a given node should be cached. | |
*/ | |
function shouldPrecacheNode(node, nodeID) { | |
return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === '' + nodeID || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' '; | |
} | |
/** | |
* Drill down (through composites and empty components) until we get a host or | |
* host text component. | |
* | |
* This is pretty polymorphic but unavoidable with the current structure we have | |
* for `_renderedChildren`. | |
*/ | |
function getRenderedHostOrTextFromComponent(component) { | |
var rendered; | |
while (rendered = component._renderedComponent) { | |
component = rendered; | |
} | |
return component; | |
} | |
/** | |
* Populate `_hostNode` on the rendered host/text component with the given | |
* DOM node. The passed `inst` can be a composite. | |
*/ | |
function precacheNode(inst, node) { | |
var hostInst = getRenderedHostOrTextFromComponent(inst); | |
hostInst._hostNode = node; | |
node[internalInstanceKey] = hostInst; | |
} | |
function precacheFiberNode$1(hostInst, node) { | |
node[internalInstanceKey] = hostInst; | |
} | |
function uncacheNode(inst) { | |
var node = inst._hostNode; | |
if (node) { | |
delete node[internalInstanceKey]; | |
inst._hostNode = null; | |
} | |
} | |
/** | |
* Populate `_hostNode` on each child of `inst`, assuming that the children | |
* match up with the DOM (element) children of `node`. | |
* | |
* We cache entire levels at once to avoid an n^2 problem where we access the | |
* children of a node sequentially and have to walk from the start to our target | |
* node every time. | |
* | |
* Since we update `_renderedChildren` and the actual DOM at (slightly) | |
* different times, we could race here and see a newer `_renderedChildren` than | |
* the DOM nodes we see. To avoid this, ReactMultiChild calls | |
* `prepareToManageChildren` before we change `_renderedChildren`, at which | |
* time the container's child nodes are always cached (until it unmounts). | |
*/ | |
function precacheChildNodes(inst, node) { | |
if (inst._flags & Flags.hasCachedChildNodes) { | |
return; | |
} | |
var children = inst._renderedChildren; | |
var childNode = node.firstChild; | |
outer: for (var name in children) { | |
if (!children.hasOwnProperty(name)) { | |
continue; | |
} | |
var childInst = children[name]; | |
var childID = getRenderedHostOrTextFromComponent(childInst)._domID; | |
if (childID === 0) { | |
// We're currently unmounting this child in ReactMultiChild; skip it. | |
continue; | |
} | |
// We assume the child nodes are in the same order as the child instances. | |
for (; childNode !== null; childNode = childNode.nextSibling) { | |
if (shouldPrecacheNode(childNode, childID)) { | |
precacheNode(childInst, childNode); | |
continue outer; | |
} | |
} | |
// We reached the end of the DOM children without finding an ID match. | |
invariant$6(false, 'Unable to find element with ID %s.', childID); | |
} | |
inst._flags |= Flags.hasCachedChildNodes; | |
} | |
/** | |
* Given a DOM node, return the closest ReactDOMComponent or | |
* ReactDOMTextComponent instance ancestor. | |
*/ | |
function getClosestInstanceFromNode(node) { | |
if (node[internalInstanceKey]) { | |
return node[internalInstanceKey]; | |
} | |
// Walk up the tree until we find an ancestor whose instance we have cached. | |
var parents = []; | |
while (!node[internalInstanceKey]) { | |
parents.push(node); | |
if (node.parentNode) { | |
node = node.parentNode; | |
} else { | |
// Top of the tree. This node must not be part of a React tree (or is | |
// unmounted, potentially). | |
return null; | |
} | |
} | |
var closest; | |
var inst = node[internalInstanceKey]; | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
// In Fiber, this will always be the deepest root. | |
return inst; | |
} | |
for (; node && (inst = node[internalInstanceKey]); node = parents.pop()) { | |
closest = inst; | |
if (parents.length) { | |
precacheChildNodes(inst, node); | |
} | |
} | |
return closest; | |
} | |
/** | |
* Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent | |
* instance, or null if the node was not rendered by this React. | |
*/ | |
function getInstanceFromNode(node) { | |
var inst = node[internalInstanceKey]; | |
if (inst) { | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
return inst; | |
} else if (inst._hostNode === node) { | |
return inst; | |
} else { | |
return null; | |
} | |
} | |
inst = getClosestInstanceFromNode(node); | |
if (inst != null && inst._hostNode === node) { | |
return inst; | |
} else { | |
return null; | |
} | |
} | |
/** | |
* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding | |
* DOM node. | |
*/ | |
function getNodeFromInstance(inst) { | |
if (inst.tag === HostComponent || inst.tag === HostText) { | |
// In Fiber this, is just the state node right now. We assume it will be | |
// a host component or host text. | |
return inst.stateNode; | |
} | |
// Without this first invariant, passing a non-DOM-component triggers the next | |
// invariant for a missing parent, which is super confusing. | |
invariant$6(inst._hostNode !== undefined, 'getNodeFromInstance: Invalid argument.'); | |
if (inst._hostNode) { | |
return inst._hostNode; | |
} | |
// Walk up the tree until we find an ancestor whose DOM node we have cached. | |
var parents = []; | |
while (!inst._hostNode) { | |
parents.push(inst); | |
invariant$6(inst._hostParent, 'React DOM tree root should always have a node reference.'); | |
inst = inst._hostParent; | |
} | |
// Now parents contains each ancestor that does *not* have a cached native | |
// node, and `inst` is the deepest ancestor that does. | |
for (; parents.length; inst = parents.pop()) { | |
precacheChildNodes(inst, inst._hostNode); | |
} | |
return inst._hostNode; | |
} | |
function getFiberCurrentPropsFromNode(node) { | |
return node[internalEventHandlersKey] || null; | |
} | |
function updateFiberProps$1(node, props) { | |
node[internalEventHandlersKey] = props; | |
} | |
var ReactDOMComponentTree$1 = { | |
getClosestInstanceFromNode: getClosestInstanceFromNode, | |
getInstanceFromNode: getInstanceFromNode, | |
getNodeFromInstance: getNodeFromInstance, | |
precacheChildNodes: precacheChildNodes, | |
precacheNode: precacheNode, | |
uncacheNode: uncacheNode, | |
precacheFiberNode: precacheFiberNode$1, | |
getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode, | |
updateFiberProps: updateFiberProps$1 | |
}; | |
var ReactDOMComponentTree_1 = ReactDOMComponentTree$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactFeatureFlags | |
* | |
*/ | |
var ReactFeatureFlags$1 = { | |
// When true, call console.time() before and .timeEnd() after each top-level | |
// render (both initial renders and updates). Useful when looking at prod-mode | |
// timeline profiles in Chrome, for example. | |
logTopLevelRenders: false, | |
prepareNewChildrenBeforeUnmountInStack: true, | |
disableNewFiberFeatures: false | |
}; | |
var ReactFeatureFlags_1 = ReactFeatureFlags$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactDOMFeatureFlags | |
*/ | |
var ReactDOMFeatureFlags$1 = { | |
useCreateElement: true, | |
useFiber: false | |
}; | |
var ReactDOMFeatureFlags_1 = ReactDOMFeatureFlags$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule CSSProperty | |
*/ | |
/** | |
* CSS properties which accept numbers but are not in units of "px". | |
*/ | |
var isUnitlessNumber = { | |
animationIterationCount: true, | |
borderImageOutset: true, | |
borderImageSlice: true, | |
borderImageWidth: true, | |
boxFlex: true, | |
boxFlexGroup: true, | |
boxOrdinalGroup: true, | |
columnCount: true, | |
flex: true, | |
flexGrow: true, | |
flexPositive: true, | |
flexShrink: true, | |
flexNegative: true, | |
flexOrder: true, | |
gridRow: true, | |
gridColumn: true, | |
fontWeight: true, | |
lineClamp: true, | |
lineHeight: true, | |
opacity: true, | |
order: true, | |
orphans: true, | |
tabSize: true, | |
widows: true, | |
zIndex: true, | |
zoom: true, | |
// SVG-related properties | |
fillOpacity: true, | |
floodOpacity: true, | |
stopOpacity: true, | |
strokeDasharray: true, | |
strokeDashoffset: true, | |
strokeMiterlimit: true, | |
strokeOpacity: true, | |
strokeWidth: true | |
}; | |
/** | |
* @param {string} prefix vendor-specific prefix, eg: Webkit | |
* @param {string} key style name, eg: transitionDuration | |
* @return {string} style name prefixed with `prefix`, properly camelCased, eg: | |
* WebkitTransitionDuration | |
*/ | |
function prefixKey(prefix, key) { | |
return prefix + key.charAt(0).toUpperCase() + key.substring(1); | |
} | |
/** | |
* Support style names that may come passed in prefixed by adding permutations | |
* of vendor prefixes. | |
*/ | |
var prefixes = ['Webkit', 'ms', 'Moz', 'O']; | |
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an | |
// infinite loop, because it iterates over the newly added props too. | |
Object.keys(isUnitlessNumber).forEach(function (prop) { | |
prefixes.forEach(function (prefix) { | |
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; | |
}); | |
}); | |
/** | |
* Most style properties can be unset by doing .style[prop] = '' but IE8 | |
* doesn't like doing that with shorthand properties so for the properties that | |
* IE8 breaks on, which are listed here, we instead unset each of the | |
* individual properties. See http://bugs.jquery.com/ticket/12385. | |
* The 4-value 'clock' properties like margin, padding, border-width seem to | |
* behave without any problems. Curiously, list-style works too without any | |
* special prodding. | |
*/ | |
var shorthandPropertyExpansions = { | |
background: { | |
backgroundAttachment: true, | |
backgroundColor: true, | |
backgroundImage: true, | |
backgroundPositionX: true, | |
backgroundPositionY: true, | |
backgroundRepeat: true | |
}, | |
backgroundPosition: { | |
backgroundPositionX: true, | |
backgroundPositionY: true | |
}, | |
border: { | |
borderWidth: true, | |
borderStyle: true, | |
borderColor: true | |
}, | |
borderBottom: { | |
borderBottomWidth: true, | |
borderBottomStyle: true, | |
borderBottomColor: true | |
}, | |
borderLeft: { | |
borderLeftWidth: true, | |
borderLeftStyle: true, | |
borderLeftColor: true | |
}, | |
borderRight: { | |
borderRightWidth: true, | |
borderRightStyle: true, | |
borderRightColor: true | |
}, | |
borderTop: { | |
borderTopWidth: true, | |
borderTopStyle: true, | |
borderTopColor: true | |
}, | |
font: { | |
fontStyle: true, | |
fontVariant: true, | |
fontWeight: true, | |
fontSize: true, | |
lineHeight: true, | |
fontFamily: true | |
}, | |
outline: { | |
outlineWidth: true, | |
outlineStyle: true, | |
outlineColor: true | |
} | |
}; | |
var CSSProperty$1 = { | |
isUnitlessNumber: isUnitlessNumber, | |
shorthandPropertyExpansions: shorthandPropertyExpansions | |
}; | |
var CSSProperty_1 = CSSProperty$1; | |
var CSSProperty$2 = CSSProperty_1; | |
var isUnitlessNumber$1 = CSSProperty$2.isUnitlessNumber; | |
/** | |
* 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`. | |
* @param {ReactDOMComponent} component | |
* @return {string} Normalized style value with dimensions applied. | |
*/ | |
function dangerousStyleValue$1(name, value, component) { | |
// 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 (typeof value === 'number' && value !== 0 && !(isUnitlessNumber$1.hasOwnProperty(name) && isUnitlessNumber$1[name])) { | |
return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers | |
} | |
return ('' + value).trim(); | |
} | |
var dangerousStyleValue_1 = dangerousStyleValue$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule getComponentName | |
*/ | |
function getComponentName$1(instanceOrFiber) { | |
if (typeof instanceOrFiber.getName === 'function') { | |
// Stack reconciler | |
var instance = instanceOrFiber; | |
return instance.getName(); | |
} | |
if (typeof instanceOrFiber.tag === 'number') { | |
// Fiber reconciler | |
var fiber = instanceOrFiber; | |
var type = fiber.type; | |
if (typeof type === 'string') { | |
return type; | |
} | |
if (typeof type === 'function') { | |
return type.displayName || type.name; | |
} | |
} | |
return null; | |
} | |
var getComponentName_1 = getComponentName$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactCurrentOwner | |
* | |
*/ | |
/** | |
* Keeps track of the current owner. | |
* | |
* The current owner is the component who should own any components that are | |
* currently being constructed. | |
*/ | |
var ReactCurrentOwner$1 = { | |
/** | |
* @internal | |
* @type {ReactComponent} | |
*/ | |
current: null | |
}; | |
var ReactCurrentOwner_1 = ReactCurrentOwner$1; | |
var ReactCurrentOwner = ReactCurrentOwner_1; | |
var ReactTypeOfWork$2 = ReactTypeOfWork; | |
var IndeterminateComponent = ReactTypeOfWork$2.IndeterminateComponent; | |
var FunctionalComponent = ReactTypeOfWork$2.FunctionalComponent; | |
var ClassComponent = ReactTypeOfWork$2.ClassComponent; | |
var HostComponent$1 = ReactTypeOfWork$2.HostComponent; | |
var getComponentName$3 = getComponentName_1; | |
var invariant$9 = invariant; | |
var warning$4 = warning; | |
function isNative(fn) { | |
// Based on isNative() from Lodash | |
var funcToString = Function.prototype.toString; | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var reIsNative = RegExp('^' + funcToString | |
// Take an example native function source for comparison | |
.call(hasOwnProperty) | |
// Strip regex characters so we can use it for regex | |
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') | |
// Remove hasOwnProperty from the template to make it generic | |
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); | |
try { | |
var source = funcToString.call(fn); | |
return reIsNative.test(source); | |
} catch (err) { | |
return false; | |
} | |
} | |
var canUseCollections = | |
// Array.from | |
typeof Array.from === 'function' && | |
// Map | |
typeof Map === 'function' && isNative(Map) && | |
// Map.prototype.keys | |
Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) && | |
// Set | |
typeof Set === 'function' && isNative(Set) && | |
// Set.prototype.keys | |
Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys); | |
var setItem; | |
var getItem; | |
var removeItem; | |
var getItemIDs; | |
var addRoot; | |
var removeRoot; | |
var getRootIDs; | |
if (canUseCollections) { | |
var itemMap = new Map(); | |
var rootIDSet = new Set(); | |
setItem = function (id, item) { | |
itemMap.set(id, item); | |
}; | |
getItem = function (id) { | |
return itemMap.get(id); | |
}; | |
removeItem = function (id) { | |
itemMap['delete'](id); | |
}; | |
getItemIDs = function () { | |
return Array.from(itemMap.keys()); | |
}; | |
addRoot = function (id) { | |
rootIDSet.add(id); | |
}; | |
removeRoot = function (id) { | |
rootIDSet['delete'](id); | |
}; | |
getRootIDs = function () { | |
return Array.from(rootIDSet.keys()); | |
}; | |
} else { | |
var itemByKey = {}; | |
var rootByKey = {}; | |
// Use non-numeric keys to prevent V8 performance issues: | |
// https://github.com/facebook/react/pull/7232 | |
var getKeyFromID = function (id) { | |
return '.' + id; | |
}; | |
var getIDFromKey = function (key) { | |
return parseInt(key.substr(1), 10); | |
}; | |
setItem = function (id, item) { | |
var key = getKeyFromID(id); | |
itemByKey[key] = item; | |
}; | |
getItem = function (id) { | |
var key = getKeyFromID(id); | |
return itemByKey[key]; | |
}; | |
removeItem = function (id) { | |
var key = getKeyFromID(id); | |
delete itemByKey[key]; | |
}; | |
getItemIDs = function () { | |
return Object.keys(itemByKey).map(getIDFromKey); | |
}; | |
addRoot = function (id) { | |
var key = getKeyFromID(id); | |
rootByKey[key] = true; | |
}; | |
removeRoot = function (id) { | |
var key = getKeyFromID(id); | |
delete rootByKey[key]; | |
}; | |
getRootIDs = function () { | |
return Object.keys(rootByKey).map(getIDFromKey); | |
}; | |
} | |
var unmountedIDs = []; | |
function purgeDeep(id) { | |
var item = getItem(id); | |
if (item) { | |
var childIDs = item.childIDs; | |
removeItem(id); | |
childIDs.forEach(purgeDeep); | |
} | |
} | |
function describeComponentFrame(name, source, ownerName) { | |
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : ''); | |
} | |
function getDisplayName(element) { | |
if (element == null) { | |
return '#empty'; | |
} else if (typeof element === 'string' || typeof element === 'number') { | |
return '#text'; | |
} else if (typeof element.type === 'string') { | |
return element.type; | |
} else { | |
return element.type.displayName || element.type.name || 'Unknown'; | |
} | |
} | |
function describeID(id) { | |
var name = ReactComponentTreeHook.getDisplayName(id); | |
var element = ReactComponentTreeHook.getElement(id); | |
var ownerID = ReactComponentTreeHook.getOwnerID(id); | |
var ownerName; | |
if (ownerID) { | |
ownerName = ReactComponentTreeHook.getDisplayName(ownerID); | |
} | |
warning$4(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id); | |
return describeComponentFrame(name, element && element._source, ownerName); | |
} | |
function describeFiber(fiber) { | |
switch (fiber.tag) { | |
case IndeterminateComponent: | |
case FunctionalComponent: | |
case ClassComponent: | |
case HostComponent$1: | |
var owner = fiber._debugOwner; | |
var source = fiber._debugSource; | |
var name = getComponentName$3(fiber); | |
var ownerName = null; | |
if (owner) { | |
ownerName = getComponentName$3(owner); | |
} | |
return describeComponentFrame(name, source, ownerName); | |
default: | |
return ''; | |
} | |
} | |
var ReactComponentTreeHook = { | |
onSetChildren: function (id, nextChildIDs) { | |
var item = getItem(id); | |
invariant$9(item, 'Item must have been set'); | |
item.childIDs = nextChildIDs; | |
for (var i = 0; i < nextChildIDs.length; i++) { | |
var nextChildID = nextChildIDs[i]; | |
var nextChild = getItem(nextChildID); | |
invariant$9(nextChild, 'Expected hook events to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$9(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null, 'Expected onSetChildren() to fire for a container child ' + 'before its parent includes it in onSetChildren().'); | |
invariant$9(nextChild.isMounted, 'Expected onMountComponent() to fire for the child ' + 'before its parent includes it in onSetChildren().'); | |
if (nextChild.parentID == null) { | |
nextChild.parentID = id; | |
// TODO: This shouldn't be necessary but mounting a new root during in | |
// componentWillMount currently causes not-yet-mounted components to | |
// be purged from our tree data so their parent id is missing. | |
} | |
invariant$9(nextChild.parentID === id, 'Expected onBeforeMountComponent() parent and onSetChildren() to ' + 'be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id); | |
} | |
}, | |
onBeforeMountComponent: function (id, element, parentID) { | |
var item = { | |
element: element, | |
parentID: parentID, | |
text: null, | |
childIDs: [], | |
isMounted: false, | |
updateCount: 0 | |
}; | |
setItem(id, item); | |
}, | |
onBeforeUpdateComponent: function (id, element) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.element = element; | |
}, | |
onMountComponent: function (id) { | |
var item = getItem(id); | |
invariant$9(item, 'Item must have been set'); | |
item.isMounted = true; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
addRoot(id); | |
} | |
}, | |
onUpdateComponent: function (id) { | |
var item = getItem(id); | |
if (!item || !item.isMounted) { | |
// We may end up here as a result of setState() in componentWillUnmount(). | |
// In this case, ignore the element. | |
return; | |
} | |
item.updateCount++; | |
}, | |
onUnmountComponent: function (id) { | |
var item = getItem(id); | |
if (item) { | |
// We need to check if it exists. | |
// `item` might not exist if it is inside an error boundary, and a sibling | |
// error boundary child threw while mounting. Then this instance never | |
// got a chance to mount, but it still gets an unmounting event during | |
// the error boundary cleanup. | |
item.isMounted = false; | |
var isRoot = item.parentID === 0; | |
if (isRoot) { | |
removeRoot(id); | |
} | |
} | |
unmountedIDs.push(id); | |
}, | |
purgeUnmountedComponents: function () { | |
if (ReactComponentTreeHook._preventPurging) { | |
// Should only be used for testing. | |
return; | |
} | |
for (var i = 0; i < unmountedIDs.length; i++) { | |
var id = unmountedIDs[i]; | |
purgeDeep(id); | |
} | |
unmountedIDs.length = 0; | |
}, | |
isMounted: function (id) { | |
var item = getItem(id); | |
return item ? item.isMounted : false; | |
}, | |
getCurrentStackAddendum: function (topElement) { | |
var info = ''; | |
if (topElement) { | |
var name = getDisplayName(topElement); | |
var owner = topElement._owner; | |
info += describeComponentFrame(name, topElement._source, owner && getComponentName$3(owner)); | |
} | |
var currentOwner = ReactCurrentOwner.current; | |
if (currentOwner) { | |
if (typeof currentOwner.tag === 'number') { | |
var workInProgress = currentOwner; | |
// Safe because if current owner exists, we are reconciling, | |
// and it is guaranteed to be the work-in-progress version. | |
info += ReactComponentTreeHook.getStackAddendumByWorkInProgressFiber(workInProgress); | |
} else if (typeof currentOwner._debugID === 'number') { | |
info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID); | |
} | |
} | |
return info; | |
}, | |
getStackAddendumByID: function (id) { | |
var info = ''; | |
while (id) { | |
info += describeID(id); | |
id = ReactComponentTreeHook.getParentID(id); | |
} | |
return info; | |
}, | |
// This function can only be called with a work-in-progress fiber and | |
// only during begin or complete phase. Do not call it under any other | |
// circumstances. | |
getStackAddendumByWorkInProgressFiber: function (workInProgress) { | |
var info = ''; | |
var node = workInProgress; | |
do { | |
info += describeFiber(node); | |
// Otherwise this return pointer might point to the wrong tree: | |
node = node['return']; | |
} while (node); | |
return info; | |
}, | |
getChildIDs: function (id) { | |
var item = getItem(id); | |
return item ? item.childIDs : []; | |
}, | |
getDisplayName: function (id) { | |
var element = ReactComponentTreeHook.getElement(id); | |
if (!element) { | |
return null; | |
} | |
return getDisplayName(element); | |
}, | |
getElement: function (id) { | |
var item = getItem(id); | |
return item ? item.element : null; | |
}, | |
getOwnerID: function (id) { | |
var element = ReactComponentTreeHook.getElement(id); | |
if (!element || !element._owner) { | |
return null; | |
} | |
return element._owner._debugID; | |
}, | |
getParentID: function (id) { | |
var item = getItem(id); | |
return item ? item.parentID : null; | |
}, | |
getSource: function (id) { | |
var item = getItem(id); | |
var element = item ? item.element : null; | |
var source = element != null ? element._source : null; | |
return source; | |
}, | |
getText: function (id) { | |
var element = ReactComponentTreeHook.getElement(id); | |
if (typeof element === 'string') { | |
return element; | |
} else if (typeof element === 'number') { | |
return '' + element; | |
} else { | |
return null; | |
} | |
}, | |
getUpdateCount: function (id) { | |
var item = getItem(id); | |
return item ? item.updateCount : 0; | |
}, | |
getRootIDs: getRootIDs, | |
getRegisteredIDs: getItemIDs | |
}; | |
var ReactComponentTreeHook_1 = ReactComponentTreeHook; | |
if (__DEV__) { | |
var getComponentName$2 = getComponentName_1; | |
var _require$4 = ReactComponentTreeHook_1, | |
getStackAddendumByWorkInProgressFiber = _require$4.getStackAddendumByWorkInProgressFiber; | |
} | |
function getCurrentFiberOwnerName$2() { | |
if (__DEV__) { | |
var fiber = ReactDebugCurrentFiber.current; | |
if (fiber === null) { | |
return null; | |
} | |
if (fiber._debugOwner != null) { | |
return getComponentName$2(fiber._debugOwner); | |
} | |
} | |
return null; | |
} | |
function getCurrentFiberStackAddendum() { | |
if (__DEV__) { | |
var fiber = ReactDebugCurrentFiber.current; | |
if (fiber === null) { | |
return null; | |
} | |
// Safe because if current fiber exists, we are reconciling, | |
// and it is guaranteed to be the work-in-progress version. | |
return getStackAddendumByWorkInProgressFiber(fiber); | |
} | |
return null; | |
} | |
var ReactDebugCurrentFiber = { | |
current: null, | |
phase: null, | |
getCurrentFiberOwnerName: getCurrentFiberOwnerName$2, | |
getCurrentFiberStackAddendum: getCurrentFiberStackAddendum | |
}; | |
var ReactDebugCurrentFiber_1 = ReactDebugCurrentFiber; | |
var CSSProperty = CSSProperty_1; | |
var ExecutionEnvironment$2 = ExecutionEnvironment; | |
var camelizeStyleName$1 = camelizeStyleName; | |
var dangerousStyleValue = dangerousStyleValue_1; | |
var getComponentName = getComponentName_1; | |
var hyphenateStyleName$1 = hyphenateStyleName; | |
var memoizeStringOnly$1 = memoizeStringOnly; | |
var warning$3 = warning; | |
if (__DEV__) { | |
var _require$3 = ReactDebugCurrentFiber_1, | |
getCurrentFiberOwnerName$1 = _require$3.getCurrentFiberOwnerName; | |
} | |
var processStyleName = memoizeStringOnly$1(function (styleName) { | |
return hyphenateStyleName$1(styleName); | |
}); | |
var hasShorthandPropertyBug = false; | |
var styleFloatAccessor = 'cssFloat'; | |
if (ExecutionEnvironment$2.canUseDOM) { | |
var tempStyle = document.createElement('div').style; | |
try { | |
// IE8 throws "Invalid argument." if resetting shorthand style properties. | |
tempStyle.font = ''; | |
} catch (e) { | |
hasShorthandPropertyBug = true; | |
} | |
// IE8 only supports accessing cssFloat (standard) as styleFloat | |
if (document.documentElement.style.cssFloat === undefined) { | |
styleFloatAccessor = 'styleFloat'; | |
} | |
} | |
if (__DEV__) { | |
// 'msTransform' is correct, but the other prefixes should be capitalized | |
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/; | |
// style values shouldn't contain a semicolon | |
var badStyleValueWithSemicolonPattern = /;\s*$/; | |
var warnedStyleNames = {}; | |
var warnedStyleValues = {}; | |
var warnedForNaNValue = false; | |
var warnHyphenatedStyleName = function (name, owner) { | |
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
return; | |
} | |
warnedStyleNames[name] = true; | |
warning$3(false, 'Unsupported style property %s. Did you mean %s?%s', name, camelizeStyleName$1(name), checkRenderMessage(owner)); | |
}; | |
var warnBadVendoredStyleName = function (name, owner) { | |
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) { | |
return; | |
} | |
warnedStyleNames[name] = true; | |
warning$3(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)); | |
}; | |
var warnStyleValueWithSemicolon = function (name, value, owner) { | |
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) { | |
return; | |
} | |
warnedStyleValues[value] = true; | |
warning$3(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')); | |
}; | |
var warnStyleValueIsNaN = function (name, value, owner) { | |
if (warnedForNaNValue) { | |
return; | |
} | |
warnedForNaNValue = true; | |
warning$3(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)); | |
}; | |
var checkRenderMessage = function (owner) { | |
var ownerName; | |
if (owner != null) { | |
// Stack passes the owner manually all the way to CSSPropertyOperations. | |
ownerName = getComponentName(owner); | |
} else { | |
// Fiber doesn't pass it but uses ReactDebugCurrentFiber to track it. | |
// It is only enabled in development and tracks host components too. | |
ownerName = getCurrentFiberOwnerName$1(); | |
// TODO: also report the stack. | |
} | |
if (ownerName) { | |
return '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
return ''; | |
}; | |
/** | |
* @param {string} name | |
* @param {*} value | |
* @param {ReactDOMComponent} component | |
*/ | |
var warnValidStyle = function (name, value, component) { | |
var owner; | |
if (component) { | |
owner = component._currentElement._owner; | |
} | |
if (name.indexOf('-') > -1) { | |
warnHyphenatedStyleName(name, owner); | |
} else if (badVendoredStyleNamePattern.test(name)) { | |
warnBadVendoredStyleName(name, owner); | |
} else if (badStyleValueWithSemicolonPattern.test(value)) { | |
warnStyleValueWithSemicolon(name, value, owner); | |
} | |
if (typeof value === 'number' && isNaN(value)) { | |
warnStyleValueIsNaN(name, value, owner); | |
} | |
}; | |
} | |
/** | |
* Operations for dealing with CSS properties. | |
*/ | |
var CSSPropertyOperations$1 = { | |
/** | |
* Serializes a mapping of style properties for use as inline styles: | |
* | |
* > createMarkupForStyles({width: '200px', height: 0}) | |
* "width:200px;height:0;" | |
* | |
* Undefined values are ignored so that declarative programming is easier. | |
* The result should be HTML-escaped before insertion into the DOM. | |
* | |
* @param {object} styles | |
* @param {ReactDOMComponent} component | |
* @return {?string} | |
*/ | |
createMarkupForStyles: function (styles, component) { | |
var serialized = ''; | |
for (var styleName in styles) { | |
if (!styles.hasOwnProperty(styleName)) { | |
continue; | |
} | |
var styleValue = styles[styleName]; | |
if (__DEV__) { | |
warnValidStyle(styleName, styleValue, component); | |
} | |
if (styleValue != null) { | |
serialized += processStyleName(styleName) + ':'; | |
serialized += dangerousStyleValue(styleName, styleValue, component) + ';'; | |
} | |
} | |
return serialized || null; | |
}, | |
/** | |
* Sets the value for multiple styles on a node. If a value is specified as | |
* '' (empty string), the corresponding style property will be unset. | |
* | |
* @param {DOMElement} node | |
* @param {object} styles | |
* @param {ReactDOMComponent} component | |
*/ | |
setValueForStyles: function (node, styles, component) { | |
var style = node.style; | |
for (var styleName in styles) { | |
if (!styles.hasOwnProperty(styleName)) { | |
continue; | |
} | |
if (__DEV__) { | |
warnValidStyle(styleName, styles[styleName], component); | |
} | |
var styleValue = dangerousStyleValue(styleName, styles[styleName], component); | |
if (styleName === 'float' || styleName === 'cssFloat') { | |
styleName = styleFloatAccessor; | |
} | |
if (styleValue) { | |
style[styleName] = styleValue; | |
} else { | |
var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName]; | |
if (expansion) { | |
// Shorthand property that IE8 won't like unsetting, so unset each | |
// component to placate it | |
for (var individualStyleName in expansion) { | |
style[individualStyleName] = ''; | |
} | |
} else { | |
style[styleName] = ''; | |
} | |
} | |
} | |
} | |
}; | |
var CSSPropertyOperations_1 = CSSPropertyOperations$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule DOMNamespaces | |
*/ | |
var DOMNamespaces$1 = { | |
html: 'http://www.w3.org/1999/xhtml', | |
mathml: 'http://www.w3.org/1998/Math/MathML', | |
svg: 'http://www.w3.org/2000/svg' | |
}; | |
var DOMNamespaces_1 = DOMNamespaces$1; | |
var warning$7 = warning; | |
var ReactInvalidSetStateWarningHook$1 = {}; | |
if (__DEV__) { | |
var processingChildContext = false; | |
var warnInvalidSetState = function () { | |
warning$7(!processingChildContext, 'setState(...): Cannot call setState() inside getChildContext()'); | |
}; | |
ReactInvalidSetStateWarningHook$1 = { | |
onBeginProcessingChildContext: function () { | |
processingChildContext = true; | |
}, | |
onEndProcessingChildContext: function () { | |
processingChildContext = false; | |
}, | |
onSetState: function () { | |
warnInvalidSetState(); | |
} | |
}; | |
} | |
var ReactInvalidSetStateWarningHook_1 = ReactInvalidSetStateWarningHook$1; | |
/** | |
* Copyright 2016-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ReactHostOperationHistoryHook | |
* | |
*/ | |
// Trust the developer to only use this with a __DEV__ check | |
var ReactHostOperationHistoryHook$1 = null; | |
if (__DEV__) { | |
var history = []; | |
ReactHostOperationHistoryHook$1 = { | |
onHostOperation: function (operation) { | |
history.push(operation); | |
}, | |
clearHistory: function () { | |
if (ReactHostOperationHistoryHook$1._preventClearing) { | |
// Should only be used for tests. | |
return; | |
} | |
history = []; | |
}, | |
getHistory: function () { | |
return history; | |
} | |
}; | |
} | |
var ReactHostOperationHistoryHook_1 = ReactHostOperationHistoryHook$1; | |
var ReactInvalidSetStateWarningHook = ReactInvalidSetStateWarningHook_1; | |
var ReactHostOperationHistoryHook = ReactHostOperationHistoryHook_1; | |
var ReactComponentTreeHook$1 = ReactComponentTreeHook_1; | |
var ExecutionEnvironment$3 = ExecutionEnvironment; | |
var performanceNow$1 = performanceNow; | |
var warning$6 = warning; | |
// Trust the developer to only use this with a __DEV__ check | |
var ReactDebugTool$1 = null; | |
if (__DEV__) { | |
var hooks = []; | |
var didHookThrowForEvent = {}; | |
var callHook = function (event, fn, context, arg1, arg2, arg3, arg4, arg5) { | |
try { | |
fn.call(context, arg1, arg2, arg3, arg4, arg5); | |
} catch (e) { | |
warning$6(didHookThrowForEvent[event], 'Exception thrown by hook while handling %s: %s', event, e + '\n' + e.stack); | |
didHookThrowForEvent[event] = true; | |
} | |
}; | |
var emitEvent = function (event, arg1, arg2, arg3, arg4, arg5) { | |
for (var i = 0; i < hooks.length; i++) { | |
var hook = hooks[i]; | |
var fn = hook[event]; | |
if (fn) { | |
callHook(event, fn, hook, arg1, arg2, arg3, arg4, arg5); | |
} | |
} | |
}; | |
var isProfiling = false; | |
var flushHistory = []; | |
var lifeCycleTimerStack = []; | |
var currentFlushNesting = 0; | |
var currentFlushMeasurements = []; | |
var currentFlushStartTime = 0; | |
var currentTimerDebugID = null; | |
var currentTimerStartTime = 0; | |
var currentTimerNestedFlushDuration = 0; | |
var currentTimerType = null; | |
var lifeCycleTimerHasWarned = false; | |
var clearHistory = function () { | |
ReactComponentTreeHook$1.purgeUnmountedComponents(); | |
ReactHostOperationHistoryHook.clearHistory(); | |
}; | |
var getTreeSnapshot = function (registeredIDs) { | |
return registeredIDs.reduce(function (tree, id) { | |
var ownerID = ReactComponentTreeHook$1.getOwnerID(id); | |
var parentID = ReactComponentTreeHook$1.getParentID(id); | |
tree[id] = { | |
displayName: ReactComponentTreeHook$1.getDisplayName(id), | |
text: ReactComponentTreeHook$1.getText(id), | |
updateCount: ReactComponentTreeHook$1.getUpdateCount(id), | |
childIDs: ReactComponentTreeHook$1.getChildIDs(id), | |
// Text nodes don't have owners but this is close enough. | |
ownerID: ownerID || parentID && ReactComponentTreeHook$1.getOwnerID(parentID) || 0, | |
parentID: parentID | |
}; | |
return tree; | |
}, {}); | |
}; | |
var resetMeasurements = function () { | |
var previousStartTime = currentFlushStartTime; | |
var previousMeasurements = currentFlushMeasurements; | |
var previousOperations = ReactHostOperationHistoryHook.getHistory(); | |
if (currentFlushNesting === 0) { | |
currentFlushStartTime = 0; | |
currentFlushMeasurements = []; | |
clearHistory(); | |
return; | |
} | |
if (previousMeasurements.length || previousOperations.length) { | |
var registeredIDs = ReactComponentTreeHook$1.getRegisteredIDs(); | |
flushHistory.push({ | |
duration: performanceNow$1() - previousStartTime, | |
measurements: previousMeasurements || [], | |
operations: previousOperations || [], | |
treeSnapshot: getTreeSnapshot(registeredIDs) | |
}); | |
} | |
clearHistory(); | |
currentFlushStartTime = performanceNow$1(); | |
currentFlushMeasurements = []; | |
}; | |
var checkDebugID = function (debugID) { | |
var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | |
if (allowRoot && debugID === 0) { | |
return; | |
} | |
if (!debugID) { | |
warning$6(false, 'ReactDebugTool: debugID may not be empty.'); | |
} | |
}; | |
var beginLifeCycleTimer = function (debugID, timerType) { | |
if (currentFlushNesting === 0) { | |
return; | |
} | |
if (currentTimerType && !lifeCycleTimerHasWarned) { | |
warning$6(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); | |
lifeCycleTimerHasWarned = true; | |
} | |
currentTimerStartTime = performanceNow$1(); | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = debugID; | |
currentTimerType = timerType; | |
}; | |
var endLifeCycleTimer = function (debugID, timerType) { | |
if (currentFlushNesting === 0) { | |
return; | |
} | |
if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) { | |
warning$6(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another'); | |
lifeCycleTimerHasWarned = true; | |
} | |
if (isProfiling) { | |
currentFlushMeasurements.push({ | |
timerType: timerType, | |
instanceID: debugID, | |
duration: performanceNow$1() - currentTimerStartTime - currentTimerNestedFlushDuration | |
}); | |
} | |
currentTimerStartTime = 0; | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = null; | |
currentTimerType = null; | |
}; | |
var pauseCurrentLifeCycleTimer = function () { | |
var currentTimer = { | |
startTime: currentTimerStartTime, | |
nestedFlushStartTime: performanceNow$1(), | |
debugID: currentTimerDebugID, | |
timerType: currentTimerType | |
}; | |
lifeCycleTimerStack.push(currentTimer); | |
currentTimerStartTime = 0; | |
currentTimerNestedFlushDuration = 0; | |
currentTimerDebugID = null; | |
currentTimerType = null; | |
}; | |
var resumeCurrentLifeCycleTimer = function () { | |
var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(), | |
startTime = _lifeCycleTimerStack$.startTime, | |
nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime, | |
debugID = _lifeCycleTimerStack$.debugID, | |
timerType = _lifeCycleTimerStack$.timerType; | |
var nestedFlushDuration = performanceNow$1() - nestedFlushStartTime; | |
currentTimerStartTime = startTime; | |
currentTimerNestedFlushDuration += nestedFlushDuration; | |
currentTimerDebugID = debugID; | |
currentTimerType = timerType; | |
}; | |
var lastMarkTimeStamp = 0; | |
var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; | |
var shouldMark = function (debugID) { | |
if (!isProfiling || !canUsePerformanceMeasure) { | |
return false; | |
} | |
var element = ReactComponentTreeHook$1.getElement(debugID); | |
if (element == null || typeof element !== 'object') { | |
return false; | |
} | |
var isHostElement = typeof element.type === 'string'; | |
if (isHostElement) { | |
return false; | |
} | |
return true; | |
}; | |
var markBegin = function (debugID, markType) { | |
if (!shouldMark(debugID)) { | |
return; | |
} | |
var markName = debugID + '::' + markType; | |
lastMarkTimeStamp = performanceNow$1(); | |
performance.mark(markName); | |
}; | |
var markEnd = function (debugID, markType) { | |
if (!shouldMark(debugID)) { | |
return; | |
} | |
var markName = debugID + '::' + markType; | |
var displayName = ReactComponentTreeHook$1.getDisplayName(debugID) || 'Unknown'; | |
// Chrome has an issue of dropping markers recorded too fast: | |
// https://bugs.chromium.org/p/chromium/issues/detail?id=640652 | |
// To work around this, we will not report very small measurements. | |
// I determined the magic number by tweaking it back and forth. | |
// 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe. | |
// When the bug is fixed, we can `measure()` unconditionally if we want to. | |
var timeStamp = performanceNow$1(); | |
if (timeStamp - lastMarkTimeStamp > 0.1) { | |
var measurementName = displayName + ' [' + markType + ']'; | |
performance.measure(measurementName, markName); | |
} | |
performance.clearMarks(markName); | |
performance.clearMeasures(measurementName); | |
}; | |
ReactDebugTool$1 = { | |
addHook: function (hook) { | |
hooks.push(hook); | |
}, | |
removeHook: function (hook) { | |
for (var i = 0; i < hooks.length; i++) { | |
if (hooks[i] === hook) { | |
hooks.splice(i, 1); | |
i--; | |
} | |
} | |
}, | |
isProfiling: function () { | |
return isProfiling; | |
}, | |
beginProfiling: function () { | |
if (isProfiling) { | |
return; | |
} | |
isProfiling = true; | |
flushHistory.length = 0; | |
resetMeasurements(); | |
ReactDebugTool$1.addHook(ReactHostOperationHistoryHook); | |
}, | |
endProfiling: function () { | |
if (!isProfiling) { | |
return; | |
} | |
isProfiling = false; | |
resetMeasurements(); | |
ReactDebugTool$1.removeHook(ReactHostOperationHistoryHook); | |
}, | |
getFlushHistory: function () { | |
return flushHistory; | |
}, | |
onBeginFlush: function () { | |
currentFlushNesting++; | |
resetMeasurements(); | |
pauseCurrentLifeCycleTimer(); | |
emitEvent('onBeginFlush'); | |
}, | |
onEndFlush: function () { | |
resetMeasurements(); | |
currentFlushNesting--; | |
resumeCurrentLifeCycleTimer(); | |
emitEvent('onEndFlush'); | |
}, | |
onBeginLifeCycleTimer: function (debugID, timerType) { | |
checkDebugID(debugID); | |
emitEvent('onBeginLifeCycleTimer', debugID, timerType); | |
markBegin(debugID, timerType); | |
beginLifeCycleTimer(debugID, timerType); | |
}, | |
onEndLifeCycleTimer: function (debugID, timerType) { | |
checkDebugID(debugID); | |
endLifeCycleTimer(debugID, timerType); | |
markEnd(debugID, timerType); | |
emitEvent('onEndLifeCycleTimer', debugID, timerType); | |
}, | |
onBeginProcessingChildContext: function () { | |
emitEvent('onBeginProcessingChildContext'); | |
}, | |
onEndProcessingChildContext: function () { | |
emitEvent('onEndProcessingChildContext'); | |
}, | |
onHostOperation: function (operation) { | |
checkDebugID(operation.instanceID); | |
emitEvent('onHostOperation', operation); | |
}, | |
onSetState: function () { | |
emitEvent('onSetState'); | |
}, | |
onSetChildren: function (debugID, childDebugIDs) { | |
checkDebugID(debugID); | |
childDebugIDs.forEach(checkDebugID); | |
emitEvent('onSetChildren', debugID, childDebugIDs); | |
}, | |
onBeforeMountComponent: function (debugID, element, parentDebugID) { | |
checkDebugID(debugID); | |
checkDebugID(parentDebugID, true); | |
emitEvent('onBeforeMountComponent', debugID, element, parentDebugID); | |
markBegin(debugID, 'mount'); | |
}, | |
onMountComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'mount'); | |
emitEvent('onMountComponent', debugID); | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
checkDebugID(debugID); | |
emitEvent('onBeforeUpdateComponent', debugID, element); | |
markBegin(debugID, 'update'); | |
}, | |
onUpdateComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'update'); | |
emitEvent('onUpdateComponent', debugID); | |
}, | |
onBeforeUnmountComponent: function (debugID) { | |
checkDebugID(debugID); | |
emitEvent('onBeforeUnmountComponent', debugID); | |
markBegin(debugID, 'unmount'); | |
}, | |
onUnmountComponent: function (debugID) { | |
checkDebugID(debugID); | |
markEnd(debugID, 'unmount'); | |
emitEvent('onUnmountComponent', debugID); | |
}, | |
onTestEvent: function () { | |
emitEvent('onTestEvent'); | |
} | |
}; | |
ReactDebugTool$1.addHook(ReactInvalidSetStateWarningHook); | |
ReactDebugTool$1.addHook(ReactComponentTreeHook$1); | |
var url = ExecutionEnvironment$3.canUseDOM && window.location.href || ''; | |
if (/[?&]react_perf\b/.test(url)) { | |
ReactDebugTool$1.beginProfiling(); | |
} | |
} | |
var ReactDebugTool_1 = ReactDebugTool$1; | |
// Trust the developer to only use ReactInstrumentation with a __DEV__ check | |
var debugTool = null; | |
if (__DEV__) { | |
var ReactDebugTool = ReactDebugTool_1; | |
debugTool = ReactDebugTool; | |
} | |
var ReactInstrumentation$1 = { debugTool: debugTool }; | |
/** | |
* Copyright 2016-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* Based on the escape-html library, which is used under the MIT License below: | |
* | |
* Copyright (c) 2012-2013 TJ Holowaychuk | |
* Copyright (c) 2015 Andreas Lubbe | |
* Copyright (c) 2015 Tiancheng "Timothy" Gu | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* 'Software'), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be | |
* included in all copies or substantial portions of the Software. | |
* | |
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
* | |
* @providesModule escapeTextContentForBrowser | |
*/ | |
// code copied and modified from escape-html | |
/** | |
* Module variables. | |
* @private | |
*/ | |
var matchHtmlRegExp = /["'&<>]/; | |
/** | |
* Escape special characters in the given string of html. | |
* | |
* @param {string} string The string to escape for inserting into HTML | |
* @return {string} | |
* @public | |
*/ | |
function escapeHtml(string) { | |
var str = '' + string; | |
var match = matchHtmlRegExp.exec(str); | |
if (!match) { | |
return str; | |
} | |
var escape; | |
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. | |
*/ | |
function escapeTextContentForBrowser$1(text) { | |
if (typeof text === 'boolean' || typeof text === 'number') { | |
// this shortcircuit helps perf for types that we know will never have | |
// special characters, especially given that this function is used often | |
// for numeric dom ids. | |
return '' + text; | |
} | |
return escapeHtml(text); | |
} | |
var escapeTextContentForBrowser_1 = escapeTextContentForBrowser$1; | |
var escapeTextContentForBrowser = escapeTextContentForBrowser_1; | |
/** | |
* Escapes attribute value to prevent scripting attacks. | |
* | |
* @param {*} value Value to escape. | |
* @return {string} An escaped string. | |
*/ | |
function quoteAttributeValueForBrowser$1(value) { | |
return '"' + escapeTextContentForBrowser(value) + '"'; | |
} | |
var quoteAttributeValueForBrowser_1 = quoteAttributeValueForBrowser$1; | |
var DOMProperty$3 = DOMProperty_1; | |
var ReactDOMComponentTree$2 = ReactDOMComponentTree_1; | |
var ReactInstrumentation = ReactInstrumentation$1; | |
var quoteAttributeValueForBrowser = quoteAttributeValueForBrowser_1; | |
var warning$5 = warning; | |
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty$3.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty$3.ATTRIBUTE_NAME_CHAR + ']*$'); | |
var illegalAttributeNameCache = {}; | |
var validatedAttributeNameCache = {}; | |
function isAttributeNameSafe(attributeName) { | |
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) { | |
return true; | |
} | |
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) { | |
return false; | |
} | |
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) { | |
validatedAttributeNameCache[attributeName] = true; | |
return true; | |
} | |
illegalAttributeNameCache[attributeName] = true; | |
warning$5(false, 'Invalid attribute name: `%s`', attributeName); | |
return false; | |
} | |
function shouldIgnoreValue(propertyInfo, value) { | |
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false; | |
} | |
/** | |
* Operations for dealing with DOM properties. | |
*/ | |
var DOMPropertyOperations$1 = { | |
/** | |
* Creates markup for the ID property. | |
* | |
* @param {string} id Unescaped ID. | |
* @return {string} Markup string. | |
*/ | |
createMarkupForID: function (id) { | |
return DOMProperty$3.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id); | |
}, | |
setAttributeForID: function (node, id) { | |
node.setAttribute(DOMProperty$3.ID_ATTRIBUTE_NAME, id); | |
}, | |
createMarkupForRoot: function () { | |
return DOMProperty$3.ROOT_ATTRIBUTE_NAME + '=""'; | |
}, | |
setAttributeForRoot: function (node) { | |
node.setAttribute(DOMProperty$3.ROOT_ATTRIBUTE_NAME, ''); | |
}, | |
/** | |
* Creates markup for a property. | |
* | |
* @param {string} name | |
* @param {*} value | |
* @return {?string} Markup string, or null if the property was invalid. | |
*/ | |
createMarkupForProperty: function (name, value) { | |
var propertyInfo = DOMProperty$3.properties.hasOwnProperty(name) ? DOMProperty$3.properties[name] : null; | |
if (propertyInfo) { | |
if (shouldIgnoreValue(propertyInfo, value)) { | |
return ''; | |
} | |
var attributeName = propertyInfo.attributeName; | |
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | |
return attributeName + '=""'; | |
} | |
return attributeName + '=' + quoteAttributeValueForBrowser(value); | |
} else if (DOMProperty$3.isCustomAttribute(name)) { | |
if (value == null) { | |
return ''; | |
} | |
return name + '=' + quoteAttributeValueForBrowser(value); | |
} | |
return null; | |
}, | |
/** | |
* Creates markup for a custom property. | |
* | |
* @param {string} name | |
* @param {*} value | |
* @return {string} Markup string, or empty string if the property was invalid. | |
*/ | |
createMarkupForCustomAttribute: function (name, value) { | |
if (!isAttributeNameSafe(name) || value == null) { | |
return ''; | |
} | |
return name + '=' + quoteAttributeValueForBrowser(value); | |
}, | |
/** | |
* Sets the value for a property on a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
* @param {*} value | |
*/ | |
setValueForProperty: function (node, name, value) { | |
var propertyInfo = DOMProperty$3.properties.hasOwnProperty(name) ? DOMProperty$3.properties[name] : null; | |
if (propertyInfo) { | |
var mutationMethod = propertyInfo.mutationMethod; | |
if (mutationMethod) { | |
mutationMethod(node, value); | |
} else if (shouldIgnoreValue(propertyInfo, value)) { | |
DOMPropertyOperations$1.deleteValueForProperty(node, name); | |
return; | |
} else if (propertyInfo.mustUseProperty) { | |
// Contrary to `setAttribute`, object properties are properly | |
// `toString`ed by IE8/9. | |
node[propertyInfo.propertyName] = value; | |
} else { | |
var attributeName = propertyInfo.attributeName; | |
var namespace = propertyInfo.attributeNamespace; | |
// `setAttribute` with objects becomes only `[object]` in IE8/9, | |
// ('' + value) makes it output the correct toString()-value. | |
if (namespace) { | |
node.setAttributeNS(namespace, attributeName, '' + value); | |
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) { | |
node.setAttribute(attributeName, ''); | |
} else { | |
node.setAttribute(attributeName, '' + value); | |
} | |
} | |
} else if (DOMProperty$3.isCustomAttribute(name)) { | |
DOMPropertyOperations$1.setValueForAttribute(node, name, value); | |
return; | |
} | |
if (__DEV__) { | |
var payload = {}; | |
payload[name] = value; | |
ReactInstrumentation.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$2.getInstanceFromNode(node)._debugID, | |
type: 'update attribute', | |
payload: payload | |
}); | |
} | |
}, | |
setValueForAttribute: function (node, name, value) { | |
if (!isAttributeNameSafe(name)) { | |
return; | |
} | |
if (value == null) { | |
node.removeAttribute(name); | |
} else { | |
node.setAttribute(name, '' + value); | |
} | |
if (__DEV__) { | |
var payload = {}; | |
payload[name] = value; | |
ReactInstrumentation.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$2.getInstanceFromNode(node)._debugID, | |
type: 'update attribute', | |
payload: payload | |
}); | |
} | |
}, | |
/** | |
* Deletes an attributes from a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
*/ | |
deleteValueForAttribute: function (node, name) { | |
node.removeAttribute(name); | |
if (__DEV__) { | |
ReactInstrumentation.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$2.getInstanceFromNode(node)._debugID, | |
type: 'remove attribute', | |
payload: name | |
}); | |
} | |
}, | |
/** | |
* Deletes the value for a property on a node. | |
* | |
* @param {DOMElement} node | |
* @param {string} name | |
*/ | |
deleteValueForProperty: function (node, name) { | |
var propertyInfo = DOMProperty$3.properties.hasOwnProperty(name) ? DOMProperty$3.properties[name] : null; | |
if (propertyInfo) { | |
var mutationMethod = propertyInfo.mutationMethod; | |
if (mutationMethod) { | |
mutationMethod(node, undefined); | |
} else if (propertyInfo.mustUseProperty) { | |
var propName = propertyInfo.propertyName; | |
if (propertyInfo.hasBooleanValue) { | |
node[propName] = false; | |
} else { | |
node[propName] = ''; | |
} | |
} else { | |
node.removeAttribute(propertyInfo.attributeName); | |
} | |
} else if (DOMProperty$3.isCustomAttribute(name)) { | |
node.removeAttribute(name); | |
} | |
if (__DEV__) { | |
ReactInstrumentation.debugTool.onHostOperation({ | |
instanceID: ReactDOMComponentTree$2.getInstanceFromNode(node)._debugID, | |
type: 'remove attribute', | |
payload: name | |
}); | |
} | |
} | |
}; | |
var DOMPropertyOperations_1 = DOMPropertyOperations$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* | |
* @providesModule ReactPropTypesSecret | |
*/ | |
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | |
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; | |
var React2 = React; | |
var ReactPropTypesSecret = ReactPropTypesSecret_1; | |
var warning$9 = warning; | |
var hasReadOnlyValue = { | |
'button': true, | |
'checkbox': true, | |
'image': true, | |
'hidden': true, | |
'radio': true, | |
'reset': true, | |
'submit': true | |
}; | |
var propTypes = { | |
value: function (props, propName, componentName) { | |
if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) { | |
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) { | |
if (!props[propName] || props.onChange || props.readOnly || props.disabled) { | |
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`.'); | |
}, | |
onChange: React2.PropTypes.func | |
}; | |
var loggedTypeFailures = {}; | |
function getDeclarationErrorAddendum$1(ownerName) { | |
if (ownerName) { | |
return '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
return ''; | |
} | |
/** | |
* Provide a linked `value` attribute for controlled forms. You should not use | |
* this outside of the ReactDOM controlled form components. | |
*/ | |
var ReactControlledValuePropTypes$1 = { | |
checkPropTypes: function (tagName, props, ownerName) { | |
for (var propName in propTypes) { | |
if (propTypes.hasOwnProperty(propName)) { | |
var error = propTypes[propName](props, propName, tagName, 'prop', null, ReactPropTypesSecret); | |
} | |
if (error instanceof Error && !(error.message in loggedTypeFailures)) { | |
// Only monitor this failure once because there tends to be a lot of the | |
// same error. | |
loggedTypeFailures[error.message] = true; | |
var addendum = getDeclarationErrorAddendum$1(ownerName); | |
warning$9(false, 'Failed form propType: %s%s', error.message, addendum); | |
} | |
} | |
} | |
}; | |
var ReactControlledValuePropTypes_1 = ReactControlledValuePropTypes$1; | |
var DOMPropertyOperations$2 = DOMPropertyOperations_1; | |
var ReactControlledValuePropTypes = ReactControlledValuePropTypes_1; | |
var ReactDOMComponentTree$3 = ReactDOMComponentTree_1; | |
var _require$5 = ReactDebugCurrentFiber_1; | |
var getCurrentFiberOwnerName$3 = _require$5.getCurrentFiberOwnerName; | |
var invariant$10 = invariant; | |
var warning$8 = warning; | |
var didWarnValueDefaultValue = false; | |
var didWarnCheckedDefaultChecked = false; | |
var didWarnControlledToUncontrolled = false; | |
var didWarnUncontrolledToControlled = false; | |
function isControlled(props) { | |
var usesChecked = props.type === 'checkbox' || props.type === 'radio'; | |
return usesChecked ? props.checked != null : props.value != null; | |
} | |
/** | |
* Implements an <input> host component that allows setting these optional | |
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`. | |
* | |
* If `checked` or `value` are not supplied (or null/undefined), user actions | |
* that affect the checked state or value will trigger updates to the element. | |
* | |
* If they are supplied (and not null/undefined), the rendered element will not | |
* trigger updates to the element. Instead, the props must change in order for | |
* the rendered element to be updated. | |
* | |
* The rendered element will be initialized as unchecked (or `defaultChecked`) | |
* with an empty value (or `defaultValue`). | |
* | |
* See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html | |
*/ | |
var ReactDOMInput = { | |
getHostProps: function (element, props) { | |
var node = element; | |
var value = props.value; | |
var checked = props.checked; | |
var hostProps = Object.assign({ | |
// Make sure we set .type before any other properties (setting .value | |
// before .type means .value is lost in IE11 and below) | |
type: undefined, | |
// Make sure we set .step before .value (setting .value before .step | |
// means .value is rounded on mount, based upon step precision) | |
step: undefined, | |
// Make sure we set .min & .max before .value (to ensure proper order | |
// in corner cases such as min or max deriving from value, e.g. Issue #7170) | |
min: undefined, | |
max: undefined | |
}, props, { | |
defaultChecked: undefined, | |
defaultValue: undefined, | |
value: value != null ? value : node._wrapperState.initialValue, | |
checked: checked != null ? checked : node._wrapperState.initialChecked | |
}); | |
return hostProps; | |
}, | |
mountWrapper: function (element, props) { | |
if (__DEV__) { | |
ReactControlledValuePropTypes.checkPropTypes('input', props, getCurrentFiberOwnerName$3()); | |
if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) { | |
warning$8(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', getCurrentFiberOwnerName$3() || 'A component', props.type); | |
didWarnCheckedDefaultChecked = true; | |
} | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) { | |
warning$8(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', getCurrentFiberOwnerName$3() || 'A component', props.type); | |
didWarnValueDefaultValue = true; | |
} | |
} | |
var defaultValue = props.defaultValue; | |
var node = element; | |
node._wrapperState = { | |
initialChecked: props.checked != null ? props.checked : props.defaultChecked, | |
initialValue: props.value != null ? props.value : defaultValue | |
}; | |
if (__DEV__) { | |
node._wrapperState.controlled = isControlled(props); | |
} | |
}, | |
updateWrapper: function (element, props) { | |
var node = element; | |
if (__DEV__) { | |
var controlled = isControlled(props); | |
if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) { | |
warning$8(false, '%s is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', getCurrentFiberOwnerName$3() || 'A component', props.type); | |
didWarnUncontrolledToControlled = true; | |
} | |
if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) { | |
warning$8(false, '%s is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', getCurrentFiberOwnerName$3() || 'A component', props.type); | |
didWarnControlledToUncontrolled = true; | |
} | |
} | |
var checked = props.checked; | |
if (checked != null) { | |
DOMPropertyOperations$2.setValueForProperty(node, 'checked', checked || false); | |
} | |
var value = props.value; | |
if (value != null) { | |
// Cast `value` to a string to ensure the value is set correctly. While | |
// browsers typically do this as necessary, jsdom doesn't. | |
var newValue = '' + value; | |
// To avoid side effects (such as losing text selection), only set value if changed | |
if (newValue !== node.value) { | |
node.value = newValue; | |
} | |
} else { | |
if (props.value == null && props.defaultValue != null) { | |
// In Chrome, assigning defaultValue to certain input types triggers input validation. | |
// For number inputs, the display value loses trailing decimal points. For email inputs, | |
// Chrome raises "The specified value <x> is not a valid email address". | |
// | |
// Here we check to see if the defaultValue has actually changed, avoiding these problems | |
// when the user is inputting text | |
// | |
// https://github.com/facebook/react/issues/7253 | |
if (node.defaultValue !== '' + props.defaultValue) { | |
node.defaultValue = '' + props.defaultValue; | |
} | |
} | |
if (props.checked == null && props.defaultChecked != null) { | |
node.defaultChecked = !!props.defaultChecked; | |
} | |
} | |
}, | |
postMountWrapper: function (element, props) { | |
var node = element; | |
// Detach value from defaultValue. We won't do anything if we're working on | |
// submit or reset inputs as those values & defaultValues are linked. They | |
// are not resetable nodes so this operation doesn't matter and actually | |
// removes browser-default values (eg "Submit Query") when no value is | |
// provided. | |
switch (props.type) { | |
case 'submit': | |
case 'reset': | |
break; | |
case 'color': | |
case 'date': | |
case 'datetime': | |
case 'datetime-local': | |
case 'month': | |
case 'time': | |
case 'week': | |
// This fixes the no-show issue on iOS Safari and Android Chrome: | |
// https://github.com/facebook/react/issues/7233 | |
node.value = ''; | |
node.value = node.defaultValue; | |
break; | |
default: | |
node.value = node.value; | |
break; | |
} | |
// Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug | |
// this is needed to work around a chrome bug where setting defaultChecked | |
// will sometimes influence the value of checked (even after detachment). | |
// Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416 | |
// We need to temporarily unset name to avoid disrupting radio button groups. | |
var name = node.name; | |
if (name !== '') { | |
node.name = ''; | |
} | |
node.defaultChecked = !node.defaultChecked; | |
node.defaultChecked = !node.defaultChecked; | |
if (name !== '') { | |
node.name = name; | |
} | |
}, | |
restoreControlledState: function (element, props) { | |
var node = element; | |
ReactDOMInput.updateWrapper(node, props); | |
updateNamedCousins(node, props); | |
} | |
}; | |
function updateNamedCousins(rootNode, props) { | |
var name = props.name; | |
if (props.type === 'radio' && name != null) { | |
var queryRoot = rootNode; | |
while (queryRoot.parentNode) { | |
queryRoot = queryRoot.parentNode; | |
} | |
// If `rootNode.form` was non-null, then we could try `form.elements`, | |
// but that sometimes behaves strangely in IE8. We could also try using | |
// `form.getElementsByName`, but that will only return direct children | |
// and won't include inputs that use the HTML5 `form=` attribute. Since | |
// the input might not even be in a form. It might not even be in the | |
// document. Let's just use the local `querySelectorAll` to ensure we don't | |
// miss anything. | |
var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]'); | |
for (var i = 0; i < group.length; i++) { | |
var otherNode = group[i]; | |
if (otherNode === rootNode || otherNode.form !== rootNode.form) { | |
continue; | |
} | |
// This will throw if radio buttons rendered by different copies of React | |
// and the same name are rendered into the same form (same as #1939). | |
// That's probably okay; we don't support it just as we don't support | |
// mixing React radio buttons with non-React ones. | |
var otherInstance = ReactDOMComponentTree$3.getInstanceFromNode(otherNode); | |
invariant$10(otherInstance, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.'); | |
// If this is a controlled radio button group, forcing the input that | |
// was previously checked to update will cause it to be come re-checked | |
// as appropriate. | |
ReactDOMInput.updateWrapper(otherNode, otherInstance.memoizedProps); | |
} | |
} | |
} | |
var ReactDOMFiberInput$1 = ReactDOMInput; | |
var React$1 = React; | |
var warning$10 = warning; | |
function flattenChildren(children) { | |
var content = ''; | |
// Flatten children and warn if they aren't strings or numbers; | |
// invalid types are ignored. | |
// We can silently skip them because invalid DOM nesting warning | |
// catches these cases in Fiber. | |
React$1.Children.forEach(children, function (child) { | |
if (child == null) { | |
return; | |
} | |
if (typeof child === 'string' || typeof child === 'number') { | |
content += child; | |
} | |
}); | |
return content; | |
} | |
/** | |
* Implements an <option> host component that warns when `selected` is set. | |
*/ | |
var ReactDOMOption = { | |
mountWrapper: function (element, props) { | |
// TODO (yungsters): Remove support for `selected` in <option>. | |
if (__DEV__) { | |
warning$10(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); | |
} | |
}, | |
postMountWrapper: function (element, props) { | |
// value="" should make a value attribute (#6219) | |
if (props.value != null) { | |
element.setAttribute('value', props.value); | |
} | |
}, | |
getHostProps: function (element, props) { | |
var hostProps = Object.assign({ children: undefined }, props); | |
var content = flattenChildren(props.children); | |
if (content) { | |
hostProps.children = content; | |
} | |
return hostProps; | |
} | |
}; | |
var ReactDOMFiberOption$1 = ReactDOMOption; | |
var ReactControlledValuePropTypes$2 = ReactControlledValuePropTypes_1; | |
var _require$6 = ReactDebugCurrentFiber_1; | |
var getCurrentFiberOwnerName$4 = _require$6.getCurrentFiberOwnerName; | |
var warning$11 = warning; | |
var didWarnValueDefaultValue$1 = false; | |
function getDeclarationErrorAddendum$2() { | |
var ownerName = getCurrentFiberOwnerName$4(); | |
if (ownerName) { | |
return '\n\nCheck the render method of `' + ownerName + '`.'; | |
} | |
return ''; | |
} | |
var valuePropNames = ['value', 'defaultValue']; | |
/** | |
* Validation function for `value` and `defaultValue`. | |
*/ | |
function checkSelectPropTypes(props) { | |
ReactControlledValuePropTypes$2.checkPropTypes('select', props, getCurrentFiberOwnerName$4()); | |
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) { | |
warning$11(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum$2()); | |
} else if (!props.multiple && isArray) { | |
warning$11(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum$2()); | |
} | |
} | |
} | |
function updateOptions(node, multiple, propValue) { | |
var options = node.options; | |
if (multiple) { | |
var selectedValues = propValue; | |
var selectedValue = {}; | |
for (var i = 0; i < selectedValues.length; i++) { | |
selectedValue['' + selectedValues[i]] = true; | |
} | |
for (var _i = 0; _i < options.length; _i++) { | |
var selected = selectedValue.hasOwnProperty(options[_i].value); | |
if (options[_i].selected !== selected) { | |
options[_i].selected = selected; | |
} | |
} | |
} else { | |
// Do not set `select.value` as exact behavior isn't consistent across all | |
// browsers for all cases. | |
var _selectedValue = '' + propValue; | |
for (var _i2 = 0; _i2 < options.length; _i2++) { | |
if (options[_i2].value === _selectedValue) { | |
options[_i2].selected = true; | |
return; | |
} | |
} | |
if (options.length) { | |
options[0].selected = true; | |
} | |
} | |
} | |
/** | |
* Implements a <select> host component that allows optionally setting the | |
* props `value` and `defaultValue`. If `multiple` is false, the prop must be a | |
* stringable. If `multiple` is true, the prop must be an array of stringables. | |
* | |
* If `value` is not supplied (or null/undefined), user actions that change the | |
* selected option will trigger updates to the rendered options. | |
* | |
* If it is supplied (and not null/undefined), the rendered options will not | |
* update in response to user actions. Instead, the `value` prop must change in | |
* order for the rendered options to update. | |
* | |
* If `defaultValue` is provided, any options with the supplied values will be | |
* selected. | |
*/ | |
var ReactDOMSelect = { | |
getHostProps: function (element, props) { | |
return Object.assign({}, props, { | |
value: undefined | |
}); | |
}, | |
mountWrapper: function (element, props) { | |
var node = element; | |
if (__DEV__) { | |
checkSelectPropTypes(props); | |
} | |
var value = props.value; | |
node._wrapperState = { | |
initialValue: value != null ? value : props.defaultValue, | |
wasMultiple: !!props.multiple | |
}; | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) { | |
warning$11(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'); | |
didWarnValueDefaultValue$1 = true; | |
} | |
node.multiple = !!props.multiple; | |
if (value != null) { | |
updateOptions(node, !!props.multiple, value); | |
} else if (props.defaultValue != null) { | |
updateOptions(node, !!props.multiple, props.defaultValue); | |
} | |
}, | |
postUpdateWrapper: function (element, props) { | |
var node = element; | |
// After the initial mount, we control selected-ness manually so don't pass | |
// this value down | |
node._wrapperState.initialValue = undefined; | |
var wasMultiple = node._wrapperState.wasMultiple; | |
node._wrapperState.wasMultiple = !!props.multiple; | |
var value = props.value; | |
if (value != null) { | |
updateOptions(node, !!props.multiple, value); | |
} else if (wasMultiple !== !!props.multiple) { | |
// For simplicity, reapply `defaultValue` if `multiple` is toggled. | |
if (props.defaultValue != null) { | |
updateOptions(node, !!props.multiple, props.defaultValue); | |
} else { | |
// Revert the select back to its default unselected state. | |
updateOptions(node, !!props.multiple, props.multiple ? [] : ''); | |
} | |
} | |
}, | |
restoreControlledState: function (element, props) { | |
var node = element; | |
var value = props.value; | |
if (value != null) { | |
updateOptions(node, !!props.multiple, value); | |
} | |
} | |
}; | |
var ReactDOMFiberSelect$1 = ReactDOMSelect; | |
var ReactControlledValuePropTypes$3 = ReactControlledValuePropTypes_1; | |
var _require$7 = ReactDebugCurrentFiber_1; | |
var getCurrentFiberOwnerName$5 = _require$7.getCurrentFiberOwnerName; | |
var invariant$11 = invariant; | |
var warning$12 = warning; | |
var didWarnValDefaultVal = false; | |
/** | |
* Implements a <textarea> host component that allows setting `value`, and | |
* `defaultValue`. This differs from the traditional DOM API because value is | |
* usually set as PCDATA children. | |
* | |
* If `value` is not supplied (or null/undefined), user actions that affect the | |
* value will trigger updates to the element. | |
* | |
* If `value` is supplied (and not null/undefined), the rendered element will | |
* not trigger updates to the element. Instead, the `value` prop must change in | |
* order for the rendered element to be updated. | |
* | |
* The rendered element will be initialized with an empty value, the prop | |
* `defaultValue` if specified, or the children content (deprecated). | |
*/ | |
var ReactDOMTextarea = { | |
getHostProps: function (element, props) { | |
var node = element; | |
invariant$11(props.dangerouslySetInnerHTML == null, '`dangerouslySetInnerHTML` does not make sense on <textarea>.'); | |
// Always set children to the same thing. In IE9, the selection range will | |
// get reset if `textContent` is mutated. We could add a check in setTextContent | |
// to only set the value if/when the value differs from the node value (which would | |
// completely solve this IE9 bug), but Sebastian+Ben seemed to like this solution. | |
// The value can be a boolean or object so that's why it's forced to be a string. | |
var hostProps = Object.assign({}, props, { | |
value: undefined, | |
defaultValue: undefined, | |
children: '' + node._wrapperState.initialValue | |
}); | |
return hostProps; | |
}, | |
mountWrapper: function (element, props) { | |
var node = element; | |
if (__DEV__) { | |
ReactControlledValuePropTypes$3.checkPropTypes('textarea', props, getCurrentFiberOwnerName$5()); | |
if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) { | |
warning$12(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'); | |
didWarnValDefaultVal = true; | |
} | |
} | |
var value = props.value; | |
var initialValue = value; | |
// Only bother fetching default value if we're going to use it | |
if (value == null) { | |
var defaultValue = props.defaultValue; | |
// TODO (yungsters): Remove support for children content in <textarea>. | |
var children = props.children; | |
if (children != null) { | |
if (__DEV__) { | |
warning$12(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.'); | |
} | |
invariant$11(defaultValue == null, 'If you supply `defaultValue` on a <textarea>, do not pass children.'); | |
if (Array.isArray(children)) { | |
invariant$11(children.length <= 1, '<textarea> can only have at most one child.'); | |
children = children[0]; | |
} | |
defaultValue = '' + children; | |
} | |
if (defaultValue == null) { | |
defaultValue = ''; | |
} | |
initialValue = defaultValue; | |
} | |
node._wrapperState = { | |
initialValue: '' + initialValue | |
}; | |
}, | |
updateWrapper: function (element, props) { | |
var node = element; | |
var value = props.value; | |
if (value != null) { | |
// Cast `value` to a string to ensure the value is set correctly. While | |
// browsers typically do this as necessary, jsdom doesn't. | |
var newValue = '' + value; | |
// To avoid side effects (such as losing text selection), only set value if changed | |
if (newValue !== node.value) { | |
node.value = newValue; | |
} | |
if (props.defaultValue == null) { | |
node.defaultValue = newValue; | |
} | |
} | |
if (props.defaultValue != null) { | |
node.defaultValue = props.defaultValue; | |
} | |
}, | |
postMountWrapper: function (element, props) { | |
var node = element; | |
// This is in postMount because we need access to the DOM node, which is not | |
// available until after the component has mounted. | |
var textContent = node.textContent; | |
// Only set node.value if textContent is equal to the expected | |
// initial value. In IE10/IE11 there is a bug where the placeholder attribute | |
// will populate textContent as well. | |
// https://developer.microsoft.com/microsoft-edge/platform/issues/101525/ | |
if (textContent === node._wrapperState.initialValue) { | |
node.value = textContent; | |
} | |
}, | |
restoreControlledState: function (element, props) { | |
// DOM component is still mounted; update | |
ReactDOMTextarea.updateWrapper(element, props); | |
} | |
}; | |
var ReactDOMFiberTextarea$1 = ReactDOMTextarea; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule createMicrosoftUnsafeLocalFunction | |
*/ | |
/* globals MSApp */ | |
/** | |
* Create a function which has 'unsafe' privileges (required by windows8 apps) | |
*/ | |
var createMicrosoftUnsafeLocalFunction$1 = function (func) { | |
if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) { | |
return function (arg0, arg1, arg2, arg3) { | |
MSApp.execUnsafeLocalFunction(function () { | |
return func(arg0, arg1, arg2, arg3); | |
}); | |
}; | |
} else { | |
return func; | |
} | |
}; | |
var createMicrosoftUnsafeLocalFunction_1 = createMicrosoftUnsafeLocalFunction$1; | |
var ExecutionEnvironment$4 = ExecutionEnvironment; | |
var DOMNamespaces$2 = DOMNamespaces_1; | |
var WHITESPACE_TEST = /^[ \r\n\t\f]/; | |
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/; | |
var createMicrosoftUnsafeLocalFunction = createMicrosoftUnsafeLocalFunction_1; | |
// SVG temp container for IE lacking innerHTML | |
var reusableSVGContainer; | |
/** | |
* Set the innerHTML property of a node, ensuring that whitespace is preserved | |
* even in IE8. | |
* | |
* @param {DOMElement} node | |
* @param {string} html | |
* @internal | |
*/ | |
var setInnerHTML$1 = createMicrosoftUnsafeLocalFunction(function (node, html) { | |
// IE does not have innerHTML for SVG nodes, so instead we inject the | |
// new markup in a temp node and then move the child nodes across into | |
// the target node | |
if (node.namespaceURI === DOMNamespaces$2.svg && !('innerHTML' in node)) { | |
reusableSVGContainer = reusableSVGContainer || document.createElement('div'); | |
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>'; | |
var svgNode = reusableSVGContainer.firstChild; | |
while (svgNode.firstChild) { | |
node.appendChild(svgNode.firstChild); | |
} | |
} else { | |
node.innerHTML = html; | |
} | |
}); | |
if (ExecutionEnvironment$4.canUseDOM) { | |
// IE8: When updating a just created node with innerHTML only leading | |
// whitespace is removed. When updating an existing node with innerHTML | |
// whitespace in root TextNodes is also collapsed. | |
// @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html | |
// Feature detection; only IE8 is known to behave improperly like this. | |
var testElement = document.createElement('div'); | |
testElement.innerHTML = ' '; | |
if (testElement.innerHTML === '') { | |
setInnerHTML$1 = function (node, html) { | |
// Magic theory: IE8 supposedly differentiates between added and updated | |
// nodes when processing innerHTML, innerHTML on updated nodes suffers | |
// from worse whitespace behavior. Re-adding a node like this triggers | |
// the initial and more favorable whitespace behavior. | |
// TODO: What to do on a detached node? | |
if (node.parentNode) { | |
node.parentNode.replaceChild(node, node); | |
} | |
// We also implement a workaround for non-visible tags disappearing into | |
// thin air on IE8, this only happens if there is no visible text | |
// in-front of the non-visible tags. Piggyback on the whitespace fix | |
// and simply check if any non-visible tags appear in the source. | |
if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) { | |
// Recover leading whitespace by temporarily prepending any character. | |
// \uFEFF has the potential advantage of being zero-width/invisible. | |
// UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode | |
// in hopes that this is preserved even if "\uFEFF" is transformed to | |
// the actual Unicode character (by Babel, for example). | |
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216 | |
node.innerHTML = String.fromCharCode(0xFEFF) + html; | |
// deleteData leaves an empty `TextNode` which offsets the index of all | |
// children. Definitely want to avoid this. | |
var textNode = node.firstChild; | |
if (textNode.data.length === 1) { | |
node.removeChild(textNode); | |
} else { | |
textNode.deleteData(0, 1); | |
} | |
} else { | |
node.innerHTML = html; | |
} | |
}; | |
} | |
testElement = null; | |
} | |
var setInnerHTML_1 = setInnerHTML$1; | |
var ExecutionEnvironment$5 = ExecutionEnvironment; | |
var escapeTextContentForBrowser$2 = escapeTextContentForBrowser_1; | |
var setInnerHTML$2 = setInnerHTML_1; | |
/** | |
* Set the textContent property of a node, ensuring that whitespace is preserved | |
* even in IE8. innerText is a poor substitute for textContent and, among many | |
* issues, inserts <br> instead of the literal newline chars. innerHTML behaves | |
* as it should. | |
* | |
* @param {DOMElement} node | |
* @param {string} text | |
* @internal | |
*/ | |
var setTextContent$1 = function (node, text) { | |
if (text) { | |
var firstChild = node.firstChild; | |
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) { | |
firstChild.nodeValue = text; | |
return; | |
} | |
} | |
node.textContent = text; | |
}; | |
if (ExecutionEnvironment$5.canUseDOM) { | |
if (!('textContent' in document.documentElement)) { | |
setTextContent$1 = function (node, text) { | |
if (node.nodeType === 3) { | |
node.nodeValue = text; | |
return; | |
} | |
setInnerHTML$2(node, escapeTextContentForBrowser$2(text)); | |
}; | |
} | |
} | |
var setTextContent_1 = setTextContent$1; | |
var ReactDOMComponentTree$4 = ReactDOMComponentTree_1; | |
function isCheckable(elem) { | |
var type = elem.type; | |
var nodeName = elem.nodeName; | |
return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio'); | |
} | |
function getTracker(inst) { | |
if (typeof inst.tag === 'number') { | |
inst = inst.stateNode; | |
} | |
return inst._wrapperState.valueTracker; | |
} | |
function attachTracker(inst, tracker) { | |
inst._wrapperState.valueTracker = tracker; | |
} | |
function detachTracker(inst) { | |
delete inst._wrapperState.valueTracker; | |
} | |
function getValueFromNode(node) { | |
var value; | |
if (node) { | |
value = isCheckable(node) ? '' + node.checked : node.value; | |
} | |
return value; | |
} | |
function trackValueOnNode(node, inst) { | |
var valueField = isCheckable(node) ? 'checked' : 'value'; | |
var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField); | |
var currentValue = '' + node[valueField]; | |
// if someone has already defined a value or Safari, then bail | |
// and don't track value will cause over reporting of changes, | |
// but it's better then a hard failure | |
// (needed for certain tests that spyOn input values and Safari) | |
if (node.hasOwnProperty(valueField) || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') { | |
return; | |
} | |
Object.defineProperty(node, valueField, { | |
enumerable: descriptor.enumerable, | |
configurable: true, | |
get: function () { | |
return descriptor.get.call(this); | |
}, | |
set: function (value) { | |
currentValue = '' + value; | |
descriptor.set.call(this, value); | |
} | |
}); | |
var tracker = { | |
getValue: function () { | |
return currentValue; | |
}, | |
setValue: function (value) { | |
currentValue = '' + value; | |
}, | |
stopTracking: function () { | |
detachTracker(inst); | |
delete node[valueField]; | |
} | |
}; | |
return tracker; | |
} | |
var inputValueTracking$1 = { | |
// exposed for testing | |
_getTrackerFromNode: function (node) { | |
return getTracker(ReactDOMComponentTree$4.getInstanceFromNode(node)); | |
}, | |
trackNode: function (node) { | |
if (node._wrapperState.valueTracker) { | |
return; | |
} | |
node._wrapperState.valueTracker = trackValueOnNode(node, node); | |
}, | |
track: function (inst) { | |
if (getTracker(inst)) { | |
return; | |
} | |
var node = ReactDOMComponentTree$4.getNodeFromInstance(inst); | |
attachTracker(inst, trackValueOnNode(node, inst)); | |
}, | |
updateValueIfChanged: function (inst) { | |
if (!inst) { | |
return false; | |
} | |
var tracker = getTracker(inst); | |
if (!tracker) { | |
if (typeof inst.tag === 'number') { | |
inputValueTracking$1.trackNode(inst.stateNode); | |
} else { | |
inputValueTracking$1.track(inst); | |
} | |
return true; | |
} | |
var lastValue = tracker.getValue(); | |
var nextValue = getValueFromNode(ReactDOMComponentTree$4.getNodeFromInstance(inst)); | |
if (nextValue !== lastValue) { | |
tracker.setValue(nextValue); | |
return true; | |
} | |
return false; | |
}, | |
stopTracking: function (inst) { | |
var tracker = getTracker(inst); | |
if (tracker) { | |
tracker.stopTracking(); | |
} | |
} | |
}; | |
var inputValueTracking_1 = inputValueTracking$1; | |
var DOMProperty$4 = DOMProperty_1; | |
var ReactComponentTreeHook$2 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$1 = ReactDebugCurrentFiber_1; | |
var warning$13 = warning; | |
var warnedProperties = {}; | |
var rARIA = new RegExp('^(aria)-[' + DOMProperty$4.ATTRIBUTE_NAME_CHAR + ']*$'); | |
function getStackAddendum(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$2.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$1.getCurrentFiberStackAddendum(); | |
} | |
} | |
function validateProperty(tagName, name, debugID) { | |
if (warnedProperties.hasOwnProperty(name) && warnedProperties[name]) { | |
return true; | |
} | |
if (rARIA.test(name)) { | |
var lowerCasedName = name.toLowerCase(); | |
var standardName = DOMProperty$4.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty$4.getPossibleStandardName[lowerCasedName] : null; | |
// If this is an aria-* attribute, but is not listed in the known DOM | |
// DOM properties, then it is an invalid aria-* attribute. | |
if (standardName == null) { | |
warnedProperties[name] = true; | |
return false; | |
} | |
// aria-* attributes should be lowercase; suggest the lowercase version. | |
if (name !== standardName) { | |
warning$13(false, 'Unknown ARIA attribute %s. Did you mean %s?%s', name, standardName, getStackAddendum(debugID)); | |
warnedProperties[name] = true; | |
return true; | |
} | |
} | |
return true; | |
} | |
function warnInvalidARIAProps(type, props, debugID) { | |
var invalidProps = []; | |
for (var key in props) { | |
var isValid = validateProperty(type, key, debugID); | |
if (!isValid) { | |
invalidProps.push(key); | |
} | |
} | |
var unknownPropString = invalidProps.map(function (prop) { | |
return '`' + prop + '`'; | |
}).join(', '); | |
if (invalidProps.length === 1) { | |
warning$13(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum(debugID)); | |
} else if (invalidProps.length > 1) { | |
warning$13(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, type, getStackAddendum(debugID)); | |
} | |
} | |
function validateProperties(type, props, debugID /* Stack only */) { | |
if (type.indexOf('-') >= 0 || props.is) { | |
return; | |
} | |
warnInvalidARIAProps(type, props, debugID); | |
} | |
var ReactDOMInvalidARIAHook$1 = { | |
// Fiber | |
validateProperties: validateProperties, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMInvalidARIAHook_1 = ReactDOMInvalidARIAHook$1; | |
var ReactComponentTreeHook$3 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$2 = ReactDebugCurrentFiber_1; | |
var warning$14 = warning; | |
var didWarnValueNull = false; | |
function getStackAddendum$1(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$3.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$2.getCurrentFiberStackAddendum(); | |
} | |
} | |
function validateProperties$1(type, props, debugID /* Stack only */) { | |
if (type !== 'input' && type !== 'textarea' && type !== 'select') { | |
return; | |
} | |
if (props != null && props.value === null && !didWarnValueNull) { | |
warning$14(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', type, getStackAddendum$1(debugID)); | |
didWarnValueNull = true; | |
} | |
} | |
var ReactDOMNullInputValuePropHook$1 = { | |
// Fiber | |
validateProperties: validateProperties$1, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$1(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$1(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMNullInputValuePropHook_1 = ReactDOMNullInputValuePropHook$1; | |
var DOMProperty$5 = DOMProperty_1; | |
var EventPluginRegistry$4 = EventPluginRegistry_1; | |
var ReactComponentTreeHook$4 = ReactComponentTreeHook_1; | |
var ReactDebugCurrentFiber$3 = ReactDebugCurrentFiber_1; | |
var warning$15 = warning; | |
function getStackAddendum$2(debugID) { | |
if (debugID != null) { | |
// This can only happen on Stack | |
return ReactComponentTreeHook$4.getStackAddendumByID(debugID); | |
} else { | |
// This can only happen on Fiber | |
return ReactDebugCurrentFiber$3.getCurrentFiberStackAddendum(); | |
} | |
} | |
if (__DEV__) { | |
var reactProps = { | |
children: true, | |
dangerouslySetInnerHTML: true, | |
key: true, | |
ref: true, | |
autoFocus: true, | |
defaultValue: true, | |
defaultChecked: true, | |
innerHTML: true, | |
suppressContentEditableWarning: true, | |
onFocusIn: true, | |
onFocusOut: true | |
}; | |
var warnedProperties$1 = {}; | |
var validateProperty$1 = function (tagName, name, debugID) { | |
if (DOMProperty$5.properties.hasOwnProperty(name) || DOMProperty$5.isCustomAttribute(name)) { | |
return true; | |
} | |
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties$1.hasOwnProperty(name) && warnedProperties$1[name]) { | |
return true; | |
} | |
if (EventPluginRegistry$4.registrationNameModules.hasOwnProperty(name)) { | |
return true; | |
} | |
warnedProperties$1[name] = true; | |
var lowerCasedName = name.toLowerCase(); | |
// data-* attributes should be lowercase; suggest the lowercase version | |
var standardName = DOMProperty$5.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty$5.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty$5.getPossibleStandardName[lowerCasedName] : null; | |
var registrationName = EventPluginRegistry$4.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry$4.possibleRegistrationNames[lowerCasedName] : null; | |
if (standardName != null) { | |
warning$15(false, 'Unknown DOM property %s. Did you mean %s?%s', name, standardName, getStackAddendum$2(debugID)); | |
return true; | |
} else if (registrationName != null) { | |
warning$15(false, 'Unknown event handler property %s. Did you mean `%s`?%s', name, registrationName, getStackAddendum$2(debugID)); | |
return true; | |
} else { | |
// We were unable to guess which prop the user intended. | |
// It is likely that the user was just blindly spreading/forwarding props | |
// Components should be careful to only render valid props/attributes. | |
// Warning will be invoked in warnUnknownProperties to allow grouping. | |
return false; | |
} | |
}; | |
} | |
var warnUnknownProperties = function (type, props, debugID) { | |
var unknownProps = []; | |
for (var key in props) { | |
var isValid = validateProperty$1(type, key, debugID); | |
if (!isValid) { | |
unknownProps.push(key); | |
} | |
} | |
var unknownPropString = unknownProps.map(function (prop) { | |
return '`' + prop + '`'; | |
}).join(', '); | |
if (unknownProps.length === 1) { | |
warning$15(false, 'Unknown prop %s on <%s> tag. Remove this prop from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, type, getStackAddendum$2(debugID)); | |
} else if (unknownProps.length > 1) { | |
warning$15(false, 'Unknown props %s on <%s> tag. Remove these props from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, type, getStackAddendum$2(debugID)); | |
} | |
}; | |
function validateProperties$2(type, props, debugID /* Stack only */) { | |
if (type.indexOf('-') >= 0 || props.is) { | |
return; | |
} | |
warnUnknownProperties(type, props, debugID); | |
} | |
var ReactDOMUnknownPropertyHook$1 = { | |
// Fiber | |
validateProperties: validateProperties$2, | |
// Stack | |
onBeforeMountComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$2(element.type, element.props, debugID); | |
} | |
}, | |
onBeforeUpdateComponent: function (debugID, element) { | |
if (__DEV__ && element != null && typeof element.type === 'string') { | |
validateProperties$2(element.type, element.props, debugID); | |
} | |
} | |
}; | |
var ReactDOMUnknownPropertyHook_1 = ReactDOMUnknownPropertyHook$1; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var CSSPropertyOperations = CSSPropertyOperations_1; | |
var DOMNamespaces = DOMNamespaces_1; | |
var DOMProperty$2 = DOMProperty_1; | |
var DOMPropertyOperations = DOMPropertyOperations_1; | |
var EventPluginRegistry$3 = EventPluginRegistry_1; | |
var ReactBrowserEventEmitter$2 = ReactBrowserEventEmitter_1; | |
var ReactDOMFiberInput = ReactDOMFiberInput$1; | |
var ReactDOMFiberOption = ReactDOMFiberOption$1; | |
var ReactDOMFiberSelect = ReactDOMFiberSelect$1; | |
var ReactDOMFiberTextarea = ReactDOMFiberTextarea$1; | |
var _require$2 = ReactDebugCurrentFiber_1; | |
var getCurrentFiberOwnerName = _require$2.getCurrentFiberOwnerName; | |
var emptyFunction$1 = emptyFunction; | |
var invariant$8 = invariant; | |
var isEventSupported$2 = isEventSupported_1; | |
var setInnerHTML = setInnerHTML_1; | |
var setTextContent = setTextContent_1; | |
var inputValueTracking = inputValueTracking_1; | |
var warning$2 = warning; | |
if (__DEV__) { | |
var ReactDOMInvalidARIAHook = ReactDOMInvalidARIAHook_1; | |
var ReactDOMNullInputValuePropHook = ReactDOMNullInputValuePropHook_1; | |
var ReactDOMUnknownPropertyHook = ReactDOMUnknownPropertyHook_1; | |
var validateARIAProperties = ReactDOMInvalidARIAHook.validateProperties; | |
var validateInputPropertes = ReactDOMNullInputValuePropHook.validateProperties; | |
var validateUnknownPropertes = ReactDOMUnknownPropertyHook.validateProperties; | |
} | |
var didWarnShadyDOM = false; | |
var listenTo = ReactBrowserEventEmitter$2.listenTo; | |
var registrationNameModules = EventPluginRegistry$3.registrationNameModules; | |
var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML'; | |
var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning'; | |
var CHILDREN = 'children'; | |
var STYLE = 'style'; | |
var HTML = '__html'; | |
var HTML_NAMESPACE = DOMNamespaces.html; | |
var SVG_NAMESPACE = DOMNamespaces.svg; | |
var MATH_NAMESPACE = DOMNamespaces.mathml; | |
// Node type for document fragments (Node.DOCUMENT_FRAGMENT_NODE). | |
var DOC_FRAGMENT_TYPE = 11; | |
function getDeclarationErrorAddendum() { | |
var ownerName = getCurrentFiberOwnerName(); | |
if (ownerName) { | |
// TODO: also report the stack. | |
return '\n\nThis DOM node was rendered by `' + ownerName + '`.'; | |
} | |
return ''; | |
} | |
function assertValidProps(tag, props) { | |
if (!props) { | |
return; | |
} | |
// Note the use of `==` which checks for null or undefined. | |
if (voidElementTags[tag]) { | |
invariant$8(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must neither have `children` nor ' + 'use `dangerouslySetInnerHTML`.%s', tag, getDeclarationErrorAddendum()); | |
} | |
if (props.dangerouslySetInnerHTML != null) { | |
invariant$8(props.children == null, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'); | |
invariant$8(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.'); | |
} | |
if (__DEV__) { | |
warning$2(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.'); | |
warning$2(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, '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.'); | |
warning$2(props.onFocusIn == null && props.onFocusOut == null, '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.'); | |
} | |
invariant$8(props.style == null || typeof props.style === 'object', 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum()); | |
} | |
if (__DEV__) { | |
var validatePropertiesInDevelopment = function (type, props) { | |
validateARIAProperties(type, props); | |
validateInputPropertes(type, props); | |
validateUnknownPropertes(type, props); | |
}; | |
} | |
function ensureListeningTo(rootContainerElement, registrationName) { | |
if (__DEV__) { | |
// IE8 has no API for event capturing and the `onScroll` event doesn't | |
// bubble. | |
warning$2(registrationName !== 'onScroll' || isEventSupported$2('scroll', true), 'This browser doesn\'t support the `onScroll` event'); | |
} | |
var isDocumentFragment = rootContainerElement.nodeType === DOC_FRAGMENT_TYPE; | |
var doc = isDocumentFragment ? rootContainerElement : rootContainerElement.ownerDocument; | |
listenTo(registrationName, doc); | |
} | |
// There are so many media events, it makes sense to just | |
// maintain a list rather than create a `trapBubbledEvent` for each | |
var mediaEvents = { | |
topAbort: 'abort', | |
topCanPlay: 'canplay', | |
topCanPlayThrough: 'canplaythrough', | |
topDurationChange: 'durationchange', | |
topEmptied: 'emptied', | |
topEncrypted: 'encrypted', | |
topEnded: 'ended', | |
topError: 'error', | |
topLoadedData: 'loadeddata', | |
topLoadedMetadata: 'loadedmetadata', | |
topLoadStart: 'loadstart', | |
topPause: 'pause', | |
topPlay: 'play', | |
topPlaying: 'playing', | |
topProgress: 'progress', | |
topRateChange: 'ratechange', | |
topSeeked: 'seeked', | |
topSeeking: 'seeking', | |
topStalled: 'stalled', | |
topSuspend: 'suspend', | |
topTimeUpdate: 'timeupdate', | |
topVolumeChange: 'volumechange', | |
topWaiting: 'waiting' | |
}; | |
function trapClickOnNonInteractiveElement(node) { | |
// Mobile Safari does not fire properly bubble click events on | |
// non-interactive elements, which means delegated click listeners do not | |
// fire. The workaround for this bug involves attaching an empty click | |
// listener on the target node. | |
// http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html | |
// Just set it using the onclick property so that we don't have to manage any | |
// bookkeeping for it. Not sure if we need to clear it when the listener is | |
// removed. | |
// TODO: Only do this for the relevant Safaris maybe? | |
node.onclick = emptyFunction$1; | |
} | |
function trapBubbledEventsLocal(node, tag) { | |
// If a component renders to null or if another component fatals and causes | |
// the state of the tree to be corrupted, `node` here can be null. | |
// TODO: Make sure that we check isMounted before firing any of these events. | |
// TODO: Inline these below since we're calling this from an equivalent | |
// switch statement. | |
switch (tag) { | |
case 'iframe': | |
case 'object': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topLoad', 'load', node); | |
break; | |
case 'video': | |
case 'audio': | |
// Create listener for each media event | |
for (var event in mediaEvents) { | |
if (mediaEvents.hasOwnProperty(event)) { | |
ReactBrowserEventEmitter$2.trapBubbledEvent(event, mediaEvents[event], node); | |
} | |
} | |
break; | |
case 'source': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topError', 'error', node); | |
break; | |
case 'img': | |
case 'image': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topError', 'error', node); | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topLoad', 'load', node); | |
break; | |
case 'form': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topReset', 'reset', node); | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topSubmit', 'submit', node); | |
break; | |
case 'input': | |
case 'select': | |
case 'textarea': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topInvalid', 'invalid', node); | |
break; | |
case 'details': | |
ReactBrowserEventEmitter$2.trapBubbledEvent('topToggle', 'toggle', node); | |
break; | |
} | |
} | |
// 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 | |
}; | |
// For HTML, certain tags cannot have children. This has the same purpose as | |
// `omittedCloseTags` except that `menuitem` should still have its closing tag. | |
var voidElementTags = _extends({ | |
'menuitem': true | |
}, omittedCloseTags); | |
function isCustomComponent(tagName, props) { | |
return tagName.indexOf('-') >= 0 || props.is != null; | |
} | |
function setInitialDOMProperties(domElement, rootContainerElement, nextProps, isCustomComponentTag) { | |
for (var propKey in nextProps) { | |
var nextProp = nextProps[propKey]; | |
if (!nextProps.hasOwnProperty(propKey)) { | |
continue; | |
} | |
if (propKey === STYLE) { | |
if (__DEV__) { | |
if (nextProp) { | |
// Freeze the next style object so that we can assume it won't be | |
// mutated. We have already warned for this in the past. | |
Object.freeze(nextProp); | |
} | |
} | |
// Relies on `updateStylesByID` not mutating `styleUpdates`. | |
// TODO: call ReactInstrumentation.debugTool.onHostOperation in DEV. | |
CSSPropertyOperations.setValueForStyles(domElement, nextProp); | |
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
var nextHtml = nextProp ? nextProp[HTML] : undefined; | |
if (nextHtml != null) { | |
setInnerHTML(domElement, nextHtml); | |
} | |
} else if (propKey === CHILDREN) { | |
if (typeof nextProp === 'string') { | |
setTextContent(domElement, nextProp); | |
} else if (typeof nextProp === 'number') { | |
setTextContent(domElement, '' + nextProp); | |
} | |
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING) { | |
// Noop | |
} else if (registrationNameModules.hasOwnProperty(propKey)) { | |
if (nextProp) { | |
ensureListeningTo(rootContainerElement, propKey); | |
} | |
} else if (isCustomComponentTag) { | |
DOMPropertyOperations.setValueForAttribute(domElement, propKey, nextProp); | |
} else if (DOMProperty$2.properties[propKey] || DOMProperty$2.isCustomAttribute(propKey)) { | |
// If we're updating to null or undefined, we should remove the property | |
// from the DOM node instead of inadvertently setting to a string. This | |
// brings us in line with the same behavior we have on initial render. | |
if (nextProp != null) { | |
DOMPropertyOperations.setValueForProperty(domElement, propKey, nextProp); | |
} | |
} | |
} | |
} | |
function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) { | |
// TODO: Handle wasCustomComponentTag | |
for (var i = 0; i < updatePayload.length; i += 2) { | |
var propKey = updatePayload[i]; | |
var propValue = updatePayload[i + 1]; | |
if (propKey === STYLE) { | |
// TODO: call ReactInstrumentation.debugTool.onHostOperation in DEV. | |
CSSPropertyOperations.setValueForStyles(domElement, propValue); | |
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
setInnerHTML(domElement, propValue); | |
} else if (propKey === CHILDREN) { | |
setTextContent(domElement, propValue); | |
} else if (isCustomComponentTag) { | |
if (propValue != null) { | |
DOMPropertyOperations.setValueForAttribute(domElement, propKey, propValue); | |
} else { | |
DOMPropertyOperations.deleteValueForAttribute(domElement, propKey); | |
} | |
} else if (DOMProperty$2.properties[propKey] || DOMProperty$2.isCustomAttribute(propKey)) { | |
// If we're updating to null or undefined, we should remove the property | |
// from the DOM node instead of inadvertently setting to a string. This | |
// brings us in line with the same behavior we have on initial render. | |
if (propValue != null) { | |
DOMPropertyOperations.setValueForProperty(domElement, propKey, propValue); | |
} else { | |
DOMPropertyOperations.deleteValueForProperty(domElement, propKey); | |
} | |
} | |
} | |
} | |
// 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; | |
} | |
} | |
var ReactDOMFiberComponent$1 = { | |
getChildNamespace: function (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; | |
}, | |
createElement: function (type, props, rootContainerElement, parentNamespace) { | |
// We create tags in the namespace of their parent container, except HTML | |
// tags get no namespace. | |
var ownerDocument = rootContainerElement.ownerDocument; | |
var domElement; | |
var namespaceURI = parentNamespace; | |
if (namespaceURI === HTML_NAMESPACE) { | |
namespaceURI = getIntrinsicNamespace(type); | |
} | |
if (namespaceURI === HTML_NAMESPACE) { | |
if (__DEV__) { | |
warning$2(type === type.toLowerCase() || isCustomComponent(type, props), '<%s /> is using uppercase HTML. Always use lowercase HTML tags ' + 'in React.', type); | |
} | |
if (type === 'script') { | |
// Create the script via .innerHTML so its "parser-inserted" flag is | |
// set to true and it does not execute | |
var div = ownerDocument.createElement('div'); | |
div.innerHTML = '<script><' + '/script>'; // eslint-disable-line | |
// This is guaranteed to yield a script element. | |
var firstChild = div.firstChild; | |
domElement = div.removeChild(firstChild); | |
} else if (props.is) { | |
domElement = ownerDocument.createElement(type, props.is); | |
} else { | |
// Separate else branch instead of using `props.is || undefined` above because of a Firefox bug. | |
// See discussion in https://github.com/facebook/react/pull/6896 | |
// and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 | |
domElement = ownerDocument.createElement(type); | |
} | |
} else { | |
domElement = ownerDocument.createElementNS(namespaceURI, type); | |
} | |
return domElement; | |
}, | |
setInitialProperties: function (domElement, tag, rawProps, rootContainerElement) { | |
var isCustomComponentTag = isCustomComponent(tag, rawProps); | |
if (__DEV__) { | |
validatePropertiesInDevelopment(tag, rawProps); | |
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) { | |
warning$2(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerName() || 'A component'); | |
didWarnShadyDOM = true; | |
} | |
} | |
var props; | |
switch (tag) { | |
case 'audio': | |
case 'form': | |
case 'iframe': | |
case 'img': | |
case 'image': | |
case 'link': | |
case 'object': | |
case 'source': | |
case 'video': | |
case 'details': | |
trapBubbledEventsLocal(domElement, tag); | |
props = rawProps; | |
break; | |
case 'input': | |
ReactDOMFiberInput.mountWrapper(domElement, rawProps); | |
props = ReactDOMFiberInput.getHostProps(domElement, rawProps); | |
trapBubbledEventsLocal(domElement, tag); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(rootContainerElement, 'onChange'); | |
break; | |
case 'option': | |
ReactDOMFiberOption.mountWrapper(domElement, rawProps); | |
props = ReactDOMFiberOption.getHostProps(domElement, rawProps); | |
break; | |
case 'select': | |
ReactDOMFiberSelect.mountWrapper(domElement, rawProps); | |
props = ReactDOMFiberSelect.getHostProps(domElement, rawProps); | |
trapBubbledEventsLocal(domElement, tag); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(rootContainerElement, 'onChange'); | |
break; | |
case 'textarea': | |
ReactDOMFiberTextarea.mountWrapper(domElement, rawProps); | |
props = ReactDOMFiberTextarea.getHostProps(domElement, rawProps); | |
trapBubbledEventsLocal(domElement, tag); | |
// For controlled components we always need to ensure we're listening | |
// to onChange. Even if there is no listener. | |
ensureListeningTo(rootContainerElement, 'onChange'); | |
break; | |
default: | |
props = rawProps; | |
} | |
assertValidProps(tag, props); | |
setInitialDOMProperties(domElement, rootContainerElement, props, isCustomComponentTag); | |
switch (tag) { | |
case 'input': | |
// TODO: Make sure we check if this is still unmounted or do any clean | |
// up necessary since we never stop tracking anymore. | |
inputValueTracking.trackNode(domElement); | |
ReactDOMFiberInput.postMountWrapper(domElement, rawProps); | |
break; | |
case 'textarea': | |
// TODO: Make sure we check if this is still unmounted or do any clean | |
// up necessary since we never stop tracking anymore. | |
inputValueTracking.trackNode(domElement); | |
ReactDOMFiberTextarea.postMountWrapper(domElement, rawProps); | |
break; | |
case 'option': | |
ReactDOMFiberOption.postMountWrapper(domElement, rawProps); | |
break; | |
default: | |
if (typeof props.onClick === 'function') { | |
// TODO: This cast may not be sound for SVG, MathML or custom elements. | |
trapClickOnNonInteractiveElement(domElement); | |
} | |
break; | |
} | |
}, | |
// Calculate the diff between the two objects. | |
diffProperties: function (domElement, tag, lastRawProps, nextRawProps, rootContainerElement) { | |
if (__DEV__) { | |
validatePropertiesInDevelopment(tag, nextRawProps); | |
} | |
var updatePayload = null; | |
var lastProps; | |
var nextProps; | |
switch (tag) { | |
case 'input': | |
lastProps = ReactDOMFiberInput.getHostProps(domElement, lastRawProps); | |
nextProps = ReactDOMFiberInput.getHostProps(domElement, nextRawProps); | |
updatePayload = []; | |
break; | |
case 'option': | |
lastProps = ReactDOMFiberOption.getHostProps(domElement, lastRawProps); | |
nextProps = ReactDOMFiberOption.getHostProps(domElement, nextRawProps); | |
updatePayload = []; | |
break; | |
case 'select': | |
lastProps = ReactDOMFiberSelect.getHostProps(domElement, lastRawProps); | |
nextProps = ReactDOMFiberSelect.getHostProps(domElement, nextRawProps); | |
updatePayload = []; | |
break; | |
case 'textarea': | |
lastProps = ReactDOMFiberTextarea.getHostProps(domElement, lastRawProps); | |
nextProps = ReactDOMFiberTextarea.getHostProps(domElement, nextRawProps); | |
updatePayload = []; | |
break; | |
default: | |
lastProps = lastRawProps; | |
nextProps = nextRawProps; | |
if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') { | |
// TODO: This cast may not be sound for SVG, MathML or custom elements. | |
trapClickOnNonInteractiveElement(domElement); | |
} | |
break; | |
} | |
assertValidProps(tag, nextProps); | |
var propKey; | |
var styleName; | |
var styleUpdates = null; | |
for (propKey in lastProps) { | |
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) { | |
continue; | |
} | |
if (propKey === STYLE) { | |
var lastStyle = lastProps[propKey]; | |
for (styleName in lastStyle) { | |
if (lastStyle.hasOwnProperty(styleName)) { | |
if (!styleUpdates) { | |
styleUpdates = {}; | |
} | |
styleUpdates[styleName] = ''; | |
} | |
} | |
} else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) { | |
// Noop. This is handled by the clear text mechanism. | |
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING) { | |
// Noop | |
} else if (registrationNameModules.hasOwnProperty(propKey)) { | |
// This is a special case. If any listener updates we need to ensure | |
// that the "current" fiber pointer gets updated so we need a commit | |
// to update this element. | |
if (!updatePayload) { | |
updatePayload = []; | |
} | |
} else { | |
// For all other deleted properties we add it to the queue. We use | |
// the whitelist in the commit phase instead. | |
(updatePayload = updatePayload || []).push(propKey, null); | |
} | |
} | |
for (propKey in nextProps) { | |
var nextProp = nextProps[propKey]; | |
var lastProp = lastProps != null ? lastProps[propKey] : undefined; | |
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) { | |
continue; | |
} | |
if (propKey === STYLE) { | |
if (__DEV__) { | |
if (nextProp) { | |
// Freeze the next style object so that we can assume it won't be | |
// mutated. We have already warned for this in the past. | |
Object.freeze(nextProp); | |
} | |
} | |
if (lastProp) { | |
// Unset styles on `lastProp` but not on `nextProp`. | |
for (styleName in lastProp) { | |
if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) { | |
if (!styleUpdates) { | |
styleUpdates = {}; | |
} | |
styleUpdates[styleName] = ''; | |
} | |
} | |
// Update styles that changed since `lastProp`. | |
for (styleName in nextProp) { | |
if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) { | |
if (!styleUpdates) { | |
styleUpdates = {}; | |
} | |
styleUpdates[styleName] = nextProp[styleName]; | |
} | |
} | |
} else { | |
// Relies on `updateStylesByID` not mutating `styleUpdates`. | |
if (!styleUpdates) { | |
if (!updatePayload) { | |
updatePayload = []; | |
} | |
updatePayload.push(propKey, styleUpdates); | |
} | |
styleUpdates = nextProp; | |
} | |
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) { | |
var nextHtml = nextProp ? nextProp[HTML] : undefined; | |
var lastHtml = lastProp ? lastProp[HTML] : undefined; | |
if (nextHtml != null) { | |
if (lastHtml !== nextHtml) { | |
(updatePayload = updatePayload || []).push(propKey, '' + nextHtml); | |
} | |
} else { | |
// TODO: It might be too late to clear this if we have children | |
// inserted already. | |
} | |
} else if (propKey === CHILDREN) { | |
if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) { | |
(updatePayload = updatePayload || []).push(propKey, '' + nextProp); | |
} | |
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING) { | |
// Noop | |
} else if (registrationNameModules.hasOwnProperty(propKey)) { | |
if (nextProp) { | |
// We eagerly listen to this even though we haven't committed yet. | |
ensureListeningTo(rootContainerElement, propKey); | |
} | |
if (!updatePayload && lastProp !== nextProp) { | |
// This is a special case. If any listener updates we need to ensure | |
// that the "current" props pointer gets updated so we need a commit | |
// to update this element. | |
updatePayload = []; | |
} | |
} else { | |
// For any other property we always add it to the queue and then we | |
// filter it out using the whitelist during the commit. | |
(updatePayload = updatePayload || []).push(propKey, nextProp); | |
} | |
} | |
if (styleUpdates) { | |
(updatePayload = updatePayload || []).push(STYLE, styleUpdates); | |
} | |
return updatePayload; | |
}, | |
// Apply the diff. | |
updateProperties: function (domElement, updatePayload, tag, lastRawProps, nextRawProps) { | |
var wasCustomComponentTag = isCustomComponent(tag, lastRawProps); | |
var isCustomComponentTag = isCustomComponent(tag, nextRawProps); | |
// Apply the diff. | |
updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); | |
// TODO: Ensure that an update gets scheduled if any of the special props | |
// changed. | |
switch (tag) { | |
case 'input': | |
// Update the wrapper around inputs *after* updating props. This has to | |
// happen after `updateDOMProperties`. Otherwise HTML5 input validations | |
// raise warnings and prevent the new value from being assigned. | |
ReactDOMFiberInput.updateWrapper(domElement, nextRawProps); | |
break; | |
case 'textarea': | |
ReactDOMFiberTextarea.updateWrapper(domElement, nextRawProps); | |
break; | |
case 'select': | |
// <select> value update needs to occur after <option> children | |
// reconciliation | |
ReactDOMFiberSelect.postUpdateWrapper(domElement, nextRawProps); | |
break; | |
} | |
}, | |
restoreControlledState: function (domElement, tag, props) { | |
switch (tag) { | |
case 'input': | |
ReactDOMFiberInput.restoreControlledState(domElement, props); | |
return; | |
case 'textarea': | |
ReactDOMFiberTextarea.restoreControlledState(domElement, props); | |
return; | |
case 'select': | |
ReactDOMFiberSelect.restoreControlledState(domElement, props); | |
return; | |
} | |
} | |
}; | |
var ReactDOMFiberComponent_1 = ReactDOMFiberComponent$1; | |
// This a built-in polyfill for requestIdleCallback. It works by scheduling | |
// a requestAnimationFrame, store the time for the start of the frame, then | |
// schedule a postMessage which gets scheduled after paint. Within the | |
// postMessage handler do as much work as possible until time + frame rate. | |
// By separating the idle call into a separate event tick we ensure that | |
// layout, paint and other browser work is counted against the available time. | |
// The frame rate is dynamically adjusted. | |
var invariant$12 = invariant; | |
// TODO: There's no way to cancel these, because Fiber doesn't atm. | |
var rAF = void 0; | |
var rIC = void 0; | |
if (typeof requestAnimationFrame !== 'function') { | |
invariant$12(false, 'React depends on requestAnimationFrame. Make sure that you load a ' + 'polyfill in older browsers.'); | |
} else if (typeof requestIdleCallback !== 'function') { | |
// Wrap requestAnimationFrame and polyfill requestIdleCallback. | |
var scheduledRAFCallback = null; | |
var scheduledRICCallback = null; | |
var isIdleScheduled = false; | |
var isAnimationFrameScheduled = false; | |
var frameDeadline = 0; | |
// We start out assuming that we run at 30fps but then the heuristic tracking | |
// will adjust this value to a faster fps if we get more frequent animation | |
// frames. | |
var previousFrameTime = 33; | |
var activeFrameTime = 33; | |
var frameDeadlineObject = { | |
timeRemaining: typeof performance === 'object' && typeof performance.now === 'function' ? function () { | |
// We assume that if we have a performance timer that the rAF callback | |
// gets a performance timer value. Not sure if this is always true. | |
return frameDeadline - performance.now(); | |
} : function () { | |
// As a fallback we use Date.now. | |
return frameDeadline - Date.now(); | |
} | |
}; | |
// We use the postMessage trick to defer idle work until after the repaint. | |
var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2); | |
var idleTick = function (event) { | |
if (event.source !== window || event.data !== messageKey) { | |
return; | |
} | |
isIdleScheduled = false; | |
var callback = scheduledRICCallback; | |
scheduledRICCallback = null; | |
if (callback) { | |
callback(frameDeadlineObject); | |
} | |
}; | |
// Assumes that we have addEventListener in this environment. Might need | |
// something better for old IE. | |
window.addEventListener('message', idleTick, false); | |
var animationTick = function (rafTime) { | |
isAnimationFrameScheduled = false; | |
var nextFrameTime = rafTime - frameDeadline + activeFrameTime; | |
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { | |
if (nextFrameTime < 8) { | |
// Defensive coding. We don't support higher frame rates than 120hz. | |
// If we get lower than that, it is probably a bug. | |
nextFrameTime = 8; | |
} | |
// If one frame goes long, then the next one can be short to catch up. | |
// If two frames are short in a row, then that's an indication that we | |
// actually have a higher frame rate than what we're currently optimizing. | |
// We adjust our heuristic dynamically accordingly. For example, if we're | |
// running on 120hz display or 90hz VR display. | |
// Take the max of the two in case one of them was an anomaly due to | |
// missed frame deadlines. | |
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; | |
} else { | |
previousFrameTime = nextFrameTime; | |
} | |
frameDeadline = rafTime + activeFrameTime; | |
if (!isIdleScheduled) { | |
isIdleScheduled = true; | |
window.postMessage(messageKey, '*'); | |
} | |
var callback = scheduledRAFCallback; | |
scheduledRAFCallback = null; | |
if (callback) { | |
callback(rafTime); | |
} | |
}; | |
rAF = function (callback) { | |
// This assumes that we only schedule one callback at a time because that's | |
// how Fiber uses it. | |
scheduledRAFCallback = callback; | |
if (!isAnimationFrameScheduled) { | |
// If rIC didn't already schedule one, we need to schedule a frame. | |
isAnimationFrameScheduled = true; | |
requestAnimationFrame(animationTick); | |
} | |
return 0; | |
}; | |
rIC = function (callback) { | |
// This assumes that we only schedule one callback at a time because that's | |
// how Fiber uses it. | |
scheduledRICCallback = callback; | |
if (!isAnimationFrameScheduled) { | |
// If rAF didn't already schedule one, we need to schedule a frame. | |
// TODO: If this rAF doesn't materialize because the browser throttles, we | |
// might want to still have setTimeout trigger rIC as a backup to ensure | |
// that we keep performing work. | |
isAnimationFrameScheduled = true; | |
requestAnimationFrame(animationTick); | |
} | |
return 0; | |
}; | |
} else { | |
rAF = requestAnimationFrame; | |
rIC = requestIdleCallback; | |
} | |
var rAF_1 = rAF; | |
var rIC_1 = rIC; | |
var ReactDOMFrameScheduling$1 = { | |
rAF: rAF_1, | |
rIC: rIC_1 | |
}; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule ARIADOMPropertyConfig | |
*/ | |
var ARIADOMPropertyConfig$1 = { | |
Properties: { | |
// Global States and Properties | |
'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 | |
}, | |
DOMAttributeNames: {}, | |
DOMPropertyNames: {} | |
}; | |
var ARIADOMPropertyConfig_1 = ARIADOMPropertyConfig$1; | |
var _require$8 = ReactTypeOfWork; | |
var HostComponent$2 = _require$8.HostComponent; | |
function getParent(inst) { | |
if (inst._hostParent !== undefined) { | |
return inst._hostParent; | |
} | |
if (typeof inst.tag === 'number') { | |
do { | |
inst = inst['return']; | |
// TODO: If this is a HostRoot we might want to bail out. | |
// That is depending on if we want nested subtrees (layers) to bubble | |
// events to their parent. We could also go through parentNode on the | |
// host node but that wouldn't work for React Native and doesn't let us | |
// do the portal feature. | |
} while (inst && inst.tag !== HostComponent$2); | |
if (inst) { | |
return inst; | |
} | |
} | |
return null; | |
} | |
/** | |
* Return the lowest common ancestor of A and B, or null if they are in | |
* different trees. | |
*/ | |
function getLowestCommonAncestor(instA, instB) { | |
var depthA = 0; | |
for (var tempA = instA; tempA; tempA = getParent(tempA)) { | |
depthA++; | |
} | |
var depthB = 0; | |
for (var tempB = instB; tempB; tempB = getParent(tempB)) { | |
depthB++; | |
} | |
// If A is deeper, crawl up. | |
while (depthA - depthB > 0) { | |
instA = getParent(instA); | |
depthA--; | |
} | |
// If B is deeper, crawl up. | |
while (depthB - depthA > 0) { | |
instB = getParent(instB); | |
depthB--; | |
} | |
// Walk in lockstep until we find a match. | |
var depth = depthA; | |
while (depth--) { | |
if (instA === instB || instA === instB.alternate) { | |
return instA; | |
} | |
instA = getParent(instA); | |
instB = getParent(instB); | |
} | |
return null; | |
} | |
/** | |
* Return if A is an ancestor of B. | |
*/ | |
function isAncestor(instA, instB) { | |
while (instB) { | |
if (instA === instB || instA === instB.alternate) { | |
return true; | |
} | |
instB = getParent(instB); | |
} | |
return false; | |
} | |
/** | |
* Return the parent instance of the passed-in instance. | |
*/ | |
function getParentInstance(inst) { | |
return getParent(inst); | |
} | |
/** | |
* Simulates the traversal of a two-phase, capture/bubble event dispatch. | |
*/ | |
function traverseTwoPhase(inst, fn, arg) { | |
var path = []; | |
while (inst) { | |
path.push(inst); | |
inst = getParent(inst); | |
} | |
var i; | |
for (i = path.length; i-- > 0;) { | |
fn(path[i], 'captured', arg); | |
} | |
for (i = 0; i < path.length; i++) { | |
fn(path[i], 'bubbled', arg); | |
} | |
} | |
/** | |
* Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that | |
* should would receive a `mouseEnter` or `mouseLeave` event. | |
* | |
* Does not invoke the callback on the nearest common ancestor because nothing | |
* "entered" or "left" that element. | |
*/ | |
function traverseEnterLeave(from, to, fn, argFrom, argTo) { | |
var common = from && to ? getLowestCommonAncestor(from, to) : null; | |
var pathFrom = []; | |
while (from && from !== common) { | |
pathFrom.push(from); | |
from = getParent(from); | |
} | |
var pathTo = []; | |
while (to && to !== common) { | |
pathTo.push(to); | |
to = getParent(to); | |
} | |
var i; | |
for (i = 0; i < pathFrom.length; i++) { | |
fn(pathFrom[i], 'bubbled', argFrom); | |
} | |
for (i = pathTo.length; i-- > 0;) { | |
fn(pathTo[i], 'captured', argTo); | |
} | |
} | |
var ReactTreeTraversal$1 = { | |
isAncestor: isAncestor, | |
getLowestCommonAncestor: getLowestCommonAncestor, | |
getParentInstance: getParentInstance, | |
traverseTwoPhase: traverseTwoPhase, | |
traverseEnterLeave: traverseEnterLeave | |
}; | |
var EventPluginHub$3 = EventPluginHub_1; | |
var ReactTreeTraversal = ReactTreeTraversal$1; | |
var accumulateInto$2 = accumulateInto_1; | |
var forEachAccumulated$2 = forEachAccumulated_1; | |
var warning$16 = warning; | |
var getListener = EventPluginHub$3.getListener; | |
/** | |
* Some event types have a notion of different registration names for different | |
* "phases" of propagation. This finds listeners by a given phase. | |
*/ | |
function listenerAtPhase(inst, event, propagationPhase) { | |
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; | |
return getListener(inst, registrationName); | |
} | |
/** | |
* Tags a `SyntheticEvent` with dispatched listeners. Creating this function | |
* here, allows us to not have to bind or create functions for each event. | |
* Mutating the event's members allows us to not have to create a wrapping | |
* "dispatch" object that pairs the event with the listener. | |
*/ | |
function accumulateDirectionalDispatches(inst, phase, event) { | |
if (__DEV__) { | |
warning$16(inst, 'Dispatching inst must not be null'); | |
} | |
var listener = listenerAtPhase(inst, event, phase); | |
if (listener) { | |
event._dispatchListeners = accumulateInto$2(event._dispatchListeners, listener); | |
event._dispatchInstances = accumulateInto$2(event._dispatchInstances, inst); | |
} | |
} | |
/** | |
* Collect dispatches (must be entirely collected before dispatching - see unit | |
* tests). Lazily allocate the array to conserve memory. We must loop through | |
* each event and perform the traversal for each one. We cannot perform a | |
* single traversal for the entire collection of events because each event may | |
* have a different target. | |
*/ | |
function accumulateTwoPhaseDispatchesSingle(event) { | |
if (event && event.dispatchConfig.phasedRegistrationNames) { | |
ReactTreeTraversal.traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); | |
} | |
} | |
/** | |
* Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. | |
*/ | |
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { | |
if (event && event.dispatchConfig.phasedRegistrationNames) { | |
var targetInst = event._targetInst; | |
var parentInst = targetInst ? ReactTreeTraversal.getParentInstance(targetInst) : null; | |
ReactTreeTraversal.traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); | |
} | |
} | |
/** | |
* Accumulates without regard to direction, does not look for phased | |
* registration names. Same as `accumulateDirectDispatchesSingle` but without | |
* requiring that the `dispatchMarker` be the same as the dispatched ID. | |
*/ | |
function accumulateDispatches(inst, ignoredDirection, event) { | |
if (event && event.dispatchConfig.registrationName) { | |
var registrationName = event.dispatchConfig.registrationName; | |
var listener = getListener(inst, registrationName); | |
if (listener) { | |
event._dispatchListeners = accumulateInto$2(event._dispatchListeners, listener); | |
event._dispatchInstances = accumulateInto$2(event._dispatchInstances, inst); | |
} | |
} | |
} | |
/** | |
* Accumulates dispatches on an `SyntheticEvent`, but only for the | |
* `dispatchMarker`. | |
* @param {SyntheticEvent} event | |
*/ | |
function accumulateDirectDispatchesSingle(event) { | |
if (event && event.dispatchConfig.registrationName) { | |
accumulateDispatches(event._targetInst, null, event); | |
} | |
} | |
function accumulateTwoPhaseDispatches(events) { | |
forEachAccumulated$2(events, accumulateTwoPhaseDispatchesSingle); | |
} | |
function accumulateTwoPhaseDispatchesSkipTarget(events) { | |
forEachAccumulated$2(events, accumulateTwoPhaseDispatchesSingleSkipTarget); | |
} | |
function accumulateEnterLeaveDispatches(leave, enter, from, to) { | |
ReactTreeTraversal.traverseEnterLeave(from, to, accumulateDispatches, leave, enter); | |
} | |
function accumulateDirectDispatches(events) { | |
forEachAccumulated$2(events, accumulateDirectDispatchesSingle); | |
} | |
/** | |
* A small set of propagation patterns, each of which will accept a small amount | |
* of information, and generate a set of "dispatch ready event objects" - which | |
* are sets of events that have already been annotated with a set of dispatched | |
* listener functions/ids. The API is designed this way to discourage these | |
* propagation strategies from actually executing the dispatches, since we | |
* always want to collect the entire set of dispatches before executing even a | |
* single one. | |
* | |
* @constructor EventPropagators | |
*/ | |
var EventPropagators$1 = { | |
accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches, | |
accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget, | |
accumulateDirectDispatches: accumulateDirectDispatches, | |
accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches | |
}; | |
var EventPropagators_1 = EventPropagators$1; | |
var invariant$13 = invariant; | |
/** | |
* Static poolers. Several custom versions for each potential number of | |
* arguments. A completely generic pooler is easy to implement, but would | |
* require accessing the `arguments` object. In each of these, `this` refers to | |
* the Class itself, not an instance. If any others are needed, simply add them | |
* here, or in their own files. | |
*/ | |
var oneArgumentPooler = function (copyFieldsFrom) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, copyFieldsFrom); | |
return instance; | |
} else { | |
return new Klass(copyFieldsFrom); | |
} | |
}; | |
var twoArgumentPooler = function (a1, a2) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2); | |
return instance; | |
} else { | |
return new Klass(a1, a2); | |
} | |
}; | |
var threeArgumentPooler = function (a1, a2, a3) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3); | |
} | |
}; | |
var fourArgumentPooler = function (a1, a2, a3, a4) { | |
var Klass = this; | |
if (Klass.instancePool.length) { | |
var instance = Klass.instancePool.pop(); | |
Klass.call(instance, a1, a2, a3, a4); | |
return instance; | |
} else { | |
return new Klass(a1, a2, a3, a4); | |
} | |
}; | |
var standardReleaser = function (instance) { | |
var Klass = this; | |
invariant$13(instance instanceof Klass, 'Trying to release an instance into a pool of a different type.'); | |
instance.destructor(); | |
if (Klass.instancePool.length < Klass.poolSize) { | |
Klass.instancePool.push(instance); | |
} | |
}; | |
var DEFAULT_POOL_SIZE = 10; | |
var DEFAULT_POOLER = oneArgumentPooler; | |
/** | |
* Augments `CopyConstructor` to be a poolable class, augmenting only the class | |
* itself (statically) not adding any prototypical fields. Any CopyConstructor | |
* you give this may have a `poolSize` property, and will look for a | |
* prototypical `destructor` on instances. | |
* | |
* @param {Function} CopyConstructor Constructor that can be used to reset. | |
* @param {Function} pooler Customizable pooler. | |
*/ | |
var addPoolingTo = function (CopyConstructor, pooler) { | |
// Casting as any so that flow ignores the actual implementation and trusts | |
// it to match the type we declared | |
var NewKlass = CopyConstructor; | |
NewKlass.instancePool = []; | |
NewKlass.getPooled = pooler || DEFAULT_POOLER; | |
if (!NewKlass.poolSize) { | |
NewKlass.poolSize = DEFAULT_POOL_SIZE; | |
} | |
NewKlass.release = standardReleaser; | |
return NewKlass; | |
}; | |
var PooledClass$1 = { | |
addPoolingTo: addPoolingTo, | |
oneArgumentPooler: oneArgumentPooler, | |
twoArgumentPooler: twoArgumentPooler, | |
threeArgumentPooler: threeArgumentPooler, | |
fourArgumentPooler: fourArgumentPooler | |
}; | |
var PooledClass_1 = PooledClass$1; | |
var ExecutionEnvironment$7 = ExecutionEnvironment; | |
var contentKey = null; | |
/** | |
* Gets the key used to access text content on a DOM node. | |
* | |
* @return {?string} Key used to access text content. | |
* @internal | |
*/ | |
function getTextContentAccessor$1() { | |
if (!contentKey && ExecutionEnvironment$7.canUseDOM) { | |
// Prefer textContent to innerText because many browsers support both but | |
// SVG <text> elements don't support innerText even when <div> does. | |
contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText'; | |
} | |
return contentKey; | |
} | |
var getTextContentAccessor_1 = getTextContentAccessor$1; | |
var PooledClass = PooledClass_1; | |
var getTextContentAccessor = getTextContentAccessor_1; | |
/** | |
* This helper class stores information about text content of a target node, | |
* allowing comparison of content before and after a given event. | |
* | |
* Identify the node where selection currently begins, then observe | |
* both its text content and its current position in the DOM. Since the | |
* browser may natively replace the target node during composition, we can | |
* use its position to find its replacement. | |
* | |
* @param {DOMEventTarget} root | |
*/ | |
function FallbackCompositionState$1(root) { | |
this._root = root; | |
this._startText = this.getText(); | |
this._fallbackText = null; | |
} | |
Object.assign(FallbackCompositionState$1.prototype, { | |
destructor: function () { | |
this._root = null; | |
this._startText = null; | |
this._fallbackText = null; | |
}, | |
/** | |
* Get current text of input. | |
* | |
* @return {string} | |
*/ | |
getText: function () { | |
if ('value' in this._root) { | |
return this._root.value; | |
} | |
return this._root[getTextContentAccessor()]; | |
}, | |
/** | |
* Determine the differing substring between the initially stored | |
* text content and the current content. | |
* | |
* @return {string} | |
*/ | |
getData: function () { | |
if (this._fallbackText) { | |
return this._fallbackText; | |
} | |
var start; | |
var startValue = this._startText; | |
var startLength = startValue.length; | |
var end; | |
var endValue = this.getText(); | |
var endLength = endValue.length; | |
for (start = 0; start < startLength; start++) { | |
if (startValue[start] !== endValue[start]) { | |
break; | |
} | |
} | |
var minEnd = startLength - start; | |
for (end = 1; end <= minEnd; end++) { | |
if (startValue[startLength - end] !== endValue[endLength - end]) { | |
break; | |
} | |
} | |
var sliceTail = end > 1 ? 1 - end : undefined; | |
this._fallbackText = endValue.slice(start, sliceTail); | |
return this._fallbackText; | |
} | |
}); | |
PooledClass.addPoolingTo(FallbackCompositionState$1); | |
var FallbackCompositionState_1 = FallbackCompositionState$1; | |
var PooledClass$2 = PooledClass_1; | |
var emptyFunction$2 = emptyFunction; | |
var warning$17 = warning; | |
var didWarnForAddedNewProperty = false; | |
var isProxySupported = typeof Proxy === 'function'; | |
var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances']; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/ | |
*/ | |
var EventInterface = { | |
type: null, | |
target: null, | |
// currentTarget is set when dispatching; no use in copying it here | |
currentTarget: emptyFunction$2.thatReturnsNull, | |
eventPhase: null, | |
bubbles: null, | |
cancelable: null, | |
timeStamp: function (event) { | |
return event.timeStamp || Date.now(); | |
}, | |
defaultPrevented: null, | |
isTrusted: null | |
}; | |
/** | |
* Synthetic events are dispatched by event plugins, typically in response to a | |
* top-level event delegation handler. | |
* | |
* These systems should generally use pooling to reduce the frequency of garbage | |
* collection. The system should check `isPersistent` to determine whether the | |
* event should be released into the pool after being dispatched. Users that | |
* need a persisted event should invoke `persist`. | |
* | |
* Synthetic events (and subclasses) implement the DOM Level 3 Events API by | |
* normalizing browser quirks. Subclasses do not necessarily have to implement a | |
* DOM interface; custom application-specific events can also subclass this. | |
* | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {*} targetInst Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @param {DOMEventTarget} nativeEventTarget Target node. | |
*/ | |
function SyntheticEvent$1(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) { | |
if (__DEV__) { | |
// these have a getter/setter for warnings | |
delete this.nativeEvent; | |
delete this.preventDefault; | |
delete this.stopPropagation; | |
} | |
this.dispatchConfig = dispatchConfig; | |
this._targetInst = targetInst; | |
this.nativeEvent = nativeEvent; | |
var Interface = this.constructor.Interface; | |
for (var propName in Interface) { | |
if (!Interface.hasOwnProperty(propName)) { | |
continue; | |
} | |
if (__DEV__) { | |
delete this[propName]; // this has a getter/setter for warnings | |
} | |
var normalize = Interface[propName]; | |
if (normalize) { | |
this[propName] = normalize(nativeEvent); | |
} else { | |
if (propName === 'target') { | |
this.target = nativeEventTarget; | |
} else { | |
this[propName] = nativeEvent[propName]; | |
} | |
} | |
} | |
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false; | |
if (defaultPrevented) { | |
this.isDefaultPrevented = emptyFunction$2.thatReturnsTrue; | |
} else { | |
this.isDefaultPrevented = emptyFunction$2.thatReturnsFalse; | |
} | |
this.isPropagationStopped = emptyFunction$2.thatReturnsFalse; | |
return this; | |
} | |
Object.assign(SyntheticEvent$1.prototype, { | |
preventDefault: function () { | |
this.defaultPrevented = true; | |
var event = this.nativeEvent; | |
if (!event) { | |
return; | |
} | |
if (event.preventDefault) { | |
event.preventDefault(); | |
} else if (typeof event.returnValue !== 'unknown') { | |
// eslint-disable-line valid-typeof | |
event.returnValue = false; | |
} | |
this.isDefaultPrevented = emptyFunction$2.thatReturnsTrue; | |
}, | |
stopPropagation: function () { | |
var event = this.nativeEvent; | |
if (!event) { | |
return; | |
} | |
if (event.stopPropagation) { | |
event.stopPropagation(); | |
} else if (typeof event.cancelBubble !== 'unknown') { | |
// eslint-disable-line valid-typeof | |
// The ChangeEventPlugin registers a "propertychange" event for | |
// IE. This event does not support bubbling or cancelling, and | |
// any references to cancelBubble throw "Member not found". A | |
// typeof check of "unknown" circumvents this issue (and is also | |
// IE specific). | |
event.cancelBubble = true; | |
} | |
this.isPropagationStopped = emptyFunction$2.thatReturnsTrue; | |
}, | |
/** | |
* We release all dispatched `SyntheticEvent`s after each event loop, adding | |
* them back into the pool. This allows a way to hold onto a reference that | |
* won't be added back into the pool. | |
*/ | |
persist: function () { | |
this.isPersistent = emptyFunction$2.thatReturnsTrue; | |
}, | |
/** | |
* Checks if this event should be released back into the pool. | |
* | |
* @return {boolean} True if this should not be released, false otherwise. | |
*/ | |
isPersistent: emptyFunction$2.thatReturnsFalse, | |
/** | |
* `PooledClass` looks for `destructor` on each instance it releases. | |
*/ | |
destructor: function () { | |
var Interface = this.constructor.Interface; | |
for (var propName in Interface) { | |
if (__DEV__) { | |
Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName])); | |
} else { | |
this[propName] = null; | |
} | |
} | |
for (var i = 0; i < shouldBeReleasedProperties.length; i++) { | |
this[shouldBeReleasedProperties[i]] = null; | |
} | |
if (__DEV__) { | |
Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null)); | |
Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', emptyFunction$2)); | |
Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', emptyFunction$2)); | |
} | |
} | |
}); | |
SyntheticEvent$1.Interface = EventInterface; | |
if (__DEV__) { | |
if (isProxySupported) { | |
/*eslint-disable no-func-assign */ | |
SyntheticEvent$1 = new Proxy(SyntheticEvent$1, { | |
construct: function (target, args) { | |
return this.apply(target, Object.create(target.prototype), args); | |
}, | |
apply: function (constructor, that, args) { | |
return new Proxy(constructor.apply(that, args), { | |
set: function (target, prop, value) { | |
if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) { | |
warning$17(didWarnForAddedNewProperty || target.isPersistent(), 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re adding a new property in the synthetic event object. ' + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.'); | |
didWarnForAddedNewProperty = true; | |
} | |
target[prop] = value; | |
return true; | |
} | |
}); | |
} | |
}); | |
/*eslint-enable no-func-assign */ | |
} | |
} | |
/** | |
* Helper to reduce boilerplate when creating subclasses. | |
* | |
* @param {function} Class | |
* @param {?object} Interface | |
*/ | |
SyntheticEvent$1.augmentClass = function (Class, Interface) { | |
var Super = this; | |
var E = function () {}; | |
E.prototype = Super.prototype; | |
var prototype = new E(); | |
Object.assign(prototype, Class.prototype); | |
Class.prototype = prototype; | |
Class.prototype.constructor = Class; | |
Class.Interface = Object.assign({}, Super.Interface, Interface); | |
Class.augmentClass = Super.augmentClass; | |
PooledClass$2.addPoolingTo(Class, PooledClass$2.fourArgumentPooler); | |
}; | |
PooledClass$2.addPoolingTo(SyntheticEvent$1, PooledClass$2.fourArgumentPooler); | |
var SyntheticEvent_1 = SyntheticEvent$1; | |
/** | |
* Helper to nullify syntheticEvent instance properties when destructing | |
* | |
* @param {object} SyntheticEvent | |
* @param {String} propName | |
* @return {object} defineProperty object | |
*/ | |
function getPooledWarningPropertyDefinition(propName, getVal) { | |
var isFunction = typeof getVal === 'function'; | |
return { | |
configurable: true, | |
set: set, | |
get: get | |
}; | |
function set(val) { | |
var action = isFunction ? 'setting the method' : 'setting the property'; | |
warn(action, 'This is effectively a no-op'); | |
return val; | |
} | |
function get() { | |
var action = isFunction ? 'accessing the method' : 'accessing the property'; | |
var result = isFunction ? 'This is a no-op function' : 'This is set to null'; | |
warn(action, result); | |
return getVal; | |
} | |
function warn(action, result) { | |
var warningCondition = false; | |
warning$17(warningCondition, 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' + 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result); | |
} | |
} | |
var SyntheticEvent = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents | |
*/ | |
var CompositionEventInterface = { | |
data: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticCompositionEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent.augmentClass(SyntheticCompositionEvent$1, CompositionEventInterface); | |
var SyntheticCompositionEvent_1 = SyntheticCompositionEvent$1; | |
var SyntheticEvent$2 = SyntheticEvent_1; | |
/** | |
* @interface Event | |
* @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105 | |
* /#events-inputevents | |
*/ | |
var InputEventInterface = { | |
data: null | |
}; | |
/** | |
* @param {object} dispatchConfig Configuration used to dispatch this event. | |
* @param {string} dispatchMarker Marker identifying the event target. | |
* @param {object} nativeEvent Native browser event. | |
* @extends {SyntheticUIEvent} | |
*/ | |
function SyntheticInputEvent$1(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) { | |
return SyntheticEvent$2.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget); | |
} | |
SyntheticEvent$2.augmentClass(SyntheticInputEvent$1, InputEventInterface); | |
var SyntheticInputEvent_1 = SyntheticInputEvent$1; | |
var EventPropagators = EventPropagators_1; | |
var ExecutionEnvironment$6 = ExecutionEnvironment; | |
var FallbackCompositionState = FallbackCompositionState_1; | |
var SyntheticCompositionEvent = SyntheticCompositionEvent_1; | |
var SyntheticInputEvent = SyntheticInputEvent_1; | |
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space | |
var START_KEYCODE = 229; | |
var canUseCompositionEvent = ExecutionEnvironment$6.canUseDOM && 'CompositionEvent' in window; | |
var documentMode = null; | |
if (ExecutionEnvironment$6.canUseDOM && 'documentMode' in document) { | |
documentMode = document.documentMode; | |
} | |
// Webkit offers a very useful `textInput` event that can be used to | |
// directly represent `beforeInput`. The IE `textinput` event is not as | |
// useful, so we don't use it. | |
var canUseTextInputEvent = ExecutionEnvironment$6.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto(); | |
// In IE9+, we have access to composition events, but the data supplied | |
// by the native compositionend event may be incorrect. Japanese ideographic | |
// spaces, for instance (\u3000) are not recorded correctly. | |
var useFallbackCompositionData = ExecutionEnvironment$6.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11); | |
/** | |
* Opera <= 12 includes TextEvent in window, but does not fire | |
* text input events. Rely on keypress instead. | |
*/ | |
function isPresto() { | |
var opera = window.opera; | |
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12; | |
} | |
var SPACEBAR_CODE = 32; | |
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); | |
// Events and their corresponding property names. | |
var eventTypes = { | |
beforeInput: { | |
phasedRegistrationNames: { | |
bubbled: 'onBeforeInput', | |
captured: 'onBeforeInputCapture' | |
}, | |
dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste'] | |
}, | |
compositionEnd: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionEnd', | |
captured: 'onCompositionEndCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionEnd', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
}, | |
compositionStart: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionStart', | |
captured: 'onCompositionStartCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionStart', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
}, | |
compositionUpdate: { | |
phasedRegistrationNames: { | |
bubbled: 'onCompositionUpdate', | |
captured: 'onCompositionUpdateCapture' | |
}, | |
dependencies: ['topBlur', 'topCompositionUpdate', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown'] | |
} | |
}; | |
// Track whether we've ever handled a keypress on the space key. | |
var hasSpaceKeypress = false; | |
/** | |
* Return whether a native keypress event is assumed to be a command. | |
* This is required because Firefox fires `keypress` events for key commands | |
* (cut, copy, select-all, etc.) even though no character is inserted. | |
*/ | |
function isKeypressCommand(nativeEvent) { | |
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && | |
// ctrlKey && altKey is equivalent to AltGr, and is not a command. | |
!(nativeEvent.ctrlKey && nativeEvent.altKey); | |
} | |
/** | |
* Translate native top level events into event types. | |
* | |
* @param {string} topLevelType | |
* @return {object} | |
*/ | |
function getCompositionEventType(topLevelType) { | |
switch (topLevelType) { | |
case 'topCompositionStart': | |
return eventTypes.compositionStart; | |
case 'topCompositionEnd': | |
return eventTypes.compositionEnd; | |
case 'topCompositionUpdate': | |
return eventTypes.compositionUpdate; | |
} | |
} | |
/** | |
* Does our fallback best-guess model think this event signifies that | |
* composition has begun? | |
* | |
* @param {string} topLevelType | |
* @param {object} nativeEvent | |
* @return {boolean} | |
*/ | |
function isFallbackCompositionStart(topLevelType, nativeEvent) { | |
return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE; | |
} | |
/** | |
* Does our fallback mode think that this event is the end of composition? | |
* | |
* @param {string} topLevelType | |
* @param {object} nativeEvent | |
* @return {boolean} | |
*/ | |
function isFallbackCompositionEnd(topLevelType, nativeEvent) { | |
switch (topLevelType) { | |
case 'topKeyUp': | |
// Command keys insert or clear IME input. | |
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; | |
case 'topKeyDown': | |
// Expect IME keyCode on each keydown. If we get any other | |
// code we must have exited earlier. | |
return nativeEvent.keyCode !== START_KEYCODE; | |
case 'topKeyPress': | |
case 'topMouseDown': | |
case 'topBlur': | |
// Events are not possible without cancelling IME. | |
return true; | |
default: | |
return false; | |
} | |
} | |
/** | |
* Google Input Tools provides composition data via a CustomEvent, | |
* with the `data` property populated in the `detail` object. If this | |
* is available on the event object, use it. If not, this is a plain | |
* composition event and we have nothing special to extract. | |
* | |
* @param {object} nativeEvent | |
* @return {?string} | |
*/ | |
function getDataFromCustomEvent(nativeEvent) { | |
var detail = nativeEvent.detail; | |
if (typeof detail === 'object' && 'data' in detail) { | |
return detail.data; | |
} | |
return null; | |
} | |
// Track the current IME composition fallback object, if any. | |
var currentComposition = null; | |
/** | |
* @return {?object} A SyntheticCompositionEvent. | |
*/ | |
function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var eventType; | |
var fallbackData; | |
if (canUseCompositionEvent) { | |
eventType = getCompositionEventType(topLevelType); | |
} else if (!currentComposition) { | |
if (isFallbackCompositionStart(topLevelType, nativeEvent)) { | |
eventType = eventTypes.compositionStart; | |
} | |
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
eventType = eventTypes.compositionEnd; | |
} | |
if (!eventType) { | |
return null; | |
} | |
if (useFallbackCompositionData) { | |
// The current composition is stored statically and must not be | |
// overwritten while composition continues. | |
if (!currentComposition && eventType === eventTypes.compositionStart) { | |
currentComposition = FallbackCompositionState.getPooled(nativeEventTarget); | |
} else if (eventType === eventTypes.compositionEnd) { | |
if (currentComposition) { | |
fallbackData = currentComposition.getData(); | |
} | |
} | |
} | |
var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget); | |
if (fallbackData) { | |
// Inject data generated from fallback path into the synthetic event. | |
// This matches the property of native CompositionEventInterface. | |
event.data = fallbackData; | |
} else { | |
var customData = getDataFromCustomEvent(nativeEvent); | |
if (customData !== null) { | |
event.data = customData; | |
} | |
} | |
EventPropagators.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {object} nativeEvent Native browser event. | |
* @return {?string} The string corresponding to this `beforeInput` event. | |
*/ | |
function getNativeBeforeInputChars(topLevelType, nativeEvent) { | |
switch (topLevelType) { | |
case 'topCompositionEnd': | |
return getDataFromCustomEvent(nativeEvent); | |
case 'topKeyPress': | |
/** | |
* If native `textInput` events are available, our goal is to make | |
* use of them. However, there is a special case: the spacebar key. | |
* In Webkit, preventing default on a spacebar `textInput` event | |
* cancels character insertion, but it *also* causes the browser | |
* to fall back to its default spacebar behavior of scrolling the | |
* page. | |
* | |
* Tracking at: | |
* https://code.google.com/p/chromium/issues/detail?id=355103 | |
* | |
* To avoid this issue, use the keypress event as if no `textInput` | |
* event is available. | |
*/ | |
var which = nativeEvent.which; | |
if (which !== SPACEBAR_CODE) { | |
return null; | |
} | |
hasSpaceKeypress = true; | |
return SPACEBAR_CHAR; | |
case 'topTextInput': | |
// Record the characters to be added to the DOM. | |
var chars = nativeEvent.data; | |
// If it's a spacebar character, assume that we have already handled | |
// it at the keypress level and bail immediately. Android Chrome | |
// doesn't give us keycodes, so we need to blacklist it. | |
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) { | |
return null; | |
} | |
return chars; | |
default: | |
// For other native event types, do nothing. | |
return null; | |
} | |
} | |
/** | |
* For browsers that do not provide the `textInput` event, extract the | |
* appropriate string to use for SyntheticInputEvent. | |
* | |
* @param {string} topLevelType Record from `EventConstants`. | |
* @param {object} nativeEvent Native browser event. | |
* @return {?string} The fallback string for this `beforeInput` event. | |
*/ | |
function getFallbackBeforeInputChars(topLevelType, nativeEvent) { | |
// If we are currently composing (IME) and using a fallback to do so, | |
// try to extract the composed characters from the fallback object. | |
// If composition event is available, we extract a string only at | |
// compositionevent, otherwise extract it at fallback events. | |
if (currentComposition) { | |
if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) { | |
var chars = currentComposition.getData(); | |
FallbackCompositionState.release(currentComposition); | |
currentComposition = null; | |
return chars; | |
} | |
return null; | |
} | |
switch (topLevelType) { | |
case 'topPaste': | |
// If a paste event occurs after a keypress, throw out the input | |
// chars. Paste events should not lead to BeforeInput events. | |
return null; | |
case 'topKeyPress': | |
/** | |
* As of v27, Firefox may fire keypress events even when no character | |
* will be inserted. A few possibilities: | |
* | |
* - `which` is `0`. Arrow keys, Esc key, etc. | |
* | |
* - `which` is the pressed key code, but no char is available. | |
* Ex: 'AltGr + d` in Polish. There is no modified character for | |
* this key combination and no character is inserted into the | |
* document, but FF fires the keypress for char code `100` anyway. | |
* No `input` event will occur. | |
* | |
* - `which` is the pressed key code, but a command combination is | |
* being used. Ex: `Cmd+C`. No character is inserted, and no | |
* `input` event will occur. | |
*/ | |
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) { | |
return String.fromCharCode(nativeEvent.which); | |
} | |
return null; | |
case 'topCompositionEnd': | |
return useFallbackCompositionData ? null : nativeEvent.data; | |
default: | |
return null; | |
} | |
} | |
/** | |
* Extract a SyntheticInputEvent for `beforeInput`, based on either native | |
* `textInput` or fallback behavior. | |
* | |
* @return {?object} A SyntheticInputEvent. | |
*/ | |
function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
var chars; | |
if (canUseTextInputEvent) { | |
chars = getNativeBeforeInputChars(topLevelType, nativeEvent); | |
} else { | |
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent); | |
} | |
// If no characters are being inserted, no BeforeInput event should | |
// be fired. | |
if (!chars) { | |
return null; | |
} | |
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget); | |
event.data = chars; | |
EventPropagators.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* Create an `onBeforeInput` event to match | |
* http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents. | |
* | |
* This event plugin is based on the native `textInput` event | |
* available in Chrome, Safari, Opera, and IE. This event fires after | |
* `onKeyPress` and `onCompositionEnd`, but before `onInput`. | |
* | |
* `beforeInput` is spec'd but not implemented in any browsers, and | |
* the `input` event does not provide any useful information about what has | |
* actually been added, contrary to the spec. Thus, `textInput` is the best | |
* available event to identify the characters that have actually been inserted | |
* into the target node. | |
* | |
* This plugin is also responsible for emitting `composition` events, thus | |
* allowing us to share composition fallback code for both `beforeInput` and | |
* `composition` event types. | |
*/ | |
var BeforeInputEventPlugin$1 = { | |
eventTypes: eventTypes, | |
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { | |
return [extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget)]; | |
} | |
}; | |
var BeforeInputEventPlugin_1 = BeforeInputEventPlugin$1; | |
var ReactControlledComponent$3 = ReactControlledComponent_1; | |
// Used as a way to call batchedUpdates when we don't know if we're in a Fiber | |
// or Stack context. Such as when we're dispatching events or if third party | |
// libraries need to call batchedUpdates. Eventually, this API will go away when | |
// everything is batched by default. We'll then have a similar API to opt-out of | |
// scheduled work and instead do synchronous work. | |
// Defaults | |
var stackBatchedUpdates = function (fn, a, b, c, d, e) { | |
return fn(a, b, c, d, e); | |
}; | |
var fiberBatchedUpdates = function (fn, bookkeeping) { | |
return fn(bookkeeping); | |
}; | |
function performFiberBatchedUpdates(fn, bookkeeping) { | |
// If we have Fiber loaded, we need to wrap this in a batching call so that | |
// Fiber can apply its default priority for this call. | |
return fiberBatchedUpdates(fn, bookkeeping); | |
} | |
function batchedUpdates(fn, bookkeeping) { | |
// We first perform work with the stack batching strategy, by passing our | |
// indirection to it. | |
return stackBatchedUpdates(performFiberBatchedUpdates, fn, bookkeeping); | |
} | |
var isNestingBatched = false; | |
function batchedUpdatesWithControlledComponents(fn, bookkeeping) { | |
if (isNestingBatched) { | |
// If we are currently inside another batch, we need to wait until it | |
// fully completes before restoring state. Therefore, we add the target to | |
// a queue of work. | |
return batchedUpdates(fn, bookkeeping); | |
} | |
isNestingBatched = true; | |
try { | |
return batchedUpdates(fn, bookkeeping); | |
} finally { | |
// Here we wait until all updates have propagated, which is important | |
// when using controlled components within layers: | |
// https://github.com/facebook/react/issues/1698 | |
// Then we restore state of any controlled component. | |
isNestingBatched = false; | |
ReactControlledComponent$3.restoreStateIfNeeded(); | |
} | |
} | |
var ReactGenericBatchingInjection = { | |
injectStackBatchedUpdates: function (_batchedUpdates) { | |
stackBatchedUpdates = _batchedUpdates; | |
}, | |
injectFiberBatchedUpdates: function (_batchedUpdates) { | |
fiberBatchedUpdates = _batchedUpdates; | |
} | |
}; | |
var ReactGenericBatching$2 = { | |
batchedUpdates: batchedUpdatesWithControlledComponents, | |
injection: ReactGenericBatchingInjection | |
}; | |
var ReactGenericBatching_1 = ReactGenericBatching$2; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule getEventTarget | |
*/ | |
/** | |
* Gets the target node from a native browser event by accounting for | |
* inconsistencies in browser DOM APIs. | |
* | |
* @param {object} nativeEvent Native browser event. | |
* @return {DOMEventTarget} Target node. | |
*/ | |
function getEventTarget$1(nativeEvent) { | |
var target = nativeEvent.target || nativeEvent.srcElement || window; | |
// Normalize SVG <use> element events #4963 | |
if (target.correspondingUseElement) { | |
target = target.correspondingUseElement; | |
} | |
// Safari may fire events on text nodes (Node.TEXT_NODE is 3). | |
// @see http://www.quirksmode.org/js/events_properties.html | |
return target.nodeType === 3 ? target.parentNode : target; | |
} | |
var getEventTarget_1 = getEventTarget$1; | |
/** | |
* Copyright 2013-present, Facebook, Inc. | |
* All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
* LICENSE file in the root directory of this source tree. An additional grant | |
* of patent rights can be found in the PATENTS file in the same directory. | |
* | |
* @providesModule isTextInputElement | |
* | |
*/ | |
/** | |
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary | |
*/ | |
var supportedInputTypes = { | |
'color': true, | |
'date': true, | |
'datetime': true, | |
'datetime-local': true, | |
'email': true, | |
'month': true, | |
'number': true, | |
'password': true, | |
'range': true, | |
'search': true, | |
'tel': true, | |
'text': true, | |
'time': true, | |
'url': true, | |
'week': true | |
}; | |
function isTextInputElement$1(elem) { | |
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | |
if (nodeName === 'input') { | |
return !!supportedInputTypes[elem.type]; | |
} | |
if (nodeName === 'textarea') { | |
return true; | |
} | |
return false; | |
} | |
var isTextInputElement_1 = isTextInputElement$1; | |
var EventPluginHub$4 = EventPluginHub_1; | |
var EventPropagators$2 = EventPropagators_1; | |
var ExecutionEnvironment$8 = ExecutionEnvironment; | |
var ReactControlledComponent$2 = ReactControlledComponent_1; | |
var ReactDOMComponentTree$6 = ReactDOMComponentTree_1; | |
var ReactGenericBatching$1 = ReactGenericBatching_1; | |
var SyntheticEvent$3 = SyntheticEvent_1; | |
var inputValueTracking$2 = inputValueTracking_1; | |
var getEventTarget = getEventTarget_1; | |
var isEventSupported$3 = isEventSupported_1; | |
var isTextInputElement = isTextInputElement_1; | |
var eventTypes$1 = { | |
change: { | |
phasedRegistrationNames: { | |
bubbled: 'onChange', | |
captured: 'onChangeCapture' | |
}, | |
dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange'] | |
} | |
}; | |
function createAndAccumulateChangeEvent(inst, nativeEvent, target) { | |
var event = SyntheticEvent$3.getPooled(eventTypes$1.change, inst, nativeEvent, target); | |
event.type = 'change'; | |
// Flag this event loop as needing state restore. | |
ReactControlledComponent$2.enqueueStateRestore(target); | |
EventPropagators$2.accumulateTwoPhaseDispatches(event); | |
return event; | |
} | |
/** | |
* For IE shims | |
*/ | |
var activeElement = null; | |
var activeElementInst = null; | |
/** | |
* SECTION: handle `change` event | |
*/ | |
function shouldUseChangeEvent(elem) { | |
var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); | |
return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; | |
} | |
var doesChangeEventBubble = false; | |
if (ExecutionEnvironment$8.canUseDOM) { | |
// See `handleChange` comment below | |
doesChangeEventBubble = isEventSupported$3('change') && (!document.documentMode || document.documentMode > 8); | |
} | |
function manualDispatchChangeEvent(nativeEvent) { | |
var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); | |
// If change and propertychange bubbled, we'd just bind to it like all the | |
// other events and have it go through ReactBrowserEventEmitter. Since it | |
// doesn't, we manually listen for the events and so we have to enqueue and | |
// process the abstract event manually. | |
// | |
// Batching is necessary here in order to ensure that all event handlers run | |
// before the next rerender (including event handlers attached to ancestor | |
// elements instead of directly on the input). Without this, controlled | |
// components don't work properly in conjunction with event bubbling because | |
// the component is rerendered and the value reverted before all the event | |
// handlers can run. See https://github.com/facebook/react/issues/708. | |
ReactGenericBatching$1.batchedUpdates(runEventInBatch, event); | |
} | |
function runEventInBatch(event) { | |
EventPluginHub$4.enqueueEvents(event); | |
EventPluginHub$4.processEventQueue(false); | |
} | |
function startWatchingForChangeEventIE8(target, targetInst) { | |
activeElement = target; | |
activeElementInst = targetInst; | |
activeElement.attachEvent('onchange', manualDispatchChangeEvent); | |
} | |
function stopWatchingForChangeEventIE8() { | |
if (!activeElement) { | |
return; | |
} | |
activeElement.detachEvent('onchange', manualDispatchChangeEvent); | |
activeElement = null; | |
activeElementInst = null; | |
} | |
function getInstIfValueChanged(targetInst) { | |
if (inputValueTracking$2.updateValueIfChanged(targetInst)) { | |
return targetInst; | |
} | |
} | |
function getTargetInstForChangeEvent(topLevelType, targetInst) { | |
if (topLevelType === 'topChange') { | |
return targetInst; | |
} | |
} | |
function handleEventsForChangeEventIE8(topLevelType, target, targetInst) { | |
if (topLevelType === 'topFocus') { | |
// stopWatching() should be a noop here but we call it just in case we | |
// missed a blur event somehow. | |
stopWatchingForChangeEventIE8(); | |
startWatchingForChangeEventIE8(target, targ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment