react 0.13.1 → 0.14.0-alpha2
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 +1 -1
- package/addons.js +7 -0
- package/addons/CSSTransitionGroup.js +1 -0
- package/addons/LinkedStateMixin.js +1 -0
- package/addons/Perf.js +1 -0
- package/addons/PureRenderMixin.js +1 -0
- package/addons/TestUtils.js +1 -0
- package/addons/TransitionGroup.js +1 -0
- package/addons/batchedUpdates.js +1 -0
- package/addons/cloneWithProps.js +1 -0
- package/addons/createFragment.js +1 -0
- package/addons/renderSubtreeIntoContainer.js +1 -0
- package/addons/shallowCompare.js +1 -0
- package/addons/update.js +1 -0
- package/dist/JSXTransformer.js +3336 -1671
- package/dist/react-with-addons.js +3320 -5125
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2952 -4533
- package/dist/react.min.js +5 -5
- package/lib/AutoFocusMixin.js +4 -3
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +9 -4
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -67
- package/lib/DOMPropertyOperations.js +30 -51
- 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 +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -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 +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +21 -28
- package/lib/ReactClass.js +81 -234
- package/lib/ReactComponent.js +17 -33
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +85 -297
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMClient.js +85 -0
- package/lib/ReactDOMComponent.js +184 -146
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -22
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +68 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +31 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +24 -57
- package/lib/ReactElementValidator.js +38 -105
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +137 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- 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 +29 -61
- package/lib/ReactReconcileTransaction.js +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +93 -165
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +27 -90
- package/lib/ReactUpdates.js +27 -79
- package/lib/ReactWithAddons.js +7 -6
- package/lib/SVGDOMPropertyConfig.js +41 -4
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- 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 +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +4 -11
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +5 -24
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +7 -5
- 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 +14 -37
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- 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 +22 -89
- package/lib/update.js +33 -90
- package/lib/validateDOMNesting.js +355 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* @providesModule ReactDefaultPerfAnalysis
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
12
14
|
var assign = require("./Object.assign");
|
|
13
15
|
|
|
14
16
|
// Don't try to save users less than 1.2ms (a number I made up)
|
|
@@ -46,7 +48,7 @@ function getDOMSummary(measurements) {
|
|
|
46
48
|
var id;
|
|
47
49
|
|
|
48
50
|
for (id in measurement.writes) {
|
|
49
|
-
measurement.writes[id].forEach(function(write) {
|
|
51
|
+
measurement.writes[id].forEach(function (write) {
|
|
50
52
|
items.push({
|
|
51
53
|
id: id,
|
|
52
54
|
type: DOM_OPERATION_TYPES[write.type] || write.type,
|
|
@@ -64,11 +66,7 @@ function getExclusiveSummary(measurements) {
|
|
|
64
66
|
|
|
65
67
|
for (var i = 0; i < measurements.length; i++) {
|
|
66
68
|
var measurement = measurements[i];
|
|
67
|
-
var allIDs = assign(
|
|
68
|
-
{},
|
|
69
|
-
measurement.exclusive,
|
|
70
|
-
measurement.inclusive
|
|
71
|
-
);
|
|
69
|
+
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
|
|
72
70
|
|
|
73
71
|
for (var id in allIDs) {
|
|
74
72
|
displayName = measurement.displayNames[id].current;
|
|
@@ -103,7 +101,7 @@ function getExclusiveSummary(measurements) {
|
|
|
103
101
|
}
|
|
104
102
|
}
|
|
105
103
|
|
|
106
|
-
arr.sort(function(a, b) {
|
|
104
|
+
arr.sort(function (a, b) {
|
|
107
105
|
return b.exclusive - a.exclusive;
|
|
108
106
|
});
|
|
109
107
|
|
|
@@ -116,11 +114,7 @@ function getInclusiveSummary(measurements, onlyClean) {
|
|
|
116
114
|
|
|
117
115
|
for (var i = 0; i < measurements.length; i++) {
|
|
118
116
|
var measurement = measurements[i];
|
|
119
|
-
var allIDs = assign(
|
|
120
|
-
{},
|
|
121
|
-
measurement.exclusive,
|
|
122
|
-
measurement.inclusive
|
|
123
|
-
);
|
|
117
|
+
var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
|
|
124
118
|
var cleanComponents;
|
|
125
119
|
|
|
126
120
|
if (onlyClean) {
|
|
@@ -162,7 +156,7 @@ function getInclusiveSummary(measurements, onlyClean) {
|
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
158
|
|
|
165
|
-
arr.sort(function(a, b) {
|
|
159
|
+
arr.sort(function (a, b) {
|
|
166
160
|
return b.time - a.time;
|
|
167
161
|
});
|
|
168
162
|
|
|
@@ -201,4 +195,4 @@ var ReactDefaultPerfAnalysis = {
|
|
|
201
195
|
getTotalTime: getTotalTime
|
|
202
196
|
};
|
|
203
197
|
|
|
204
|
-
module.exports = ReactDefaultPerfAnalysis;
|
|
198
|
+
module.exports = ReactDefaultPerfAnalysis;
|
package/lib/ReactElement.js
CHANGED
|
@@ -35,20 +35,15 @@ function defineWarningProperty(object, key) {
|
|
|
35
35
|
configurable: false,
|
|
36
36
|
enumerable: true,
|
|
37
37
|
|
|
38
|
-
get: function() {
|
|
38
|
+
get: function () {
|
|
39
39
|
if (!this._store) {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
return this._store[key];
|
|
43
43
|
},
|
|
44
44
|
|
|
45
|
-
set: function(value) {
|
|
46
|
-
|
|
47
|
-
false,
|
|
48
|
-
'Don\'t set the %s property of the React element. Instead, ' +
|
|
49
|
-
'specify the correct value when initially creating the element.',
|
|
50
|
-
key
|
|
51
|
-
) : null);
|
|
45
|
+
set: function (value) {
|
|
46
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set the %s property of the React element. Instead, ' + 'specify the correct value when initially creating the element.', key) : null;
|
|
52
47
|
this._store[key] = value;
|
|
53
48
|
}
|
|
54
49
|
|
|
@@ -75,9 +70,7 @@ function defineMutationMembrane(prototype) {
|
|
|
75
70
|
defineWarningProperty(prototype, key);
|
|
76
71
|
}
|
|
77
72
|
useMutationMembrane = true;
|
|
78
|
-
} catch (x) {
|
|
79
|
-
// IE will fail on defineProperty
|
|
80
|
-
}
|
|
73
|
+
} catch (x) {}
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
/**
|
|
@@ -90,7 +83,7 @@ function defineMutationMembrane(prototype) {
|
|
|
90
83
|
* @param {*} props
|
|
91
84
|
* @internal
|
|
92
85
|
*/
|
|
93
|
-
var ReactElement = function(type, key, ref, owner, context, props) {
|
|
86
|
+
var ReactElement = function (type, key, ref, owner, context, props) {
|
|
94
87
|
// Built-in properties that belong on the element
|
|
95
88
|
this.type = type;
|
|
96
89
|
this.key = key;
|
|
@@ -99,16 +92,12 @@ var ReactElement = function(type, key, ref, owner, context, props) {
|
|
|
99
92
|
// Record the component responsible for creating this element.
|
|
100
93
|
this._owner = owner;
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
// through the owner.
|
|
104
|
-
this._context = context;
|
|
105
|
-
|
|
106
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
95
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
107
96
|
// The validation flag and props are currently mutative. We put them on
|
|
108
97
|
// an external backing store so that we can freeze the whole object.
|
|
109
98
|
// This can be replaced with a WeakMap once they are implemented in
|
|
110
99
|
// commonly used development environments.
|
|
111
|
-
this._store = {props: props, originalProps: assign({}, props)};
|
|
100
|
+
this._store = { props: props, originalProps: assign({}, props) };
|
|
112
101
|
|
|
113
102
|
// To make comparing ReactElements easier for testing purposes, we make
|
|
114
103
|
// the validation flag non-enumerable (where possible, which should
|
|
@@ -120,8 +109,7 @@ var ReactElement = function(type, key, ref, owner, context, props) {
|
|
|
120
109
|
enumerable: false,
|
|
121
110
|
writable: true
|
|
122
111
|
});
|
|
123
|
-
} catch (x) {
|
|
124
|
-
}
|
|
112
|
+
} catch (x) {}
|
|
125
113
|
this._store.validated = false;
|
|
126
114
|
|
|
127
115
|
// We're not allowed to set props directly on the object so we early
|
|
@@ -142,11 +130,11 @@ ReactElement.prototype = {
|
|
|
142
130
|
_isReactElement: true
|
|
143
131
|
};
|
|
144
132
|
|
|
145
|
-
if (
|
|
133
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
146
134
|
defineMutationMembrane(ReactElement.prototype);
|
|
147
135
|
}
|
|
148
136
|
|
|
149
|
-
ReactElement.createElement = function(type, config, children) {
|
|
137
|
+
ReactElement.createElement = function (type, config, children) {
|
|
150
138
|
var propName;
|
|
151
139
|
|
|
152
140
|
// Reserved names are extracted
|
|
@@ -160,8 +148,7 @@ ReactElement.createElement = function(type, config, children) {
|
|
|
160
148
|
key = config.key === undefined ? null : '' + config.key;
|
|
161
149
|
// Remaining properties are added to a new props object
|
|
162
150
|
for (propName in config) {
|
|
163
|
-
if (config.hasOwnProperty(propName) &&
|
|
164
|
-
!RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
151
|
+
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
165
152
|
props[propName] = config[propName];
|
|
166
153
|
}
|
|
167
154
|
}
|
|
@@ -190,20 +177,13 @@ ReactElement.createElement = function(type, config, children) {
|
|
|
190
177
|
}
|
|
191
178
|
}
|
|
192
179
|
|
|
193
|
-
return new ReactElement(
|
|
194
|
-
type,
|
|
195
|
-
key,
|
|
196
|
-
ref,
|
|
197
|
-
ReactCurrentOwner.current,
|
|
198
|
-
ReactContext.current,
|
|
199
|
-
props
|
|
200
|
-
);
|
|
180
|
+
return new ReactElement(type, key, ref, ReactCurrentOwner.current, ReactContext.current, props);
|
|
201
181
|
};
|
|
202
182
|
|
|
203
|
-
ReactElement.createFactory = function(type) {
|
|
183
|
+
ReactElement.createFactory = function (type) {
|
|
204
184
|
var factory = ReactElement.createElement.bind(null, type);
|
|
205
185
|
// Expose the type on the factory and the prototype so that it can be
|
|
206
|
-
// easily accessed on elements. E.g.
|
|
186
|
+
// easily accessed on elements. E.g. `<Foo />.type === Foo`.
|
|
207
187
|
// This should not be named `constructor` since this may not be the function
|
|
208
188
|
// that created the element, and it may not even be a constructor.
|
|
209
189
|
// Legacy hook TODO: Warn if this is accessed
|
|
@@ -211,24 +191,17 @@ ReactElement.createFactory = function(type) {
|
|
|
211
191
|
return factory;
|
|
212
192
|
};
|
|
213
193
|
|
|
214
|
-
ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
|
|
215
|
-
var newElement = new ReactElement(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
oldElement.ref,
|
|
219
|
-
oldElement._owner,
|
|
220
|
-
oldElement._context,
|
|
221
|
-
newProps
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
194
|
+
ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
|
|
195
|
+
var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps);
|
|
196
|
+
|
|
197
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
225
198
|
// If the key on the original is valid, then the clone is valid
|
|
226
199
|
newElement._store.validated = oldElement._store.validated;
|
|
227
200
|
}
|
|
228
201
|
return newElement;
|
|
229
202
|
};
|
|
230
203
|
|
|
231
|
-
ReactElement.cloneElement = function(element, config, children) {
|
|
204
|
+
ReactElement.cloneElement = function (element, config, children) {
|
|
232
205
|
var propName;
|
|
233
206
|
|
|
234
207
|
// Original props are copied
|
|
@@ -252,8 +225,7 @@ ReactElement.cloneElement = function(element, config, children) {
|
|
|
252
225
|
}
|
|
253
226
|
// Remaining properties override existing props
|
|
254
227
|
for (propName in config) {
|
|
255
|
-
if (config.hasOwnProperty(propName) &&
|
|
256
|
-
!RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
228
|
+
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
257
229
|
props[propName] = config[propName];
|
|
258
230
|
}
|
|
259
231
|
}
|
|
@@ -272,14 +244,7 @@ ReactElement.cloneElement = function(element, config, children) {
|
|
|
272
244
|
props.children = childArray;
|
|
273
245
|
}
|
|
274
246
|
|
|
275
|
-
return new ReactElement(
|
|
276
|
-
element.type,
|
|
277
|
-
key,
|
|
278
|
-
ref,
|
|
279
|
-
owner,
|
|
280
|
-
element._context,
|
|
281
|
-
props
|
|
282
|
-
);
|
|
247
|
+
return new ReactElement(element.type, key, ref, owner, element._context, props);
|
|
283
248
|
};
|
|
284
249
|
|
|
285
250
|
/**
|
|
@@ -287,7 +252,7 @@ ReactElement.cloneElement = function(element, config, children) {
|
|
|
287
252
|
* @return {boolean} True if `object` is a valid component.
|
|
288
253
|
* @final
|
|
289
254
|
*/
|
|
290
|
-
ReactElement.isValidElement = function(object) {
|
|
255
|
+
ReactElement.isValidElement = function (object) {
|
|
291
256
|
// ReactTestUtils is often used outside of beforeEach where as React is
|
|
292
257
|
// within it. This leads to two different instances of React on the same
|
|
293
258
|
// page. To identify a element from a different React instance we use
|
|
@@ -302,3 +267,5 @@ ReactElement.isValidElement = function(object) {
|
|
|
302
267
|
};
|
|
303
268
|
|
|
304
269
|
module.exports = ReactElement;
|
|
270
|
+
|
|
271
|
+
// IE will fail on defineProperty
|
|
@@ -76,9 +76,7 @@ function getName(instance) {
|
|
|
76
76
|
*/
|
|
77
77
|
function getCurrentOwnerDisplayName() {
|
|
78
78
|
var current = ReactCurrentOwner.current;
|
|
79
|
-
return (
|
|
80
|
-
current && getName(current) || undefined
|
|
81
|
-
);
|
|
79
|
+
return current && getName(current) || undefined;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
/**
|
|
@@ -97,11 +95,7 @@ function validateExplicitKey(element, parentType) {
|
|
|
97
95
|
}
|
|
98
96
|
element._store.validated = true;
|
|
99
97
|
|
|
100
|
-
warnAndMonitorForKeyUse(
|
|
101
|
-
'Each child in an array or iterator should have a unique "key" prop.',
|
|
102
|
-
element,
|
|
103
|
-
parentType
|
|
104
|
-
);
|
|
98
|
+
warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
/**
|
|
@@ -117,11 +111,7 @@ function validatePropertyKey(name, element, parentType) {
|
|
|
117
111
|
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
118
112
|
return;
|
|
119
113
|
}
|
|
120
|
-
warnAndMonitorForKeyUse(
|
|
121
|
-
'Child objects should have non-numeric keys so ordering is preserved.',
|
|
122
|
-
element,
|
|
123
|
-
parentType
|
|
124
|
-
);
|
|
114
|
+
warnAndMonitorForKeyUse('Child objects should have non-numeric keys so ordering is preserved.', element, parentType);
|
|
125
115
|
}
|
|
126
116
|
|
|
127
117
|
/**
|
|
@@ -134,42 +124,29 @@ function validatePropertyKey(name, element, parentType) {
|
|
|
134
124
|
*/
|
|
135
125
|
function warnAndMonitorForKeyUse(message, element, parentType) {
|
|
136
126
|
var ownerName = getCurrentOwnerDisplayName();
|
|
137
|
-
var parentName = typeof parentType === 'string' ?
|
|
138
|
-
parentType : parentType.displayName || parentType.name;
|
|
127
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
139
128
|
|
|
140
129
|
var useName = ownerName || parentName;
|
|
141
|
-
var memoizer = ownerHasKeyUseWarning[message] || (
|
|
142
|
-
(ownerHasKeyUseWarning[message] = {})
|
|
143
|
-
);
|
|
130
|
+
var memoizer = ownerHasKeyUseWarning[message] || (ownerHasKeyUseWarning[message] = {});
|
|
144
131
|
if (memoizer.hasOwnProperty(useName)) {
|
|
145
132
|
return;
|
|
146
133
|
}
|
|
147
134
|
memoizer[useName] = true;
|
|
148
135
|
|
|
149
|
-
var parentOrOwnerAddendum =
|
|
150
|
-
ownerName ? (" Check the render method of " + ownerName + ".") :
|
|
151
|
-
parentName ? (" Check the React.render call using <" + parentName + ">.") :
|
|
152
|
-
'';
|
|
136
|
+
var parentOrOwnerAddendum = ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : '';
|
|
153
137
|
|
|
154
138
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
155
139
|
// property, it may be the creator of the child that's responsible for
|
|
156
140
|
// assigning it a key.
|
|
157
141
|
var childOwnerAddendum = '';
|
|
158
|
-
if (element &&
|
|
159
|
-
element._owner &&
|
|
160
|
-
element._owner !== ReactCurrentOwner.current) {
|
|
142
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
161
143
|
// Name of the component that originally created this child.
|
|
162
144
|
var childOwnerName = getName(element._owner);
|
|
163
145
|
|
|
164
|
-
childOwnerAddendum =
|
|
146
|
+
childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
|
|
165
147
|
}
|
|
166
148
|
|
|
167
|
-
|
|
168
|
-
false,
|
|
169
|
-
message + '%s%s See http://fb.me/react-warning-keys for more information.',
|
|
170
|
-
parentOrOwnerAddendum,
|
|
171
|
-
childOwnerAddendum
|
|
172
|
-
) : null);
|
|
149
|
+
'production' !== process.env.NODE_ENV ? warning(false, message + '%s%s See https://fb.me/react-warning-keys for more information.', parentOrOwnerAddendum, childOwnerAddendum) : null;
|
|
173
150
|
}
|
|
174
151
|
|
|
175
152
|
/**
|
|
@@ -235,25 +212,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
|
|
|
235
212
|
try {
|
|
236
213
|
// This is intentionally an invariant that gets caught. It's the same
|
|
237
214
|
// behavior as without this statement except with a better message.
|
|
238
|
-
|
|
239
|
-
typeof propTypes[propName] === 'function',
|
|
240
|
-
'%s: %s type `%s` is invalid; it must be a function, usually from ' +
|
|
241
|
-
'React.PropTypes.',
|
|
242
|
-
componentName || 'React class',
|
|
243
|
-
ReactPropTypeLocationNames[location],
|
|
244
|
-
propName
|
|
245
|
-
) : invariant(typeof propTypes[propName] === 'function'));
|
|
215
|
+
'production' !== process.env.NODE_ENV ? invariant(typeof propTypes[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(typeof propTypes[propName] === 'function');
|
|
246
216
|
error = propTypes[propName](props, propName, componentName, location);
|
|
247
217
|
} catch (ex) {
|
|
248
218
|
error = ex;
|
|
249
219
|
}
|
|
220
|
+
'production' !== process.env.NODE_ENV ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : null;
|
|
250
221
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
251
222
|
// Only monitor this failure once because there tends to be a lot of the
|
|
252
223
|
// same error.
|
|
253
224
|
loggedTypeFailures[error.message] = true;
|
|
254
225
|
|
|
255
|
-
var addendum = getDeclarationErrorAddendum(
|
|
256
|
-
|
|
226
|
+
var addendum = getDeclarationErrorAddendum();
|
|
227
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null;
|
|
257
228
|
}
|
|
258
229
|
}
|
|
259
230
|
}
|
|
@@ -270,8 +241,7 @@ var warnedPropsMutations = {};
|
|
|
270
241
|
function warnForPropsMutation(propName, element) {
|
|
271
242
|
var type = element.type;
|
|
272
243
|
var elementName = typeof type === 'string' ? type : type.displayName;
|
|
273
|
-
var ownerName = element._owner ?
|
|
274
|
-
element._owner.getPublicInstance().constructor.displayName : null;
|
|
244
|
+
var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
|
|
275
245
|
|
|
276
246
|
var warningKey = propName + '|' + elementName + '|' + ownerName;
|
|
277
247
|
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
|
|
@@ -288,15 +258,7 @@ function warnForPropsMutation(propName, element) {
|
|
|
288
258
|
ownerInfo = ' The element was created by ' + ownerName + '.';
|
|
289
259
|
}
|
|
290
260
|
|
|
291
|
-
|
|
292
|
-
false,
|
|
293
|
-
'Don\'t set .props.%s of the React component%s. ' +
|
|
294
|
-
'Instead, specify the correct value when ' +
|
|
295
|
-
'initially creating the element.%s',
|
|
296
|
-
propName,
|
|
297
|
-
elementInfo,
|
|
298
|
-
ownerInfo
|
|
299
|
-
) : null);
|
|
261
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set .props.%s of the React component%s. Instead, specify the ' + 'correct value when initially creating the element or use ' + 'React.cloneElement to make a new element with updated props.%s', propName, elementInfo, ownerInfo) : null;
|
|
300
262
|
}
|
|
301
263
|
|
|
302
264
|
// Inline Object.is polyfill
|
|
@@ -332,8 +294,7 @@ function checkAndWarnForMutatedProps(element) {
|
|
|
332
294
|
|
|
333
295
|
for (var propName in props) {
|
|
334
296
|
if (props.hasOwnProperty(propName)) {
|
|
335
|
-
if (!originalProps.hasOwnProperty(propName) ||
|
|
336
|
-
!is(originalProps[propName], props[propName])) {
|
|
297
|
+
if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
|
|
337
298
|
warnForPropsMutation(propName, element);
|
|
338
299
|
|
|
339
300
|
// Copy over the new value so that the two props objects match again
|
|
@@ -350,7 +311,7 @@ function checkAndWarnForMutatedProps(element) {
|
|
|
350
311
|
* @param {ReactElement} element
|
|
351
312
|
*/
|
|
352
313
|
function validatePropTypes(element) {
|
|
353
|
-
if (element.type
|
|
314
|
+
if (!(typeof element.type === 'string' || typeof element.type === 'function')) {
|
|
354
315
|
// This has already warned. Don't throw.
|
|
355
316
|
return;
|
|
356
317
|
}
|
|
@@ -358,24 +319,13 @@ function validatePropTypes(element) {
|
|
|
358
319
|
// to a composite class which may have propTypes.
|
|
359
320
|
// TODO: Validating a string's propTypes is not decoupled from the
|
|
360
321
|
// rendering target which is problematic.
|
|
361
|
-
var componentClass = ReactNativeComponent.getComponentClassForElement(
|
|
362
|
-
element
|
|
363
|
-
);
|
|
322
|
+
var componentClass = ReactNativeComponent.getComponentClassForElement(element);
|
|
364
323
|
var name = componentClass.displayName || componentClass.name;
|
|
365
324
|
if (componentClass.propTypes) {
|
|
366
|
-
checkPropTypes(
|
|
367
|
-
name,
|
|
368
|
-
componentClass.propTypes,
|
|
369
|
-
element.props,
|
|
370
|
-
ReactPropTypeLocations.prop
|
|
371
|
-
);
|
|
325
|
+
checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
|
|
372
326
|
}
|
|
373
327
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
374
|
-
|
|
375
|
-
componentClass.getDefaultProps.isReactClassApproved,
|
|
376
|
-
'getDefaultProps is only used on classic React.createClass ' +
|
|
377
|
-
'definitions. Use a static property named `defaultProps` instead.'
|
|
378
|
-
) : null);
|
|
328
|
+
'production' !== process.env.NODE_ENV ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : null;
|
|
379
329
|
}
|
|
380
330
|
}
|
|
381
331
|
|
|
@@ -383,15 +333,10 @@ var ReactElementValidator = {
|
|
|
383
333
|
|
|
384
334
|
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
|
|
385
335
|
|
|
386
|
-
createElement: function(type, props, children) {
|
|
336
|
+
createElement: function (type, props, children) {
|
|
387
337
|
// We warn in this case but don't throw. We expect the element creation to
|
|
388
338
|
// succeed and there will likely be errors in render.
|
|
389
|
-
|
|
390
|
-
type != null,
|
|
391
|
-
'React.createElement: type should not be null or undefined. It should ' +
|
|
392
|
-
'be a string (for DOM elements) or a ReactClass (for composite ' +
|
|
393
|
-
'components).'
|
|
394
|
-
) : null);
|
|
339
|
+
'production' !== process.env.NODE_ENV ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : null;
|
|
395
340
|
|
|
396
341
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
397
342
|
|
|
@@ -410,44 +355,30 @@ var ReactElementValidator = {
|
|
|
410
355
|
return element;
|
|
411
356
|
},
|
|
412
357
|
|
|
413
|
-
createFactory: function(type) {
|
|
414
|
-
var validatedFactory = ReactElementValidator.createElement.bind(
|
|
415
|
-
null,
|
|
416
|
-
type
|
|
417
|
-
);
|
|
358
|
+
createFactory: function (type) {
|
|
359
|
+
var validatedFactory = ReactElementValidator.createElement.bind(null, type);
|
|
418
360
|
// Legacy hook TODO: Warn if this is accessed
|
|
419
361
|
validatedFactory.type = type;
|
|
420
362
|
|
|
421
|
-
if (
|
|
363
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
422
364
|
try {
|
|
423
|
-
Object.defineProperty(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
'Factory.type is deprecated. Access the class directly ' +
|
|
432
|
-
'before passing it to createFactory.'
|
|
433
|
-
) : null);
|
|
434
|
-
Object.defineProperty(this, 'type', {
|
|
435
|
-
value: type
|
|
436
|
-
});
|
|
437
|
-
return type;
|
|
438
|
-
}
|
|
365
|
+
Object.defineProperty(validatedFactory, 'type', {
|
|
366
|
+
enumerable: false,
|
|
367
|
+
get: function () {
|
|
368
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : null;
|
|
369
|
+
Object.defineProperty(this, 'type', {
|
|
370
|
+
value: type
|
|
371
|
+
});
|
|
372
|
+
return type;
|
|
439
373
|
}
|
|
440
|
-
);
|
|
441
|
-
} catch (x) {
|
|
442
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
443
|
-
}
|
|
374
|
+
});
|
|
375
|
+
} catch (x) {}
|
|
444
376
|
}
|
|
445
377
|
|
|
446
|
-
|
|
447
378
|
return validatedFactory;
|
|
448
379
|
},
|
|
449
380
|
|
|
450
|
-
cloneElement: function(element, props, children) {
|
|
381
|
+
cloneElement: function (element, props, children) {
|
|
451
382
|
var newElement = ReactElement.cloneElement.apply(this, arguments);
|
|
452
383
|
for (var i = 2; i < arguments.length; i++) {
|
|
453
384
|
validateChildKeys(arguments[i], newElement.type);
|
|
@@ -459,3 +390,5 @@ var ReactElementValidator = {
|
|
|
459
390
|
};
|
|
460
391
|
|
|
461
392
|
module.exports = ReactElementValidator;
|
|
393
|
+
|
|
394
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|