зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1473842 - Upgrade React to v16.4.1 r=nchevobbe
MozReview-Commit-ID: CKlj71e4ZHy --HG-- extra : rebase_source : 9529e6e33d4f789eb41b04ff3815379fe41a233d
This commit is contained in:
Родитель
092a352343
Коммит
838616630e
|
@ -17,7 +17,7 @@ You should start by upgrading our prop-types library to match the latest version
|
|||
```bash
|
||||
git clone https://github.com/facebook/react.git
|
||||
cd react
|
||||
git checkout v16.2.0 # or the version you are targetting
|
||||
git checkout v16.4.1 # or the version you are targetting
|
||||
```
|
||||
|
||||
## Preparing to Build
|
||||
|
@ -27,6 +27,7 @@ We need to disable minification and tree shaking as they overcomplicate the upgr
|
|||
- Open scripts/rollup/build.js
|
||||
- Find a method called `function getRollupOutputOptions()`
|
||||
- After `sourcemap: false` add `treeshake: false` and `freeze: false`
|
||||
- Remove `freeze: !isProduction,` from the same section.
|
||||
- Change this:
|
||||
|
||||
```js
|
||||
|
@ -66,40 +67,6 @@ yarn
|
|||
yarn build
|
||||
```
|
||||
|
||||
### Package Testing Utilities
|
||||
|
||||
Go through `build/packages/react-test-renderer` and in each file remove all code meant for a production build e.g.
|
||||
|
||||
Change this:
|
||||
|
||||
```js
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./cjs/react-test-renderer-shallow.production.min.js');
|
||||
} else {
|
||||
module.exports = require('./cjs/react-test-renderer-shallow.development.js');
|
||||
}
|
||||
```
|
||||
|
||||
To this:
|
||||
|
||||
```js
|
||||
module.exports = require('./cjs/react-test-renderer-shallow.development.js');
|
||||
```
|
||||
|
||||
**NOTE: Be sure to remove all `process.env` conditions from inside the files in the cjs folder.**
|
||||
|
||||
Also in the cjs folder replace the React require paths to point at the current React version:
|
||||
|
||||
```js
|
||||
var React = require('../../../dist/react.development');
|
||||
```
|
||||
|
||||
From within `build/packages/react-test-renderer`:
|
||||
|
||||
```bash
|
||||
browserify shallow.js -o react-test-renderer-shallow.js --standalone ShallowRenderer
|
||||
```
|
||||
|
||||
### Copy the Files Into your Firefox Repo
|
||||
|
||||
```bash
|
||||
|
@ -112,7 +79,7 @@ cp build/dist/react.development.js <gecko-dev>/devtools/client/shared/vendor/rea
|
|||
cp build/dist/react-dom.development.js <gecko-dev>/devtools/client/shared/vendor/react-dom-dev.js
|
||||
cp build/dist/react-dom-server.browser.development.js <gecko-dev>/devtools/client/shared/vendor/react-dom-server-dev.js
|
||||
cp build/dist/react-dom-test-utils.development.js <gecko-dev>/devtools/client/shared/vendor/react-dom-test-utils-dev.js
|
||||
cp build/packages/react-test-renderer/react-test-renderer-shallow.js <gecko-dev>/devtools/client/shared/vendor/react-test-renderer-shallow.js
|
||||
cp build/dist/react-test-renderer-shallow.production.min.js <gecko-dev>/devtools/client/shared/vendor/react-test-renderer-shallow.js
|
||||
```
|
||||
|
||||
From this point we will no longer need your react repository so feel free to delete it.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/** @license React v16.2.0
|
||||
/** @license React v16.4.1
|
||||
* react.development.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
@ -108,17 +108,22 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
|
|||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
var ReactVersion = '16.2.0';
|
||||
var ReactVersion = '16.4.1';
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||
|
||||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
|
||||
var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
|
||||
var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
|
||||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
|
||||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
||||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
||||
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
||||
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
||||
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
||||
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
||||
var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1;
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
|
@ -134,31 +139,6 @@ function getIteratorFn(maybeIterable) {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: DO NOT manually require this module.
|
||||
* This is a replacement for `invariant(...)` used by the error code system
|
||||
* and will _only_ be required by the corresponding babel pass.
|
||||
* It always throws.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
var emptyObject = {};
|
||||
|
||||
{
|
||||
Object.freeze(emptyObject);
|
||||
}
|
||||
|
||||
var emptyObject_1 = emptyObject;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -213,6 +193,59 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|||
|
||||
var invariant_1 = invariant;
|
||||
|
||||
// Relying on the `invariant()` implementation lets us
|
||||
// have preserve the format and params in the www builds.
|
||||
|
||||
// Exports ReactDOM.createRoot
|
||||
|
||||
|
||||
// Experimental error-boundary API that can recover from errors within a single
|
||||
// render phase
|
||||
|
||||
// Suspense
|
||||
var enableSuspense = false;
|
||||
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
||||
|
||||
|
||||
// In some cases, StrictMode should also double-render lifecycles.
|
||||
// This can be confusing for tests though,
|
||||
// And it can be bad for performance in production.
|
||||
// This feature flag can be used to control the behavior:
|
||||
|
||||
|
||||
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
||||
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
||||
|
||||
|
||||
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
||||
|
||||
|
||||
// Warn about legacy context API
|
||||
|
||||
|
||||
// Gather advanced timing metrics for Profiler subtrees.
|
||||
|
||||
|
||||
// Only used in www builds.
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
var emptyObject = {};
|
||||
|
||||
{
|
||||
Object.freeze(emptyObject);
|
||||
}
|
||||
|
||||
var emptyObject_1 = emptyObject;
|
||||
|
||||
/**
|
||||
* Forked from fbjs/warning:
|
||||
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
||||
|
@ -368,13 +401,13 @@ var didWarnStateUpdateForUnmountedComponent = {};
|
|||
|
||||
function warnNoop(publicInstance, callerName) {
|
||||
{
|
||||
var constructor = publicInstance.constructor;
|
||||
var componentName = constructor && (constructor.displayName || constructor.name) || 'ReactClass';
|
||||
var _constructor = publicInstance.constructor;
|
||||
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
||||
var warningKey = componentName + '.' + callerName;
|
||||
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
||||
return;
|
||||
}
|
||||
warning_1(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, componentName);
|
||||
warning_1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
|
||||
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
||||
}
|
||||
}
|
||||
|
@ -534,46 +567,36 @@ Component.prototype.forceUpdate = function (callback) {
|
|||
}
|
||||
}
|
||||
|
||||
function ComponentDummy() {}
|
||||
ComponentDummy.prototype = Component.prototype;
|
||||
|
||||
/**
|
||||
* Base class helpers for the updating state of a component.
|
||||
* Convenience component with default shallow equality check for sCU.
|
||||
*/
|
||||
function PureComponent(props, context, updater) {
|
||||
// Duplicated from Component.
|
||||
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 = Component.prototype;
|
||||
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
||||
pureComponentPrototype.constructor = PureComponent;
|
||||
// Avoid an extra prototype jump for these methods.
|
||||
objectAssign(pureComponentPrototype, Component.prototype);
|
||||
pureComponentPrototype.isPureReactComponent = true;
|
||||
|
||||
function AsyncComponent(props, context, updater) {
|
||||
// Duplicated from Component.
|
||||
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;
|
||||
// an immutable object with a single mutable value
|
||||
function createRef() {
|
||||
var refObject = {
|
||||
current: null
|
||||
};
|
||||
{
|
||||
Object.seal(refObject);
|
||||
}
|
||||
return refObject;
|
||||
}
|
||||
|
||||
var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy();
|
||||
asyncComponentPrototype.constructor = AsyncComponent;
|
||||
// Avoid an extra prototype jump for these methods.
|
||||
objectAssign(asyncComponentPrototype, Component.prototype);
|
||||
asyncComponentPrototype.unstable_isAsyncReactComponent = true;
|
||||
asyncComponentPrototype.render = function () {
|
||||
return this.props.children;
|
||||
};
|
||||
|
||||
/**
|
||||
* Keeps track of the current owner.
|
||||
*
|
||||
|
@ -597,8 +620,8 @@ var RESERVED_PROPS = {
|
|||
__source: true
|
||||
};
|
||||
|
||||
var specialPropKeyWarningShown;
|
||||
var specialPropRefWarningShown;
|
||||
var specialPropKeyWarningShown = void 0;
|
||||
var specialPropRefWarningShown = void 0;
|
||||
|
||||
function hasValidRef(config) {
|
||||
{
|
||||
|
@ -674,7 +697,7 @@ function defineRefPropWarningGetter(props, displayName) {
|
|||
*/
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allow us to uniquely identify this as a React Element
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
|
||||
// Built-in properties that belong on the element
|
||||
|
@ -733,7 +756,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|||
* See https://reactjs.org/docs/react-api.html#createelement
|
||||
*/
|
||||
function createElement(type, config, children) {
|
||||
var propName;
|
||||
var propName = void 0;
|
||||
|
||||
// Reserved names are extracted
|
||||
var props = {};
|
||||
|
@ -821,7 +844,9 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
|||
* See https://reactjs.org/docs/react-api.html#cloneelement
|
||||
*/
|
||||
function cloneElement(element, config, children) {
|
||||
var propName;
|
||||
!!(element === null || element === undefined) ? invariant_1(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
|
||||
|
||||
var propName = void 0;
|
||||
|
||||
// Original props are copied
|
||||
var props = objectAssign({}, element.props);
|
||||
|
@ -850,7 +875,7 @@ function cloneElement(element, config, children) {
|
|||
}
|
||||
|
||||
// Remaining properties override existing props
|
||||
var defaultProps;
|
||||
var defaultProps = void 0;
|
||||
if (element.type && element.type.defaultProps) {
|
||||
defaultProps = element.type.defaultProps;
|
||||
}
|
||||
|
@ -1004,8 +1029,6 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
case 'object':
|
||||
switch (children.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
case REACT_CALL_TYPE:
|
||||
case REACT_RETURN_TYPE:
|
||||
case REACT_PORTAL_TYPE:
|
||||
invokeCallback = true;
|
||||
}
|
||||
|
@ -1020,8 +1043,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
return 1;
|
||||
}
|
||||
|
||||
var child;
|
||||
var nextName;
|
||||
var child = void 0;
|
||||
var nextName = void 0;
|
||||
var subtreeCount = 0; // Count of children found in the current subtree.
|
||||
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
||||
|
||||
|
@ -1037,13 +1060,13 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
{
|
||||
// Warn about using Maps as children
|
||||
if (iteratorFn === children.entries) {
|
||||
warning_1(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum());
|
||||
!didWarnAboutMaps ? warning_1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', ReactDebugCurrentFrame.getStackAddendum()) : void 0;
|
||||
didWarnAboutMaps = true;
|
||||
}
|
||||
}
|
||||
|
||||
var iterator = iteratorFn.call(children);
|
||||
var step;
|
||||
var step = void 0;
|
||||
var ii = 0;
|
||||
while (!(step = iterator.next()).done) {
|
||||
child = step.value;
|
||||
|
@ -1115,7 +1138,7 @@ function forEachSingleChild(bookKeeping, child, name) {
|
|||
/**
|
||||
* Iterates through children that are typically specified as `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.foreach
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenforeach
|
||||
*
|
||||
* The provided forEachFunc(child, index) will be called for each
|
||||
* leaf child.
|
||||
|
@ -1167,7 +1190,7 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|||
/**
|
||||
* Maps children that are typically specified as `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.map
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenmap
|
||||
*
|
||||
* The provided mapFunction(child, key, index) will be called for each
|
||||
* leaf child.
|
||||
|
@ -1190,12 +1213,12 @@ function mapChildren(children, func, context) {
|
|||
* Count the number of children that are typically specified as
|
||||
* `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.count
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrencount
|
||||
*
|
||||
* @param {?*} children Children tree container.
|
||||
* @return {number} The number of children.
|
||||
*/
|
||||
function countChildren(children, context) {
|
||||
function countChildren(children) {
|
||||
return traverseAllChildren(children, emptyFunction_1.thatReturnsNull, null);
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1226,7 @@ function countChildren(children, context) {
|
|||
* Flatten a children object (typically specified as `props.children`) and
|
||||
* return an array with appropriately re-keyed children.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.toarray
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
||||
*/
|
||||
function toArray(children) {
|
||||
var result = [];
|
||||
|
@ -1215,7 +1238,7 @@ function toArray(children) {
|
|||
* Returns the first child in a collection of children and verifies that there
|
||||
* is only one child in the collection.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.only
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenonly
|
||||
*
|
||||
* 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
|
||||
|
@ -1230,18 +1253,105 @@ function onlyChild(children) {
|
|||
return children;
|
||||
}
|
||||
|
||||
function createContext(defaultValue, calculateChangedBits) {
|
||||
if (calculateChangedBits === undefined) {
|
||||
calculateChangedBits = null;
|
||||
} else {
|
||||
{
|
||||
!(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warning_1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
var context = {
|
||||
$$typeof: REACT_CONTEXT_TYPE,
|
||||
_calculateChangedBits: calculateChangedBits,
|
||||
_defaultValue: defaultValue,
|
||||
_currentValue: defaultValue,
|
||||
// As a workaround to support multiple concurrent renderers, we categorize
|
||||
// some renderers as primary and others as secondary. We only expect
|
||||
// there to be two concurrent renderers at most: React Native (primary) and
|
||||
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
||||
// Secondary renderers store their context values on separate fields.
|
||||
_currentValue2: defaultValue,
|
||||
_changedBits: 0,
|
||||
_changedBits2: 0,
|
||||
// These are circular
|
||||
Provider: null,
|
||||
Consumer: null
|
||||
};
|
||||
|
||||
context.Provider = {
|
||||
$$typeof: REACT_PROVIDER_TYPE,
|
||||
_context: context
|
||||
};
|
||||
context.Consumer = context;
|
||||
|
||||
{
|
||||
context._currentRenderer = null;
|
||||
context._currentRenderer2 = null;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
function forwardRef(render) {
|
||||
{
|
||||
!(typeof render === 'function') ? warning_1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render) : void 0;
|
||||
|
||||
if (render != null) {
|
||||
!(render.defaultProps == null && render.propTypes == null) ? warning_1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
$$typeof: REACT_FORWARD_REF_TYPE,
|
||||
render: render
|
||||
};
|
||||
}
|
||||
|
||||
var describeComponentFrame = function (name, source, ownerName) {
|
||||
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
||||
};
|
||||
|
||||
function isValidElementType(type) {
|
||||
return typeof type === 'string' || typeof type === 'function' ||
|
||||
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
||||
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_TIMEOUT_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
||||
}
|
||||
|
||||
function getComponentName(fiber) {
|
||||
var type = fiber.type;
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name;
|
||||
}
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name;
|
||||
switch (type) {
|
||||
case REACT_ASYNC_MODE_TYPE:
|
||||
return 'AsyncMode';
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return 'Context.Consumer';
|
||||
case REACT_FRAGMENT_TYPE:
|
||||
return 'ReactFragment';
|
||||
case REACT_PORTAL_TYPE:
|
||||
return 'ReactPortal';
|
||||
case REACT_PROFILER_TYPE:
|
||||
return 'Profiler(' + fiber.pendingProps.id + ')';
|
||||
case REACT_PROVIDER_TYPE:
|
||||
return 'Context.Provider';
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return 'StrictMode';
|
||||
case REACT_TIMEOUT_TYPE:
|
||||
return 'Timeout';
|
||||
}
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
switch (type.$$typeof) {
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
var functionName = type.render.displayName || type.render.name || '';
|
||||
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1326,26 +1436,38 @@ var checkPropTypes_1 = checkPropTypes;
|
|||
* that support it.
|
||||
*/
|
||||
|
||||
var currentlyValidatingElement = void 0;
|
||||
var propTypesMisspellWarningShown = void 0;
|
||||
|
||||
var getDisplayName = function () {};
|
||||
var getStackAddendum = function () {};
|
||||
|
||||
{
|
||||
var currentlyValidatingElement = null;
|
||||
currentlyValidatingElement = null;
|
||||
|
||||
var propTypesMisspellWarningShown = false;
|
||||
propTypesMisspellWarningShown = false;
|
||||
|
||||
var getDisplayName = function (element) {
|
||||
getDisplayName = function (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 if (element.type === REACT_FRAGMENT_TYPE) {
|
||||
}
|
||||
|
||||
var type = element.type;
|
||||
if (type === REACT_FRAGMENT_TYPE) {
|
||||
return 'React.Fragment';
|
||||
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
||||
var functionName = type.render.displayName || type.render.name || '';
|
||||
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
||||
} else {
|
||||
return element.type.displayName || element.type.name || 'Unknown';
|
||||
return type.displayName || type.name || 'Unknown';
|
||||
}
|
||||
};
|
||||
|
||||
var getStackAddendum = function () {
|
||||
getStackAddendum = function () {
|
||||
var stack = '';
|
||||
if (currentlyValidatingElement) {
|
||||
var name = getDisplayName(currentlyValidatingElement);
|
||||
|
@ -1355,8 +1477,6 @@ var checkPropTypes_1 = checkPropTypes;
|
|||
stack += ReactDebugCurrentFrame.getStackAddendum() || '';
|
||||
return stack;
|
||||
};
|
||||
|
||||
var VALID_FRAGMENT_PROPS = new Map([['children', true], ['key', true]]);
|
||||
}
|
||||
|
||||
function getDeclarationErrorAddendum() {
|
||||
|
@ -1469,7 +1589,7 @@ function validateChildKeys(node, parentType) {
|
|||
// but now we print a separate warning for them later.
|
||||
if (iteratorFn !== node.entries) {
|
||||
var iterator = iteratorFn.call(node);
|
||||
var step;
|
||||
var step = void 0;
|
||||
while (!(step = iterator.next()).done) {
|
||||
if (isValidElement(step.value)) {
|
||||
validateExplicitKey(step.value, parentType);
|
||||
|
@ -1487,22 +1607,31 @@ function validateChildKeys(node, parentType) {
|
|||
* @param {ReactElement} element
|
||||
*/
|
||||
function validatePropTypes(element) {
|
||||
var componentClass = element.type;
|
||||
if (typeof componentClass !== 'function') {
|
||||
var type = element.type;
|
||||
var name = void 0,
|
||||
propTypes = void 0;
|
||||
if (typeof type === 'function') {
|
||||
// Class or functional component
|
||||
name = type.displayName || type.name;
|
||||
propTypes = type.propTypes;
|
||||
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
||||
// ForwardRef
|
||||
var functionName = type.render.displayName || type.render.name || '';
|
||||
name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
||||
propTypes = type.propTypes;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
var name = componentClass.displayName || componentClass.name;
|
||||
var propTypes = componentClass.propTypes;
|
||||
if (propTypes) {
|
||||
currentlyValidatingElement = element;
|
||||
checkPropTypes_1(propTypes, element.props, 'prop', name, getStackAddendum);
|
||||
currentlyValidatingElement = null;
|
||||
} else if (componentClass.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
||||
propTypesMisspellWarningShown = true;
|
||||
warning_1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
||||
}
|
||||
if (typeof componentClass.getDefaultProps === 'function') {
|
||||
warning_1(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
||||
if (typeof type.getDefaultProps === 'function') {
|
||||
!type.getDefaultProps.isReactClassApproved ? warning_1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,31 +1642,12 @@ function validatePropTypes(element) {
|
|||
function validateFragmentProps(fragment) {
|
||||
currentlyValidatingElement = fragment;
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = Object.keys(fragment.props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var key = _step.value;
|
||||
|
||||
if (!VALID_FRAGMENT_PROPS.has(key)) {
|
||||
warning_1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator['return']) {
|
||||
_iterator['return']();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
var keys = Object.keys(fragment.props);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
if (key !== 'children' && key !== 'key') {
|
||||
warning_1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1549,7 +1659,8 @@ function validateFragmentProps(fragment) {
|
|||
}
|
||||
|
||||
function createElementWithValidation(type, props, children) {
|
||||
var validType = typeof type === 'string' || typeof type === 'function' || typeof type === 'symbol' || typeof type === 'number';
|
||||
var validType = isValidElementType(type);
|
||||
|
||||
// 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) {
|
||||
|
@ -1567,7 +1678,16 @@ function createElementWithValidation(type, props, children) {
|
|||
|
||||
info += getStackAddendum() || '';
|
||||
|
||||
warning_1(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 typeString = void 0;
|
||||
if (type === null) {
|
||||
typeString = 'null';
|
||||
} else if (Array.isArray(type)) {
|
||||
typeString = 'array';
|
||||
} else {
|
||||
typeString = typeof type;
|
||||
}
|
||||
|
||||
warning_1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
||||
}
|
||||
|
||||
var element = createElement.apply(this, arguments);
|
||||
|
@ -1589,7 +1709,7 @@ function createElementWithValidation(type, props, children) {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof type === 'symbol' && type === REACT_FRAGMENT_TYPE) {
|
||||
if (type === REACT_FRAGMENT_TYPE) {
|
||||
validateFragmentProps(element);
|
||||
} else {
|
||||
validatePropTypes(element);
|
||||
|
@ -1600,9 +1720,8 @@ function createElementWithValidation(type, props, children) {
|
|||
|
||||
function createFactoryWithValidation(type) {
|
||||
var validatedFactory = createElementWithValidation.bind(null, type);
|
||||
// Legacy hook TODO: Warn if this is accessed
|
||||
validatedFactory.type = type;
|
||||
|
||||
// Legacy hook: remove it
|
||||
{
|
||||
Object.defineProperty(validatedFactory, 'type', {
|
||||
enumerable: false,
|
||||
|
@ -1637,11 +1756,17 @@ var React = {
|
|||
only: onlyChild
|
||||
},
|
||||
|
||||
createRef: createRef,
|
||||
Component: Component,
|
||||
PureComponent: PureComponent,
|
||||
unstable_AsyncComponent: AsyncComponent,
|
||||
|
||||
createContext: createContext,
|
||||
forwardRef: forwardRef,
|
||||
|
||||
Fragment: REACT_FRAGMENT_TYPE,
|
||||
StrictMode: REACT_STRICT_MODE_TYPE,
|
||||
unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
|
||||
unstable_Profiler: REACT_PROFILER_TYPE,
|
||||
|
||||
createElement: createElementWithValidation,
|
||||
cloneElement: cloneElementWithValidation,
|
||||
|
@ -1657,6 +1782,10 @@ var React = {
|
|||
}
|
||||
};
|
||||
|
||||
if (enableSuspense) {
|
||||
React.Timeout = REACT_TIMEOUT_TYPE;
|
||||
}
|
||||
|
||||
{
|
||||
objectAssign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
||||
// These should not be included in production.
|
||||
|
@ -1669,7 +1798,7 @@ var React = {
|
|||
|
||||
|
||||
|
||||
var React$2 = Object.freeze({
|
||||
var React$2 = ({
|
||||
default: React
|
||||
});
|
||||
|
||||
|
@ -1677,7 +1806,7 @@ var React$3 = ( React$2 && React ) || React$2;
|
|||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
var react = React$3['default'] ? React$3['default'] : React$3;
|
||||
var react = React$3.default ? React$3.default : React$3;
|
||||
|
||||
return react;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,4 +1,4 @@
|
|||
/** @license React v16.2.0
|
||||
/** @license React v16.4.1
|
||||
* react-dom-test-utils.development.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
@ -19,13 +19,6 @@ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|||
|
||||
var _assign = ReactInternals.assign;
|
||||
|
||||
/**
|
||||
* WARNING: DO NOT manually require this module.
|
||||
* This is a replacement for `invariant(...)` used by the error code system
|
||||
* and will _only_ be required by the corresponding babel pass.
|
||||
* It always throws.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -80,6 +73,9 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|||
|
||||
var invariant_1 = invariant;
|
||||
|
||||
// Relying on the `invariant()` implementation lets us
|
||||
// have preserve the format and params in the www builds.
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -204,6 +200,9 @@ var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|||
var ReactCurrentOwner = ReactInternals$1.ReactCurrentOwner;
|
||||
var ReactDebugCurrentFrame = ReactInternals$1.ReactDebugCurrentFrame;
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
|
||||
// Before we know whether it is functional or class
|
||||
var FunctionalComponent = 1;
|
||||
var ClassComponent = 2;
|
||||
|
@ -212,19 +211,22 @@ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
|
|||
var HostComponent = 5;
|
||||
var HostText = 6;
|
||||
|
||||
// Don't change these two values:
|
||||
var NoEffect = 0; // 0b00000000
|
||||
// 0b00000001
|
||||
// Don't change these two values. They're used by React Dev Tools.
|
||||
var NoEffect = /* */0;
|
||||
|
||||
|
||||
// You can change the rest (and add more).
|
||||
var Placement = 2; // 0b00000010
|
||||
// 0b00000100
|
||||
// 0b00000110
|
||||
// 0b00001000
|
||||
// 0b00010000
|
||||
// 0b00100000
|
||||
// 0b01000000
|
||||
// 0b10000000
|
||||
var Placement = /* */2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Union of all host effects
|
||||
|
||||
var MOUNTING = 1;
|
||||
var MOUNTED = 2;
|
||||
|
@ -238,15 +240,15 @@ function isFiberMountedImpl(fiber) {
|
|||
if ((node.effectTag & Placement) !== NoEffect) {
|
||||
return MOUNTING;
|
||||
}
|
||||
while (node['return']) {
|
||||
node = node['return'];
|
||||
while (node.return) {
|
||||
node = node.return;
|
||||
if ((node.effectTag & Placement) !== NoEffect) {
|
||||
return MOUNTING;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (node['return']) {
|
||||
node = node['return'];
|
||||
while (node.return) {
|
||||
node = node.return;
|
||||
}
|
||||
}
|
||||
if (node.tag === HostRoot) {
|
||||
|
@ -284,7 +286,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|||
var a = fiber;
|
||||
var b = alternate;
|
||||
while (true) {
|
||||
var parentA = a['return'];
|
||||
var parentA = a.return;
|
||||
var parentB = parentA ? parentA.alternate : null;
|
||||
if (!parentA || !parentB) {
|
||||
// We're at the root.
|
||||
|
@ -314,7 +316,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|||
invariant_1(false, 'Unable to find node on an unmounted component.');
|
||||
}
|
||||
|
||||
if (a['return'] !== b['return']) {
|
||||
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
|
||||
|
@ -382,7 +384,6 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|||
/* eslint valid-typeof: 0 */
|
||||
|
||||
var didWarnForAddedNewProperty = false;
|
||||
var isProxySupported = typeof Proxy === 'function';
|
||||
var EVENT_POOL_SIZE = 10;
|
||||
|
||||
var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
|
||||
|
@ -543,24 +544,26 @@ SyntheticEvent.Interface = EventInterface;
|
|||
|
||||
/**
|
||||
* Helper to reduce boilerplate when creating subclasses.
|
||||
*
|
||||
* @param {function} Class
|
||||
* @param {?object} Interface
|
||||
*/
|
||||
SyntheticEvent.augmentClass = function (Class, Interface) {
|
||||
SyntheticEvent.extend = function (Interface) {
|
||||
var Super = this;
|
||||
|
||||
var E = function () {};
|
||||
E.prototype = Super.prototype;
|
||||
var prototype = new E();
|
||||
|
||||
function Class() {
|
||||
return Super.apply(this, arguments);
|
||||
}
|
||||
_assign(prototype, Class.prototype);
|
||||
Class.prototype = prototype;
|
||||
Class.prototype.constructor = Class;
|
||||
|
||||
Class.Interface = _assign({}, Super.Interface, Interface);
|
||||
Class.augmentClass = Super.augmentClass;
|
||||
Class.extend = Super.extend;
|
||||
addEventPoolingTo(Class);
|
||||
|
||||
return Class;
|
||||
};
|
||||
|
||||
/** Proxying after everything set on SyntheticEvent
|
||||
|
@ -568,6 +571,10 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
|
|||
* in which some Event properties are set to undefined (GH#10010)
|
||||
*/
|
||||
{
|
||||
var isProxySupported = typeof Proxy === 'function' &&
|
||||
// https://github.com/facebook/react/issues/12011
|
||||
!Object.isSealed(new Proxy({}, {}));
|
||||
|
||||
if (isProxySupported) {
|
||||
/*eslint-disable no-func-assign */
|
||||
SyntheticEvent = new Proxy(SyntheticEvent, {
|
||||
|
@ -578,7 +585,7 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
|
|||
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_1(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 || target.isPersistent()) ? warning_1(false, "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.') : void 0;
|
||||
didWarnForAddedNewProperty = true;
|
||||
}
|
||||
target[prop] = value;
|
||||
|
@ -623,7 +630,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
|
|||
|
||||
function warn(action, result) {
|
||||
var warningCondition = false;
|
||||
warning_1(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);
|
||||
!warningCondition ? warning_1(false, "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) : void 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,6 +661,14 @@ function addEventPoolingTo(EventConstructor) {
|
|||
|
||||
var SyntheticEvent$1 = SyntheticEvent;
|
||||
|
||||
// Do not uses the below two methods directly!
|
||||
// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
|
||||
// (It is the only module that is allowed to access these methods.)
|
||||
|
||||
function unsafeCastStringToDOMTopLevelType(topLevelType) {
|
||||
return topLevelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -770,90 +785,101 @@ function getVendorPrefixedEventName(eventName) {
|
|||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return eventName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of raw signals from the browser caught at the top level.
|
||||
*
|
||||
* 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.
|
||||
* To identify top level events in ReactDOM, we use constants defined by this
|
||||
* module. This is the only module that uses the unsafe* methods to express
|
||||
* that the constants actually correspond to the browser event names. This lets
|
||||
* us save some bundle size by avoiding a top level type -> event name map.
|
||||
* The rest of ReactDOM code should import top level types from this file.
|
||||
*/
|
||||
var topLevelTypes$1 = {
|
||||
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',
|
||||
topLoad: 'load',
|
||||
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'
|
||||
};
|
||||
var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
|
||||
var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
|
||||
var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
|
||||
var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
|
||||
var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
|
||||
var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
|
||||
var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
|
||||
var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
|
||||
var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
|
||||
var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
|
||||
var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
|
||||
var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
|
||||
var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
|
||||
var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
|
||||
var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
|
||||
var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
|
||||
var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
|
||||
var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
|
||||
var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
|
||||
var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
|
||||
var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
|
||||
var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
|
||||
var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
|
||||
var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
|
||||
var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
|
||||
var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
|
||||
var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
|
||||
var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
|
||||
var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
|
||||
var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
|
||||
var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
|
||||
var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
|
||||
|
||||
var BrowserEventConstants = {
|
||||
topLevelTypes: topLevelTypes$1
|
||||
};
|
||||
var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
|
||||
|
||||
var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
|
||||
var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
|
||||
var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
|
||||
var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
|
||||
var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
|
||||
var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
|
||||
var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
|
||||
|
||||
var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
|
||||
var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
|
||||
var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
|
||||
var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
|
||||
var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
|
||||
var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
|
||||
var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
|
||||
var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
|
||||
var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
|
||||
var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
|
||||
|
||||
var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
|
||||
var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
|
||||
var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
|
||||
var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
|
||||
var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
|
||||
|
||||
var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
|
||||
var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
|
||||
var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
|
||||
var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
|
||||
var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
|
||||
var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
|
||||
var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
|
||||
var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
|
||||
var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
|
||||
var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
|
||||
var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
|
||||
var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
|
||||
|
||||
// List of events that need to be individually attached to media elements.
|
||||
// Note that events in this list will *not* be listened to at the top level
|
||||
// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
|
||||
|
||||
var findDOMNode = ReactDOM.findDOMNode;
|
||||
var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
@ -865,14 +891,35 @@ var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree;
|
|||
var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener;
|
||||
|
||||
|
||||
var topLevelTypes = BrowserEventConstants.topLevelTypes;
|
||||
|
||||
function Event(suffix) {}
|
||||
|
||||
/**
|
||||
* @class ReactTestUtils
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simulates a top level event being dispatched from a raw event that occurred
|
||||
* on an `Element` node.
|
||||
* @param {number} topLevelType A number from `TopLevelEventTypes`
|
||||
* @param {!Element} node The dom to simulate an event occurring on.
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
|
||||
fakeNativeEvent.target = node;
|
||||
ReactDOMEventListener.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 `BrowserEventConstants.topLevelTypes`.
|
||||
* @param {!ReactDOMComponent} comp
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
|
||||
simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
|
||||
}
|
||||
|
||||
function findAllInRenderedFiberTreeInternal(fiber, test) {
|
||||
if (!fiber) {
|
||||
return [];
|
||||
|
@ -891,7 +938,7 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
|
|||
}
|
||||
}
|
||||
if (node.child) {
|
||||
node.child['return'] = node;
|
||||
node.child.return = node;
|
||||
node = node.child;
|
||||
continue;
|
||||
}
|
||||
|
@ -899,12 +946,12 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
|
|||
return ret;
|
||||
}
|
||||
while (!node.sibling) {
|
||||
if (!node['return'] || node['return'] === currentParent) {
|
||||
if (!node.return || node.return === currentParent) {
|
||||
return ret;
|
||||
}
|
||||
node = node['return'];
|
||||
node = node.return;
|
||||
}
|
||||
node.sibling['return'] = node['return'];
|
||||
node.sibling.return = node.return;
|
||||
node = node.sibling;
|
||||
}
|
||||
}
|
||||
|
@ -1085,29 +1132,6 @@ var ReactTestUtils = {
|
|||
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 `BrowserEventConstants.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;
|
||||
ReactDOMEventListener.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 `BrowserEventConstants.topLevelTypes`.
|
||||
* @param {!ReactDOMComponent} comp
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
|
||||
ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
|
||||
},
|
||||
|
||||
nativeTouchData: function (x, y) {
|
||||
return {
|
||||
touches: [{ pageX: x, pageY: y }]
|
||||
|
@ -1157,17 +1181,16 @@ function makeSimulator(eventType) {
|
|||
// Normally extractEvent enqueues a state restore, but we'll just always
|
||||
// do that since we we're by-passing it here.
|
||||
ReactControlledComponent.enqueueStateRestore(domNode);
|
||||
|
||||
EventPluginHub.enqueueEvents(event);
|
||||
EventPluginHub.processEventQueue(true);
|
||||
EventPluginHub.runEventsInBatch(event, true);
|
||||
});
|
||||
ReactControlledComponent.restoreStateIfNeeded();
|
||||
};
|
||||
}
|
||||
|
||||
function buildSimulators() {
|
||||
ReactTestUtils.Simulate = {};
|
||||
|
||||
var eventType;
|
||||
var eventType = void 0;
|
||||
for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
|
||||
/**
|
||||
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
||||
|
@ -1207,32 +1230,33 @@ buildSimulators();
|
|||
* to dispatch synthetic events.
|
||||
*/
|
||||
|
||||
function makeNativeSimulator(eventType) {
|
||||
function makeNativeSimulator(eventType, topLevelType) {
|
||||
return function (domComponentOrNode, nativeEventData) {
|
||||
var fakeNativeEvent = new Event(eventType);
|
||||
_assign(fakeNativeEvent, nativeEventData);
|
||||
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
||||
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
||||
simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
|
||||
} else if (domComponentOrNode.tagName) {
|
||||
// Will allow on actual dom nodes.
|
||||
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
|
||||
simulateNativeEventOnNode(topLevelType, 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;
|
||||
[[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
|
||||
var topLevelType = _ref[0],
|
||||
eventType = _ref[1];
|
||||
|
||||
/**
|
||||
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
||||
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
|
||||
ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var ReactTestUtils$2 = Object.freeze({
|
||||
var ReactTestUtils$2 = ({
|
||||
default: ReactTestUtils
|
||||
});
|
||||
|
||||
|
@ -1240,7 +1264,7 @@ var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$
|
|||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3;
|
||||
var testUtils = ReactTestUtils$3.default ? ReactTestUtils$3.default : ReactTestUtils$3;
|
||||
|
||||
return testUtils;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/** @license React v16.2.0
|
||||
/** @license React v16.4.1
|
||||
* react-dom-test-utils.production.min.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
@ -16,6 +16,39 @@ var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|||
|
||||
var _assign = ReactInternals.assign;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function invariant(condition, format, a, b, c, d, e, f) {
|
||||
if (!condition) {
|
||||
var error;
|
||||
if (format === undefined) {
|
||||
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
||||
} else {
|
||||
var args = [a, b, c, d, e, f];
|
||||
var argIndex = 0;
|
||||
error = new Error(format.replace(/%s/g, function () {
|
||||
return args[argIndex++];
|
||||
}));
|
||||
error.name = 'Invariant Violation';
|
||||
}
|
||||
|
||||
error.framesToPop = 1; // we don't care about invariant's own frame
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
var invariant_1 = invariant;
|
||||
|
||||
// Relying on the `invariant()` implementation lets us
|
||||
// have preserve the format and params in the www builds.
|
||||
/**
|
||||
* WARNING: DO NOT manually require this module.
|
||||
* This is a replacement for `invariant(...)` used by the error code system
|
||||
|
@ -24,30 +57,20 @@ var _assign = ReactInternals.assign;
|
|||
*/
|
||||
function reactProdInvariant(code) {
|
||||
var argCount = arguments.length - 1;
|
||||
|
||||
var message = 'Minified React error #' + code + '; visit ' + 'http://facebook.github.io/react/docs/error-decoder.html?invariant=' + code;
|
||||
|
||||
var url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
|
||||
for (var argIdx = 0; argIdx < argCount; argIdx++) {
|
||||
message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
||||
url += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
||||
}
|
||||
|
||||
message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
|
||||
|
||||
var error = new Error(message);
|
||||
error.name = 'Invariant Violation';
|
||||
error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
|
||||
|
||||
throw error;
|
||||
// Rename it so that our build transform doesn't atttempt
|
||||
// to replace this invariant() call with reactProdInvariant().
|
||||
var i = invariant_1;
|
||||
i(false,
|
||||
// The error code is intentionally part of the message (and
|
||||
// not the format argument) so that we could deduplicate
|
||||
// different errors in logs based on the code.
|
||||
'Minified React error #' + code + '; visit %s ' + 'for the full message or use the non-minified dev environment ' + 'for full errors and additional helpful warnings. ', url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -116,6 +139,9 @@ var ReactInternals$1 = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|||
|
||||
var ReactCurrentOwner = ReactInternals$1.ReactCurrentOwner;
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
|
||||
// Before we know whether it is functional or class
|
||||
var FunctionalComponent = 1;
|
||||
var ClassComponent = 2;
|
||||
|
@ -124,19 +150,22 @@ var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
|
|||
var HostComponent = 5;
|
||||
var HostText = 6;
|
||||
|
||||
// Don't change these two values:
|
||||
var NoEffect = 0; // 0b00000000
|
||||
// 0b00000001
|
||||
// Don't change these two values. They're used by React Dev Tools.
|
||||
var NoEffect = /* */0;
|
||||
|
||||
|
||||
// You can change the rest (and add more).
|
||||
var Placement = 2; // 0b00000010
|
||||
// 0b00000100
|
||||
// 0b00000110
|
||||
// 0b00001000
|
||||
// 0b00010000
|
||||
// 0b00100000
|
||||
// 0b01000000
|
||||
// 0b10000000
|
||||
var Placement = /* */2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Union of all host effects
|
||||
|
||||
var MOUNTING = 1;
|
||||
var MOUNTED = 2;
|
||||
|
@ -150,15 +179,15 @@ function isFiberMountedImpl(fiber) {
|
|||
if ((node.effectTag & Placement) !== NoEffect) {
|
||||
return MOUNTING;
|
||||
}
|
||||
while (node['return']) {
|
||||
node = node['return'];
|
||||
while (node.return) {
|
||||
node = node.return;
|
||||
if ((node.effectTag & Placement) !== NoEffect) {
|
||||
return MOUNTING;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (node['return']) {
|
||||
node = node['return'];
|
||||
while (node.return) {
|
||||
node = node.return;
|
||||
}
|
||||
}
|
||||
if (node.tag === HostRoot) {
|
||||
|
@ -196,7 +225,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|||
var a = fiber;
|
||||
var b = alternate;
|
||||
while (true) {
|
||||
var parentA = a['return'];
|
||||
var parentA = a.return;
|
||||
var parentB = parentA ? parentA.alternate : null;
|
||||
if (!parentA || !parentB) {
|
||||
// We're at the root.
|
||||
|
@ -226,7 +255,7 @@ function findCurrentFiberUsingSlowPath(fiber) {
|
|||
reactProdInvariant('188');
|
||||
}
|
||||
|
||||
if (a['return'] !== b['return']) {
|
||||
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
|
||||
|
@ -439,24 +468,26 @@ SyntheticEvent.Interface = EventInterface;
|
|||
|
||||
/**
|
||||
* Helper to reduce boilerplate when creating subclasses.
|
||||
*
|
||||
* @param {function} Class
|
||||
* @param {?object} Interface
|
||||
*/
|
||||
SyntheticEvent.augmentClass = function (Class, Interface) {
|
||||
SyntheticEvent.extend = function (Interface) {
|
||||
var Super = this;
|
||||
|
||||
var E = function () {};
|
||||
E.prototype = Super.prototype;
|
||||
var prototype = new E();
|
||||
|
||||
function Class() {
|
||||
return Super.apply(this, arguments);
|
||||
}
|
||||
_assign(prototype, Class.prototype);
|
||||
Class.prototype = prototype;
|
||||
Class.prototype.constructor = Class;
|
||||
|
||||
Class.Interface = _assign({}, Super.Interface, Interface);
|
||||
Class.augmentClass = Super.augmentClass;
|
||||
Class.extend = Super.extend;
|
||||
addEventPoolingTo(Class);
|
||||
|
||||
return Class;
|
||||
};
|
||||
|
||||
/** Proxying after everything set on SyntheticEvent
|
||||
|
@ -490,6 +521,14 @@ function addEventPoolingTo(EventConstructor) {
|
|||
EventConstructor.release = releasePooledEvent;
|
||||
}
|
||||
|
||||
// Do not uses the below two methods directly!
|
||||
// Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
|
||||
// (It is the only module that is allowed to access these methods.)
|
||||
|
||||
function unsafeCastStringToDOMTopLevelType(topLevelType) {
|
||||
return topLevelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -606,90 +645,101 @@ function getVendorPrefixedEventName(eventName) {
|
|||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
return eventName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Types of raw signals from the browser caught at the top level.
|
||||
*
|
||||
* 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.
|
||||
* To identify top level events in ReactDOM, we use constants defined by this
|
||||
* module. This is the only module that uses the unsafe* methods to express
|
||||
* that the constants actually correspond to the browser event names. This lets
|
||||
* us save some bundle size by avoiding a top level type -> event name map.
|
||||
* The rest of ReactDOM code should import top level types from this file.
|
||||
*/
|
||||
var topLevelTypes$1 = {
|
||||
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',
|
||||
topLoad: 'load',
|
||||
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'
|
||||
};
|
||||
var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
|
||||
var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
|
||||
var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
|
||||
var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
|
||||
var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
|
||||
var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
|
||||
var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
|
||||
var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
|
||||
var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
|
||||
var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
|
||||
var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
|
||||
var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
|
||||
var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
|
||||
var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
|
||||
var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
|
||||
var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
|
||||
var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
|
||||
var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
|
||||
var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
|
||||
var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
|
||||
var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
|
||||
var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
|
||||
var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
|
||||
var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
|
||||
var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
|
||||
var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
|
||||
var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
|
||||
var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
|
||||
var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
|
||||
var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
|
||||
var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
|
||||
var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
|
||||
|
||||
var BrowserEventConstants = {
|
||||
topLevelTypes: topLevelTypes$1
|
||||
};
|
||||
var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
|
||||
|
||||
var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
|
||||
var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
|
||||
var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
|
||||
var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
|
||||
var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
|
||||
var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
|
||||
var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
|
||||
|
||||
var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
|
||||
var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
|
||||
var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
|
||||
var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
|
||||
var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
|
||||
var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
|
||||
var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
|
||||
var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
|
||||
var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
|
||||
var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
|
||||
|
||||
var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
|
||||
var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
|
||||
var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
|
||||
var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
|
||||
var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
|
||||
|
||||
var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
|
||||
var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
|
||||
var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
|
||||
var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
|
||||
var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
|
||||
var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
|
||||
var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
|
||||
var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
|
||||
var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
|
||||
var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
|
||||
var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
|
||||
var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
|
||||
|
||||
// List of events that need to be individually attached to media elements.
|
||||
// Note that events in this list will *not* be listened to at the top level
|
||||
// unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
|
||||
|
||||
var findDOMNode = ReactDOM.findDOMNode;
|
||||
var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
|
@ -701,14 +751,35 @@ var ReactDOMComponentTree = _ReactDOM$__SECRET_IN.ReactDOMComponentTree;
|
|||
var ReactDOMEventListener = _ReactDOM$__SECRET_IN.ReactDOMEventListener;
|
||||
|
||||
|
||||
var topLevelTypes = BrowserEventConstants.topLevelTypes;
|
||||
|
||||
function Event(suffix) {}
|
||||
|
||||
/**
|
||||
* @class ReactTestUtils
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simulates a top level event being dispatched from a raw event that occurred
|
||||
* on an `Element` node.
|
||||
* @param {number} topLevelType A number from `TopLevelEventTypes`
|
||||
* @param {!Element} node The dom to simulate an event occurring on.
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) {
|
||||
fakeNativeEvent.target = node;
|
||||
ReactDOMEventListener.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 `BrowserEventConstants.topLevelTypes`.
|
||||
* @param {!ReactDOMComponent} comp
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
function simulateNativeEventOnDOMComponent(topLevelType, comp, fakeNativeEvent) {
|
||||
simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
|
||||
}
|
||||
|
||||
function findAllInRenderedFiberTreeInternal(fiber, test) {
|
||||
if (!fiber) {
|
||||
return [];
|
||||
|
@ -727,7 +798,7 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
|
|||
}
|
||||
}
|
||||
if (node.child) {
|
||||
node.child['return'] = node;
|
||||
node.child.return = node;
|
||||
node = node.child;
|
||||
continue;
|
||||
}
|
||||
|
@ -735,12 +806,12 @@ function findAllInRenderedFiberTreeInternal(fiber, test) {
|
|||
return ret;
|
||||
}
|
||||
while (!node.sibling) {
|
||||
if (!node['return'] || node['return'] === currentParent) {
|
||||
if (!node.return || node.return === currentParent) {
|
||||
return ret;
|
||||
}
|
||||
node = node['return'];
|
||||
node = node.return;
|
||||
}
|
||||
node.sibling['return'] = node['return'];
|
||||
node.sibling.return = node.return;
|
||||
node = node.sibling;
|
||||
}
|
||||
}
|
||||
|
@ -921,29 +992,6 @@ var ReactTestUtils = {
|
|||
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 `BrowserEventConstants.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;
|
||||
ReactDOMEventListener.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 `BrowserEventConstants.topLevelTypes`.
|
||||
* @param {!ReactDOMComponent} comp
|
||||
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
|
||||
ReactTestUtils.simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent);
|
||||
},
|
||||
|
||||
nativeTouchData: function (x, y) {
|
||||
return {
|
||||
touches: [{ pageX: x, pageY: y }]
|
||||
|
@ -993,17 +1041,16 @@ function makeSimulator(eventType) {
|
|||
// Normally extractEvent enqueues a state restore, but we'll just always
|
||||
// do that since we we're by-passing it here.
|
||||
ReactControlledComponent.enqueueStateRestore(domNode);
|
||||
|
||||
EventPluginHub.enqueueEvents(event);
|
||||
EventPluginHub.processEventQueue(true);
|
||||
EventPluginHub.runEventsInBatch(event, true);
|
||||
});
|
||||
ReactControlledComponent.restoreStateIfNeeded();
|
||||
};
|
||||
}
|
||||
|
||||
function buildSimulators() {
|
||||
ReactTestUtils.Simulate = {};
|
||||
|
||||
var eventType;
|
||||
var eventType = void 0;
|
||||
for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
|
||||
/**
|
||||
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
||||
|
@ -1043,32 +1090,33 @@ buildSimulators();
|
|||
* to dispatch synthetic events.
|
||||
*/
|
||||
|
||||
function makeNativeSimulator(eventType) {
|
||||
function makeNativeSimulator(eventType, topLevelType) {
|
||||
return function (domComponentOrNode, nativeEventData) {
|
||||
var fakeNativeEvent = new Event(eventType);
|
||||
_assign(fakeNativeEvent, nativeEventData);
|
||||
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
||||
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
||||
simulateNativeEventOnDOMComponent(topLevelType, domComponentOrNode, fakeNativeEvent);
|
||||
} else if (domComponentOrNode.tagName) {
|
||||
// Will allow on actual dom nodes.
|
||||
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
|
||||
simulateNativeEventOnNode(topLevelType, 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;
|
||||
[[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_BLUR, 'blur'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CANCEL, 'cancel'], [TOP_CHANGE, 'change'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_COMPOSITION_END, 'compositionEnd'], [TOP_COMPOSITION_START, 'compositionStart'], [TOP_COMPOSITION_UPDATE, 'compositionUpdate'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DRAG_START, 'dragStart'], [TOP_DRAG, 'drag'], [TOP_DROP, 'drop'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD_START, 'loadStart'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_PLAYING, 'playing'], [TOP_PROGRESS, 'progress'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_SCROLL, 'scroll'], [TOP_SEEKED, 'seeked'], [TOP_SEEKING, 'seeking'], [TOP_SELECTION_CHANGE, 'selectionChange'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TEXT_INPUT, 'textInput'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TOUCH_START, 'touchStart'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_VOLUME_CHANGE, 'volumeChange'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']].forEach(function (_ref) {
|
||||
var topLevelType = _ref[0],
|
||||
eventType = _ref[1];
|
||||
|
||||
/**
|
||||
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
||||
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
||||
*/
|
||||
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
|
||||
ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator(eventType, topLevelType);
|
||||
});
|
||||
|
||||
|
||||
|
||||
var ReactTestUtils$2 = Object.freeze({
|
||||
var ReactTestUtils$2 = ({
|
||||
default: ReactTestUtils
|
||||
});
|
||||
|
||||
|
@ -1076,7 +1124,7 @@ var ReactTestUtils$3 = ( ReactTestUtils$2 && ReactTestUtils ) || ReactTestUtils$
|
|||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
var testUtils = ReactTestUtils$3['default'] ? ReactTestUtils$3['default'] : ReactTestUtils$3;
|
||||
var testUtils = ReactTestUtils$3.default ? ReactTestUtils$3.default : ReactTestUtils$3;
|
||||
|
||||
return testUtils;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,4 +1,4 @@
|
|||
/** @license React v16.2.0
|
||||
/** @license React v16.4.1
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
@ -105,17 +105,22 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
|
|||
|
||||
// TODO: this is special because it gets imported during build.
|
||||
|
||||
var ReactVersion = '16.2.0';
|
||||
var ReactVersion = '16.4.1';
|
||||
|
||||
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
||||
// nor polyfill, then a plain number is used for performance.
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol['for'];
|
||||
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||
|
||||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol['for']('react.element') : 0xeac7;
|
||||
var REACT_CALL_TYPE = hasSymbol ? Symbol['for']('react.call') : 0xeac8;
|
||||
var REACT_RETURN_TYPE = hasSymbol ? Symbol['for']('react.return') : 0xeac9;
|
||||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol['for']('react.portal') : 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol['for']('react.fragment') : 0xeacb;
|
||||
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
||||
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
||||
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
||||
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
||||
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
||||
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
||||
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
||||
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
||||
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
||||
var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1;
|
||||
|
||||
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
||||
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
||||
|
@ -131,6 +136,39 @@ function getIteratorFn(maybeIterable) {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function invariant(condition, format, a, b, c, d, e, f) {
|
||||
if (!condition) {
|
||||
var error;
|
||||
if (format === undefined) {
|
||||
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
||||
} else {
|
||||
var args = [a, b, c, d, e, f];
|
||||
var argIndex = 0;
|
||||
error = new Error(format.replace(/%s/g, function () {
|
||||
return args[argIndex++];
|
||||
}));
|
||||
error.name = 'Invariant Violation';
|
||||
}
|
||||
|
||||
error.framesToPop = 1; // we don't care about invariant's own frame
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
var invariant_1 = invariant;
|
||||
|
||||
// Relying on the `invariant()` implementation lets us
|
||||
// have preserve the format and params in the www builds.
|
||||
/**
|
||||
* WARNING: DO NOT manually require this module.
|
||||
* This is a replacement for `invariant(...)` used by the error code system
|
||||
|
@ -139,22 +177,52 @@ function getIteratorFn(maybeIterable) {
|
|||
*/
|
||||
function reactProdInvariant(code) {
|
||||
var argCount = arguments.length - 1;
|
||||
|
||||
var message = 'Minified React error #' + code + '; visit ' + 'http://facebook.github.io/react/docs/error-decoder.html?invariant=' + code;
|
||||
|
||||
var url = 'https://reactjs.org/docs/error-decoder.html?invariant=' + code;
|
||||
for (var argIdx = 0; argIdx < argCount; argIdx++) {
|
||||
message += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
||||
url += '&args[]=' + encodeURIComponent(arguments[argIdx + 1]);
|
||||
}
|
||||
|
||||
message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
|
||||
|
||||
var error = new Error(message);
|
||||
error.name = 'Invariant Violation';
|
||||
error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
|
||||
|
||||
throw error;
|
||||
// Rename it so that our build transform doesn't atttempt
|
||||
// to replace this invariant() call with reactProdInvariant().
|
||||
var i = invariant_1;
|
||||
i(false,
|
||||
// The error code is intentionally part of the message (and
|
||||
// not the format argument) so that we could deduplicate
|
||||
// different errors in logs based on the code.
|
||||
'Minified React error #' + code + '; visit %s ' + 'for the full message or use the non-minified dev environment ' + 'for full errors and additional helpful warnings. ', url);
|
||||
}
|
||||
|
||||
// Exports ReactDOM.createRoot
|
||||
|
||||
|
||||
// Experimental error-boundary API that can recover from errors within a single
|
||||
// render phase
|
||||
|
||||
// Suspense
|
||||
var enableSuspense = false;
|
||||
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
||||
|
||||
|
||||
// In some cases, StrictMode should also double-render lifecycles.
|
||||
// This can be confusing for tests though,
|
||||
// And it can be bad for performance in production.
|
||||
// This feature flag can be used to control the behavior:
|
||||
|
||||
|
||||
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
||||
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
||||
|
||||
|
||||
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
||||
|
||||
|
||||
// Warn about legacy context API
|
||||
|
||||
|
||||
// Gather advanced timing metrics for Profiler subtrees.
|
||||
|
||||
|
||||
// Only used in www builds.
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -169,14 +237,6 @@ var emptyObject = {};
|
|||
|
||||
var emptyObject_1 = emptyObject;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Forked from fbjs/warning:
|
||||
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
|
||||
|
@ -369,46 +429,33 @@ Component.prototype.forceUpdate = function (callback) {
|
|||
* 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.
|
||||
*/
|
||||
function ComponentDummy() {}
|
||||
ComponentDummy.prototype = Component.prototype;
|
||||
|
||||
/**
|
||||
* Base class helpers for the updating state of a component.
|
||||
* Convenience component with default shallow equality check for sCU.
|
||||
*/
|
||||
function PureComponent(props, context, updater) {
|
||||
// Duplicated from Component.
|
||||
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 = Component.prototype;
|
||||
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
||||
pureComponentPrototype.constructor = PureComponent;
|
||||
// Avoid an extra prototype jump for these methods.
|
||||
objectAssign(pureComponentPrototype, Component.prototype);
|
||||
pureComponentPrototype.isPureReactComponent = true;
|
||||
|
||||
function AsyncComponent(props, context, updater) {
|
||||
// Duplicated from Component.
|
||||
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;
|
||||
// an immutable object with a single mutable value
|
||||
function createRef() {
|
||||
var refObject = {
|
||||
current: null
|
||||
};
|
||||
return refObject;
|
||||
}
|
||||
|
||||
var asyncComponentPrototype = AsyncComponent.prototype = new ComponentDummy();
|
||||
asyncComponentPrototype.constructor = AsyncComponent;
|
||||
// Avoid an extra prototype jump for these methods.
|
||||
objectAssign(asyncComponentPrototype, Component.prototype);
|
||||
asyncComponentPrototype.unstable_isAsyncReactComponent = true;
|
||||
asyncComponentPrototype.render = function () {
|
||||
return this.props.children;
|
||||
};
|
||||
|
||||
/**
|
||||
* Keeps track of the current owner.
|
||||
*
|
||||
|
@ -462,7 +509,7 @@ function hasValidKey(config) {
|
|||
*/
|
||||
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
||||
var element = {
|
||||
// This tag allow us to uniquely identify this as a React Element
|
||||
// This tag allows us to uniquely identify this as a React Element
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
|
||||
// Built-in properties that belong on the element
|
||||
|
@ -483,7 +530,7 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|||
* See https://reactjs.org/docs/react-api.html#createelement
|
||||
*/
|
||||
function createElement(type, config, children) {
|
||||
var propName;
|
||||
var propName = void 0;
|
||||
|
||||
// Reserved names are extracted
|
||||
var props = {};
|
||||
|
@ -546,7 +593,7 @@ function createFactory(type) {
|
|||
// 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
|
||||
// Legacy hook: remove it
|
||||
factory.type = type;
|
||||
return factory;
|
||||
}
|
||||
|
@ -562,7 +609,9 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
|||
* See https://reactjs.org/docs/react-api.html#cloneelement
|
||||
*/
|
||||
function cloneElement(element, config, children) {
|
||||
var propName;
|
||||
!!(element === null || element === undefined) ? reactProdInvariant('267', element) : void 0;
|
||||
|
||||
var propName = void 0;
|
||||
|
||||
// Original props are copied
|
||||
var props = objectAssign({}, element.props);
|
||||
|
@ -591,7 +640,7 @@ function cloneElement(element, config, children) {
|
|||
}
|
||||
|
||||
// Remaining properties override existing props
|
||||
var defaultProps;
|
||||
var defaultProps = void 0;
|
||||
if (element.type && element.type.defaultProps) {
|
||||
defaultProps = element.type.defaultProps;
|
||||
}
|
||||
|
@ -723,8 +772,6 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
case 'object':
|
||||
switch (children.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
case REACT_CALL_TYPE:
|
||||
case REACT_RETURN_TYPE:
|
||||
case REACT_PORTAL_TYPE:
|
||||
invokeCallback = true;
|
||||
}
|
||||
|
@ -739,8 +786,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
return 1;
|
||||
}
|
||||
|
||||
var child;
|
||||
var nextName;
|
||||
var child = void 0;
|
||||
var nextName = void 0;
|
||||
var subtreeCount = 0; // Count of children found in the current subtree.
|
||||
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
||||
|
||||
|
@ -754,7 +801,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|||
var iteratorFn = getIteratorFn(children);
|
||||
if (typeof iteratorFn === 'function') {
|
||||
var iterator = iteratorFn.call(children);
|
||||
var step;
|
||||
var step = void 0;
|
||||
var ii = 0;
|
||||
while (!(step = iterator.next()).done) {
|
||||
child = step.value;
|
||||
|
@ -823,7 +870,7 @@ function forEachSingleChild(bookKeeping, child, name) {
|
|||
/**
|
||||
* Iterates through children that are typically specified as `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.foreach
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenforeach
|
||||
*
|
||||
* The provided forEachFunc(child, index) will be called for each
|
||||
* leaf child.
|
||||
|
@ -875,7 +922,7 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|||
/**
|
||||
* Maps children that are typically specified as `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.map
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenmap
|
||||
*
|
||||
* The provided mapFunction(child, key, index) will be called for each
|
||||
* leaf child.
|
||||
|
@ -898,12 +945,12 @@ function mapChildren(children, func, context) {
|
|||
* Count the number of children that are typically specified as
|
||||
* `props.children`.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.count
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrencount
|
||||
*
|
||||
* @param {?*} children Children tree container.
|
||||
* @return {number} The number of children.
|
||||
*/
|
||||
function countChildren(children, context) {
|
||||
function countChildren(children) {
|
||||
return traverseAllChildren(children, emptyFunction_1.thatReturnsNull, null);
|
||||
}
|
||||
|
||||
|
@ -911,7 +958,7 @@ function countChildren(children, context) {
|
|||
* Flatten a children object (typically specified as `props.children`) and
|
||||
* return an array with appropriately re-keyed children.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.toarray
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
||||
*/
|
||||
function toArray(children) {
|
||||
var result = [];
|
||||
|
@ -923,7 +970,7 @@ function toArray(children) {
|
|||
* Returns the first child in a collection of children and verifies that there
|
||||
* is only one child in the collection.
|
||||
*
|
||||
* See https://reactjs.org/docs/react-api.html#react.children.only
|
||||
* See https://reactjs.org/docs/react-api.html#reactchildrenonly
|
||||
*
|
||||
* 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
|
||||
|
@ -938,6 +985,47 @@ function onlyChild(children) {
|
|||
return children;
|
||||
}
|
||||
|
||||
function createContext(defaultValue, calculateChangedBits) {
|
||||
if (calculateChangedBits === undefined) {
|
||||
calculateChangedBits = null;
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
var context = {
|
||||
$$typeof: REACT_CONTEXT_TYPE,
|
||||
_calculateChangedBits: calculateChangedBits,
|
||||
_defaultValue: defaultValue,
|
||||
_currentValue: defaultValue,
|
||||
// As a workaround to support multiple concurrent renderers, we categorize
|
||||
// some renderers as primary and others as secondary. We only expect
|
||||
// there to be two concurrent renderers at most: React Native (primary) and
|
||||
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
||||
// Secondary renderers store their context values on separate fields.
|
||||
_currentValue2: defaultValue,
|
||||
_changedBits: 0,
|
||||
_changedBits2: 0,
|
||||
// These are circular
|
||||
Provider: null,
|
||||
Consumer: null
|
||||
};
|
||||
|
||||
context.Provider = {
|
||||
$$typeof: REACT_PROVIDER_TYPE,
|
||||
_context: context
|
||||
};
|
||||
context.Consumer = context;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
function forwardRef(render) {
|
||||
return {
|
||||
$$typeof: REACT_FORWARD_REF_TYPE,
|
||||
render: render
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
|
@ -961,11 +1049,17 @@ var React = {
|
|||
only: onlyChild
|
||||
},
|
||||
|
||||
createRef: createRef,
|
||||
Component: Component,
|
||||
PureComponent: PureComponent,
|
||||
unstable_AsyncComponent: AsyncComponent,
|
||||
|
||||
createContext: createContext,
|
||||
forwardRef: forwardRef,
|
||||
|
||||
Fragment: REACT_FRAGMENT_TYPE,
|
||||
StrictMode: REACT_STRICT_MODE_TYPE,
|
||||
unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
|
||||
unstable_Profiler: REACT_PROFILER_TYPE,
|
||||
|
||||
createElement: createElement,
|
||||
cloneElement: cloneElement,
|
||||
|
@ -981,9 +1075,13 @@ var React = {
|
|||
}
|
||||
};
|
||||
|
||||
if (enableSuspense) {
|
||||
React.Timeout = REACT_TIMEOUT_TYPE;
|
||||
}
|
||||
|
||||
|
||||
var React$2 = Object.freeze({
|
||||
|
||||
var React$2 = ({
|
||||
default: React
|
||||
});
|
||||
|
||||
|
@ -991,7 +1089,7 @@ var React$3 = ( React$2 && React ) || React$2;
|
|||
|
||||
// TODO: decide on the top-level export form.
|
||||
// This is hacky but makes it work with both Rollup and Jest.
|
||||
var react = React$3['default'] ? React$3['default'] : React$3;
|
||||
var react = React$3.default ? React$3.default : React$3;
|
||||
|
||||
return react;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче