react 0.14.0-alpha1 → 0.14.0-beta2

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 (195) hide show
  1. package/README.md +5 -2
  2. package/addons.js +5 -2
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5376 -4800
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +5175 -4626
  7. package/dist/react.min.js +6 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  9. package/lib/BeforeInputEventPlugin.js +13 -13
  10. package/lib/CSSProperty.js +3 -0
  11. package/lib/CSSPropertyOperations.js +13 -13
  12. package/lib/CallbackQueue.js +4 -4
  13. package/lib/ChangeEventPlugin.js +16 -14
  14. package/lib/DOMChildrenOperations.js +10 -6
  15. package/lib/DOMProperty.js +82 -119
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -16
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +8 -8
  20. package/lib/EventConstants.js +23 -1
  21. package/lib/EventPluginHub.js +13 -13
  22. package/lib/EventPluginRegistry.js +8 -8
  23. package/lib/EventPluginUtils.js +17 -17
  24. package/lib/EventPropagators.js +7 -7
  25. package/lib/FallbackCompositionState.js +3 -3
  26. package/lib/HTMLDOMPropertyConfig.js +14 -5
  27. package/lib/LinkedStateMixin.js +2 -2
  28. package/lib/LinkedValueUtils.js +50 -38
  29. package/lib/MetaMatchers.js +118 -0
  30. package/lib/OrderedMap.js +453 -0
  31. package/lib/PooledClass.js +14 -2
  32. package/lib/React.js +9 -111
  33. package/lib/ReactBrowserComponentMixin.js +4 -4
  34. package/lib/ReactBrowserEventEmitter.js +30 -7
  35. package/lib/ReactCSSTransitionGroup.js +16 -5
  36. package/lib/ReactCSSTransitionGroupChild.js +20 -11
  37. package/lib/ReactChildReconciler.js +25 -18
  38. package/lib/ReactChildren.js +24 -22
  39. package/lib/ReactClass.js +68 -86
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -4
  42. package/lib/ReactComponentEnvironment.js +2 -2
  43. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  44. package/lib/ReactCompositeComponent.js +80 -111
  45. package/lib/ReactDOM.js +72 -158
  46. package/lib/ReactDOMButton.js +15 -26
  47. package/lib/ReactDOMComponent.js +384 -62
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -25
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +38 -42
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +24 -0
  55. package/lib/ReactDOMTextComponent.js +13 -13
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +34 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +35 -92
  62. package/lib/ReactElementValidator.js +53 -130
  63. package/lib/ReactEmptyComponent.js +4 -4
  64. package/lib/ReactErrorUtils.js +1 -1
  65. package/lib/ReactEventEmitterMixin.js +3 -4
  66. package/lib/ReactEventListener.js +57 -12
  67. package/lib/ReactFragment.js +22 -17
  68. package/lib/ReactInjection.js +11 -11
  69. package/lib/ReactInputSelection.js +8 -7
  70. package/lib/ReactInstanceHandles.js +12 -12
  71. package/lib/ReactIsomorphic.js +70 -0
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +90 -89
  75. package/lib/ReactMultiChild.js +83 -22
  76. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  77. package/lib/ReactNativeComponent.js +3 -8
  78. package/lib/ReactNoopUpdateQueue.js +118 -0
  79. package/lib/ReactOwner.js +3 -3
  80. package/lib/ReactPerf.js +2 -2
  81. package/lib/ReactPropTransferer.js +3 -3
  82. package/lib/ReactPropTypeLocationNames.js +1 -1
  83. package/lib/ReactPropTypeLocations.js +1 -1
  84. package/lib/ReactPropTypes.js +72 -33
  85. package/lib/ReactReconcileTransaction.js +8 -8
  86. package/lib/ReactReconciler.js +18 -20
  87. package/lib/ReactRef.js +1 -1
  88. package/lib/ReactServerBatchingStrategy.js +23 -0
  89. package/lib/ReactServerRendering.js +22 -9
  90. package/lib/ReactServerRenderingTransaction.js +7 -7
  91. package/lib/ReactTestUtils.js +80 -58
  92. package/lib/ReactTransitionChildMapping.js +2 -2
  93. package/lib/ReactTransitionEvents.js +1 -1
  94. package/lib/ReactTransitionGroup.js +5 -6
  95. package/lib/ReactUpdateQueue.js +61 -36
  96. package/lib/ReactUpdates.js +14 -17
  97. package/lib/ReactWithAddons.js +14 -16
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -3
  102. package/lib/SelectEventPlugin.js +14 -15
  103. package/lib/SimpleEventPlugin.js +205 -29
  104. package/lib/SyntheticClipboardEvent.js +3 -3
  105. package/lib/SyntheticCompositionEvent.js +3 -3
  106. package/lib/SyntheticDragEvent.js +3 -3
  107. package/lib/SyntheticEvent.js +9 -8
  108. package/lib/SyntheticFocusEvent.js +3 -3
  109. package/lib/SyntheticInputEvent.js +3 -3
  110. package/lib/SyntheticKeyboardEvent.js +6 -6
  111. package/lib/SyntheticMouseEvent.js +5 -5
  112. package/lib/SyntheticTouchEvent.js +4 -4
  113. package/lib/SyntheticUIEvent.js +4 -4
  114. package/lib/SyntheticWheelEvent.js +3 -3
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +16 -10
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -9
  120. package/lib/cloneWithProps.js +12 -7
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +47 -0
  124. package/lib/findDOMNode.js +11 -12
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +0 -1
  130. package/lib/getTestDocument.js +28 -0
  131. package/lib/getTextContentAccessor.js +1 -1
  132. package/lib/instantiateReactComponent.js +24 -20
  133. package/lib/isEventSupported.js +1 -1
  134. package/lib/isTextInputElement.js +2 -1
  135. package/lib/joinClasses.js +1 -1
  136. package/lib/onlyChild.js +3 -3
  137. package/lib/quoteAttributeValueForBrowser.js +1 -1
  138. package/lib/reactComponentExpect.js +210 -0
  139. package/lib/renderSubtreeIntoContainer.js +1 -1
  140. package/lib/setInnerHTML.js +2 -2
  141. package/lib/setTextContent.js +3 -3
  142. package/lib/shallowCompare.js +1 -1
  143. package/lib/sliceChildren.js +51 -0
  144. package/lib/traverseAllChildren.js +24 -27
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +199 -100
  147. package/lib/webcomponents.js +6379 -0
  148. package/package.json +4 -6
  149. package/react.js +53 -1
  150. package/addons/CSSTransitionGroup.js +0 -1
  151. package/addons/LinkedStateMixin.js +0 -1
  152. package/addons/Perf.js +0 -1
  153. package/addons/PureRenderMixin.js +0 -1
  154. package/addons/TestUtils.js +0 -1
  155. package/addons/TransitionGroup.js +0 -1
  156. package/addons/batchedUpdates.js +0 -1
  157. package/addons/cloneWithProps.js +0 -1
  158. package/addons/createFragment.js +0 -1
  159. package/addons/renderSubtreeIntoContainer.js +0 -1
  160. package/addons/shallowCompare.js +0 -1
  161. package/addons/update.js +0 -1
  162. package/lib/CSSCore.js +0 -97
  163. package/lib/EventListener.js +0 -84
  164. package/lib/ExecutionEnvironment.js +0 -38
  165. package/lib/LocalEventTrapMixin.js +0 -46
  166. package/lib/ReactContext.js +0 -32
  167. package/lib/ReactDOMForm.js +0 -47
  168. package/lib/ReactDOMIframe.js +0 -43
  169. package/lib/ReactDOMImg.js +0 -44
  170. package/lib/ReactLifeCycle.js +0 -35
  171. package/lib/camelize.js +0 -32
  172. package/lib/camelizeStyleName.js +0 -40
  173. package/lib/containsNode.js +0 -55
  174. package/lib/createArrayFromMixed.js +0 -85
  175. package/lib/createFullPageComponent.js +0 -51
  176. package/lib/createNodesFromMarkup.js +0 -84
  177. package/lib/emptyFunction.js +0 -38
  178. package/lib/emptyObject.js +0 -20
  179. package/lib/focusNode.js +0 -26
  180. package/lib/getActiveElement.js +0 -29
  181. package/lib/getMarkupWrap.js +0 -115
  182. package/lib/getUnboundedScrollPosition.js +0 -38
  183. package/lib/hyphenate.js +0 -33
  184. package/lib/hyphenateStyleName.js +0 -39
  185. package/lib/invariant.js +0 -49
  186. package/lib/isNode.js +0 -23
  187. package/lib/isTextNode.js +0 -25
  188. package/lib/keyMirror.js +0 -48
  189. package/lib/keyOf.js +0 -35
  190. package/lib/mapObject.js +0 -51
  191. package/lib/performance.js +0 -23
  192. package/lib/performanceNow.js +0 -28
  193. package/lib/shallowEqual.js +0 -48
  194. package/lib/toArray.js +0 -57
  195. package/lib/warning.js +0 -61
@@ -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
@@ -56,7 +56,7 @@ var Mixin = {
56
56
  * @see Transaction
57
57
  * @abstract
58
58
  * @final
59
- * @return {array} Empty list of operation wrap proceedures.
59
+ * @return {array} Empty list of operation wrap procedures.
60
60
  */
61
61
  getTransactionWrappers: function () {
62
62
  return TRANSACTION_WRAPPERS;
@@ -71,7 +71,7 @@ var Mixin = {
71
71
 
72
72
  /**
73
73
  * `PooledClass` looks for this, and will invoke this before allowing this
74
- * instance to be resused.
74
+ * instance to be reused.
75
75
  */
76
76
  destructor: function () {
77
77
  CallbackQueue.release(this.reactMountReady);
@@ -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 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('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.
@@ -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 = React.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
  },
@@ -226,7 +249,7 @@ var ReactTestUtils = {
226
249
  /**
227
250
  * Simulates a top level event being dispatched from a raw event that occured
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
  */
@@ -238,8 +261,8 @@ var ReactTestUtils = {
238
261
  /**
239
262
  * Simulates a top level event being dispatched from a raw event that occured
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) {
@@ -314,7 +337,9 @@ ReactShallowRenderer.prototype.unmount = function () {
314
337
  };
315
338
 
316
339
  ReactShallowRenderer.prototype._render = function (element, transaction, context) {
317
- if (!this._instance) {
340
+ if (this._instance) {
341
+ this._instance.receiveComponent(element, transaction, context);
342
+ } else {
318
343
  var rootID = ReactInstanceHandles.createReactRootID();
319
344
  var instance = new ShallowComponentWrapper(element.type);
320
345
  instance.construct(element);
@@ -322,8 +347,6 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
322
347
  instance.mountComponent(rootID, transaction, context);
323
348
 
324
349
  this._instance = instance;
325
- } else {
326
- this._instance.receiveComponent(element, transaction, context);
327
350
  }
328
351
  };
329
352
 
@@ -350,7 +373,7 @@ function makeSimulator(eventType) {
350
373
  fakeNativeEvent.target = node;
351
374
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
352
375
  // properly destroying any properties assigned from `eventData` upon release
353
- var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent);
376
+ var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent, node);
354
377
  assign(event, eventData);
355
378
 
356
379
  if (dispatchConfig.phasedRegistrationNames) {
@@ -372,7 +395,7 @@ function buildSimulators() {
372
395
  var eventType;
373
396
  for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
374
397
  /**
375
- * @param {!Element || ReactDOMComponent} domComponentOrNode
398
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
376
399
  * @param {?object} eventData Fake event data to use in SyntheticEvent.
377
400
  */
378
401
  ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
@@ -415,22 +438,21 @@ function makeNativeSimulator(eventType) {
415
438
  assign(fakeNativeEvent, nativeEventData);
416
439
  if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
417
440
  ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
418
- } else if (!!domComponentOrNode.tagName) {
441
+ } else if (domComponentOrNode.tagName) {
419
442
  // Will allow on actual dom nodes.
420
443
  ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
421
444
  }
422
445
  };
423
446
  }
424
447
 
425
- var eventType;
426
- for (eventType in topLevelTypes) {
448
+ Object.keys(topLevelTypes).forEach(function (eventType) {
427
449
  // Event type is stored as 'topClick' - we transform that to 'click'
428
450
  var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
429
451
  /**
430
- * @param {!Element || ReactDOMComponent} domComponentOrNode
452
+ * @param {!Element|ReactDOMComponent} domComponentOrNode
431
453
  * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
432
454
  */
433
455
  ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
434
- }
456
+ });
435
457
 
436
458
  module.exports = ReactTestUtils;
@@ -12,8 +12,8 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var ReactChildren = require("./ReactChildren");
16
- var ReactFragment = require("./ReactFragment");
15
+ var ReactChildren = require('./ReactChildren');
16
+ var ReactFragment = require('./ReactFragment');
17
17
 
18
18
  var ReactTransitionChildMapping = {
19
19
  /**
@@ -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,44 +11,35 @@
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
- 'production' !== process.env.NODE_ENV ? invariant(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) : invariant(ReactCurrentOwner.current == null);
28
+ if (process.env.NODE_ENV !== 'production') {
29
+ 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;
30
+ }
36
31
 
37
32
  var internalInstance = ReactInstanceMap.get(publicInstance);
38
33
  if (!internalInstance) {
39
- if ('production' !== process.env.NODE_ENV) {
34
+ if (process.env.NODE_ENV !== 'production') {
40
35
  // Only warn when we have a callerName. Otherwise we should be silent.
41
36
  // We're probably calling from enqueueCallback. We don't want to warn
42
37
  // 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) : null;
38
+ 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
39
  }
45
40
  return null;
46
41
  }
47
42
 
48
- if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
49
- return null;
50
- }
51
-
52
43
  return internalInstance;
53
44
  }
54
45
 
@@ -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
- 'production' !== process.env.NODE_ENV ? invariant(typeof callback === 'function', 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(typeof callback === 'function');
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
- 'production' !== process.env.NODE_ENV ? invariant(typeof callback === 'function', 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(typeof callback === 'function');
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
- 'production' !== process.env.NODE_ENV ? invariant(internalInstance._isTopLevel, '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(internalInstance._isTopLevel);
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
- 'production' !== process.env.NODE_ENV ? invariant(internalInstance._isTopLevel, '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(internalInstance._isTopLevel);
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) {