react 0.13.3 → 0.14.0-beta1
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/README.md +5 -2
- package/addons.js +7 -0
- package/dist/JSXTransformer.js +4101 -2432
- package/dist/react-with-addons.js +4389 -6277
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +4028 -5697
- package/dist/react.min.js +5 -6
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +26 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +86 -147
- package/lib/DOMPropertyOperations.js +91 -67
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +33 -44
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +15 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +71 -89
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +20 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +26 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +24 -31
- package/lib/ReactClass.js +96 -267
- package/lib/ReactComponent.js +28 -57
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +6 -7
- package/lib/ReactCompositeComponent.js +115 -381
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +16 -28
- package/lib/ReactDOMClient.js +90 -0
- package/lib/ReactDOMComponent.js +468 -156
- package/lib/ReactDOMIDOperations.js +25 -22
- package/lib/ReactDOMInput.js +79 -108
- package/lib/ReactDOMOption.js +58 -20
- package/lib/ReactDOMSelect.js +95 -83
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +44 -69
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +20 -76
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +26 -120
- package/lib/ReactElementValidator.js +56 -192
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +3 -3
- package/lib/ReactEventEmitterMixin.js +3 -13
- package/lib/ReactEventListener.js +58 -40
- package/lib/ReactFragment.js +33 -59
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +14 -23
- package/lib/ReactInstanceHandles.js +29 -58
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +142 -285
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -15
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +11 -36
- package/lib/ReactReconciler.js +14 -26
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +20 -15
- package/lib/ReactServerRenderingTransaction.js +9 -34
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +137 -190
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +69 -107
- package/lib/ReactUpdates.js +26 -81
- package/lib/ReactWithAddons.js +5 -6
- package/lib/SVGDOMPropertyConfig.js +39 -4
- package/lib/SelectEventPlugin.js +31 -33
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +138 -130
- package/lib/SyntheticClipboardEvent.js +5 -9
- package/lib/SyntheticCompositionEvent.js +4 -10
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +14 -15
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +4 -10
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +10 -16
- package/lib/SyntheticTouchEvent.js +3 -3
- package/lib/SyntheticUIEvent.js +5 -5
- package/lib/SyntheticWheelEvent.js +13 -17
- package/lib/Transaction.js +22 -28
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +6 -12
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +7 -27
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +3 -3
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +18 -40
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +23 -43
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +3 -3
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +23 -90
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +15 -17
- package/package.json +3 -3
- package/react.js +53 -1
- package/lib/LocalEventTrapMixin.js +0 -53
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactContext.js +0 -74
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/createFullPageComponent.js +0 -58
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
|
@@ -23,11 +23,11 @@ var ReactTransitionChildMapping = {
|
|
|
23
23
|
* @param {*} children `this.props.children`
|
|
24
24
|
* @return {object} Mapping of key to child
|
|
25
25
|
*/
|
|
26
|
-
getChildMapping: function(children) {
|
|
26
|
+
getChildMapping: function (children) {
|
|
27
27
|
if (!children) {
|
|
28
28
|
return children;
|
|
29
29
|
}
|
|
30
|
-
return ReactFragment.extract(ReactChildren.map(children, function(child) {
|
|
30
|
+
return ReactFragment.extract(ReactChildren.map(children, function (child) {
|
|
31
31
|
return child;
|
|
32
32
|
}));
|
|
33
33
|
},
|
|
@@ -49,7 +49,7 @@ var ReactTransitionChildMapping = {
|
|
|
49
49
|
* @return {object} a key set that contains all keys in `prev` and all keys
|
|
50
50
|
* in `next` in a reasonable order.
|
|
51
51
|
*/
|
|
52
|
-
mergeChildMappings: function(prev, next) {
|
|
52
|
+
mergeChildMappings: function (prev, next) {
|
|
53
53
|
prev = prev || {};
|
|
54
54
|
next = next || {};
|
|
55
55
|
|
|
@@ -83,9 +83,7 @@ var ReactTransitionChildMapping = {
|
|
|
83
83
|
if (nextKeysPending.hasOwnProperty(nextKey)) {
|
|
84
84
|
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
|
|
85
85
|
var pendingNextKey = nextKeysPending[nextKey][i];
|
|
86
|
-
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(
|
|
87
|
-
pendingNextKey
|
|
88
|
-
);
|
|
86
|
+
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
childMapping[nextKey] = getValueForKey(nextKey);
|
|
@@ -100,4 +98,4 @@ var ReactTransitionChildMapping = {
|
|
|
100
98
|
}
|
|
101
99
|
};
|
|
102
100
|
|
|
103
|
-
module.exports = ReactTransitionChildMapping;
|
|
101
|
+
module.exports = ReactTransitionChildMapping;
|
|
@@ -84,26 +84,26 @@ function removeEventListener(node, eventName, eventListener) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
var ReactTransitionEvents = {
|
|
87
|
-
addEndEventListener: function(node, eventListener) {
|
|
87
|
+
addEndEventListener: function (node, eventListener) {
|
|
88
88
|
if (endEvents.length === 0) {
|
|
89
89
|
// If CSS transitions are not supported, trigger an "end animation"
|
|
90
90
|
// event immediately.
|
|
91
91
|
window.setTimeout(eventListener, 0);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
endEvents.forEach(function(endEvent) {
|
|
94
|
+
endEvents.forEach(function (endEvent) {
|
|
95
95
|
addEventListener(node, endEvent, eventListener);
|
|
96
96
|
});
|
|
97
97
|
},
|
|
98
98
|
|
|
99
|
-
removeEndEventListener: function(node, eventListener) {
|
|
99
|
+
removeEndEventListener: function (node, eventListener) {
|
|
100
100
|
if (endEvents.length === 0) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
endEvents.forEach(function(endEvent) {
|
|
103
|
+
endEvents.forEach(function (endEvent) {
|
|
104
104
|
removeEventListener(node, endEvent, eventListener);
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
module.exports = ReactTransitionEvents;
|
|
109
|
+
module.exports = ReactTransitionEvents;
|
|
@@ -26,26 +26,26 @@ var ReactTransitionGroup = React.createClass({
|
|
|
26
26
|
childFactory: React.PropTypes.func
|
|
27
27
|
},
|
|
28
28
|
|
|
29
|
-
getDefaultProps: function() {
|
|
29
|
+
getDefaultProps: function () {
|
|
30
30
|
return {
|
|
31
31
|
component: 'span',
|
|
32
32
|
childFactory: emptyFunction.thatReturnsArgument
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
35
|
|
|
36
|
-
getInitialState: function() {
|
|
36
|
+
getInitialState: function () {
|
|
37
37
|
return {
|
|
38
38
|
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
|
|
42
|
-
componentWillMount: function() {
|
|
42
|
+
componentWillMount: function () {
|
|
43
43
|
this.currentlyTransitioningKeys = {};
|
|
44
44
|
this.keysToEnter = [];
|
|
45
45
|
this.keysToLeave = [];
|
|
46
46
|
},
|
|
47
47
|
|
|
48
|
-
componentDidMount: function() {
|
|
48
|
+
componentDidMount: function () {
|
|
49
49
|
var initialChildMapping = this.state.children;
|
|
50
50
|
for (var key in initialChildMapping) {
|
|
51
51
|
if (initialChildMapping[key]) {
|
|
@@ -54,33 +54,26 @@ var ReactTransitionGroup = React.createClass({
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
|
|
57
|
-
componentWillReceiveProps: function(nextProps) {
|
|
58
|
-
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
59
|
-
nextProps.children
|
|
60
|
-
);
|
|
57
|
+
componentWillReceiveProps: function (nextProps) {
|
|
58
|
+
var nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children);
|
|
61
59
|
var prevChildMapping = this.state.children;
|
|
62
60
|
|
|
63
61
|
this.setState({
|
|
64
|
-
children: ReactTransitionChildMapping.mergeChildMappings(
|
|
65
|
-
prevChildMapping,
|
|
66
|
-
nextChildMapping
|
|
67
|
-
)
|
|
62
|
+
children: ReactTransitionChildMapping.mergeChildMappings(prevChildMapping, nextChildMapping)
|
|
68
63
|
});
|
|
69
64
|
|
|
70
65
|
var key;
|
|
71
66
|
|
|
72
67
|
for (key in nextChildMapping) {
|
|
73
68
|
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
|
|
74
|
-
if (nextChildMapping[key] && !hasPrev &&
|
|
75
|
-
!this.currentlyTransitioningKeys[key]) {
|
|
69
|
+
if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {
|
|
76
70
|
this.keysToEnter.push(key);
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
|
|
80
74
|
for (key in prevChildMapping) {
|
|
81
75
|
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
|
|
82
|
-
if (prevChildMapping[key] && !hasNext &&
|
|
83
|
-
!this.currentlyTransitioningKeys[key]) {
|
|
76
|
+
if (prevChildMapping[key] && !hasNext && !this.currentlyTransitioningKeys[key]) {
|
|
84
77
|
this.keysToLeave.push(key);
|
|
85
78
|
}
|
|
86
79
|
}
|
|
@@ -88,7 +81,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
88
81
|
// If we want to someday check for reordering, we could do it here.
|
|
89
82
|
},
|
|
90
83
|
|
|
91
|
-
componentDidUpdate: function() {
|
|
84
|
+
componentDidUpdate: function () {
|
|
92
85
|
var keysToEnter = this.keysToEnter;
|
|
93
86
|
this.keysToEnter = [];
|
|
94
87
|
keysToEnter.forEach(this.performEnter);
|
|
@@ -98,21 +91,19 @@ var ReactTransitionGroup = React.createClass({
|
|
|
98
91
|
keysToLeave.forEach(this.performLeave);
|
|
99
92
|
},
|
|
100
93
|
|
|
101
|
-
performAppear: function(key) {
|
|
94
|
+
performAppear: function (key) {
|
|
102
95
|
this.currentlyTransitioningKeys[key] = true;
|
|
103
96
|
|
|
104
97
|
var component = this.refs[key];
|
|
105
98
|
|
|
106
99
|
if (component.componentWillAppear) {
|
|
107
|
-
component.componentWillAppear(
|
|
108
|
-
this._handleDoneAppearing.bind(this, key)
|
|
109
|
-
);
|
|
100
|
+
component.componentWillAppear(this._handleDoneAppearing.bind(this, key));
|
|
110
101
|
} else {
|
|
111
102
|
this._handleDoneAppearing(key);
|
|
112
103
|
}
|
|
113
104
|
},
|
|
114
105
|
|
|
115
|
-
_handleDoneAppearing: function(key) {
|
|
106
|
+
_handleDoneAppearing: function (key) {
|
|
116
107
|
var component = this.refs[key];
|
|
117
108
|
if (component.componentDidAppear) {
|
|
118
109
|
component.componentDidAppear();
|
|
@@ -120,9 +111,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
120
111
|
|
|
121
112
|
delete this.currentlyTransitioningKeys[key];
|
|
122
113
|
|
|
123
|
-
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
124
|
-
this.props.children
|
|
125
|
-
);
|
|
114
|
+
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
126
115
|
|
|
127
116
|
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
|
|
128
117
|
// This was removed before it had fully appeared. Remove it.
|
|
@@ -130,21 +119,19 @@ var ReactTransitionGroup = React.createClass({
|
|
|
130
119
|
}
|
|
131
120
|
},
|
|
132
121
|
|
|
133
|
-
performEnter: function(key) {
|
|
122
|
+
performEnter: function (key) {
|
|
134
123
|
this.currentlyTransitioningKeys[key] = true;
|
|
135
124
|
|
|
136
125
|
var component = this.refs[key];
|
|
137
126
|
|
|
138
127
|
if (component.componentWillEnter) {
|
|
139
|
-
component.componentWillEnter(
|
|
140
|
-
this._handleDoneEntering.bind(this, key)
|
|
141
|
-
);
|
|
128
|
+
component.componentWillEnter(this._handleDoneEntering.bind(this, key));
|
|
142
129
|
} else {
|
|
143
130
|
this._handleDoneEntering(key);
|
|
144
131
|
}
|
|
145
132
|
},
|
|
146
133
|
|
|
147
|
-
_handleDoneEntering: function(key) {
|
|
134
|
+
_handleDoneEntering: function (key) {
|
|
148
135
|
var component = this.refs[key];
|
|
149
136
|
if (component.componentDidEnter) {
|
|
150
137
|
component.componentDidEnter();
|
|
@@ -152,9 +139,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
152
139
|
|
|
153
140
|
delete this.currentlyTransitioningKeys[key];
|
|
154
141
|
|
|
155
|
-
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
156
|
-
this.props.children
|
|
157
|
-
);
|
|
142
|
+
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
158
143
|
|
|
159
144
|
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
|
|
160
145
|
// This was removed before it had fully entered. Remove it.
|
|
@@ -162,7 +147,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
162
147
|
}
|
|
163
148
|
},
|
|
164
149
|
|
|
165
|
-
performLeave: function(key) {
|
|
150
|
+
performLeave: function (key) {
|
|
166
151
|
this.currentlyTransitioningKeys[key] = true;
|
|
167
152
|
|
|
168
153
|
var component = this.refs[key];
|
|
@@ -176,7 +161,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
176
161
|
}
|
|
177
162
|
},
|
|
178
163
|
|
|
179
|
-
_handleDoneLeaving: function(key) {
|
|
164
|
+
_handleDoneLeaving: function (key) {
|
|
180
165
|
var component = this.refs[key];
|
|
181
166
|
|
|
182
167
|
if (component.componentDidLeave) {
|
|
@@ -185,21 +170,21 @@ var ReactTransitionGroup = React.createClass({
|
|
|
185
170
|
|
|
186
171
|
delete this.currentlyTransitioningKeys[key];
|
|
187
172
|
|
|
188
|
-
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(
|
|
189
|
-
this.props.children
|
|
190
|
-
);
|
|
173
|
+
var currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
191
174
|
|
|
192
175
|
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
|
|
193
176
|
// This entered again before it fully left. Add it again.
|
|
194
177
|
this.performEnter(key);
|
|
195
178
|
} else {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
this.setState(function (state) {
|
|
180
|
+
var newChildren = assign({}, state.children);
|
|
181
|
+
delete newChildren[key];
|
|
182
|
+
return { children: newChildren };
|
|
183
|
+
});
|
|
199
184
|
}
|
|
200
185
|
},
|
|
201
186
|
|
|
202
|
-
render: function() {
|
|
187
|
+
render: function () {
|
|
203
188
|
// TODO: we could get rid of the need for the wrapper node
|
|
204
189
|
// by cloning a single child
|
|
205
190
|
var childrenToRender = [];
|
|
@@ -211,18 +196,11 @@ var ReactTransitionGroup = React.createClass({
|
|
|
211
196
|
// already been removed. In case you need this behavior you can provide
|
|
212
197
|
// a childFactory function to wrap every child, even the ones that are
|
|
213
198
|
// leaving.
|
|
214
|
-
childrenToRender.push(cloneWithProps(
|
|
215
|
-
this.props.childFactory(child),
|
|
216
|
-
{ref: key, key: key}
|
|
217
|
-
));
|
|
199
|
+
childrenToRender.push(cloneWithProps(this.props.childFactory(child), { ref: key, key: key }));
|
|
218
200
|
}
|
|
219
201
|
}
|
|
220
|
-
return React.createElement(
|
|
221
|
-
this.props.component,
|
|
222
|
-
this.props,
|
|
223
|
-
childrenToRender
|
|
224
|
-
);
|
|
202
|
+
return React.createElement(this.props.component, this.props, childrenToRender);
|
|
225
203
|
}
|
|
226
204
|
});
|
|
227
205
|
|
|
228
|
-
module.exports = ReactTransitionGroup;
|
|
206
|
+
module.exports = ReactTransitionGroup;
|
package/lib/ReactUpdateQueue.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactLifeCycle = require("./ReactLifeCycle");
|
|
15
14
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
16
15
|
var ReactElement = require("./ReactElement");
|
|
17
16
|
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
@@ -22,46 +21,25 @@ var invariant = require("./invariant");
|
|
|
22
21
|
var warning = require("./warning");
|
|
23
22
|
|
|
24
23
|
function enqueueUpdate(internalInstance) {
|
|
25
|
-
|
|
26
|
-
// If we're in a componentWillMount handler, don't enqueue a rerender
|
|
27
|
-
// because ReactUpdates assumes we're in a browser context (which is
|
|
28
|
-
// wrong for server rendering) and we're about to do a render anyway.
|
|
29
|
-
// See bug in #1740.
|
|
30
|
-
ReactUpdates.enqueueUpdate(internalInstance);
|
|
31
|
-
}
|
|
24
|
+
ReactUpdates.enqueueUpdate(internalInstance);
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
|
|
35
|
-
(
|
|
36
|
-
ReactCurrentOwner.current == null,
|
|
37
|
-
|
|
38
|
-
'(such as within `render`). Render methods should be a pure function ' +
|
|
39
|
-
'of props and state.',
|
|
40
|
-
callerName
|
|
41
|
-
) : invariant(ReactCurrentOwner.current == null));
|
|
28
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
29
|
+
'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
|
|
30
|
+
}
|
|
42
31
|
|
|
43
32
|
var internalInstance = ReactInstanceMap.get(publicInstance);
|
|
44
33
|
if (!internalInstance) {
|
|
45
|
-
if (
|
|
34
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
46
35
|
// Only warn when we have a callerName. Otherwise we should be silent.
|
|
47
36
|
// We're probably calling from enqueueCallback. We don't want to warn
|
|
48
37
|
// there because we already warned for the corresponding lifecycle method.
|
|
49
|
-
|
|
50
|
-
!callerName,
|
|
51
|
-
'%s(...): Can only update a mounted or mounting component. ' +
|
|
52
|
-
'This usually means you called %s() on an unmounted ' +
|
|
53
|
-
'component. This is a no-op.',
|
|
54
|
-
callerName,
|
|
55
|
-
callerName
|
|
56
|
-
) : null);
|
|
38
|
+
'production' !== process.env.NODE_ENV ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
|
|
57
39
|
}
|
|
58
40
|
return null;
|
|
59
41
|
}
|
|
60
42
|
|
|
61
|
-
if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
43
|
return internalInstance;
|
|
66
44
|
}
|
|
67
45
|
|
|
@@ -71,6 +49,32 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
|
|
|
71
49
|
*/
|
|
72
50
|
var ReactUpdateQueue = {
|
|
73
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Checks whether or not this composite component is mounted.
|
|
54
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
|
55
|
+
* @return {boolean} True if mounted, false otherwise.
|
|
56
|
+
* @protected
|
|
57
|
+
* @final
|
|
58
|
+
*/
|
|
59
|
+
isMounted: function (publicInstance) {
|
|
60
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
61
|
+
var owner = ReactCurrentOwner.current;
|
|
62
|
+
if (owner !== null) {
|
|
63
|
+
'production' !== process.env.NODE_ENV ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
|
|
64
|
+
owner._warnedAboutRefsInRender = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
var internalInstance = ReactInstanceMap.get(publicInstance);
|
|
68
|
+
if (internalInstance) {
|
|
69
|
+
// During componentWillMount and render this will still be null but after
|
|
70
|
+
// that will always render to something. At least for now. So we can use
|
|
71
|
+
// this hack.
|
|
72
|
+
return !!internalInstance._renderedComponent;
|
|
73
|
+
} else {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
74
78
|
/**
|
|
75
79
|
* Enqueue a callback that will be executed after all the pending updates
|
|
76
80
|
* have processed.
|
|
@@ -79,13 +83,8 @@ var ReactUpdateQueue = {
|
|
|
79
83
|
* @param {?function} callback Called after state is updated.
|
|
80
84
|
* @internal
|
|
81
85
|
*/
|
|
82
|
-
enqueueCallback: function(publicInstance, callback) {
|
|
83
|
-
(
|
|
84
|
-
typeof callback === 'function',
|
|
85
|
-
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
|
|
86
|
-
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
|
|
87
|
-
'isn\'t callable.'
|
|
88
|
-
) : invariant(typeof callback === 'function'));
|
|
86
|
+
enqueueCallback: function (publicInstance, callback) {
|
|
87
|
+
!(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
|
|
89
88
|
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
|
90
89
|
|
|
91
90
|
// Previously we would throw an error if we didn't have an internal
|
|
@@ -93,8 +92,7 @@ var ReactUpdateQueue = {
|
|
|
93
92
|
// behavior we have in other enqueue* methods.
|
|
94
93
|
// We also need to ignore callbacks in componentWillMount. See
|
|
95
94
|
// enqueueUpdates.
|
|
96
|
-
if (!internalInstance
|
|
97
|
-
internalInstance === ReactLifeCycle.currentlyMountingInstance) {
|
|
95
|
+
if (!internalInstance) {
|
|
98
96
|
return null;
|
|
99
97
|
}
|
|
100
98
|
|
|
@@ -110,13 +108,8 @@ var ReactUpdateQueue = {
|
|
|
110
108
|
enqueueUpdate(internalInstance);
|
|
111
109
|
},
|
|
112
110
|
|
|
113
|
-
enqueueCallbackInternal: function(internalInstance, callback) {
|
|
114
|
-
(
|
|
115
|
-
typeof callback === 'function',
|
|
116
|
-
'enqueueCallback(...): You called `setProps`, `replaceProps`, ' +
|
|
117
|
-
'`setState`, `replaceState`, or `forceUpdate` with a callback that ' +
|
|
118
|
-
'isn\'t callable.'
|
|
119
|
-
) : invariant(typeof callback === 'function'));
|
|
111
|
+
enqueueCallbackInternal: function (internalInstance, callback) {
|
|
112
|
+
!(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
|
|
120
113
|
if (internalInstance._pendingCallbacks) {
|
|
121
114
|
internalInstance._pendingCallbacks.push(callback);
|
|
122
115
|
} else {
|
|
@@ -132,17 +125,14 @@ var ReactUpdateQueue = {
|
|
|
132
125
|
* You may want to call this when you know that some deeper aspect of the
|
|
133
126
|
* component's state has changed but `setState` was not called.
|
|
134
127
|
*
|
|
135
|
-
* This will not invoke `
|
|
128
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
136
129
|
* `componentWillUpdate` and `componentDidUpdate`.
|
|
137
130
|
*
|
|
138
131
|
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
139
132
|
* @internal
|
|
140
133
|
*/
|
|
141
|
-
enqueueForceUpdate: function(publicInstance) {
|
|
142
|
-
var internalInstance = getInternalInstanceReadyForUpdate(
|
|
143
|
-
publicInstance,
|
|
144
|
-
'forceUpdate'
|
|
145
|
-
);
|
|
134
|
+
enqueueForceUpdate: function (publicInstance) {
|
|
135
|
+
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate');
|
|
146
136
|
|
|
147
137
|
if (!internalInstance) {
|
|
148
138
|
return;
|
|
@@ -164,11 +154,8 @@ var ReactUpdateQueue = {
|
|
|
164
154
|
* @param {object} completeState Next state.
|
|
165
155
|
* @internal
|
|
166
156
|
*/
|
|
167
|
-
enqueueReplaceState: function(publicInstance, completeState) {
|
|
168
|
-
var internalInstance = getInternalInstanceReadyForUpdate(
|
|
169
|
-
publicInstance,
|
|
170
|
-
'replaceState'
|
|
171
|
-
);
|
|
157
|
+
enqueueReplaceState: function (publicInstance, completeState) {
|
|
158
|
+
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');
|
|
172
159
|
|
|
173
160
|
if (!internalInstance) {
|
|
174
161
|
return;
|
|
@@ -190,19 +177,14 @@ var ReactUpdateQueue = {
|
|
|
190
177
|
* @param {object} partialState Next partial state to be merged with state.
|
|
191
178
|
* @internal
|
|
192
179
|
*/
|
|
193
|
-
enqueueSetState: function(publicInstance, partialState) {
|
|
194
|
-
var internalInstance = getInternalInstanceReadyForUpdate(
|
|
195
|
-
publicInstance,
|
|
196
|
-
'setState'
|
|
197
|
-
);
|
|
180
|
+
enqueueSetState: function (publicInstance, partialState) {
|
|
181
|
+
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
|
|
198
182
|
|
|
199
183
|
if (!internalInstance) {
|
|
200
184
|
return;
|
|
201
185
|
}
|
|
202
186
|
|
|
203
|
-
var queue =
|
|
204
|
-
internalInstance._pendingStateQueue ||
|
|
205
|
-
(internalInstance._pendingStateQueue = []);
|
|
187
|
+
var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []);
|
|
206
188
|
queue.push(partialState);
|
|
207
189
|
|
|
208
190
|
enqueueUpdate(internalInstance);
|
|
@@ -215,36 +197,26 @@ var ReactUpdateQueue = {
|
|
|
215
197
|
* @param {object} partialProps Subset of the next props.
|
|
216
198
|
* @internal
|
|
217
199
|
*/
|
|
218
|
-
enqueueSetProps: function(publicInstance, partialProps) {
|
|
219
|
-
var internalInstance = getInternalInstanceReadyForUpdate(
|
|
220
|
-
publicInstance,
|
|
221
|
-
'setProps'
|
|
222
|
-
);
|
|
223
|
-
|
|
200
|
+
enqueueSetProps: function (publicInstance, partialProps) {
|
|
201
|
+
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
|
|
224
202
|
if (!internalInstance) {
|
|
225
203
|
return;
|
|
226
204
|
}
|
|
205
|
+
ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
|
|
206
|
+
},
|
|
227
207
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
'component with a parent. This is an anti-pattern since props will ' +
|
|
232
|
-
'get reactively updated when rendered. Instead, change the owner\'s ' +
|
|
233
|
-
'`render` method to pass the correct value as props to the component ' +
|
|
234
|
-
'where it is created.'
|
|
235
|
-
) : invariant(internalInstance._isTopLevel));
|
|
208
|
+
enqueueSetPropsInternal: function (internalInstance, partialProps) {
|
|
209
|
+
var topLevelWrapper = internalInstance._topLevelWrapper;
|
|
210
|
+
!topLevelWrapper ? 'production' !== process.env.NODE_ENV ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
|
|
236
211
|
|
|
237
212
|
// Merge with the pending element if it exists, otherwise with existing
|
|
238
213
|
// element props.
|
|
239
|
-
var
|
|
240
|
-
|
|
214
|
+
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
|
|
215
|
+
var element = wrapElement.props;
|
|
241
216
|
var props = assign({}, element.props, partialProps);
|
|
242
|
-
|
|
243
|
-
element,
|
|
244
|
-
props
|
|
245
|
-
);
|
|
217
|
+
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
|
|
246
218
|
|
|
247
|
-
enqueueUpdate(
|
|
219
|
+
enqueueUpdate(topLevelWrapper);
|
|
248
220
|
},
|
|
249
221
|
|
|
250
222
|
/**
|
|
@@ -254,42 +226,32 @@ var ReactUpdateQueue = {
|
|
|
254
226
|
* @param {object} props New props.
|
|
255
227
|
* @internal
|
|
256
228
|
*/
|
|
257
|
-
enqueueReplaceProps: function(publicInstance, props) {
|
|
258
|
-
var internalInstance = getInternalInstanceReadyForUpdate(
|
|
259
|
-
publicInstance,
|
|
260
|
-
'replaceProps'
|
|
261
|
-
);
|
|
262
|
-
|
|
229
|
+
enqueueReplaceProps: function (publicInstance, props) {
|
|
230
|
+
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
|
|
263
231
|
if (!internalInstance) {
|
|
264
232
|
return;
|
|
265
233
|
}
|
|
234
|
+
ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
|
|
235
|
+
},
|
|
266
236
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
'component with a parent. This is an anti-pattern since props will ' +
|
|
271
|
-
'get reactively updated when rendered. Instead, change the owner\'s ' +
|
|
272
|
-
'`render` method to pass the correct value as props to the component ' +
|
|
273
|
-
'where it is created.'
|
|
274
|
-
) : invariant(internalInstance._isTopLevel));
|
|
237
|
+
enqueueReplacePropsInternal: function (internalInstance, props) {
|
|
238
|
+
var topLevelWrapper = internalInstance._topLevelWrapper;
|
|
239
|
+
!topLevelWrapper ? 'production' !== process.env.NODE_ENV ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
|
|
275
240
|
|
|
276
241
|
// Merge with the pending element if it exists, otherwise with existing
|
|
277
242
|
// element props.
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
element,
|
|
282
|
-
props
|
|
283
|
-
);
|
|
243
|
+
var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
|
|
244
|
+
var element = wrapElement.props;
|
|
245
|
+
topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
|
|
284
246
|
|
|
285
|
-
enqueueUpdate(
|
|
247
|
+
enqueueUpdate(topLevelWrapper);
|
|
286
248
|
},
|
|
287
249
|
|
|
288
|
-
enqueueElementInternal: function(internalInstance, newElement) {
|
|
250
|
+
enqueueElementInternal: function (internalInstance, newElement) {
|
|
289
251
|
internalInstance._pendingElement = newElement;
|
|
290
252
|
enqueueUpdate(internalInstance);
|
|
291
253
|
}
|
|
292
254
|
|
|
293
255
|
};
|
|
294
256
|
|
|
295
|
-
module.exports = ReactUpdateQueue;
|
|
257
|
+
module.exports = ReactUpdateQueue;
|