react 15.0.3-alpha.1 → 15.2.0-rc.1
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 +3311 -2007
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +2734 -2014
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +5 -5
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +42 -7
- package/lib/DOMLazyTree.js +18 -5
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +35 -12
- 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/LinkedStateMixin.js +1 -0
- 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/ReactCSSTransitionGroup.js +5 -0
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactChildren.js +9 -1
- package/lib/ReactClass.js +15 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentBrowserEnvironment.js +0 -5
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +223 -0
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -0
- package/lib/ReactCompositeComponent.js +208 -119
- package/lib/ReactDOM.js +3 -6
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +165 -71
- 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/ReactDOMIDOperations.js +0 -5
- package/lib/ReactDOMInput.js +57 -19
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +28 -26
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
- package/lib/ReactDebugTool.js +250 -11
- package/lib/ReactDefaultInjection.js +2 -11
- package/lib/ReactElement.js +90 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +8 -3
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/ReactHostOperationHistoryDevtool.js +37 -0
- package/lib/ReactInjection.js +2 -4
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactLink.js +3 -0
- package/lib/ReactMount.js +43 -20
- package/lib/ReactMultiChild.js +51 -8
- 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 +4 -8
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +25 -8
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +18 -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 +473 -75
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +57 -11
- package/lib/ReactServerRendering.js +24 -3
- package/lib/ReactServerRenderingTransaction.js +5 -1
- 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 +25 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +44 -5
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +30 -11
- package/lib/ReactVersion.js +1 -1
- package/lib/ReactWithAddons.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 +8 -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 +44 -10
- package/lib/onlyChild.js +10 -5
- 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/shallowCompare.js +1 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +16 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
- package/lib/ReactDebugInstanceMap.js +0 -102
- package/lib/ReactDefaultPerf.js +0 -316
- package/lib/ReactDefaultPerfAnalysis.js +0 -210
package/lib/ReactDebugTool.js
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
|
+
|
|
16
|
+
var performanceNow = require('fbjs/lib/performanceNow');
|
|
15
17
|
var warning = require('fbjs/lib/warning');
|
|
16
18
|
|
|
17
19
|
var eventHandlers = [];
|
|
@@ -25,13 +27,135 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
|
25
27
|
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
26
28
|
}
|
|
27
29
|
} catch (e) {
|
|
28
|
-
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;
|
|
29
31
|
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
var isProfiling = false;
|
|
38
|
+
var flushHistory = [];
|
|
39
|
+
var lifeCycleTimerStack = [];
|
|
40
|
+
var currentFlushNesting = 0;
|
|
41
|
+
var currentFlushMeasurements = null;
|
|
42
|
+
var currentFlushStartTime = null;
|
|
43
|
+
var currentTimerDebugID = null;
|
|
44
|
+
var currentTimerStartTime = null;
|
|
45
|
+
var currentTimerNestedFlushDuration = null;
|
|
46
|
+
var currentTimerType = null;
|
|
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
|
+
|
|
70
|
+
function resetMeasurements() {
|
|
71
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
72
|
+
var previousStartTime = currentFlushStartTime;
|
|
73
|
+
var previousMeasurements = currentFlushMeasurements || [];
|
|
74
|
+
var previousOperations = ReactHostOperationHistoryDevtool.getHistory();
|
|
75
|
+
|
|
76
|
+
if (!isProfiling || currentFlushNesting === 0) {
|
|
77
|
+
currentFlushStartTime = null;
|
|
78
|
+
currentFlushMeasurements = null;
|
|
79
|
+
clearHistory();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (previousMeasurements.length || previousOperations.length) {
|
|
84
|
+
var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
|
|
85
|
+
flushHistory.push({
|
|
86
|
+
duration: performanceNow() - previousStartTime,
|
|
87
|
+
measurements: previousMeasurements || [],
|
|
88
|
+
operations: previousOperations || [],
|
|
89
|
+
treeSnapshot: getTreeSnapshot(registeredIDs)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
clearHistory();
|
|
94
|
+
currentFlushStartTime = performanceNow();
|
|
95
|
+
currentFlushMeasurements = [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
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
|
+
|
|
35
159
|
var ReactDebugTool = {
|
|
36
160
|
addDevtool: function (devtool) {
|
|
37
161
|
eventHandlers.push(devtool);
|
|
@@ -44,29 +168,144 @@ var ReactDebugTool = {
|
|
|
44
168
|
}
|
|
45
169
|
}
|
|
46
170
|
},
|
|
171
|
+
isProfiling: function () {
|
|
172
|
+
return isProfiling;
|
|
173
|
+
},
|
|
174
|
+
beginProfiling: function () {
|
|
175
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
176
|
+
if (isProfiling) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
isProfiling = true;
|
|
181
|
+
flushHistory.length = 0;
|
|
182
|
+
resetMeasurements();
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
endProfiling: function () {
|
|
186
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
187
|
+
if (!isProfiling) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
isProfiling = false;
|
|
192
|
+
resetMeasurements();
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
getFlushHistory: function () {
|
|
196
|
+
return flushHistory;
|
|
197
|
+
},
|
|
198
|
+
onBeginFlush: function () {
|
|
199
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
200
|
+
currentFlushNesting++;
|
|
201
|
+
resetMeasurements();
|
|
202
|
+
pauseCurrentLifeCycleTimer();
|
|
203
|
+
}
|
|
204
|
+
emitEvent('onBeginFlush');
|
|
205
|
+
},
|
|
206
|
+
onEndFlush: function () {
|
|
207
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
208
|
+
resetMeasurements();
|
|
209
|
+
currentFlushNesting--;
|
|
210
|
+
resumeCurrentLifeCycleTimer();
|
|
211
|
+
}
|
|
212
|
+
emitEvent('onEndFlush');
|
|
213
|
+
},
|
|
214
|
+
onBeginLifeCycleTimer: function (debugID, timerType) {
|
|
215
|
+
checkDebugID(debugID);
|
|
216
|
+
emitEvent('onBeginLifeCycleTimer', debugID, timerType);
|
|
217
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
218
|
+
beginLifeCycleTimer(debugID, timerType);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
onEndLifeCycleTimer: function (debugID, timerType) {
|
|
222
|
+
checkDebugID(debugID);
|
|
223
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
224
|
+
endLifeCycleTimer(debugID, timerType);
|
|
225
|
+
}
|
|
226
|
+
emitEvent('onEndLifeCycleTimer', debugID, timerType);
|
|
227
|
+
},
|
|
228
|
+
onBeginReconcilerTimer: function (debugID, timerType) {
|
|
229
|
+
checkDebugID(debugID);
|
|
230
|
+
emitEvent('onBeginReconcilerTimer', debugID, timerType);
|
|
231
|
+
},
|
|
232
|
+
onEndReconcilerTimer: function (debugID, timerType) {
|
|
233
|
+
checkDebugID(debugID);
|
|
234
|
+
emitEvent('onEndReconcilerTimer', debugID, timerType);
|
|
235
|
+
},
|
|
47
236
|
onBeginProcessingChildContext: function () {
|
|
48
237
|
emitEvent('onBeginProcessingChildContext');
|
|
49
238
|
},
|
|
50
239
|
onEndProcessingChildContext: function () {
|
|
51
240
|
emitEvent('onEndProcessingChildContext');
|
|
52
241
|
},
|
|
242
|
+
onHostOperation: function (debugID, type, payload) {
|
|
243
|
+
checkDebugID(debugID);
|
|
244
|
+
emitEvent('onHostOperation', debugID, type, payload);
|
|
245
|
+
},
|
|
53
246
|
onSetState: function () {
|
|
54
247
|
emitEvent('onSetState');
|
|
55
248
|
},
|
|
56
|
-
|
|
57
|
-
|
|
249
|
+
onSetDisplayName: function (debugID, displayName) {
|
|
250
|
+
checkDebugID(debugID);
|
|
251
|
+
emitEvent('onSetDisplayName', debugID, displayName);
|
|
252
|
+
},
|
|
253
|
+
onSetChildren: function (debugID, childDebugIDs) {
|
|
254
|
+
checkDebugID(debugID);
|
|
255
|
+
emitEvent('onSetChildren', debugID, childDebugIDs);
|
|
256
|
+
},
|
|
257
|
+
onSetOwner: function (debugID, ownerDebugID) {
|
|
258
|
+
checkDebugID(debugID);
|
|
259
|
+
emitEvent('onSetOwner', debugID, ownerDebugID);
|
|
260
|
+
},
|
|
261
|
+
onSetParent: function (debugID, parentDebugID) {
|
|
262
|
+
checkDebugID(debugID);
|
|
263
|
+
emitEvent('onSetParent', debugID, parentDebugID);
|
|
58
264
|
},
|
|
59
|
-
|
|
60
|
-
|
|
265
|
+
onSetText: function (debugID, text) {
|
|
266
|
+
checkDebugID(debugID);
|
|
267
|
+
emitEvent('onSetText', debugID, text);
|
|
61
268
|
},
|
|
62
|
-
|
|
63
|
-
|
|
269
|
+
onMountRootComponent: function (debugID) {
|
|
270
|
+
checkDebugID(debugID);
|
|
271
|
+
emitEvent('onMountRootComponent', debugID);
|
|
64
272
|
},
|
|
65
|
-
|
|
66
|
-
|
|
273
|
+
onBeforeMountComponent: function (debugID, element) {
|
|
274
|
+
checkDebugID(debugID);
|
|
275
|
+
emitEvent('onBeforeMountComponent', debugID, element);
|
|
276
|
+
},
|
|
277
|
+
onMountComponent: function (debugID) {
|
|
278
|
+
checkDebugID(debugID);
|
|
279
|
+
emitEvent('onMountComponent', debugID);
|
|
280
|
+
},
|
|
281
|
+
onBeforeUpdateComponent: function (debugID, element) {
|
|
282
|
+
checkDebugID(debugID);
|
|
283
|
+
emitEvent('onBeforeUpdateComponent', debugID, element);
|
|
284
|
+
},
|
|
285
|
+
onUpdateComponent: function (debugID) {
|
|
286
|
+
checkDebugID(debugID);
|
|
287
|
+
emitEvent('onUpdateComponent', debugID);
|
|
288
|
+
},
|
|
289
|
+
onUnmountComponent: function (debugID) {
|
|
290
|
+
checkDebugID(debugID);
|
|
291
|
+
emitEvent('onUnmountComponent', debugID);
|
|
292
|
+
},
|
|
293
|
+
onTestEvent: function () {
|
|
294
|
+
emitEvent('onTestEvent');
|
|
67
295
|
}
|
|
68
296
|
};
|
|
69
297
|
|
|
70
|
-
|
|
298
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
299
|
+
var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
|
|
300
|
+
var ReactHostOperationHistoryDevtool = require('./ReactHostOperationHistoryDevtool');
|
|
301
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
302
|
+
ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
|
|
303
|
+
ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
|
|
304
|
+
ReactDebugTool.addDevtool(ReactHostOperationHistoryDevtool);
|
|
305
|
+
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
306
|
+
if (/[?&]react_perf\b/.test(url)) {
|
|
307
|
+
ReactDebugTool.beginProfiling();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
71
310
|
|
|
72
311
|
module.exports = ReactDebugTool;
|
|
@@ -15,7 +15,6 @@ var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
|
|
|
15
15
|
var ChangeEventPlugin = require('./ChangeEventPlugin');
|
|
16
16
|
var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
|
|
17
17
|
var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
|
|
18
|
-
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
19
18
|
var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
|
|
20
19
|
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
21
20
|
var ReactDOMComponent = require('./ReactDOMComponent');
|
|
@@ -63,9 +62,9 @@ function inject() {
|
|
|
63
62
|
BeforeInputEventPlugin: BeforeInputEventPlugin
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
ReactInjection.
|
|
65
|
+
ReactInjection.HostComponent.injectGenericComponentClass(ReactDOMComponent);
|
|
67
66
|
|
|
68
|
-
ReactInjection.
|
|
67
|
+
ReactInjection.HostComponent.injectTextComponentClass(ReactDOMTextComponent);
|
|
69
68
|
|
|
70
69
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
|
71
70
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
|
@@ -78,14 +77,6 @@ function inject() {
|
|
|
78
77
|
ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
79
78
|
|
|
80
79
|
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
|
81
|
-
|
|
82
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
83
|
-
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
84
|
-
if (/[?&]react_perf\b/.test(url)) {
|
|
85
|
-
var ReactDefaultPerf = require('./ReactDefaultPerf');
|
|
86
|
-
ReactDefaultPerf.start();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
80
|
}
|
|
90
81
|
|
|
91
82
|
module.exports = {
|
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
|
|
@@ -113,6 +138,10 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
113
138
|
return element;
|
|
114
139
|
};
|
|
115
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Create and return a new ReactElement of the given type.
|
|
143
|
+
* See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
|
|
144
|
+
*/
|
|
116
145
|
ReactElement.createElement = function (type, config, children) {
|
|
117
146
|
var propName;
|
|
118
147
|
|
|
@@ -126,17 +155,25 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
126
155
|
|
|
127
156
|
if (config != null) {
|
|
128
157
|
if (process.env.NODE_ENV !== 'production') {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
158
|
+
process.env.NODE_ENV !== 'production' ? warning(
|
|
159
|
+
/* eslint-disable no-proto */
|
|
160
|
+
config.__proto__ == null || config.__proto__ === Object.prototype,
|
|
161
|
+
/* eslint-enable no-proto */
|
|
162
|
+
'React.createElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
|
|
134
163
|
}
|
|
164
|
+
|
|
165
|
+
if (hasValidRef(config)) {
|
|
166
|
+
ref = config.ref;
|
|
167
|
+
}
|
|
168
|
+
if (hasValidKey(config)) {
|
|
169
|
+
key = '' + config.key;
|
|
170
|
+
}
|
|
171
|
+
|
|
135
172
|
self = config.__self === undefined ? null : config.__self;
|
|
136
173
|
source = config.__source === undefined ? null : config.__source;
|
|
137
174
|
// Remaining properties are added to a new props object
|
|
138
175
|
for (propName in config) {
|
|
139
|
-
if (
|
|
176
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
140
177
|
props[propName] = config[propName];
|
|
141
178
|
}
|
|
142
179
|
}
|
|
@@ -165,30 +202,37 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
165
202
|
}
|
|
166
203
|
}
|
|
167
204
|
if (process.env.NODE_ENV !== 'production') {
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
|
|
170
226
|
if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
|
|
171
227
|
if (!props.hasOwnProperty('key')) {
|
|
172
228
|
Object.defineProperty(props, 'key', {
|
|
173
|
-
get:
|
|
174
|
-
if (!specialPropKeyWarningShown) {
|
|
175
|
-
specialPropKeyWarningShown = true;
|
|
176
|
-
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;
|
|
177
|
-
}
|
|
178
|
-
return undefined;
|
|
179
|
-
},
|
|
229
|
+
get: warnAboutAccessingKey,
|
|
180
230
|
configurable: true
|
|
181
231
|
});
|
|
182
232
|
}
|
|
183
233
|
if (!props.hasOwnProperty('ref')) {
|
|
184
234
|
Object.defineProperty(props, 'ref', {
|
|
185
|
-
get:
|
|
186
|
-
if (!specialPropRefWarningShown) {
|
|
187
|
-
specialPropRefWarningShown = true;
|
|
188
|
-
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;
|
|
189
|
-
}
|
|
190
|
-
return undefined;
|
|
191
|
-
},
|
|
235
|
+
get: warnAboutAccessingRef,
|
|
192
236
|
configurable: true
|
|
193
237
|
});
|
|
194
238
|
}
|
|
@@ -197,6 +241,10 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
197
241
|
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
198
242
|
};
|
|
199
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Return a function that produces ReactElements of a given type.
|
|
246
|
+
* See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
|
|
247
|
+
*/
|
|
200
248
|
ReactElement.createFactory = function (type) {
|
|
201
249
|
var factory = ReactElement.createElement.bind(null, type);
|
|
202
250
|
// Expose the type on the factory and the prototype so that it can be
|
|
@@ -214,6 +262,10 @@ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
|
|
|
214
262
|
return newElement;
|
|
215
263
|
};
|
|
216
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Clone and return a new ReactElement using element as the starting point.
|
|
267
|
+
* See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
|
|
268
|
+
*/
|
|
217
269
|
ReactElement.cloneElement = function (element, config, children) {
|
|
218
270
|
var propName;
|
|
219
271
|
|
|
@@ -234,21 +286,30 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
234
286
|
var owner = element._owner;
|
|
235
287
|
|
|
236
288
|
if (config != null) {
|
|
237
|
-
if (
|
|
289
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
290
|
+
process.env.NODE_ENV !== 'production' ? warning(
|
|
291
|
+
/* eslint-disable no-proto */
|
|
292
|
+
config.__proto__ == null || config.__proto__ === Object.prototype,
|
|
293
|
+
/* eslint-enable no-proto */
|
|
294
|
+
'React.cloneElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (hasValidRef(config)) {
|
|
238
298
|
// Silently steal the ref from the parent.
|
|
239
299
|
ref = config.ref;
|
|
240
300
|
owner = ReactCurrentOwner.current;
|
|
241
301
|
}
|
|
242
|
-
if (config
|
|
302
|
+
if (hasValidKey(config)) {
|
|
243
303
|
key = '' + config.key;
|
|
244
304
|
}
|
|
305
|
+
|
|
245
306
|
// Remaining properties override existing props
|
|
246
307
|
var defaultProps;
|
|
247
308
|
if (element.type && element.type.defaultProps) {
|
|
248
309
|
defaultProps = element.type.defaultProps;
|
|
249
310
|
}
|
|
250
311
|
for (propName in config) {
|
|
251
|
-
if (
|
|
312
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
252
313
|
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
253
314
|
// Resolve default props
|
|
254
315
|
props[propName] = defaultProps[propName];
|
|
@@ -276,6 +337,8 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
276
337
|
};
|
|
277
338
|
|
|
278
339
|
/**
|
|
340
|
+
* Verifies the object is a ReactElement.
|
|
341
|
+
* See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
|
|
279
342
|
* @param {?object} object
|
|
280
343
|
* @return {boolean} True if `object` is a valid component.
|
|
281
344
|
* @final
|
|
@@ -284,4 +347,6 @@ ReactElement.isValidElement = function (object) {
|
|
|
284
347
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
285
348
|
};
|
|
286
349
|
|
|
350
|
+
ReactElement.REACT_ELEMENT_TYPE = REACT_ELEMENT_TYPE;
|
|
351
|
+
|
|
287
352
|
module.exports = ReactElement;
|