react 15.1.0-alpha.1 → 15.2.0
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 +2145 -1396
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1941 -1329
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +15 -8
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +17 -3
- package/lib/Danger.js +10 -8
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +99 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +66 -106
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +7 -1
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMInput.js +52 -16
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +132 -45
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactErrorUtils.js +15 -65
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +9 -4
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactMount.js +25 -14
- package/lib/ReactMultiChild.js +31 -9
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +7 -1
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +5 -3
- package/lib/ReactNoop.js +76 -0
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +8 -2
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +126 -0
- package/lib/ReactTestReconcileTransaction.js +100 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +21 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +40 -6
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +9 -8
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +8 -6
- package/lib/ResponderTouchHistoryStore.js +6 -4
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +3 -1
- package/lib/accumulateInto.js +3 -1
- package/lib/checkReactTypeSpec.js +71 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +13 -4
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/instantiateReactComponent.js +20 -17
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +38 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
package/lib/ReactDebugTool.js
CHANGED
|
@@ -27,7 +27,7 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
|
27
27
|
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
28
28
|
}
|
|
29
29
|
} catch (e) {
|
|
30
|
-
process.env.NODE_ENV !== 'production' ? warning(
|
|
30
|
+
process.env.NODE_ENV !== 'production' ? warning(handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e + '\n' + e.stack) : void 0;
|
|
31
31
|
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -36,55 +36,126 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
|
36
36
|
|
|
37
37
|
var isProfiling = false;
|
|
38
38
|
var flushHistory = [];
|
|
39
|
+
var lifeCycleTimerStack = [];
|
|
39
40
|
var currentFlushNesting = 0;
|
|
40
41
|
var currentFlushMeasurements = null;
|
|
41
42
|
var currentFlushStartTime = null;
|
|
42
43
|
var currentTimerDebugID = null;
|
|
43
44
|
var currentTimerStartTime = null;
|
|
45
|
+
var currentTimerNestedFlushDuration = null;
|
|
44
46
|
var currentTimerType = null;
|
|
45
47
|
|
|
48
|
+
function clearHistory() {
|
|
49
|
+
ReactComponentTreeDevtool.purgeUnmountedComponents();
|
|
50
|
+
ReactHostOperationHistoryDevtool.clearHistory();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getTreeSnapshot(registeredIDs) {
|
|
54
|
+
return registeredIDs.reduce(function (tree, id) {
|
|
55
|
+
var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
|
|
56
|
+
var parentID = ReactComponentTreeDevtool.getParentID(id);
|
|
57
|
+
tree[id] = {
|
|
58
|
+
displayName: ReactComponentTreeDevtool.getDisplayName(id),
|
|
59
|
+
text: ReactComponentTreeDevtool.getText(id),
|
|
60
|
+
updateCount: ReactComponentTreeDevtool.getUpdateCount(id),
|
|
61
|
+
childIDs: ReactComponentTreeDevtool.getChildIDs(id),
|
|
62
|
+
// Text nodes don't have owners but this is close enough.
|
|
63
|
+
ownerID: ownerID || ReactComponentTreeDevtool.getOwnerID(parentID),
|
|
64
|
+
parentID: parentID
|
|
65
|
+
};
|
|
66
|
+
return tree;
|
|
67
|
+
}, {});
|
|
68
|
+
}
|
|
69
|
+
|
|
46
70
|
function resetMeasurements() {
|
|
47
71
|
if (process.env.NODE_ENV !== 'production') {
|
|
72
|
+
var previousStartTime = currentFlushStartTime;
|
|
73
|
+
var previousMeasurements = currentFlushMeasurements || [];
|
|
74
|
+
var previousOperations = ReactHostOperationHistoryDevtool.getHistory();
|
|
75
|
+
|
|
48
76
|
if (!isProfiling || currentFlushNesting === 0) {
|
|
49
77
|
currentFlushStartTime = null;
|
|
50
78
|
currentFlushMeasurements = null;
|
|
79
|
+
clearHistory();
|
|
51
80
|
return;
|
|
52
81
|
}
|
|
53
82
|
|
|
54
|
-
var previousStartTime = currentFlushStartTime;
|
|
55
|
-
var previousMeasurements = currentFlushMeasurements || [];
|
|
56
|
-
var previousOperations = ReactNativeOperationHistoryDevtool.getHistory();
|
|
57
|
-
|
|
58
83
|
if (previousMeasurements.length || previousOperations.length) {
|
|
59
84
|
var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
|
|
60
85
|
flushHistory.push({
|
|
61
86
|
duration: performanceNow() - previousStartTime,
|
|
62
87
|
measurements: previousMeasurements || [],
|
|
63
88
|
operations: previousOperations || [],
|
|
64
|
-
treeSnapshot: registeredIDs
|
|
65
|
-
var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
|
|
66
|
-
var parentID = ReactComponentTreeDevtool.getParentID(id);
|
|
67
|
-
tree[id] = {
|
|
68
|
-
displayName: ReactComponentTreeDevtool.getDisplayName(id),
|
|
69
|
-
text: ReactComponentTreeDevtool.getText(id),
|
|
70
|
-
updateCount: ReactComponentTreeDevtool.getUpdateCount(id),
|
|
71
|
-
childIDs: ReactComponentTreeDevtool.getChildIDs(id),
|
|
72
|
-
// Text nodes don't have owners but this is close enough.
|
|
73
|
-
ownerID: ownerID || ReactComponentTreeDevtool.getOwnerID(parentID),
|
|
74
|
-
parentID: parentID
|
|
75
|
-
};
|
|
76
|
-
return tree;
|
|
77
|
-
}, {})
|
|
89
|
+
treeSnapshot: getTreeSnapshot(registeredIDs)
|
|
78
90
|
});
|
|
79
91
|
}
|
|
80
92
|
|
|
93
|
+
clearHistory();
|
|
81
94
|
currentFlushStartTime = performanceNow();
|
|
82
95
|
currentFlushMeasurements = [];
|
|
83
|
-
ReactComponentTreeDevtool.purgeUnmountedComponents();
|
|
84
|
-
ReactNativeOperationHistoryDevtool.clearHistory();
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
|
|
99
|
+
function checkDebugID(debugID) {
|
|
100
|
+
process.env.NODE_ENV !== 'production' ? warning(debugID, 'ReactDebugTool: debugID may not be empty.') : void 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function beginLifeCycleTimer(debugID, timerType) {
|
|
104
|
+
if (!isProfiling || currentFlushNesting === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
108
|
+
currentTimerStartTime = performanceNow();
|
|
109
|
+
currentTimerNestedFlushDuration = 0;
|
|
110
|
+
currentTimerDebugID = debugID;
|
|
111
|
+
currentTimerType = timerType;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function endLifeCycleTimer(debugID, timerType) {
|
|
115
|
+
if (!isProfiling || currentFlushNesting === 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
119
|
+
currentFlushMeasurements.push({
|
|
120
|
+
timerType: timerType,
|
|
121
|
+
instanceID: debugID,
|
|
122
|
+
duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration
|
|
123
|
+
});
|
|
124
|
+
currentTimerStartTime = null;
|
|
125
|
+
currentTimerNestedFlushDuration = null;
|
|
126
|
+
currentTimerDebugID = null;
|
|
127
|
+
currentTimerType = null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function pauseCurrentLifeCycleTimer() {
|
|
131
|
+
var currentTimer = {
|
|
132
|
+
startTime: currentTimerStartTime,
|
|
133
|
+
nestedFlushStartTime: performanceNow(),
|
|
134
|
+
debugID: currentTimerDebugID,
|
|
135
|
+
timerType: currentTimerType
|
|
136
|
+
};
|
|
137
|
+
lifeCycleTimerStack.push(currentTimer);
|
|
138
|
+
currentTimerStartTime = null;
|
|
139
|
+
currentTimerNestedFlushDuration = null;
|
|
140
|
+
currentTimerDebugID = null;
|
|
141
|
+
currentTimerType = null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function resumeCurrentLifeCycleTimer() {
|
|
145
|
+
var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop();
|
|
146
|
+
|
|
147
|
+
var startTime = _lifeCycleTimerStack$.startTime;
|
|
148
|
+
var nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime;
|
|
149
|
+
var debugID = _lifeCycleTimerStack$.debugID;
|
|
150
|
+
var timerType = _lifeCycleTimerStack$.timerType;
|
|
151
|
+
|
|
152
|
+
var nestedFlushDuration = performanceNow() - nestedFlushStartTime;
|
|
153
|
+
currentTimerStartTime = startTime;
|
|
154
|
+
currentTimerNestedFlushDuration += nestedFlushDuration;
|
|
155
|
+
currentTimerDebugID = debugID;
|
|
156
|
+
currentTimerType = timerType;
|
|
157
|
+
}
|
|
158
|
+
|
|
88
159
|
var ReactDebugTool = {
|
|
89
160
|
addDevtool: function (devtool) {
|
|
90
161
|
eventHandlers.push(devtool);
|
|
@@ -97,6 +168,9 @@ var ReactDebugTool = {
|
|
|
97
168
|
}
|
|
98
169
|
}
|
|
99
170
|
},
|
|
171
|
+
isProfiling: function () {
|
|
172
|
+
return isProfiling;
|
|
173
|
+
},
|
|
100
174
|
beginProfiling: function () {
|
|
101
175
|
if (process.env.NODE_ENV !== 'production') {
|
|
102
176
|
if (isProfiling) {
|
|
@@ -119,14 +193,13 @@ var ReactDebugTool = {
|
|
|
119
193
|
}
|
|
120
194
|
},
|
|
121
195
|
getFlushHistory: function () {
|
|
122
|
-
|
|
123
|
-
return flushHistory;
|
|
124
|
-
}
|
|
196
|
+
return flushHistory;
|
|
125
197
|
},
|
|
126
198
|
onBeginFlush: function () {
|
|
127
199
|
if (process.env.NODE_ENV !== 'production') {
|
|
128
200
|
currentFlushNesting++;
|
|
129
201
|
resetMeasurements();
|
|
202
|
+
pauseCurrentLifeCycleTimer();
|
|
130
203
|
}
|
|
131
204
|
emitEvent('onBeginFlush');
|
|
132
205
|
},
|
|
@@ -134,40 +207,30 @@ var ReactDebugTool = {
|
|
|
134
207
|
if (process.env.NODE_ENV !== 'production') {
|
|
135
208
|
resetMeasurements();
|
|
136
209
|
currentFlushNesting--;
|
|
210
|
+
resumeCurrentLifeCycleTimer();
|
|
137
211
|
}
|
|
138
212
|
emitEvent('onEndFlush');
|
|
139
213
|
},
|
|
140
214
|
onBeginLifeCycleTimer: function (debugID, timerType) {
|
|
215
|
+
checkDebugID(debugID);
|
|
141
216
|
emitEvent('onBeginLifeCycleTimer', debugID, timerType);
|
|
142
217
|
if (process.env.NODE_ENV !== 'production') {
|
|
143
|
-
|
|
144
|
-
process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
145
|
-
currentTimerStartTime = performanceNow();
|
|
146
|
-
currentTimerDebugID = debugID;
|
|
147
|
-
currentTimerType = timerType;
|
|
148
|
-
}
|
|
218
|
+
beginLifeCycleTimer(debugID, timerType);
|
|
149
219
|
}
|
|
150
220
|
},
|
|
151
221
|
onEndLifeCycleTimer: function (debugID, timerType) {
|
|
222
|
+
checkDebugID(debugID);
|
|
152
223
|
if (process.env.NODE_ENV !== 'production') {
|
|
153
|
-
|
|
154
|
-
process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
155
|
-
currentFlushMeasurements.push({
|
|
156
|
-
timerType: timerType,
|
|
157
|
-
instanceID: debugID,
|
|
158
|
-
duration: performanceNow() - currentTimerStartTime
|
|
159
|
-
});
|
|
160
|
-
currentTimerStartTime = null;
|
|
161
|
-
currentTimerDebugID = null;
|
|
162
|
-
currentTimerType = null;
|
|
163
|
-
}
|
|
224
|
+
endLifeCycleTimer(debugID, timerType);
|
|
164
225
|
}
|
|
165
226
|
emitEvent('onEndLifeCycleTimer', debugID, timerType);
|
|
166
227
|
},
|
|
167
228
|
onBeginReconcilerTimer: function (debugID, timerType) {
|
|
229
|
+
checkDebugID(debugID);
|
|
168
230
|
emitEvent('onBeginReconcilerTimer', debugID, timerType);
|
|
169
231
|
},
|
|
170
232
|
onEndReconcilerTimer: function (debugID, timerType) {
|
|
233
|
+
checkDebugID(debugID);
|
|
171
234
|
emitEvent('onEndReconcilerTimer', debugID, timerType);
|
|
172
235
|
},
|
|
173
236
|
onBeginProcessingChildContext: function () {
|
|
@@ -176,45 +239,69 @@ var ReactDebugTool = {
|
|
|
176
239
|
onEndProcessingChildContext: function () {
|
|
177
240
|
emitEvent('onEndProcessingChildContext');
|
|
178
241
|
},
|
|
179
|
-
|
|
180
|
-
|
|
242
|
+
onHostOperation: function (debugID, type, payload) {
|
|
243
|
+
checkDebugID(debugID);
|
|
244
|
+
emitEvent('onHostOperation', debugID, type, payload);
|
|
181
245
|
},
|
|
182
246
|
onSetState: function () {
|
|
183
247
|
emitEvent('onSetState');
|
|
184
248
|
},
|
|
185
249
|
onSetDisplayName: function (debugID, displayName) {
|
|
250
|
+
checkDebugID(debugID);
|
|
186
251
|
emitEvent('onSetDisplayName', debugID, displayName);
|
|
187
252
|
},
|
|
188
253
|
onSetChildren: function (debugID, childDebugIDs) {
|
|
254
|
+
checkDebugID(debugID);
|
|
189
255
|
emitEvent('onSetChildren', debugID, childDebugIDs);
|
|
190
256
|
},
|
|
191
257
|
onSetOwner: function (debugID, ownerDebugID) {
|
|
258
|
+
checkDebugID(debugID);
|
|
192
259
|
emitEvent('onSetOwner', debugID, ownerDebugID);
|
|
193
260
|
},
|
|
261
|
+
onSetParent: function (debugID, parentDebugID) {
|
|
262
|
+
checkDebugID(debugID);
|
|
263
|
+
emitEvent('onSetParent', debugID, parentDebugID);
|
|
264
|
+
},
|
|
194
265
|
onSetText: function (debugID, text) {
|
|
266
|
+
checkDebugID(debugID);
|
|
195
267
|
emitEvent('onSetText', debugID, text);
|
|
196
268
|
},
|
|
197
269
|
onMountRootComponent: function (debugID) {
|
|
270
|
+
checkDebugID(debugID);
|
|
198
271
|
emitEvent('onMountRootComponent', debugID);
|
|
199
272
|
},
|
|
273
|
+
onBeforeMountComponent: function (debugID, element) {
|
|
274
|
+
checkDebugID(debugID);
|
|
275
|
+
emitEvent('onBeforeMountComponent', debugID, element);
|
|
276
|
+
},
|
|
200
277
|
onMountComponent: function (debugID) {
|
|
278
|
+
checkDebugID(debugID);
|
|
201
279
|
emitEvent('onMountComponent', debugID);
|
|
202
280
|
},
|
|
281
|
+
onBeforeUpdateComponent: function (debugID, element) {
|
|
282
|
+
checkDebugID(debugID);
|
|
283
|
+
emitEvent('onBeforeUpdateComponent', debugID, element);
|
|
284
|
+
},
|
|
203
285
|
onUpdateComponent: function (debugID) {
|
|
286
|
+
checkDebugID(debugID);
|
|
204
287
|
emitEvent('onUpdateComponent', debugID);
|
|
205
288
|
},
|
|
206
289
|
onUnmountComponent: function (debugID) {
|
|
290
|
+
checkDebugID(debugID);
|
|
207
291
|
emitEvent('onUnmountComponent', debugID);
|
|
292
|
+
},
|
|
293
|
+
onTestEvent: function () {
|
|
294
|
+
emitEvent('onTestEvent');
|
|
208
295
|
}
|
|
209
296
|
};
|
|
210
297
|
|
|
211
298
|
if (process.env.NODE_ENV !== 'production') {
|
|
212
299
|
var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
|
|
213
|
-
var
|
|
300
|
+
var ReactHostOperationHistoryDevtool = require('./ReactHostOperationHistoryDevtool');
|
|
214
301
|
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
215
302
|
ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
|
|
216
303
|
ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
|
|
217
|
-
ReactDebugTool.addDevtool(
|
|
304
|
+
ReactDebugTool.addDevtool(ReactHostOperationHistoryDevtool);
|
|
218
305
|
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
219
306
|
if (/[?&]react_perf\b/.test(url)) {
|
|
220
307
|
ReactDebugTool.beginProfiling();
|
|
@@ -62,9 +62,9 @@ function inject() {
|
|
|
62
62
|
BeforeInputEventPlugin: BeforeInputEventPlugin
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
ReactInjection.
|
|
65
|
+
ReactInjection.HostComponent.injectGenericComponentClass(ReactDOMComponent);
|
|
66
66
|
|
|
67
|
-
ReactInjection.
|
|
67
|
+
ReactInjection.HostComponent.injectTextComponentClass(ReactDOMTextComponent);
|
|
68
68
|
|
|
69
69
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
|
70
70
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
package/lib/ReactElement.js
CHANGED
|
@@ -17,6 +17,7 @@ var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
|
17
17
|
|
|
18
18
|
var warning = require('fbjs/lib/warning');
|
|
19
19
|
var canDefineProperty = require('./canDefineProperty');
|
|
20
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
20
21
|
|
|
21
22
|
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
|
22
23
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -31,6 +32,30 @@ var RESERVED_PROPS = {
|
|
|
31
32
|
|
|
32
33
|
var specialPropKeyWarningShown, specialPropRefWarningShown;
|
|
33
34
|
|
|
35
|
+
function hasValidRef(config) {
|
|
36
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
37
|
+
if (hasOwnProperty.call(config, 'ref')) {
|
|
38
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
39
|
+
if (getter && getter.isReactWarning) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return config.ref !== undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function hasValidKey(config) {
|
|
48
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
49
|
+
if (hasOwnProperty.call(config, 'key')) {
|
|
50
|
+
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
51
|
+
if (getter && getter.isReactWarning) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return config.key !== undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
34
59
|
/**
|
|
35
60
|
* Factory method to create a new React element. This no longer adheres to
|
|
36
61
|
* the class pattern, so do not use new to call it. Also, no instanceof check
|
|
@@ -135,17 +160,20 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
135
160
|
config.__proto__ == null || config.__proto__ === Object.prototype,
|
|
136
161
|
/* eslint-enable no-proto */
|
|
137
162
|
'React.createElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
|
|
138
|
-
ref = !config.hasOwnProperty('ref') || Object.getOwnPropertyDescriptor(config, 'ref').get ? null : config.ref;
|
|
139
|
-
key = !config.hasOwnProperty('key') || Object.getOwnPropertyDescriptor(config, 'key').get ? null : '' + config.key;
|
|
140
|
-
} else {
|
|
141
|
-
ref = config.ref === undefined ? null : config.ref;
|
|
142
|
-
key = config.key === undefined ? null : '' + config.key;
|
|
143
163
|
}
|
|
164
|
+
|
|
165
|
+
if (hasValidRef(config)) {
|
|
166
|
+
ref = config.ref;
|
|
167
|
+
}
|
|
168
|
+
if (hasValidKey(config)) {
|
|
169
|
+
key = '' + config.key;
|
|
170
|
+
}
|
|
171
|
+
|
|
144
172
|
self = config.__self === undefined ? null : config.__self;
|
|
145
173
|
source = config.__source === undefined ? null : config.__source;
|
|
146
174
|
// Remaining properties are added to a new props object
|
|
147
175
|
for (propName in config) {
|
|
148
|
-
if (
|
|
176
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
149
177
|
props[propName] = config[propName];
|
|
150
178
|
}
|
|
151
179
|
}
|
|
@@ -174,30 +202,37 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
174
202
|
}
|
|
175
203
|
}
|
|
176
204
|
if (process.env.NODE_ENV !== 'production') {
|
|
177
|
-
|
|
178
|
-
|
|
205
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
206
|
+
|
|
207
|
+
// Create dummy `key` and `ref` property to `props` to warn users against its use
|
|
208
|
+
var warnAboutAccessingKey = function () {
|
|
209
|
+
if (!specialPropKeyWarningShown) {
|
|
210
|
+
specialPropKeyWarningShown = true;
|
|
211
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
};
|
|
215
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
216
|
+
|
|
217
|
+
var warnAboutAccessingRef = function () {
|
|
218
|
+
if (!specialPropRefWarningShown) {
|
|
219
|
+
specialPropRefWarningShown = true;
|
|
220
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
};
|
|
224
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
225
|
+
|
|
179
226
|
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
|
180
227
|
if (!props.hasOwnProperty('key')) {
|
|
181
228
|
Object.defineProperty(props, 'key', {
|
|
182
|
-
get:
|
|
183
|
-
if (!specialPropKeyWarningShown) {
|
|
184
|
-
specialPropKeyWarningShown = true;
|
|
185
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
|
|
186
|
-
}
|
|
187
|
-
return undefined;
|
|
188
|
-
},
|
|
229
|
+
get: warnAboutAccessingKey,
|
|
189
230
|
configurable: true
|
|
190
231
|
});
|
|
191
232
|
}
|
|
192
233
|
if (!props.hasOwnProperty('ref')) {
|
|
193
234
|
Object.defineProperty(props, 'ref', {
|
|
194
|
-
get:
|
|
195
|
-
if (!specialPropRefWarningShown) {
|
|
196
|
-
specialPropRefWarningShown = true;
|
|
197
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', typeof type === 'function' && 'displayName' in type ? type.displayName : 'Element') : void 0;
|
|
198
|
-
}
|
|
199
|
-
return undefined;
|
|
200
|
-
},
|
|
235
|
+
get: warnAboutAccessingRef,
|
|
201
236
|
configurable: true
|
|
202
237
|
});
|
|
203
238
|
}
|
|
@@ -258,21 +293,23 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
258
293
|
/* eslint-enable no-proto */
|
|
259
294
|
'React.cloneElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
|
|
260
295
|
}
|
|
261
|
-
|
|
296
|
+
|
|
297
|
+
if (hasValidRef(config)) {
|
|
262
298
|
// Silently steal the ref from the parent.
|
|
263
299
|
ref = config.ref;
|
|
264
300
|
owner = ReactCurrentOwner.current;
|
|
265
301
|
}
|
|
266
|
-
if (config
|
|
302
|
+
if (hasValidKey(config)) {
|
|
267
303
|
key = '' + config.key;
|
|
268
304
|
}
|
|
305
|
+
|
|
269
306
|
// Remaining properties override existing props
|
|
270
307
|
var defaultProps;
|
|
271
308
|
if (element.type && element.type.defaultProps) {
|
|
272
309
|
defaultProps = element.type.defaultProps;
|
|
273
310
|
}
|
|
274
311
|
for (propName in config) {
|
|
275
|
-
if (
|
|
312
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
276
313
|
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
277
314
|
// Resolve default props
|
|
278
315
|
props[propName] = defaultProps[propName];
|
|
@@ -310,4 +347,6 @@ ReactElement.isValidElement = function (object) {
|
|
|
310
347
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
311
348
|
};
|
|
312
349
|
|
|
350
|
+
ReactElement.REACT_ELEMENT_TYPE = REACT_ELEMENT_TYPE;
|
|
351
|
+
|
|
313
352
|
module.exports = ReactElement;
|