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.
Files changed (200) hide show
  1. package/README.md +5 -2
  2. package/addons.js +8 -3
  3. package/dist/react-dom.js +42 -0
  4. package/dist/react-dom.min.js +12 -0
  5. package/dist/react-with-addons.js +6076 -5337
  6. package/dist/react-with-addons.min.js +6 -6
  7. package/dist/react.js +5445 -4839
  8. package/dist/react.min.js +6 -5
  9. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  10. package/lib/BeforeInputEventPlugin.js +13 -13
  11. package/lib/CSSProperty.js +18 -3
  12. package/lib/CSSPropertyOperations.js +22 -14
  13. package/lib/CallbackQueue.js +4 -4
  14. package/lib/ChangeEventPlugin.js +18 -15
  15. package/lib/DOMChildrenOperations.js +17 -7
  16. package/lib/DOMProperty.js +82 -117
  17. package/lib/DOMPropertyOperations.js +84 -33
  18. package/lib/Danger.js +21 -16
  19. package/lib/DefaultEventPluginOrder.js +2 -2
  20. package/lib/EnterLeaveEventPlugin.js +21 -13
  21. package/lib/EventConstants.js +23 -1
  22. package/lib/EventPluginHub.js +17 -20
  23. package/lib/EventPluginRegistry.js +8 -8
  24. package/lib/EventPluginUtils.js +33 -42
  25. package/lib/EventPropagators.js +8 -8
  26. package/lib/FallbackCompositionState.js +9 -3
  27. package/lib/HTMLDOMPropertyConfig.js +19 -3
  28. package/lib/LinkedStateMixin.js +2 -2
  29. package/lib/LinkedValueUtils.js +50 -38
  30. package/lib/MetaMatchers.js +118 -0
  31. package/lib/OrderedMap.js +453 -0
  32. package/lib/PooledClass.js +15 -5
  33. package/lib/React.js +18 -7
  34. package/lib/ReactBrowserComponentMixin.js +4 -4
  35. package/lib/ReactBrowserEventEmitter.js +30 -7
  36. package/lib/ReactCSSTransitionGroup.js +35 -9
  37. package/lib/ReactCSSTransitionGroupChild.js +56 -30
  38. package/lib/ReactChildReconciler.js +24 -19
  39. package/lib/ReactChildren.js +75 -35
  40. package/lib/ReactClass.js +70 -87
  41. package/lib/ReactComponent.js +27 -20
  42. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  43. package/lib/ReactComponentEnvironment.js +2 -2
  44. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  45. package/lib/ReactCompositeComponent.js +117 -106
  46. package/lib/ReactDOM.js +74 -158
  47. package/lib/ReactDOMButton.js +15 -26
  48. package/lib/ReactDOMComponent.js +441 -72
  49. package/lib/ReactDOMFactories.js +177 -0
  50. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  51. package/lib/ReactDOMIDOperations.js +8 -66
  52. package/lib/ReactDOMInput.js +87 -99
  53. package/lib/ReactDOMOption.js +25 -44
  54. package/lib/ReactDOMSelect.js +88 -98
  55. package/lib/ReactDOMSelection.js +3 -3
  56. package/lib/ReactDOMServer.js +5 -3
  57. package/lib/ReactDOMTextComponent.js +33 -20
  58. package/lib/ReactDOMTextarea.js +48 -61
  59. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  60. package/lib/ReactDefaultInjection.js +23 -72
  61. package/lib/ReactDefaultPerf.js +7 -7
  62. package/lib/ReactDefaultPerfAnalysis.js +6 -11
  63. package/lib/ReactElement.js +92 -107
  64. package/lib/ReactElementValidator.js +53 -173
  65. package/lib/ReactEmptyComponent.js +26 -62
  66. package/lib/ReactEmptyComponentRegistry.js +48 -0
  67. package/lib/ReactErrorUtils.js +45 -9
  68. package/lib/ReactEventEmitterMixin.js +3 -4
  69. package/lib/ReactEventListener.js +64 -12
  70. package/lib/ReactFragment.js +29 -115
  71. package/lib/ReactInjection.js +10 -12
  72. package/lib/ReactInputSelection.js +8 -7
  73. package/lib/ReactInstanceHandles.js +12 -12
  74. package/lib/ReactIsomorphic.js +15 -11
  75. package/lib/ReactLink.js +1 -1
  76. package/lib/ReactMarkupChecksum.js +6 -2
  77. package/lib/ReactMount.js +196 -122
  78. package/lib/ReactMultiChild.js +119 -25
  79. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  80. package/lib/ReactNativeComponent.js +3 -8
  81. package/lib/ReactNoopUpdateQueue.js +118 -0
  82. package/lib/ReactOwner.js +3 -3
  83. package/lib/ReactPerf.js +2 -2
  84. package/lib/ReactPropTransferer.js +3 -3
  85. package/lib/ReactPropTypeLocationNames.js +1 -1
  86. package/lib/ReactPropTypeLocations.js +1 -1
  87. package/lib/ReactPropTypes.js +41 -12
  88. package/lib/ReactReconcileTransaction.js +12 -10
  89. package/lib/ReactReconciler.js +8 -11
  90. package/lib/ReactRef.js +15 -2
  91. package/lib/ReactServerBatchingStrategy.js +23 -0
  92. package/lib/ReactServerRendering.js +22 -9
  93. package/lib/ReactServerRenderingTransaction.js +8 -7
  94. package/lib/ReactTestUtils.js +89 -64
  95. package/lib/ReactTransitionChildMapping.js +3 -6
  96. package/lib/ReactTransitionEvents.js +1 -1
  97. package/lib/ReactTransitionGroup.js +5 -6
  98. package/lib/ReactUpdateQueue.js +60 -35
  99. package/lib/ReactUpdates.js +15 -18
  100. package/lib/{isTextNode.js → ReactVersion.js} +2 -13
  101. package/lib/ReactWithAddons.js +24 -17
  102. package/lib/ResponderEventPlugin.js +514 -0
  103. package/lib/ResponderSyntheticEvent.js +40 -0
  104. package/lib/ResponderTouchHistoryStore.js +180 -0
  105. package/lib/SVGDOMPropertyConfig.js +1 -1
  106. package/lib/SelectEventPlugin.js +25 -16
  107. package/lib/SimpleEventPlugin.js +200 -45
  108. package/lib/SyntheticClipboardEvent.js +3 -3
  109. package/lib/SyntheticCompositionEvent.js +3 -3
  110. package/lib/SyntheticDragEvent.js +3 -3
  111. package/lib/SyntheticEvent.js +24 -8
  112. package/lib/SyntheticFocusEvent.js +3 -3
  113. package/lib/SyntheticInputEvent.js +3 -3
  114. package/lib/SyntheticKeyboardEvent.js +6 -6
  115. package/lib/SyntheticMouseEvent.js +5 -5
  116. package/lib/SyntheticTouchEvent.js +4 -4
  117. package/lib/SyntheticUIEvent.js +4 -4
  118. package/lib/SyntheticWheelEvent.js +3 -3
  119. package/lib/TapEventPlugin.js +119 -0
  120. package/lib/Transaction.js +17 -11
  121. package/lib/accumulate.js +44 -0
  122. package/lib/accumulateInto.js +2 -2
  123. package/lib/adler32.js +19 -7
  124. package/lib/cloneWithProps.js +12 -7
  125. package/lib/createHierarchyRenderer.js +85 -0
  126. package/lib/dangerousStyleValue.js +1 -1
  127. package/lib/deprecated.js +48 -0
  128. package/lib/findDOMNode.js +11 -12
  129. package/lib/flattenChildren.js +4 -4
  130. package/lib/forEachAccumulated.js +1 -1
  131. package/lib/getEventCharCode.js +1 -1
  132. package/lib/getEventKey.js +1 -1
  133. package/lib/getEventModifierState.js +0 -1
  134. package/lib/getTestDocument.js +28 -0
  135. package/lib/getTextContentAccessor.js +1 -1
  136. package/lib/instantiateReactComponent.js +27 -25
  137. package/lib/isEventSupported.js +1 -1
  138. package/lib/isTextInputElement.js +2 -1
  139. package/lib/joinClasses.js +1 -1
  140. package/lib/onlyChild.js +3 -3
  141. package/lib/quoteAttributeValueForBrowser.js +1 -1
  142. package/lib/reactComponentExpect.js +216 -0
  143. package/lib/renderSubtreeIntoContainer.js +1 -1
  144. package/lib/setInnerHTML.js +2 -2
  145. package/lib/setTextContent.js +3 -3
  146. package/lib/shallowCompare.js +1 -1
  147. package/lib/shouldUpdateReactComponent.js +12 -8
  148. package/lib/sliceChildren.js +34 -0
  149. package/lib/traverseAllChildren.js +21 -19
  150. package/lib/update.js +13 -13
  151. package/lib/validateDOMNesting.js +6 -6
  152. package/lib/webcomponents.js +6379 -0
  153. package/package.json +4 -6
  154. package/react.js +2 -0
  155. package/addons/CSSTransitionGroup.js +0 -1
  156. package/addons/LinkedStateMixin.js +0 -1
  157. package/addons/Perf.js +0 -1
  158. package/addons/PureRenderMixin.js +0 -1
  159. package/addons/TestUtils.js +0 -1
  160. package/addons/TransitionGroup.js +0 -1
  161. package/addons/batchedUpdates.js +0 -1
  162. package/addons/cloneWithProps.js +0 -1
  163. package/addons/createFragment.js +0 -1
  164. package/addons/renderSubtreeIntoContainer.js +0 -1
  165. package/addons/shallowCompare.js +0 -1
  166. package/addons/update.js +0 -1
  167. package/dist/JSXTransformer.js +0 -17589
  168. package/lib/CSSCore.js +0 -97
  169. package/lib/EventListener.js +0 -84
  170. package/lib/ExecutionEnvironment.js +0 -38
  171. package/lib/LocalEventTrapMixin.js +0 -46
  172. package/lib/ReactContext.js +0 -32
  173. package/lib/ReactDOMClient.js +0 -85
  174. package/lib/ReactDOMForm.js +0 -47
  175. package/lib/ReactDOMIframe.js +0 -43
  176. package/lib/ReactDOMImg.js +0 -44
  177. package/lib/ReactLifeCycle.js +0 -35
  178. package/lib/camelize.js +0 -32
  179. package/lib/camelizeStyleName.js +0 -40
  180. package/lib/containsNode.js +0 -55
  181. package/lib/createArrayFromMixed.js +0 -85
  182. package/lib/createFullPageComponent.js +0 -51
  183. package/lib/createNodesFromMarkup.js +0 -84
  184. package/lib/emptyFunction.js +0 -38
  185. package/lib/focusNode.js +0 -26
  186. package/lib/getActiveElement.js +0 -29
  187. package/lib/getMarkupWrap.js +0 -115
  188. package/lib/getUnboundedScrollPosition.js +0 -38
  189. package/lib/hyphenate.js +0 -33
  190. package/lib/hyphenateStyleName.js +0 -39
  191. package/lib/invariant.js +0 -49
  192. package/lib/isNode.js +0 -23
  193. package/lib/keyMirror.js +0 -48
  194. package/lib/keyOf.js +0 -35
  195. package/lib/mapObject.js +0 -51
  196. package/lib/performance.js +0 -23
  197. package/lib/performanceNow.js +0 -28
  198. package/lib/shallowEqual.js +0 -48
  199. package/lib/toArray.js +0 -57
  200. 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("./invariant");
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) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to add a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
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) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to remove a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
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 ('production' !== process.env.NODE_ENV) {
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 ('production' !== process.env.NODE_ENV) {
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("./Object.assign");
15
- var emptyFunction = require("./emptyFunction");
16
- var joinClasses = require("./joinClasses");
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
@@ -13,7 +13,7 @@
13
13
 
14
14
  var ReactPropTypeLocationNames = {};
15
15
 
16
- if ('production' !== process.env.NODE_ENV) {
16
+ if (process.env.NODE_ENV !== 'production') {
17
17
  ReactPropTypeLocationNames = {
18
18
  prop: 'prop',
19
19
  context: 'context',
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var keyMirror = require("./keyMirror");
14
+ var keyMirror = require('fbjs/lib/keyMirror');
15
15
 
16
16
  var ReactPropTypeLocations = keyMirror({
17
17
  prop: null,
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactElement = require("./ReactElement");
15
- var ReactFragment = require("./ReactFragment");
16
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
14
+ var ReactElement = require('./ReactElement');
15
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
17
16
 
18
- var emptyFunction = require("./emptyFunction");
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, '' + propFullName + '[' + i + ']');
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
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected instance of `' + expectedClassName + '`.'));
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, '' + propFullName + '.' + key);
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, '' + propFullName + '.' + key);
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
- propValue = ReactFragment.extractIfFragment(propValue);
287
- for (var k in propValue) {
288
- if (!isNode(propValue[k])) {
289
- return false;
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("./CallbackQueue");
16
- var PooledClass = require("./PooledClass");
17
- var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
18
- var ReactInputSelection = require("./ReactInputSelection");
19
- var Transaction = require("./Transaction");
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("./Object.assign");
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 occured. `close`
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 proceedures.
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 resused.
139
+ * instance to be reused.
138
140
  */
139
141
  destructor: function () {
140
142
  CallbackQueue.release(this.reactMountReady);
@@ -11,8 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactRef = require("./ReactRef");
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 ('production' !== process.env.NODE_ENV) {
40
- ReactElementValidator.checkAndWarnForMutatedProps(internalInstance._currentElement);
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 && nextElement._owner != null) {
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
- if ('production' !== process.env.NODE_ENV) {
81
- ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
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("./ReactOwner");
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
- return nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref;
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 ReactElement = require("./ReactElement");
15
- var ReactInstanceHandles = require("./ReactInstanceHandles");
16
- var ReactMarkupChecksum = require("./ReactMarkupChecksum");
17
- var ReactServerRenderingTransaction = require("./ReactServerRenderingTransaction");
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("./emptyObject");
20
- var instantiateReactComponent = require("./instantiateReactComponent");
21
- var invariant = require("./invariant");
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) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
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) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
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("./PooledClass");
16
- var CallbackQueue = require("./CallbackQueue");
17
- var Transaction = require("./Transaction");
15
+ var PooledClass = require('./PooledClass');
16
+ var CallbackQueue = require('./CallbackQueue');
17
+ var Transaction = require('./Transaction');
18
18
 
19
- var assign = require("./Object.assign");
20
- var emptyFunction = require("./emptyFunction");
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 proceedures.
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 resused.
75
+ * instance to be reused.
75
76
  */
76
77
  destructor: function () {
77
78
  CallbackQueue.release(this.reactMountReady);