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,7 +23,7 @@ var joinClasses = require("./joinClasses");
|
|
|
23
23
|
* @return {function}
|
|
24
24
|
*/
|
|
25
25
|
function createTransferStrategy(mergeStrategy) {
|
|
26
|
-
return function(props, key, value) {
|
|
26
|
+
return function (props, key, value) {
|
|
27
27
|
if (!props.hasOwnProperty(key)) {
|
|
28
28
|
props[key] = value;
|
|
29
29
|
} else {
|
|
@@ -32,7 +32,7 @@ function createTransferStrategy(mergeStrategy) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var transferStrategyMerge = createTransferStrategy(function(a, b) {
|
|
35
|
+
var transferStrategyMerge = createTransferStrategy(function (a, b) {
|
|
36
36
|
// `merge` overrides the first object's (`props[key]` above) keys using the
|
|
37
37
|
// second object's (`value`) keys. An object's style's existing `propA` would
|
|
38
38
|
// get overridden. Flip the order here.
|
|
@@ -99,10 +99,10 @@ var ReactPropTransferer = {
|
|
|
99
99
|
* @param {object} newProps new props to merge in
|
|
100
100
|
* @return {object} a new object containing both sets of props merged.
|
|
101
101
|
*/
|
|
102
|
-
mergeProps: function(oldProps, newProps) {
|
|
102
|
+
mergeProps: function (oldProps, newProps) {
|
|
103
103
|
return transferInto(assign({}, oldProps), newProps);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
module.exports = ReactPropTransferer;
|
|
108
|
+
module.exports = ReactPropTransferer;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var ReactPropTypeLocationNames = {};
|
|
15
15
|
|
|
16
|
-
if (
|
|
16
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
17
17
|
ReactPropTypeLocationNames = {
|
|
18
18
|
prop: 'prop',
|
|
19
19
|
context: 'context',
|
|
@@ -21,4 +21,4 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
module.exports = ReactPropTypeLocationNames;
|
|
24
|
+
module.exports = ReactPropTypeLocationNames;
|
package/lib/ReactPropTypes.js
CHANGED
|
@@ -66,9 +66,6 @@ var emptyFunction = require("./emptyFunction");
|
|
|
66
66
|
|
|
67
67
|
var ANONYMOUS = '<<anonymous>>';
|
|
68
68
|
|
|
69
|
-
var elementTypeChecker = createElementTypeChecker();
|
|
70
|
-
var nodeTypeChecker = createNodeChecker();
|
|
71
|
-
|
|
72
69
|
var ReactPropTypes = {
|
|
73
70
|
array: createPrimitiveTypeChecker('array'),
|
|
74
71
|
bool: createPrimitiveTypeChecker('boolean'),
|
|
@@ -79,9 +76,9 @@ var ReactPropTypes = {
|
|
|
79
76
|
|
|
80
77
|
any: createAnyTypeChecker(),
|
|
81
78
|
arrayOf: createArrayOfTypeChecker,
|
|
82
|
-
element:
|
|
79
|
+
element: createElementTypeChecker(),
|
|
83
80
|
instanceOf: createInstanceTypeChecker,
|
|
84
|
-
node:
|
|
81
|
+
node: createNodeChecker(),
|
|
85
82
|
objectOf: createObjectOfTypeChecker,
|
|
86
83
|
oneOf: createEnumTypeChecker,
|
|
87
84
|
oneOfType: createUnionTypeChecker,
|
|
@@ -89,19 +86,17 @@ var ReactPropTypes = {
|
|
|
89
86
|
};
|
|
90
87
|
|
|
91
88
|
function createChainableTypeChecker(validate) {
|
|
92
|
-
function checkType(isRequired, props, propName, componentName, location) {
|
|
89
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName) {
|
|
93
90
|
componentName = componentName || ANONYMOUS;
|
|
91
|
+
propFullName = propFullName || propName;
|
|
94
92
|
if (props[propName] == null) {
|
|
95
93
|
var locationName = ReactPropTypeLocationNames[location];
|
|
96
94
|
if (isRequired) {
|
|
97
|
-
return new Error(
|
|
98
|
-
("Required " + locationName + " `" + propName + "` was not specified in ") +
|
|
99
|
-
("`" + componentName + "`.")
|
|
100
|
-
);
|
|
95
|
+
return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
|
|
101
96
|
}
|
|
102
97
|
return null;
|
|
103
98
|
} else {
|
|
104
|
-
return validate(props, propName, componentName, location);
|
|
99
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
|
|
@@ -112,7 +107,7 @@ function createChainableTypeChecker(validate) {
|
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
function createPrimitiveTypeChecker(expectedType) {
|
|
115
|
-
function validate(props, propName, componentName, location) {
|
|
110
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
116
111
|
var propValue = props[propName];
|
|
117
112
|
var propType = getPropType(propValue);
|
|
118
113
|
if (propType !== expectedType) {
|
|
@@ -122,10 +117,7 @@ function createPrimitiveTypeChecker(expectedType) {
|
|
|
122
117
|
// 'of type `object`'.
|
|
123
118
|
var preciseType = getPreciseType(propValue);
|
|
124
119
|
|
|
125
|
-
return new Error(
|
|
126
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + preciseType + "` ") +
|
|
127
|
-
("supplied to `" + componentName + "`, expected `" + expectedType + "`.")
|
|
128
|
-
);
|
|
120
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
129
121
|
}
|
|
130
122
|
return null;
|
|
131
123
|
}
|
|
@@ -137,18 +129,15 @@ function createAnyTypeChecker() {
|
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
function createArrayOfTypeChecker(typeChecker) {
|
|
140
|
-
function validate(props, propName, componentName, location) {
|
|
132
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
141
133
|
var propValue = props[propName];
|
|
142
134
|
if (!Array.isArray(propValue)) {
|
|
143
135
|
var locationName = ReactPropTypeLocationNames[location];
|
|
144
136
|
var propType = getPropType(propValue);
|
|
145
|
-
return new Error(
|
|
146
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
147
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an array.")
|
|
148
|
-
);
|
|
137
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
149
138
|
}
|
|
150
139
|
for (var i = 0; i < propValue.length; i++) {
|
|
151
|
-
var error = typeChecker(propValue, i, componentName, location);
|
|
140
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
|
|
152
141
|
if (error instanceof Error) {
|
|
153
142
|
return error;
|
|
154
143
|
}
|
|
@@ -159,13 +148,10 @@ function createArrayOfTypeChecker(typeChecker) {
|
|
|
159
148
|
}
|
|
160
149
|
|
|
161
150
|
function createElementTypeChecker() {
|
|
162
|
-
function validate(props, propName, componentName, location) {
|
|
151
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
163
152
|
if (!ReactElement.isValidElement(props[propName])) {
|
|
164
153
|
var locationName = ReactPropTypeLocationNames[location];
|
|
165
|
-
return new Error(
|
|
166
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
167
|
-
("`" + componentName + "`, expected a ReactElement.")
|
|
168
|
-
);
|
|
154
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
|
|
169
155
|
}
|
|
170
156
|
return null;
|
|
171
157
|
}
|
|
@@ -173,14 +159,11 @@ function createElementTypeChecker() {
|
|
|
173
159
|
}
|
|
174
160
|
|
|
175
161
|
function createInstanceTypeChecker(expectedClass) {
|
|
176
|
-
function validate(props, propName, componentName, location) {
|
|
162
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
177
163
|
if (!(props[propName] instanceof expectedClass)) {
|
|
178
164
|
var locationName = ReactPropTypeLocationNames[location];
|
|
179
165
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
180
|
-
return new Error(
|
|
181
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
182
|
-
("`" + componentName + "`, expected instance of `" + expectedClassName + "`.")
|
|
183
|
-
);
|
|
166
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
|
|
184
167
|
}
|
|
185
168
|
return null;
|
|
186
169
|
}
|
|
@@ -188,7 +171,13 @@ function createInstanceTypeChecker(expectedClass) {
|
|
|
188
171
|
}
|
|
189
172
|
|
|
190
173
|
function createEnumTypeChecker(expectedValues) {
|
|
191
|
-
|
|
174
|
+
if (!Array.isArray(expectedValues)) {
|
|
175
|
+
return createChainableTypeChecker(function () {
|
|
176
|
+
return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
192
181
|
var propValue = props[propName];
|
|
193
182
|
for (var i = 0; i < expectedValues.length; i++) {
|
|
194
183
|
if (propValue === expectedValues[i]) {
|
|
@@ -198,28 +187,22 @@ function createEnumTypeChecker(expectedValues) {
|
|
|
198
187
|
|
|
199
188
|
var locationName = ReactPropTypeLocationNames[location];
|
|
200
189
|
var valuesString = JSON.stringify(expectedValues);
|
|
201
|
-
return new Error(
|
|
202
|
-
("Invalid " + locationName + " `" + propName + "` of value `" + propValue + "` ") +
|
|
203
|
-
("supplied to `" + componentName + "`, expected one of " + valuesString + ".")
|
|
204
|
-
);
|
|
190
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
205
191
|
}
|
|
206
192
|
return createChainableTypeChecker(validate);
|
|
207
193
|
}
|
|
208
194
|
|
|
209
195
|
function createObjectOfTypeChecker(typeChecker) {
|
|
210
|
-
function validate(props, propName, componentName, location) {
|
|
196
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
211
197
|
var propValue = props[propName];
|
|
212
198
|
var propType = getPropType(propValue);
|
|
213
199
|
if (propType !== 'object') {
|
|
214
200
|
var locationName = ReactPropTypeLocationNames[location];
|
|
215
|
-
return new Error(
|
|
216
|
-
("Invalid " + locationName + " `" + propName + "` of type ") +
|
|
217
|
-
("`" + propType + "` supplied to `" + componentName + "`, expected an object.")
|
|
218
|
-
);
|
|
201
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
219
202
|
}
|
|
220
203
|
for (var key in propValue) {
|
|
221
204
|
if (propValue.hasOwnProperty(key)) {
|
|
222
|
-
var error = typeChecker(propValue, key, componentName, location);
|
|
205
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
223
206
|
if (error instanceof Error) {
|
|
224
207
|
return error;
|
|
225
208
|
}
|
|
@@ -231,31 +214,31 @@ function createObjectOfTypeChecker(typeChecker) {
|
|
|
231
214
|
}
|
|
232
215
|
|
|
233
216
|
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
234
|
-
|
|
217
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
218
|
+
return createChainableTypeChecker(function () {
|
|
219
|
+
return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
235
224
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
236
225
|
var checker = arrayOfTypeCheckers[i];
|
|
237
|
-
if (checker(props, propName, componentName, location) == null) {
|
|
226
|
+
if (checker(props, propName, componentName, location, propFullName) == null) {
|
|
238
227
|
return null;
|
|
239
228
|
}
|
|
240
229
|
}
|
|
241
230
|
|
|
242
231
|
var locationName = ReactPropTypeLocationNames[location];
|
|
243
|
-
return new Error(
|
|
244
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
245
|
-
("`" + componentName + "`.")
|
|
246
|
-
);
|
|
232
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
247
233
|
}
|
|
248
234
|
return createChainableTypeChecker(validate);
|
|
249
235
|
}
|
|
250
236
|
|
|
251
237
|
function createNodeChecker() {
|
|
252
|
-
function validate(props, propName, componentName, location) {
|
|
238
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
253
239
|
if (!isNode(props[propName])) {
|
|
254
240
|
var locationName = ReactPropTypeLocationNames[location];
|
|
255
|
-
return new Error(
|
|
256
|
-
("Invalid " + locationName + " `" + propName + "` supplied to ") +
|
|
257
|
-
("`" + componentName + "`, expected a ReactNode.")
|
|
258
|
-
);
|
|
241
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
259
242
|
}
|
|
260
243
|
return null;
|
|
261
244
|
}
|
|
@@ -263,22 +246,19 @@ function createNodeChecker() {
|
|
|
263
246
|
}
|
|
264
247
|
|
|
265
248
|
function createShapeTypeChecker(shapeTypes) {
|
|
266
|
-
function validate(props, propName, componentName, location) {
|
|
249
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
267
250
|
var propValue = props[propName];
|
|
268
251
|
var propType = getPropType(propValue);
|
|
269
252
|
if (propType !== 'object') {
|
|
270
253
|
var locationName = ReactPropTypeLocationNames[location];
|
|
271
|
-
return new Error(
|
|
272
|
-
("Invalid " + locationName + " `" + propName + "` of type `" + propType + "` ") +
|
|
273
|
-
("supplied to `" + componentName + "`, expected `object`.")
|
|
274
|
-
);
|
|
254
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
275
255
|
}
|
|
276
256
|
for (var key in shapeTypes) {
|
|
277
257
|
var checker = shapeTypes[key];
|
|
278
258
|
if (!checker) {
|
|
279
259
|
continue;
|
|
280
260
|
}
|
|
281
|
-
var error = checker(propValue, key, componentName, location);
|
|
261
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
282
262
|
if (error) {
|
|
283
263
|
return error;
|
|
284
264
|
}
|
|
@@ -344,4 +324,4 @@ function getPreciseType(propValue) {
|
|
|
344
324
|
return propType;
|
|
345
325
|
}
|
|
346
326
|
|
|
347
|
-
module.exports = ReactPropTypes;
|
|
327
|
+
module.exports = ReactPropTypes;
|
|
@@ -16,7 +16,6 @@ var CallbackQueue = require("./CallbackQueue");
|
|
|
16
16
|
var PooledClass = require("./PooledClass");
|
|
17
17
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
18
18
|
var ReactInputSelection = require("./ReactInputSelection");
|
|
19
|
-
var ReactPutListenerQueue = require("./ReactPutListenerQueue");
|
|
20
19
|
var Transaction = require("./Transaction");
|
|
21
20
|
|
|
22
21
|
var assign = require("./Object.assign");
|
|
@@ -46,7 +45,7 @@ var EVENT_SUPPRESSION = {
|
|
|
46
45
|
* @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
|
|
47
46
|
* the reconciliation.
|
|
48
47
|
*/
|
|
49
|
-
initialize: function() {
|
|
48
|
+
initialize: function () {
|
|
50
49
|
var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
|
|
51
50
|
ReactBrowserEventEmitter.setEnabled(false);
|
|
52
51
|
return currentlyEnabled;
|
|
@@ -57,7 +56,7 @@ var EVENT_SUPPRESSION = {
|
|
|
57
56
|
* `ReactBrowserEventEmitter` before the reconciliation occured. `close`
|
|
58
57
|
* restores the previous value.
|
|
59
58
|
*/
|
|
60
|
-
close: function(previouslyEnabled) {
|
|
59
|
+
close: function (previouslyEnabled) {
|
|
61
60
|
ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
|
|
62
61
|
}
|
|
63
62
|
};
|
|
@@ -70,39 +69,24 @@ var ON_DOM_READY_QUEUEING = {
|
|
|
70
69
|
/**
|
|
71
70
|
* Initializes the internal `onDOMReady` queue.
|
|
72
71
|
*/
|
|
73
|
-
initialize: function() {
|
|
72
|
+
initialize: function () {
|
|
74
73
|
this.reactMountReady.reset();
|
|
75
74
|
},
|
|
76
75
|
|
|
77
76
|
/**
|
|
78
77
|
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
|
|
79
78
|
*/
|
|
80
|
-
close: function() {
|
|
79
|
+
close: function () {
|
|
81
80
|
this.reactMountReady.notifyAll();
|
|
82
81
|
}
|
|
83
82
|
};
|
|
84
83
|
|
|
85
|
-
var PUT_LISTENER_QUEUEING = {
|
|
86
|
-
initialize: function() {
|
|
87
|
-
this.putListenerQueue.reset();
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
close: function() {
|
|
91
|
-
this.putListenerQueue.putListeners();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
84
|
/**
|
|
96
85
|
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
97
86
|
* being member methods, but with an implied ordering while being isolated from
|
|
98
87
|
* each other.
|
|
99
88
|
*/
|
|
100
|
-
var TRANSACTION_WRAPPERS = [
|
|
101
|
-
PUT_LISTENER_QUEUEING,
|
|
102
|
-
SELECTION_RESTORATION,
|
|
103
|
-
EVENT_SUPPRESSION,
|
|
104
|
-
ON_DOM_READY_QUEUEING
|
|
105
|
-
];
|
|
89
|
+
var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING];
|
|
106
90
|
|
|
107
91
|
/**
|
|
108
92
|
* Currently:
|
|
@@ -127,7 +111,6 @@ function ReactReconcileTransaction() {
|
|
|
127
111
|
// `ReactTextComponent` checks it in `mountComponent`.`
|
|
128
112
|
this.renderToStaticMarkup = false;
|
|
129
113
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
130
|
-
this.putListenerQueue = ReactPutListenerQueue.getPooled();
|
|
131
114
|
}
|
|
132
115
|
|
|
133
116
|
var Mixin = {
|
|
@@ -135,40 +118,32 @@ var Mixin = {
|
|
|
135
118
|
* @see Transaction
|
|
136
119
|
* @abstract
|
|
137
120
|
* @final
|
|
138
|
-
* @return {array<object>} List of operation wrap
|
|
121
|
+
* @return {array<object>} List of operation wrap procedures.
|
|
139
122
|
* TODO: convert to array<TransactionWrapper>
|
|
140
123
|
*/
|
|
141
|
-
getTransactionWrappers: function() {
|
|
124
|
+
getTransactionWrappers: function () {
|
|
142
125
|
return TRANSACTION_WRAPPERS;
|
|
143
126
|
},
|
|
144
127
|
|
|
145
128
|
/**
|
|
146
129
|
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
147
130
|
*/
|
|
148
|
-
getReactMountReady: function() {
|
|
131
|
+
getReactMountReady: function () {
|
|
149
132
|
return this.reactMountReady;
|
|
150
133
|
},
|
|
151
134
|
|
|
152
|
-
getPutListenerQueue: function() {
|
|
153
|
-
return this.putListenerQueue;
|
|
154
|
-
},
|
|
155
|
-
|
|
156
135
|
/**
|
|
157
136
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
158
|
-
* instance to be
|
|
137
|
+
* instance to be reused.
|
|
159
138
|
*/
|
|
160
|
-
destructor: function() {
|
|
139
|
+
destructor: function () {
|
|
161
140
|
CallbackQueue.release(this.reactMountReady);
|
|
162
141
|
this.reactMountReady = null;
|
|
163
|
-
|
|
164
|
-
ReactPutListenerQueue.release(this.putListenerQueue);
|
|
165
|
-
this.putListenerQueue = null;
|
|
166
142
|
}
|
|
167
143
|
};
|
|
168
144
|
|
|
169
|
-
|
|
170
145
|
assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
|
171
146
|
|
|
172
147
|
PooledClass.addPoolingTo(ReactReconcileTransaction);
|
|
173
148
|
|
|
174
|
-
module.exports = ReactReconcileTransaction;
|
|
149
|
+
module.exports = ReactReconcileTransaction;
|
package/lib/ReactReconciler.js
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactRef = require("./ReactRef");
|
|
15
|
-
var ReactElementValidator = require("./ReactElementValidator");
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Helper to call ReactRef.attachRefs with this composite component, split out
|
|
@@ -34,14 +33,11 @@ var ReactReconciler = {
|
|
|
34
33
|
* @final
|
|
35
34
|
* @internal
|
|
36
35
|
*/
|
|
37
|
-
mountComponent: function(internalInstance, rootID, transaction, context) {
|
|
36
|
+
mountComponent: function (internalInstance, rootID, transaction, context) {
|
|
38
37
|
var markup = internalInstance.mountComponent(rootID, transaction, context);
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
internalInstance._currentElement
|
|
42
|
-
);
|
|
38
|
+
if (internalInstance._currentElement.ref != null) {
|
|
39
|
+
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
43
40
|
}
|
|
44
|
-
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
45
41
|
return markup;
|
|
46
42
|
},
|
|
47
43
|
|
|
@@ -51,7 +47,7 @@ var ReactReconciler = {
|
|
|
51
47
|
* @final
|
|
52
48
|
* @internal
|
|
53
49
|
*/
|
|
54
|
-
unmountComponent: function(internalInstance) {
|
|
50
|
+
unmountComponent: function (internalInstance) {
|
|
55
51
|
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
|
|
56
52
|
internalInstance.unmountComponent();
|
|
57
53
|
},
|
|
@@ -65,12 +61,11 @@ var ReactReconciler = {
|
|
|
65
61
|
* @param {object} context
|
|
66
62
|
* @internal
|
|
67
63
|
*/
|
|
68
|
-
receiveComponent: function(
|
|
69
|
-
internalInstance, nextElement, transaction, context
|
|
70
|
-
) {
|
|
64
|
+
receiveComponent: function (internalInstance, nextElement, transaction, context) {
|
|
71
65
|
var prevElement = internalInstance._currentElement;
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
if (nextElement === prevElement && nextElement._owner != null
|
|
67
|
+
// TODO: Shouldn't we need to do this: `&& context === internalInstance._context`
|
|
68
|
+
) {
|
|
74
69
|
// Since elements are immutable after the owner is rendered,
|
|
75
70
|
// we can do a cheap identity compare here to determine if this is a
|
|
76
71
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
@@ -78,17 +73,13 @@ var ReactReconciler = {
|
|
|
78
73
|
// the element. We explicitly check for the existence of an owner since
|
|
79
74
|
// it's possible for an element created outside a composite to be
|
|
80
75
|
// deeply mutated and reused.
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
76
|
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
// TODO: Bailing out early is just a perf optimization right?
|
|
78
|
+
// TODO: Removing the return statement should affect correctness?
|
|
79
|
+
return;
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
var refsChanged = ReactRef.shouldUpdateRefs(
|
|
89
|
-
prevElement,
|
|
90
|
-
nextElement
|
|
91
|
-
);
|
|
82
|
+
var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
|
|
92
83
|
|
|
93
84
|
if (refsChanged) {
|
|
94
85
|
ReactRef.detachRefs(internalInstance, prevElement);
|
|
@@ -108,13 +99,10 @@ var ReactReconciler = {
|
|
|
108
99
|
* @param {ReactReconcileTransaction} transaction
|
|
109
100
|
* @internal
|
|
110
101
|
*/
|
|
111
|
-
performUpdateIfNecessary: function(
|
|
112
|
-
internalInstance,
|
|
113
|
-
transaction
|
|
114
|
-
) {
|
|
102
|
+
performUpdateIfNecessary: function (internalInstance, transaction) {
|
|
115
103
|
internalInstance.performUpdateIfNecessary(transaction);
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
};
|
|
119
107
|
|
|
120
|
-
module.exports = ReactReconciler;
|
|
108
|
+
module.exports = ReactReconciler;
|