react 16.0.0-alpha → 16.0.0-alpha.4
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/dist/react-with-addons.js +595 -536
- package/dist/react-with-addons.min.js +7 -2
- package/dist/react.js +547 -486
- package/dist/react.min.js +7 -2
- package/lib/React.js +17 -19
- package/lib/ReactAddonsDOMDependencies.js +1 -1
- package/lib/{ReactComponent.js → ReactBaseClasses.js} +27 -2
- package/lib/ReactClass.js +9 -9
- package/lib/ReactComponentTreeHook.js +8 -47
- package/lib/ReactDebugCurrentFrame.js +55 -0
- package/lib/ReactElementValidator.js +40 -22
- package/lib/ReactFiberComponentTreeHook.js +62 -0
- package/lib/ReactNoopUpdateQueue.js +1 -1
- package/lib/ReactPropTypes.js +33 -31
- package/lib/{ReactPropTypeLocations.js → ReactPropTypesSecret.js} +5 -1
- package/lib/ReactVersion.js +1 -1
- package/lib/checkPropTypes.js +64 -0
- package/lib/checkReactTypeSpec.js +5 -80
- package/lib/getComponentName.js +14 -16
- package/lib/traverseAllChildren.js +16 -27
- package/lib/update.js +2 -2
- package/package.json +2 -2
- package/lib/ReactPropTypeLocationNames.js +0 -24
- package/lib/ReactPureComponent.js +0 -41
- package/lib/ReactStateSetters.js +0 -103
- package/lib/sliceChildren.js +0 -33
|
@@ -95,52 +95,41 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
95
95
|
} else {
|
|
96
96
|
var iteratorFn = getIteratorFn(children);
|
|
97
97
|
if (iteratorFn) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var ii = 0;
|
|
102
|
-
while (!(step = iterator.next()).done) {
|
|
103
|
-
child = step.value;
|
|
104
|
-
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
105
|
-
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
98
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
99
|
+
// Warn about using Maps as children
|
|
100
|
+
if (iteratorFn === children.entries) {
|
|
109
101
|
var mapsAsChildrenAddendum = '';
|
|
110
102
|
if (ReactCurrentOwner.current) {
|
|
111
103
|
var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
|
|
112
104
|
if (mapsAsChildrenOwnerName) {
|
|
113
|
-
mapsAsChildrenAddendum = '
|
|
105
|
+
mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';
|
|
114
106
|
}
|
|
115
107
|
}
|
|
116
|
-
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is
|
|
108
|
+
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
|
|
117
109
|
didWarnAboutMaps = true;
|
|
118
110
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var iterator = iteratorFn.call(children);
|
|
114
|
+
var step;
|
|
115
|
+
var ii = 0;
|
|
116
|
+
while (!(step = iterator.next()).done) {
|
|
117
|
+
child = step.value;
|
|
118
|
+
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
119
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
128
120
|
}
|
|
129
121
|
} else if (type === 'object') {
|
|
130
122
|
var addendum = '';
|
|
131
123
|
if (process.env.NODE_ENV !== 'production') {
|
|
132
124
|
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
|
|
133
|
-
if (children._isReactElement) {
|
|
134
|
-
addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
|
|
135
|
-
}
|
|
136
125
|
if (ReactCurrentOwner.current) {
|
|
137
126
|
var name = ReactCurrentOwner.current.getName();
|
|
138
127
|
if (name) {
|
|
139
|
-
addendum += '
|
|
128
|
+
addendum += '\n\nCheck the render method of `' + name + '`.';
|
|
140
129
|
}
|
|
141
130
|
}
|
|
142
131
|
}
|
|
143
|
-
var childrenString =
|
|
132
|
+
var childrenString = '' + children;
|
|
144
133
|
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
|
|
145
134
|
}
|
|
146
135
|
}
|
package/lib/update.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var
|
|
16
|
-
|
|
15
|
+
var _assign = require('object-assign'),
|
|
16
|
+
_prodInvariant = require('./reactProdInvariant');
|
|
17
17
|
|
|
18
18
|
var invariant = require('fbjs/lib/invariant');
|
|
19
19
|
var hasOwnProperty = {}.hasOwnProperty;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react",
|
|
3
3
|
"description": "React is a JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "16.0.0-alpha",
|
|
4
|
+
"version": "16.0.0-alpha.4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react"
|
|
7
7
|
],
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=0.10.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"fbjs": "^0.8.
|
|
26
|
+
"fbjs": "^0.8.9",
|
|
27
27
|
"loose-envify": "^1.1.0",
|
|
28
28
|
"object-assign": "^4.1.0"
|
|
29
29
|
},
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
var ReactPropTypeLocationNames = {};
|
|
15
|
-
|
|
16
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
-
ReactPropTypeLocationNames = {
|
|
18
|
-
prop: 'prop',
|
|
19
|
-
context: 'context',
|
|
20
|
-
childContext: 'child context'
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = ReactPropTypeLocationNames;
|
|
@@ -1,41 +0,0 @@
|
|
|
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 _assign = require('object-assign');
|
|
14
|
-
|
|
15
|
-
var ReactComponent = require('./ReactComponent');
|
|
16
|
-
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
17
|
-
|
|
18
|
-
var emptyObject = require('fbjs/lib/emptyObject');
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Base class helpers for the updating state of a component.
|
|
22
|
-
*/
|
|
23
|
-
function ReactPureComponent(props, context, updater) {
|
|
24
|
-
// Duplicated from ReactComponent.
|
|
25
|
-
this.props = props;
|
|
26
|
-
this.context = context;
|
|
27
|
-
this.refs = emptyObject;
|
|
28
|
-
// We initialize the default updater but the real one gets injected by the
|
|
29
|
-
// renderer.
|
|
30
|
-
this.updater = updater || ReactNoopUpdateQueue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function ComponentDummy() {}
|
|
34
|
-
ComponentDummy.prototype = ReactComponent.prototype;
|
|
35
|
-
ReactPureComponent.prototype = new ComponentDummy();
|
|
36
|
-
ReactPureComponent.prototype.constructor = ReactPureComponent;
|
|
37
|
-
// Avoid an extra prototype jump for these methods.
|
|
38
|
-
_assign(ReactPureComponent.prototype, ReactComponent.prototype);
|
|
39
|
-
ReactPureComponent.prototype.isPureReactComponent = true;
|
|
40
|
-
|
|
41
|
-
module.exports = ReactPureComponent;
|
package/lib/ReactStateSetters.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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 ReactStateSetters = {
|
|
14
|
-
/**
|
|
15
|
-
* Returns a function that calls the provided function, and uses the result
|
|
16
|
-
* of that to set the component's state.
|
|
17
|
-
*
|
|
18
|
-
* @param {ReactCompositeComponent} component
|
|
19
|
-
* @param {function} funcReturningState Returned callback uses this to
|
|
20
|
-
* determine how to update state.
|
|
21
|
-
* @return {function} callback that when invoked uses funcReturningState to
|
|
22
|
-
* determined the object literal to setState.
|
|
23
|
-
*/
|
|
24
|
-
createStateSetter: function (component, funcReturningState) {
|
|
25
|
-
return function (a, b, c, d, e, f) {
|
|
26
|
-
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
|
|
27
|
-
if (partialState) {
|
|
28
|
-
component.setState(partialState);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Returns a single-argument callback that can be used to update a single
|
|
35
|
-
* key in the component's state.
|
|
36
|
-
*
|
|
37
|
-
* Note: this is memoized function, which makes it inexpensive to call.
|
|
38
|
-
*
|
|
39
|
-
* @param {ReactCompositeComponent} component
|
|
40
|
-
* @param {string} key The key in the state that you should update.
|
|
41
|
-
* @return {function} callback of 1 argument which calls setState() with
|
|
42
|
-
* the provided keyName and callback argument.
|
|
43
|
-
*/
|
|
44
|
-
createStateKeySetter: function (component, key) {
|
|
45
|
-
// Memoize the setters.
|
|
46
|
-
var cache = component.__keySetters || (component.__keySetters = {});
|
|
47
|
-
return cache[key] || (cache[key] = createStateKeySetter(component, key));
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function createStateKeySetter(component, key) {
|
|
52
|
-
// Partial state is allocated outside of the function closure so it can be
|
|
53
|
-
// reused with every call, avoiding memory allocation when this function
|
|
54
|
-
// is called.
|
|
55
|
-
var partialState = {};
|
|
56
|
-
return function stateKeySetter(value) {
|
|
57
|
-
partialState[key] = value;
|
|
58
|
-
component.setState(partialState);
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
ReactStateSetters.Mixin = {
|
|
63
|
-
/**
|
|
64
|
-
* Returns a function that calls the provided function, and uses the result
|
|
65
|
-
* of that to set the component's state.
|
|
66
|
-
*
|
|
67
|
-
* For example, these statements are equivalent:
|
|
68
|
-
*
|
|
69
|
-
* this.setState({x: 1});
|
|
70
|
-
* this.createStateSetter(function(xValue) {
|
|
71
|
-
* return {x: xValue};
|
|
72
|
-
* })(1);
|
|
73
|
-
*
|
|
74
|
-
* @param {function} funcReturningState Returned callback uses this to
|
|
75
|
-
* determine how to update state.
|
|
76
|
-
* @return {function} callback that when invoked uses funcReturningState to
|
|
77
|
-
* determined the object literal to setState.
|
|
78
|
-
*/
|
|
79
|
-
createStateSetter: function (funcReturningState) {
|
|
80
|
-
return ReactStateSetters.createStateSetter(this, funcReturningState);
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns a single-argument callback that can be used to update a single
|
|
85
|
-
* key in the component's state.
|
|
86
|
-
*
|
|
87
|
-
* For example, these statements are equivalent:
|
|
88
|
-
*
|
|
89
|
-
* this.setState({x: 1});
|
|
90
|
-
* this.createStateKeySetter('x')(1);
|
|
91
|
-
*
|
|
92
|
-
* Note: this is memoized function, which makes it inexpensive to call.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} key The key in the state that you should update.
|
|
95
|
-
* @return {function} callback of 1 argument which calls setState() with
|
|
96
|
-
* the provided keyName and callback argument.
|
|
97
|
-
*/
|
|
98
|
-
createStateKeySetter: function (key) {
|
|
99
|
-
return ReactStateSetters.createStateKeySetter(this, key);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
module.exports = ReactStateSetters;
|
package/lib/sliceChildren.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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 ReactChildren = require('./ReactChildren');
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Slice children that are typically specified as `props.children`. This version
|
|
17
|
-
* of slice children ignores empty child components.
|
|
18
|
-
*
|
|
19
|
-
* @param {*} children The children set to filter.
|
|
20
|
-
* @param {number} start The first zero-based index to include in the subset.
|
|
21
|
-
* @param {?number} end The non-inclusive last index of the subset.
|
|
22
|
-
* @return {object} mirrored array with mapped children
|
|
23
|
-
*/
|
|
24
|
-
function sliceChildren(children, start, end) {
|
|
25
|
-
if (children == null) {
|
|
26
|
-
return children;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var array = ReactChildren.toArray(children);
|
|
30
|
-
return array.slice(start, end);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
module.exports = sliceChildren;
|