react 15.7.0 → 16.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -16
- package/PATENTS +33 -0
- package/README.md +7 -0
- package/dist/react-with-addons.js +3798 -4340
- package/dist/react-with-addons.min.js +12 -6
- package/dist/react.js +2834 -3191
- package/dist/react.min.js +12 -5
- package/lib/KeyEscapeUtils.js +5 -3
- package/lib/PooledClass.js +5 -3
- package/lib/React.js +14 -57
- package/lib/ReactAddonsDOMDependencies.js +5 -3
- package/lib/ReactAddonsDOMDependenciesUMDShim.js +5 -3
- package/lib/ReactBaseClasses.js +9 -13
- package/lib/ReactCSSTransitionGroup.js +9 -9
- package/lib/ReactCSSTransitionGroupChild.js +118 -134
- package/lib/ReactChildren.js +9 -7
- package/lib/ReactClass.js +703 -0
- package/lib/ReactComponentTreeHook.js +63 -58
- package/lib/ReactComponentTreeHookUMDShim.js +5 -3
- package/lib/ReactComponentWithPureRenderMixin.js +5 -3
- package/lib/ReactCurrentOwner.js +7 -3
- package/lib/ReactCurrentOwnerUMDShim.js +5 -3
- package/lib/ReactDOMFactories.js +6 -3
- package/lib/ReactDebugCurrentFrame.js +53 -0
- package/lib/ReactElement.js +9 -7
- package/lib/ReactElementSymbol.js +5 -3
- package/lib/ReactElementType.js +5 -3
- package/lib/ReactElementValidator.js +46 -29
- package/lib/ReactFragment.js +5 -3
- package/lib/ReactNoopUpdateQueue.js +16 -17
- package/lib/ReactPropTypes.js +449 -7
- package/lib/ReactPropTypesSecret.js +5 -3
- package/lib/ReactStateSetters.js +5 -3
- package/lib/ReactTransitionChildMapping.js +5 -3
- package/lib/ReactTransitionEvents.js +5 -3
- package/lib/ReactTransitionGroup.js +8 -12
- package/lib/ReactTypeOfWork.js +26 -0
- package/lib/ReactUMDEntry.js +8 -7
- package/lib/ReactUMDShim.js +5 -3
- package/lib/ReactVersion.js +6 -4
- package/lib/ReactWithAddons.js +5 -5
- package/lib/ReactWithAddonsUMDEntry.js +8 -7
- package/lib/canDefineProperty.js +5 -3
- package/lib/checkPropTypes.js +64 -0
- package/lib/checkReactTypeSpec.js +10 -72
- package/lib/deprecated.js +8 -6
- package/lib/flattenChildren.js +5 -3
- package/lib/getComponentName.js +35 -0
- package/lib/getIteratorFn.js +5 -3
- package/lib/getNextDebugID.js +5 -3
- package/lib/onlyChild.js +6 -4
- package/lib/reactProdInvariant.js +4 -2
- package/lib/shallowCompare.js +5 -3
- package/lib/sliceChildren.js +5 -3
- package/lib/traverseAllChildren.js +20 -29
- package/lib/update.js +5 -3
- package/package.json +24 -35
- package/cjs/react-jsx-dev-runtime.development.js +0 -866
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -888
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/LinkedStateMixin.js +0 -32
- package/lib/ReactComponentTreeDevtool.js +0 -12
- package/lib/ReactLink.js +0 -47
- package/lib/ReactPropTypeLocationNames.js +0 -22
- package/lib/ReactPropTypeLocations.js +0 -10
- package/lib/createClass.js +0 -20
- package/lib/getNextDebugIDUMDShim.js +0 -15
- package/lib/lowPriorityWarning.js +0 -62
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*
|
|
8
10
|
*/
|
package/lib/ReactStateSetters.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -19,9 +21,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
19
21
|
var React = require('./React');
|
|
20
22
|
var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
|
|
21
23
|
|
|
22
|
-
var propTypesFactory = require('prop-types/factory');
|
|
23
|
-
var PropTypes = propTypesFactory(React.isValidElement);
|
|
24
|
-
|
|
25
24
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -193,10 +192,7 @@ var ReactTransitionGroup = function (_React$Component) {
|
|
|
193
192
|
// already been removed. In case you need this behavior you can provide
|
|
194
193
|
// a childFactory function to wrap every child, even the ones that are
|
|
195
194
|
// leaving.
|
|
196
|
-
childrenToRender.push(React.cloneElement(this.props.childFactory(child), {
|
|
197
|
-
ref: key,
|
|
198
|
-
key: key
|
|
199
|
-
}));
|
|
195
|
+
childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
|
|
200
196
|
}
|
|
201
197
|
}
|
|
202
198
|
|
|
@@ -220,8 +216,8 @@ var ReactTransitionGroup = function (_React$Component) {
|
|
|
220
216
|
|
|
221
217
|
ReactTransitionGroup.displayName = 'ReactTransitionGroup';
|
|
222
218
|
ReactTransitionGroup.propTypes = {
|
|
223
|
-
component: PropTypes.any,
|
|
224
|
-
childFactory: PropTypes.func
|
|
219
|
+
component: React.PropTypes.any,
|
|
220
|
+
childFactory: React.PropTypes.func
|
|
225
221
|
};
|
|
226
222
|
ReactTransitionGroup.defaultProps = {
|
|
227
223
|
component: 'span',
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
IndeterminateComponent: 0, // Before we know whether it is functional or class
|
|
16
|
+
FunctionalComponent: 1,
|
|
17
|
+
ClassComponent: 2,
|
|
18
|
+
HostRoot: 3, // Root of a host tree. Could be nested inside another node.
|
|
19
|
+
HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
|
|
20
|
+
HostComponent: 5,
|
|
21
|
+
HostText: 6,
|
|
22
|
+
CoroutineComponent: 7,
|
|
23
|
+
CoroutineHandlerPhase: 8,
|
|
24
|
+
YieldComponent: 9,
|
|
25
|
+
Fragment: 10
|
|
26
|
+
};
|
package/lib/ReactUMDEntry.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -13,17 +15,16 @@ var _assign = require('object-assign');
|
|
|
13
15
|
var React = require('./React');
|
|
14
16
|
|
|
15
17
|
// `version` will be added here by the React module.
|
|
16
|
-
var ReactUMDEntry = _assign(
|
|
18
|
+
var ReactUMDEntry = _assign({
|
|
17
19
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
|
18
20
|
ReactCurrentOwner: require('./ReactCurrentOwner')
|
|
19
21
|
}
|
|
20
|
-
});
|
|
22
|
+
}, React);
|
|
21
23
|
|
|
22
24
|
if (process.env.NODE_ENV !== 'production') {
|
|
23
25
|
_assign(ReactUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
24
26
|
// ReactComponentTreeHook should not be included in production.
|
|
25
|
-
ReactComponentTreeHook: require('./ReactComponentTreeHook')
|
|
26
|
-
getNextDebugID: require('./getNextDebugID')
|
|
27
|
+
ReactComponentTreeHook: require('./ReactComponentTreeHook')
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
package/lib/ReactUMDShim.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
package/lib/ReactVersion.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
'use strict';
|
|
10
12
|
|
|
11
|
-
module.exports = '
|
|
13
|
+
module.exports = '16.0.0-alpha.3';
|
package/lib/ReactWithAddons.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
'use strict';
|
|
10
12
|
|
|
11
|
-
var LinkedStateMixin = require('./LinkedStateMixin');
|
|
12
13
|
var React = require('./React');
|
|
13
14
|
var ReactAddonsDOMDependencies = require('./ReactAddonsDOMDependencies');
|
|
14
15
|
var ReactComponentWithPureRenderMixin = require('./ReactComponentWithPureRenderMixin');
|
|
@@ -21,7 +22,6 @@ var update = require('./update');
|
|
|
21
22
|
|
|
22
23
|
React.addons = {
|
|
23
24
|
CSSTransitionGroup: ReactCSSTransitionGroup,
|
|
24
|
-
LinkedStateMixin: LinkedStateMixin,
|
|
25
25
|
PureRenderMixin: ReactComponentWithPureRenderMixin,
|
|
26
26
|
TransitionGroup: ReactTransitionGroup,
|
|
27
27
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
@@ -13,18 +15,17 @@ var _assign = require('object-assign');
|
|
|
13
15
|
var ReactWithAddons = require('./ReactWithAddons');
|
|
14
16
|
|
|
15
17
|
// `version` will be added here by the React module.
|
|
16
|
-
var ReactWithAddonsUMDEntry = _assign(
|
|
18
|
+
var ReactWithAddonsUMDEntry = _assign({
|
|
17
19
|
__SECRET_INJECTED_REACT_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: null, // Will be injected by ReactDOM UMD build.
|
|
18
20
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
|
19
21
|
ReactCurrentOwner: require('./ReactCurrentOwner')
|
|
20
22
|
}
|
|
21
|
-
});
|
|
23
|
+
}, ReactWithAddons);
|
|
22
24
|
|
|
23
25
|
if (process.env.NODE_ENV !== 'production') {
|
|
24
26
|
_assign(ReactWithAddonsUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
25
27
|
// ReactComponentTreeHook should not be included in production.
|
|
26
|
-
ReactComponentTreeHook: require('./ReactComponentTreeHook')
|
|
27
|
-
getNextDebugID: require('./getNextDebugID')
|
|
28
|
+
ReactComponentTreeHook: require('./ReactComponentTreeHook')
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
|
package/lib/canDefineProperty.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*
|
|
8
10
|
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
14
|
+
|
|
15
|
+
var ReactPropTypesSecret = require('./ReactPropTypesSecret');
|
|
16
|
+
|
|
17
|
+
var invariant = require('fbjs/lib/invariant');
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
19
|
+
|
|
20
|
+
var loggedTypeFailures = {};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Assert that the values match with the type specs.
|
|
24
|
+
* Error messages are memorized and will only be shown once.
|
|
25
|
+
*
|
|
26
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
27
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
28
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
29
|
+
* @param {string} componentName Name of the component for error messages.
|
|
30
|
+
* @param {?Function} getStack Returns the component stack.
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
34
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
+
for (var typeSpecName in typeSpecs) {
|
|
36
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
37
|
+
var error;
|
|
38
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
39
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
40
|
+
// After these have been cleaned up, we'll let them throw.
|
|
41
|
+
try {
|
|
42
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
43
|
+
// behavior as without this statement except with a better message.
|
|
44
|
+
!(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', location, typeSpecName) : _prodInvariant('84', componentName || 'React class', location, typeSpecName) : void 0;
|
|
45
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
46
|
+
} catch (ex) {
|
|
47
|
+
error = ex;
|
|
48
|
+
}
|
|
49
|
+
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error) : void 0;
|
|
50
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
51
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
52
|
+
// same error.
|
|
53
|
+
loggedTypeFailures[error.message] = true;
|
|
54
|
+
|
|
55
|
+
var stack = getStack ? getStack() : '';
|
|
56
|
+
|
|
57
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '') : void 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = checkPropTypes;
|
|
@@ -1,84 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
'use strict';
|
|
10
12
|
|
|
11
|
-
var
|
|
13
|
+
var checkPropTypes = require('./checkPropTypes');
|
|
12
14
|
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
+
var _require = require('./ReactDebugCurrentFrame'),
|
|
16
|
+
getStackAddendum = _require.getStackAddendum;
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var ReactComponentTreeHook;
|
|
20
|
-
|
|
21
|
-
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
|
|
22
|
-
// Temporary hack.
|
|
23
|
-
// Inline requires don't work well with Jest:
|
|
24
|
-
// https://github.com/facebook/react/issues/7240
|
|
25
|
-
// Remove the inline requires when we don't need them anymore:
|
|
26
|
-
// https://github.com/facebook/react/pull/7178
|
|
27
|
-
ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var loggedTypeFailures = {};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Assert that the values match with the type specs.
|
|
34
|
-
* Error messages are memorized and will only be shown once.
|
|
35
|
-
*
|
|
36
|
-
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
37
|
-
* @param {object} values Runtime values that need to be type-checked
|
|
38
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
39
|
-
* @param {string} componentName Name of the component for error messages.
|
|
40
|
-
* @param {?object} element The React element that is being type-checked
|
|
41
|
-
* @param {?number} debugID The React component instance that is being type-checked
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
|
|
45
|
-
for (var typeSpecName in typeSpecs) {
|
|
46
|
-
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
47
|
-
var error;
|
|
48
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
49
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
50
|
-
// After these have been cleaned up, we'll let them throw.
|
|
51
|
-
try {
|
|
52
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
53
|
-
// behavior as without this statement except with a better message.
|
|
54
|
-
!(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
|
|
55
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
56
|
-
} catch (ex) {
|
|
57
|
-
error = ex;
|
|
58
|
-
}
|
|
59
|
-
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
|
|
60
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
61
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
62
|
-
// same error.
|
|
63
|
-
loggedTypeFailures[error.message] = true;
|
|
64
|
-
|
|
65
|
-
var componentStackInfo = '';
|
|
66
|
-
|
|
67
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
68
|
-
if (!ReactComponentTreeHook) {
|
|
69
|
-
ReactComponentTreeHook = require('./ReactComponentTreeHook');
|
|
70
|
-
}
|
|
71
|
-
if (debugID !== null) {
|
|
72
|
-
componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
|
|
73
|
-
} else if (element !== null) {
|
|
74
|
-
componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
18
|
+
function checkReactTypeSpec(typeSpecs, values, location, componentName) {
|
|
19
|
+
checkPropTypes(typeSpecs, values, location, componentName, getStackAddendum);
|
|
82
20
|
}
|
|
83
21
|
|
|
84
22
|
module.exports = checkReactTypeSpec;
|
package/lib/deprecated.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
3
4
|
*
|
|
4
|
-
* This source code is licensed under the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
6
8
|
*
|
|
7
9
|
*
|
|
8
10
|
*/
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
|
|
12
14
|
var _assign = require('object-assign');
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var warning = require('fbjs/lib/warning');
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* This will log a single deprecation notice per function and forward the call
|
|
@@ -28,12 +30,12 @@ function deprecated(fnName, newModule, newPackage, ctx, fn) {
|
|
|
28
30
|
var warned = false;
|
|
29
31
|
if (process.env.NODE_ENV !== 'production') {
|
|
30
32
|
var newFn = function () {
|
|
31
|
-
|
|
33
|
+
process.env.NODE_ENV !== 'production' ? warning(warned,
|
|
32
34
|
/* eslint-disable no-useless-concat */
|
|
33
35
|
// Require examples in this string must be split to prevent React's
|
|
34
36
|
// build tools from mistaking them for real requires.
|
|
35
37
|
// Otherwise the build tools will attempt to build a '%s' module.
|
|
36
|
-
'React.%s is deprecated. Please use %s.%s from require' +
|
|
38
|
+
'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : void 0;
|
|
37
39
|
/* eslint-enable no-useless-concat */
|
|
38
40
|
warned = true;
|
|
39
41
|
return fn.apply(ctx, arguments);
|