react 0.14.0-alpha3 → 0.14.0-rc1
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 +8 -3
- package/dist/react-dom.js +42 -0
- package/dist/react-dom.min.js +12 -0
- package/dist/react-with-addons.js +6076 -5337
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +5445 -4839
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +22 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +18 -15
- package/lib/DOMChildrenOperations.js +17 -7
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +84 -33
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +21 -13
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +17 -20
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +33 -42
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +19 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +15 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +56 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +75 -35
- package/lib/ReactClass.js +70 -87
- package/lib/ReactComponent.js +27 -20
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +117 -106
- package/lib/ReactDOM.js +74 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +441 -72
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -66
- package/lib/ReactDOMInput.js +87 -99
- package/lib/ReactDOMOption.js +25 -44
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -72
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -11
- package/lib/ReactElement.js +92 -107
- package/lib/ReactElementValidator.js +53 -173
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +45 -9
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +64 -12
- package/lib/ReactFragment.js +29 -115
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +196 -122
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -12
- package/lib/ReactReconcileTransaction.js +12 -10
- package/lib/ReactReconciler.js +8 -11
- package/lib/ReactRef.js +15 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +8 -7
- package/lib/ReactTestUtils.js +89 -64
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +60 -35
- package/lib/ReactUpdates.js +15 -18
- package/lib/{isTextNode.js → ReactVersion.js} +2 -13
- package/lib/ReactWithAddons.js +24 -17
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +25 -16
- package/lib/SimpleEventPlugin.js +200 -45
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +24 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +17 -11
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +48 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +27 -25
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +21 -19
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +2 -0
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/dist/JSXTransformer.js +0 -17589
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- 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/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/ReactOwner.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var invariant = require(
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* ReactOwners are capable of storing references to owned components.
|
|
@@ -64,7 +64,7 @@ var ReactOwner = {
|
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
66
|
addComponentAsRefTo: function (component, ref, owner) {
|
|
67
|
-
!ReactOwner.isValidOwner(owner) ?
|
|
67
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
|
|
68
68
|
owner.attachRef(ref, component);
|
|
69
69
|
},
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ var ReactOwner = {
|
|
|
78
78
|
* @internal
|
|
79
79
|
*/
|
|
80
80
|
removeComponentAsRefFrom: function (component, ref, owner) {
|
|
81
|
-
!ReactOwner.isValidOwner(owner) ?
|
|
81
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
|
|
82
82
|
// Check that `component` is still the current ref because we do not want to
|
|
83
83
|
// detach the ref if another component stole it.
|
|
84
84
|
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
|
package/lib/ReactPerf.js
CHANGED
|
@@ -35,7 +35,7 @@ var ReactPerf = {
|
|
|
35
35
|
* @param {object<string>} methodNames
|
|
36
36
|
*/
|
|
37
37
|
measureMethods: function (object, objectName, methodNames) {
|
|
38
|
-
if (
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
39
|
for (var key in methodNames) {
|
|
40
40
|
if (!methodNames.hasOwnProperty(key)) {
|
|
41
41
|
continue;
|
|
@@ -54,7 +54,7 @@ var ReactPerf = {
|
|
|
54
54
|
* @return {function}
|
|
55
55
|
*/
|
|
56
56
|
measure: function (objName, fnName, func) {
|
|
57
|
-
if (
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
58
|
var measuredFunc = null;
|
|
59
59
|
var wrapper = function () {
|
|
60
60
|
if (ReactPerf.enableMeasure) {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var assign = require(
|
|
15
|
-
var emptyFunction = require(
|
|
16
|
-
var joinClasses = require(
|
|
14
|
+
var assign = require('./Object.assign');
|
|
15
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
16
|
+
var joinClasses = require('./joinClasses');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates a transfer strategy that will merge prop values using the supplied
|
package/lib/ReactPropTypes.js
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactElement = require(
|
|
15
|
-
var
|
|
16
|
-
var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
17
16
|
|
|
18
|
-
var emptyFunction = require(
|
|
17
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
18
|
+
var getIteratorFn = require('./getIteratorFn');
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Collection of methods that allow declaration and validation of props that are
|
|
@@ -137,7 +137,7 @@ function createArrayOfTypeChecker(typeChecker) {
|
|
|
137
137
|
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
138
138
|
}
|
|
139
139
|
for (var i = 0; i < propValue.length; i++) {
|
|
140
|
-
var error = typeChecker(propValue, i, componentName, location,
|
|
140
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
|
|
141
141
|
if (error instanceof Error) {
|
|
142
142
|
return error;
|
|
143
143
|
}
|
|
@@ -163,7 +163,8 @@ function createInstanceTypeChecker(expectedClass) {
|
|
|
163
163
|
if (!(props[propName] instanceof expectedClass)) {
|
|
164
164
|
var locationName = ReactPropTypeLocationNames[location];
|
|
165
165
|
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
166
|
-
|
|
166
|
+
var actualClassName = getClassName(props[propName]);
|
|
167
|
+
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
167
168
|
}
|
|
168
169
|
return null;
|
|
169
170
|
}
|
|
@@ -202,7 +203,7 @@ function createObjectOfTypeChecker(typeChecker) {
|
|
|
202
203
|
}
|
|
203
204
|
for (var key in propValue) {
|
|
204
205
|
if (propValue.hasOwnProperty(key)) {
|
|
205
|
-
var error = typeChecker(propValue, key, componentName, location,
|
|
206
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
206
207
|
if (error instanceof Error) {
|
|
207
208
|
return error;
|
|
208
209
|
}
|
|
@@ -258,7 +259,7 @@ function createShapeTypeChecker(shapeTypes) {
|
|
|
258
259
|
if (!checker) {
|
|
259
260
|
continue;
|
|
260
261
|
}
|
|
261
|
-
var error = checker(propValue, key, componentName, location,
|
|
262
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
262
263
|
if (error) {
|
|
263
264
|
return error;
|
|
264
265
|
}
|
|
@@ -283,12 +284,32 @@ function isNode(propValue) {
|
|
|
283
284
|
if (propValue === null || ReactElement.isValidElement(propValue)) {
|
|
284
285
|
return true;
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
|
|
288
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
289
|
+
if (iteratorFn) {
|
|
290
|
+
var iterator = iteratorFn.call(propValue);
|
|
291
|
+
var step;
|
|
292
|
+
if (iteratorFn !== propValue.entries) {
|
|
293
|
+
while (!(step = iterator.next()).done) {
|
|
294
|
+
if (!isNode(step.value)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
300
|
+
while (!(step = iterator.next()).done) {
|
|
301
|
+
var entry = step.value;
|
|
302
|
+
if (entry) {
|
|
303
|
+
if (!isNode(entry[1])) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
290
308
|
}
|
|
309
|
+
} else {
|
|
310
|
+
return false;
|
|
291
311
|
}
|
|
312
|
+
|
|
292
313
|
return true;
|
|
293
314
|
default:
|
|
294
315
|
return false;
|
|
@@ -324,4 +345,12 @@ function getPreciseType(propValue) {
|
|
|
324
345
|
return propType;
|
|
325
346
|
}
|
|
326
347
|
|
|
348
|
+
// Returns class name of the object, if any.
|
|
349
|
+
function getClassName(propValue) {
|
|
350
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
351
|
+
return '<<anonymous>>';
|
|
352
|
+
}
|
|
353
|
+
return propValue.constructor.name;
|
|
354
|
+
}
|
|
355
|
+
|
|
327
356
|
module.exports = ReactPropTypes;
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var CallbackQueue = require(
|
|
16
|
-
var PooledClass = require(
|
|
17
|
-
var ReactBrowserEventEmitter = require(
|
|
18
|
-
var
|
|
19
|
-
var
|
|
15
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
16
|
+
var PooledClass = require('./PooledClass');
|
|
17
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
18
|
+
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
|
|
19
|
+
var ReactInputSelection = require('./ReactInputSelection');
|
|
20
|
+
var Transaction = require('./Transaction');
|
|
20
21
|
|
|
21
|
-
var assign = require(
|
|
22
|
+
var assign = require('./Object.assign');
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Ensures that, when possible, the selection range (currently selected text
|
|
@@ -53,7 +54,7 @@ var EVENT_SUPPRESSION = {
|
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* @param {boolean} previouslyEnabled Enabled status of
|
|
56
|
-
* `ReactBrowserEventEmitter` before the reconciliation
|
|
57
|
+
* `ReactBrowserEventEmitter` before the reconciliation occurred. `close`
|
|
57
58
|
* restores the previous value.
|
|
58
59
|
*/
|
|
59
60
|
close: function (previouslyEnabled) {
|
|
@@ -102,7 +103,7 @@ var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_REA
|
|
|
102
103
|
*
|
|
103
104
|
* @class ReactReconcileTransaction
|
|
104
105
|
*/
|
|
105
|
-
function ReactReconcileTransaction() {
|
|
106
|
+
function ReactReconcileTransaction(forceHTML) {
|
|
106
107
|
this.reinitializeTransaction();
|
|
107
108
|
// Only server-side rendering really needs this option (see
|
|
108
109
|
// `ReactServerRendering`), but server-side uses
|
|
@@ -111,6 +112,7 @@ function ReactReconcileTransaction() {
|
|
|
111
112
|
// `ReactTextComponent` checks it in `mountComponent`.`
|
|
112
113
|
this.renderToStaticMarkup = false;
|
|
113
114
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
115
|
+
this.useCreateElement = !forceHTML && ReactDOMFeatureFlags.useCreateElement;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
var Mixin = {
|
|
@@ -118,7 +120,7 @@ var Mixin = {
|
|
|
118
120
|
* @see Transaction
|
|
119
121
|
* @abstract
|
|
120
122
|
* @final
|
|
121
|
-
* @return {array<object>} List of operation wrap
|
|
123
|
+
* @return {array<object>} List of operation wrap procedures.
|
|
122
124
|
* TODO: convert to array<TransactionWrapper>
|
|
123
125
|
*/
|
|
124
126
|
getTransactionWrappers: function () {
|
|
@@ -134,7 +136,7 @@ var Mixin = {
|
|
|
134
136
|
|
|
135
137
|
/**
|
|
136
138
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
137
|
-
* instance to be
|
|
139
|
+
* instance to be reused.
|
|
138
140
|
*/
|
|
139
141
|
destructor: function () {
|
|
140
142
|
CallbackQueue.release(this.reactMountReady);
|
package/lib/ReactReconciler.js
CHANGED
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactRef = require(
|
|
15
|
-
var ReactElementValidator = require("./ReactElementValidator");
|
|
14
|
+
var ReactRef = require('./ReactRef');
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Helper to call ReactRef.attachRefs with this composite component, split out
|
|
@@ -36,10 +35,9 @@ var ReactReconciler = {
|
|
|
36
35
|
*/
|
|
37
36
|
mountComponent: function (internalInstance, rootID, transaction, context) {
|
|
38
37
|
var markup = internalInstance.mountComponent(rootID, transaction, context);
|
|
39
|
-
if (
|
|
40
|
-
|
|
38
|
+
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
39
|
+
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
41
40
|
}
|
|
42
|
-
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
43
41
|
return markup;
|
|
44
42
|
},
|
|
45
43
|
|
|
@@ -66,7 +64,7 @@ var ReactReconciler = {
|
|
|
66
64
|
receiveComponent: function (internalInstance, nextElement, transaction, context) {
|
|
67
65
|
var prevElement = internalInstance._currentElement;
|
|
68
66
|
|
|
69
|
-
if (nextElement === prevElement &&
|
|
67
|
+
if (nextElement === prevElement && context === internalInstance._context) {
|
|
70
68
|
// Since elements are immutable after the owner is rendered,
|
|
71
69
|
// we can do a cheap identity compare here to determine if this is a
|
|
72
70
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
@@ -74,11 +72,10 @@ var ReactReconciler = {
|
|
|
74
72
|
// the element. We explicitly check for the existence of an owner since
|
|
75
73
|
// it's possible for an element created outside a composite to be
|
|
76
74
|
// deeply mutated and reused.
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
// TODO: Bailing out early is just a perf optimization right?
|
|
77
|
+
// TODO: Removing the return statement should affect correctness?
|
|
78
|
+
return;
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
|
|
@@ -89,7 +86,7 @@ var ReactReconciler = {
|
|
|
89
86
|
|
|
90
87
|
internalInstance.receiveComponent(nextElement, transaction, context);
|
|
91
88
|
|
|
92
|
-
if (refsChanged) {
|
|
89
|
+
if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
93
90
|
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
94
91
|
}
|
|
95
92
|
},
|
package/lib/ReactRef.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactOwner = require(
|
|
14
|
+
var ReactOwner = require('./ReactOwner');
|
|
15
15
|
|
|
16
16
|
var ReactRef = {};
|
|
17
17
|
|
|
@@ -34,6 +34,9 @@ function detachRef(ref, component, owner) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
ReactRef.attachRefs = function (instance, element) {
|
|
37
|
+
if (element === null || element === false) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
var ref = element.ref;
|
|
38
41
|
if (ref != null) {
|
|
39
42
|
attachRef(ref, instance, element._owner);
|
|
@@ -53,10 +56,20 @@ ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
|
|
|
53
56
|
// is made. It probably belongs where the key checking and
|
|
54
57
|
// instantiateReactComponent is done.
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
var prevEmpty = prevElement === null || prevElement === false;
|
|
60
|
+
var nextEmpty = nextElement === null || nextElement === false;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
// This has a few false positives w/r/t empty components.
|
|
64
|
+
// This has a few false positives w/r/t empty components.
|
|
65
|
+
prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref
|
|
66
|
+
);
|
|
57
67
|
};
|
|
58
68
|
|
|
59
69
|
ReactRef.detachRefs = function (instance, element) {
|
|
70
|
+
if (element === null || element === false) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
60
73
|
var ref = element.ref;
|
|
61
74
|
if (ref != null) {
|
|
62
75
|
detachRef(ref, instance, element._owner);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactServerBatchingStrategy
|
|
10
|
+
* @typechecks
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactServerBatchingStrategy = {
|
|
16
|
+
isBatchingUpdates: false,
|
|
17
|
+
batchedUpdates: function (callback) {
|
|
18
|
+
// Don't do anything here. During the server rendering we don't want to
|
|
19
|
+
// schedule any updates. We will simply ignore them.
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = ReactServerBatchingStrategy;
|
|
@@ -11,24 +11,29 @@
|
|
|
11
11
|
*/
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
14
|
+
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
17
|
+
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
18
|
+
var ReactServerBatchingStrategy = require('./ReactServerBatchingStrategy');
|
|
19
|
+
var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
|
|
20
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
18
21
|
|
|
19
|
-
var emptyObject = require(
|
|
20
|
-
var instantiateReactComponent = require(
|
|
21
|
-
var invariant = require(
|
|
22
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
23
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
24
|
+
var invariant = require('fbjs/lib/invariant');
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* @param {ReactElement} element
|
|
25
28
|
* @return {string} the HTML markup
|
|
26
29
|
*/
|
|
27
30
|
function renderToString(element) {
|
|
28
|
-
!ReactElement.isValidElement(element) ?
|
|
31
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
29
32
|
|
|
30
33
|
var transaction;
|
|
31
34
|
try {
|
|
35
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
36
|
+
|
|
32
37
|
var id = ReactInstanceHandles.createReactRootID();
|
|
33
38
|
transaction = ReactServerRenderingTransaction.getPooled(false);
|
|
34
39
|
|
|
@@ -39,6 +44,9 @@ function renderToString(element) {
|
|
|
39
44
|
}, null);
|
|
40
45
|
} finally {
|
|
41
46
|
ReactServerRenderingTransaction.release(transaction);
|
|
47
|
+
// Revert to the DOM batching strategy since these two renderers
|
|
48
|
+
// currently share these stateful modules.
|
|
49
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -48,10 +56,12 @@ function renderToString(element) {
|
|
|
48
56
|
* (for generating static pages)
|
|
49
57
|
*/
|
|
50
58
|
function renderToStaticMarkup(element) {
|
|
51
|
-
!ReactElement.isValidElement(element) ?
|
|
59
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
52
60
|
|
|
53
61
|
var transaction;
|
|
54
62
|
try {
|
|
63
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
64
|
+
|
|
55
65
|
var id = ReactInstanceHandles.createReactRootID();
|
|
56
66
|
transaction = ReactServerRenderingTransaction.getPooled(true);
|
|
57
67
|
|
|
@@ -61,6 +71,9 @@ function renderToStaticMarkup(element) {
|
|
|
61
71
|
}, null);
|
|
62
72
|
} finally {
|
|
63
73
|
ReactServerRenderingTransaction.release(transaction);
|
|
74
|
+
// Revert to the DOM batching strategy since these two renderers
|
|
75
|
+
// currently share these stateful modules.
|
|
76
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var PooledClass = require(
|
|
16
|
-
var CallbackQueue = require(
|
|
17
|
-
var Transaction = require(
|
|
15
|
+
var PooledClass = require('./PooledClass');
|
|
16
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
17
|
+
var Transaction = require('./Transaction');
|
|
18
18
|
|
|
19
|
-
var assign = require(
|
|
20
|
-
var emptyFunction = require(
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
|
|
@@ -49,6 +49,7 @@ function ReactServerRenderingTransaction(renderToStaticMarkup) {
|
|
|
49
49
|
this.reinitializeTransaction();
|
|
50
50
|
this.renderToStaticMarkup = renderToStaticMarkup;
|
|
51
51
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
52
|
+
this.useCreateElement = false;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
var Mixin = {
|
|
@@ -56,7 +57,7 @@ var Mixin = {
|
|
|
56
57
|
* @see Transaction
|
|
57
58
|
* @abstract
|
|
58
59
|
* @final
|
|
59
|
-
* @return {array} Empty list of operation wrap
|
|
60
|
+
* @return {array} Empty list of operation wrap procedures.
|
|
60
61
|
*/
|
|
61
62
|
getTransactionWrappers: function () {
|
|
62
63
|
return TRANSACTION_WRAPPERS;
|
|
@@ -71,7 +72,7 @@ var Mixin = {
|
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
74
|
-
* instance to be
|
|
75
|
+
* instance to be reused.
|
|
75
76
|
*/
|
|
76
77
|
destructor: function () {
|
|
77
78
|
CallbackQueue.release(this.reactMountReady);
|