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
@@ -11,23 +11,24 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var EventConstants = require("./EventConstants");
15
- var EventPluginHub = require("./EventPluginHub");
16
- var EventPropagators = require("./EventPropagators");
17
- var React = require("./React");
18
- var ReactElement = require("./ReactElement");
19
- var ReactEmptyComponent = require("./ReactEmptyComponent");
20
- var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
21
- var ReactCompositeComponent = require("./ReactCompositeComponent");
22
- var ReactInstanceHandles = require("./ReactInstanceHandles");
23
- var ReactInstanceMap = require("./ReactInstanceMap");
24
- var ReactMount = require("./ReactMount");
25
- var ReactUpdates = require("./ReactUpdates");
26
- var SyntheticEvent = require("./SyntheticEvent");
27
-
28
- var assign = require("./Object.assign");
29
- var emptyObject = require("./emptyObject");
30
- var findDOMNode = require("./findDOMNode");
14
+ var EventConstants = require('./EventConstants');
15
+ var EventPluginHub = require('./EventPluginHub');
16
+ var EventPropagators = require('./EventPropagators');
17
+ var React = require('./React');
18
+ var ReactDOM = require('./ReactDOM');
19
+ var ReactElement = require('./ReactElement');
20
+ var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
21
+ var ReactCompositeComponent = require('./ReactCompositeComponent');
22
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
23
+ var ReactInstanceMap = require('./ReactInstanceMap');
24
+ var ReactMount = require('./ReactMount');
25
+ var ReactUpdates = require('./ReactUpdates');
26
+ var SyntheticEvent = require('./SyntheticEvent');
27
+
28
+ var assign = require('./Object.assign');
29
+ var emptyObject = require('fbjs/lib/emptyObject');
30
+ var findDOMNode = require('./findDOMNode');
31
+ var invariant = require('fbjs/lib/invariant');
31
32
 
32
33
  var topLevelTypes = EventConstants.topLevelTypes;
33
34
 
@@ -37,6 +38,27 @@ function Event(suffix) {}
37
38
  * @class ReactTestUtils
38
39
  */
39
40
 
41
+ function findAllInRenderedTreeInternal(inst, test) {
42
+ if (!inst || !inst.getPublicInstance) {
43
+ return [];
44
+ }
45
+ var publicInst = inst.getPublicInstance();
46
+ var ret = test(publicInst) ? [publicInst] : [];
47
+ if (ReactTestUtils.isDOMComponent(publicInst)) {
48
+ var renderedChildren = inst._renderedChildren;
49
+ var key;
50
+ for (key in renderedChildren) {
51
+ if (!renderedChildren.hasOwnProperty(key)) {
52
+ continue;
53
+ }
54
+ ret = ret.concat(findAllInRenderedTreeInternal(renderedChildren[key], test));
55
+ }
56
+ } else if (ReactTestUtils.isCompositeComponent(publicInst)) {
57
+ ret = ret.concat(findAllInRenderedTreeInternal(inst._renderedComponent, test));
58
+ }
59
+ return ret;
60
+ }
61
+
40
62
  /**
41
63
  * Todo: Support the entire DOM.scry query syntax. For now, these simple
42
64
  * utilities will suffice for testing purposes.
@@ -50,7 +72,7 @@ var ReactTestUtils = {
50
72
  // clean up, so we're going to stop honoring the name of this method
51
73
  // (and probably rename it eventually) if no problems arise.
52
74
  // document.documentElement.appendChild(div);
53
- return React.render(instance, div);
75
+ return ReactDOM.render(instance, div);
54
76
  },
55
77
 
56
78
  isElement: function (element) {
@@ -64,7 +86,7 @@ var ReactTestUtils = {
64
86
  isDOMComponent: function (inst) {
65
87
  // TODO: Fix this heuristic. It's just here because composites can currently
66
88
  // pretend to be DOM components.
67
- return !!(inst && inst.tagName && inst.getDOMNode);
89
+ return !!(inst && inst.nodeType === 1 && inst.tagName);
68
90
  },
69
91
 
70
92
  isDOMComponentElement: function (inst) {
@@ -72,11 +94,22 @@ var ReactTestUtils = {
72
94
  },
73
95
 
74
96
  isCompositeComponent: function (inst) {
97
+ if (ReactTestUtils.isDOMComponent(inst)) {
98
+ // Accessing inst.setState warns; just return false as that'll be what
99
+ // this returns when we have DOM nodes as refs directly
100
+ return false;
101
+ }
75
102
  return typeof inst.render === 'function' && typeof inst.setState === 'function';
76
103
  },
77
104
 
78
105
  isCompositeComponentWithType: function (inst, type) {
79
- return !!(ReactTestUtils.isCompositeComponent(inst) && inst.constructor === type);
106
+ if (!ReactTestUtils.isCompositeComponent(inst)) {
107
+ return false;
108
+ }
109
+ var internalInstance = ReactInstanceMap.get(inst);
110
+ var constructor = internalInstance._currentElement.type;
111
+
112
+ return constructor === type;
80
113
  },
81
114
 
82
115
  isCompositeComponentElement: function (inst) {
@@ -90,7 +123,10 @@ var ReactTestUtils = {
90
123
  },
91
124
 
92
125
  isCompositeComponentElementWithType: function (inst, type) {
93
- return !!(ReactTestUtils.isCompositeComponentElement(inst) && inst.constructor === type);
126
+ var internalInstance = ReactInstanceMap.get(inst);
127
+ var constructor = internalInstance._currentElement.type;
128
+
129
+ return !!(ReactTestUtils.isCompositeComponentElement(inst) && constructor === type);
94
130
  },
95
131
 
96
132
  getRenderedChildOfCompositeComponent: function (inst) {
@@ -105,35 +141,22 @@ var ReactTestUtils = {
105
141
  if (!inst) {
106
142
  return [];
107
143
  }
108
- var ret = test(inst) ? [inst] : [];
109
- if (ReactTestUtils.isDOMComponent(inst)) {
110
- var internalInstance = ReactInstanceMap.get(inst);
111
- var renderedChildren = internalInstance._renderedComponent._renderedChildren;
112
- var key;
113
- for (key in renderedChildren) {
114
- if (!renderedChildren.hasOwnProperty(key)) {
115
- continue;
116
- }
117
- if (!renderedChildren[key].getPublicInstance) {
118
- continue;
119
- }
120
- ret = ret.concat(ReactTestUtils.findAllInRenderedTree(renderedChildren[key].getPublicInstance(), test));
121
- }
122
- } else if (ReactTestUtils.isCompositeComponent(inst)) {
123
- ret = ret.concat(ReactTestUtils.findAllInRenderedTree(ReactTestUtils.getRenderedChildOfCompositeComponent(inst), test));
124
- }
125
- return ret;
144
+ !ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : undefined;
145
+ return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
126
146
  },
127
147
 
128
148
  /**
129
149
  * Finds all instance of components in the rendered tree that are DOM
130
150
  * components with the class name matching `className`.
131
- * @return an array of all the matches.
151
+ * @return {array} an array of all the matches.
132
152
  */
133
153
  scryRenderedDOMComponentsWithClass: function (root, className) {
134
154
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
135
- var instClassName = inst.props.className;
136
- return ReactTestUtils.isDOMComponent(inst) && (instClassName && (' ' + instClassName + ' ').indexOf(' ' + className + ' ') !== -1);
155
+ if (ReactTestUtils.isDOMComponent(inst)) {
156
+ var instClassName = ReactDOM.findDOMNode(inst).className;
157
+ return instClassName && ('' + instClassName).split(/\s+/).indexOf(className) !== -1;
158
+ }
159
+ return false;
137
160
  });
138
161
  },
139
162
 
@@ -154,11 +177,11 @@ var ReactTestUtils = {
154
177
  /**
155
178
  * Finds all instance of components in the rendered tree that are DOM
156
179
  * components with the tag name matching `tagName`.
157
- * @return an array of all the matches.
180
+ * @return {array} an array of all the matches.
158
181
  */
159
182
  scryRenderedDOMComponentsWithTag: function (root, tagName) {
160
183
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
161
- return ReactTestUtils.isDOMComponent(inst) && inst.tagName === tagName.toUpperCase();
184
+ return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
162
185
  });
163
186
  },
164
187
 
@@ -178,7 +201,7 @@ var ReactTestUtils = {
178
201
 
179
202
  /**
180
203
  * Finds all instances of components with type equal to `componentType`.
181
- * @return an array of all the matches.
204
+ * @return {array} an array of all the matches.
182
205
  */
183
206
  scryRenderedComponentsWithType: function (root, componentType) {
184
207
  return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
@@ -195,7 +218,7 @@ var ReactTestUtils = {
195
218
  findRenderedComponentWithType: function (root, componentType) {
196
219
  var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
197
220
  if (all.length !== 1) {
198
- throw new Error('Did not find exactly one match for componentType:' + componentType);
221
+ throw new Error('Did not find exactly one match for componentType:' + componentType + ' (found ' + all.length + ')');
199
222
  }
200
223
  return all[0];
201
224
  },
@@ -224,9 +247,9 @@ var ReactTestUtils = {
224
247
  },
225
248
 
226
249
  /**
227
- * Simulates a top level event being dispatched from a raw event that occured
250
+ * Simulates a top level event being dispatched from a raw event that occurred
228
251
  * on an `Element` node.
229
- * @param topLevelType {Object} A type from `EventConstants.topLevelTypes`
252
+ * @param {Object} topLevelType A type from `EventConstants.topLevelTypes`
230
253
  * @param {!Element} node The dom to simulate an event occurring on.
231
254
  * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
232
255
  */
@@ -236,10 +259,10 @@ var ReactTestUtils = {
236
259
  },
237
260
 
238
261
  /**
239
- * Simulates a top level event being dispatched from a raw event that occured
262
+ * Simulates a top level event being dispatched from a raw event that occurred
240
263
  * on the `ReactDOMComponent` `comp`.
241
- * @param topLevelType {Object} A type from `EventConstants.topLevelTypes`.
242
- * @param comp {!ReactDOMComponent}
264
+ * @param {Object} topLevelType A type from `EventConstants.topLevelTypes`.
265
+ * @param {!ReactDOMComponent} comp
243
266
  * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
244
267
  */
245
268
  simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
@@ -273,7 +296,7 @@ ReactShallowRenderer.prototype.getRenderOutput = function () {
273
296
 
274
297
  var NoopInternalComponent = function (element) {
275
298
  this._renderedOutput = element;
276
- this._currentElement = element === null || element === false ? ReactEmptyComponent.emptyElement : element;
299
+ this._currentElement = element;
277
300
  };
278
301
 
279
302
  NoopInternalComponent.prototype = {
@@ -282,7 +305,7 @@ NoopInternalComponent.prototype = {
282
305
 
283
306
  receiveComponent: function (element) {
284
307
  this._renderedOutput = element;
285
- this._currentElement = element === null || element === false ? ReactEmptyComponent.emptyElement : element;
308
+ this._currentElement = element;
286
309
  },
287
310
 
288
311
  unmountComponent: function () {}
@@ -299,10 +322,13 @@ assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
299
322
  });
300
323
 
301
324
  ReactShallowRenderer.prototype.render = function (element, context) {
325
+ !ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : invariant(false) : undefined;
326
+ !(typeof element.type !== 'string') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom ' + 'components, not primitives (%s). Instead of calling `.render(el)` and ' + 'inspecting the rendered output, look at `el.props` directly instead.', element.type) : invariant(false) : undefined;
327
+
302
328
  if (!context) {
303
329
  context = emptyObject;
304
330
  }
305
- var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
331
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(false);
306
332
  this._render(element, transaction, context);
307
333
  ReactUpdates.ReactReconcileTransaction.release(transaction);
308
334
  };
@@ -314,7 +340,9 @@ ReactShallowRenderer.prototype.unmount = function () {
314
340
  };
315
341
 
316
342
  ReactShallowRenderer.prototype._render = function (element, transaction, context) {
317
- if (!this._instance) {
343
+ if (this._instance) {
344
+ this._instance.receiveComponent(element, transaction, context);
345
+ } else {
318
346
  var rootID = ReactInstanceHandles.createReactRootID();
319
347
  var instance = new ShallowComponentWrapper(element.type);
320
348
  instance.construct(element);
@@ -322,8 +350,6 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
322
350
  instance.mountComponent(rootID, transaction, context);
323
351
 
324
352
  this._instance = instance;
325
- } else {
326
- this._instance.receiveComponent(element, transaction, context);
327
353
  }
328
354
  };
329
355
 
@@ -350,7 +376,7 @@ function makeSimulator(eventType) {
350
376
  fakeNativeEvent.target = node;
351
377
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
352
378
  // properly destroying any properties assigned from `eventData` upon release
353
- var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent);
379
+ var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent, node);
354
380
  assign(event, eventData);
355
381
 
356
382
  if (dispatchConfig.phasedRegistrationNames) {
@@ -372,7 +398,7 @@ function buildSimulators() {
372
398
  var eventType;
373
399
  for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
374
400
  /**
375
- * @param {!Element || ReactDOMComponent} domComponentOrNode
401
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
376
402
  * @param {?object} eventData Fake event data to use in SyntheticEvent.
377
403
  */
378
404
  ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
@@ -415,22 +441,21 @@ function makeNativeSimulator(eventType) {
415
441
  assign(fakeNativeEvent, nativeEventData);
416
442
  if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
417
443
  ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
418
- } else if (!!domComponentOrNode.tagName) {
444
+ } else if (domComponentOrNode.tagName) {
419
445
  // Will allow on actual dom nodes.
420
446
  ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
421
447
  }
422
448
  };
423
449
  }
424
450
 
425
- var eventType;
426
- for (eventType in topLevelTypes) {
451
+ Object.keys(topLevelTypes).forEach(function (eventType) {
427
452
  // Event type is stored as 'topClick' - we transform that to 'click'
428
453
  var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
429
454
  /**
430
- * @param {!Element || ReactDOMComponent} domComponentOrNode
455
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
431
456
  * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
432
457
  */
433
458
  ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
434
- }
459
+ });
435
460
 
436
461
  module.exports = ReactTestUtils;
@@ -12,13 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var ReactChildren = require("./ReactChildren");
16
- var ReactFragment = require("./ReactFragment");
15
+ var flattenChildren = require('./flattenChildren');
17
16
 
18
17
  var ReactTransitionChildMapping = {
19
18
  /**
20
19
  * Given `this.props.children`, return an object mapping key to child. Just
21
- * simple syntactic sugar around ReactChildren.map().
20
+ * simple syntactic sugar around flattenChildren().
22
21
  *
23
22
  * @param {*} children `this.props.children`
24
23
  * @return {object} Mapping of key to child
@@ -27,9 +26,7 @@ var ReactTransitionChildMapping = {
27
26
  if (!children) {
28
27
  return children;
29
28
  }
30
- return ReactFragment.extract(ReactChildren.map(children, function (child) {
31
- return child;
32
- }));
29
+ return flattenChildren(children);
33
30
  },
34
31
 
35
32
  /**
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ExecutionEnvironment = require("./ExecutionEnvironment");
14
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
15
 
16
16
  /**
17
17
  * EVENT_NAME_MAP is used to determine which event fired when a
@@ -11,12 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var React = require("./React");
15
- var ReactTransitionChildMapping = require("./ReactTransitionChildMapping");
14
+ var React = require('./React');
15
+ var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
16
16
 
17
- var assign = require("./Object.assign");
18
- var cloneWithProps = require("./cloneWithProps");
19
- var emptyFunction = require("./emptyFunction");
17
+ var assign = require('./Object.assign');
18
+ var emptyFunction = require('fbjs/lib/emptyFunction');
20
19
 
21
20
  var ReactTransitionGroup = React.createClass({
22
21
  displayName: 'ReactTransitionGroup',
@@ -196,7 +195,7 @@ var ReactTransitionGroup = React.createClass({
196
195
  // already been removed. In case you need this behavior you can provide
197
196
  // a childFactory function to wrap every child, even the ones that are
198
197
  // leaving.
199
- childrenToRender.push(cloneWithProps(this.props.childFactory(child), { ref: key, key: key }));
198
+ childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
200
199
  }
201
200
  }
202
201
  return React.createElement(this.props.component, this.props, childrenToRender);
@@ -11,42 +11,33 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactLifeCycle = require("./ReactLifeCycle");
15
- var ReactCurrentOwner = require("./ReactCurrentOwner");
16
- var ReactElement = require("./ReactElement");
17
- var ReactInstanceMap = require("./ReactInstanceMap");
18
- var ReactUpdates = require("./ReactUpdates");
14
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
15
+ var ReactElement = require('./ReactElement');
16
+ var ReactInstanceMap = require('./ReactInstanceMap');
17
+ var ReactUpdates = require('./ReactUpdates');
19
18
 
20
- var assign = require("./Object.assign");
21
- var invariant = require("./invariant");
22
- var warning = require("./warning");
19
+ var assign = require('./Object.assign');
20
+ var invariant = require('fbjs/lib/invariant');
21
+ var warning = require('fbjs/lib/warning');
23
22
 
24
23
  function enqueueUpdate(internalInstance) {
25
- if (internalInstance !== ReactLifeCycle.currentlyMountingInstance) {
26
- // If we're in a componentWillMount handler, don't enqueue a rerender
27
- // because ReactUpdates assumes we're in a browser context (which is
28
- // wrong for server rendering) and we're about to do a render anyway.
29
- // See bug in #1740.
30
- ReactUpdates.enqueueUpdate(internalInstance);
31
- }
24
+ ReactUpdates.enqueueUpdate(internalInstance);
32
25
  }
33
26
 
34
27
  function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
35
- !(ReactCurrentOwner.current == null) ? 'production' !== process.env.NODE_ENV ? invariant(false, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : invariant(false) : undefined;
36
-
37
28
  var internalInstance = ReactInstanceMap.get(publicInstance);
38
29
  if (!internalInstance) {
39
- if ('production' !== process.env.NODE_ENV) {
30
+ if (process.env.NODE_ENV !== 'production') {
40
31
  // Only warn when we have a callerName. Otherwise we should be silent.
41
32
  // We're probably calling from enqueueCallback. We don't want to warn
42
33
  // there because we already warned for the corresponding lifecycle method.
43
- 'production' !== process.env.NODE_ENV ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted ' + 'component. This is a no-op.', callerName, callerName) : undefined;
34
+ process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
44
35
  }
45
36
  return null;
46
37
  }
47
38
 
48
- if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
49
- return null;
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
50
41
  }
51
42
 
52
43
  return internalInstance;
@@ -58,6 +49,32 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
58
49
  */
59
50
  var ReactUpdateQueue = {
60
51
 
52
+ /**
53
+ * Checks whether or not this composite component is mounted.
54
+ * @param {ReactClass} publicInstance The instance we want to test.
55
+ * @return {boolean} True if mounted, false otherwise.
56
+ * @protected
57
+ * @final
58
+ */
59
+ isMounted: function (publicInstance) {
60
+ if (process.env.NODE_ENV !== 'production') {
61
+ var owner = ReactCurrentOwner.current;
62
+ if (owner !== null) {
63
+ process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
64
+ owner._warnedAboutRefsInRender = true;
65
+ }
66
+ }
67
+ var internalInstance = ReactInstanceMap.get(publicInstance);
68
+ if (internalInstance) {
69
+ // During componentWillMount and render this will still be null but after
70
+ // that will always render to something. At least for now. So we can use
71
+ // this hack.
72
+ return !!internalInstance._renderedComponent;
73
+ } else {
74
+ return false;
75
+ }
76
+ },
77
+
61
78
  /**
62
79
  * Enqueue a callback that will be executed after all the pending updates
63
80
  * have processed.
@@ -67,7 +84,7 @@ var ReactUpdateQueue = {
67
84
  * @internal
68
85
  */
69
86
  enqueueCallback: function (publicInstance, callback) {
70
- !(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
87
+ !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
71
88
  var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
72
89
 
73
90
  // Previously we would throw an error if we didn't have an internal
@@ -75,7 +92,7 @@ var ReactUpdateQueue = {
75
92
  // behavior we have in other enqueue* methods.
76
93
  // We also need to ignore callbacks in componentWillMount. See
77
94
  // enqueueUpdates.
78
- if (!internalInstance || internalInstance === ReactLifeCycle.currentlyMountingInstance) {
95
+ if (!internalInstance) {
79
96
  return null;
80
97
  }
81
98
 
@@ -92,7 +109,7 @@ var ReactUpdateQueue = {
92
109
  },
93
110
 
94
111
  enqueueCallbackInternal: function (internalInstance, callback) {
95
- !(typeof callback === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
112
+ !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
96
113
  if (internalInstance._pendingCallbacks) {
97
114
  internalInstance._pendingCallbacks.push(callback);
98
115
  } else {
@@ -108,7 +125,7 @@ var ReactUpdateQueue = {
108
125
  * You may want to call this when you know that some deeper aspect of the
109
126
  * component's state has changed but `setState` was not called.
110
127
  *
111
- * This will not invoke `shouldUpdateComponent`, but it will invoke
128
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
112
129
  * `componentWillUpdate` and `componentDidUpdate`.
113
130
  *
114
131
  * @param {ReactClass} publicInstance The instance that should rerender.
@@ -182,20 +199,24 @@ var ReactUpdateQueue = {
182
199
  */
183
200
  enqueueSetProps: function (publicInstance, partialProps) {
184
201
  var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
185
-
186
202
  if (!internalInstance) {
187
203
  return;
188
204
  }
205
+ ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
206
+ },
189
207
 
190
- !internalInstance._isTopLevel ? 'production' !== process.env.NODE_ENV ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
208
+ enqueueSetPropsInternal: function (internalInstance, partialProps) {
209
+ var topLevelWrapper = internalInstance._topLevelWrapper;
210
+ !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
191
211
 
192
212
  // Merge with the pending element if it exists, otherwise with existing
193
213
  // element props.
194
- var element = internalInstance._pendingElement || internalInstance._currentElement;
214
+ var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
215
+ var element = wrapElement.props;
195
216
  var props = assign({}, element.props, partialProps);
196
- internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(element, props);
217
+ topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
197
218
 
198
- enqueueUpdate(internalInstance);
219
+ enqueueUpdate(topLevelWrapper);
199
220
  },
200
221
 
201
222
  /**
@@ -207,19 +228,23 @@ var ReactUpdateQueue = {
207
228
  */
208
229
  enqueueReplaceProps: function (publicInstance, props) {
209
230
  var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
210
-
211
231
  if (!internalInstance) {
212
232
  return;
213
233
  }
234
+ ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
235
+ },
214
236
 
215
- !internalInstance._isTopLevel ? 'production' !== process.env.NODE_ENV ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
237
+ enqueueReplacePropsInternal: function (internalInstance, props) {
238
+ var topLevelWrapper = internalInstance._topLevelWrapper;
239
+ !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
216
240
 
217
241
  // Merge with the pending element if it exists, otherwise with existing
218
242
  // element props.
219
- var element = internalInstance._pendingElement || internalInstance._currentElement;
220
- internalInstance._pendingElement = ReactElement.cloneAndReplaceProps(element, props);
243
+ var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
244
+ var element = wrapElement.props;
245
+ topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
221
246
 
222
- enqueueUpdate(internalInstance);
247
+ enqueueUpdate(topLevelWrapper);
223
248
  },
224
249
 
225
250
  enqueueElementInternal: function (internalInstance, newElement) {