react 0.11.0 → 0.12.0

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 (173) hide show
  1. package/dist/JSXTransformer.js +1373 -963
  2. package/dist/react-with-addons.js +3151 -3585
  3. package/dist/react-with-addons.min.js +11 -17
  4. package/dist/react.js +2960 -3308
  5. package/dist/react.min.js +11 -16
  6. package/lib/AutoFocusMixin.js +5 -12
  7. package/lib/BeforeInputEventPlugin.js +12 -14
  8. package/lib/CSSCore.js +6 -13
  9. package/lib/CSSProperty.js +5 -12
  10. package/lib/CSSPropertyOperations.js +46 -12
  11. package/lib/CallbackQueue.js +7 -14
  12. package/lib/ChangeEventPlugin.js +5 -12
  13. package/lib/ClientReactRootIndex.js +5 -12
  14. package/lib/CompositionEventPlugin.js +5 -12
  15. package/lib/DOMChildrenOperations.js +8 -15
  16. package/lib/DOMProperty.js +16 -19
  17. package/lib/DOMPropertyOperations.js +14 -14
  18. package/lib/Danger.js +12 -17
  19. package/lib/DefaultEventPluginOrder.js +5 -12
  20. package/lib/EnterLeaveEventPlugin.js +5 -12
  21. package/lib/EventConstants.js +5 -12
  22. package/lib/EventListener.js +14 -0
  23. package/lib/EventPluginHub.js +8 -26
  24. package/lib/EventPluginRegistry.js +5 -12
  25. package/lib/EventPluginUtils.js +5 -12
  26. package/lib/EventPropagators.js +12 -17
  27. package/lib/ExecutionEnvironment.js +5 -12
  28. package/lib/HTMLDOMPropertyConfig.js +14 -16
  29. package/lib/LinkedStateMixin.js +5 -12
  30. package/lib/LinkedValueUtils.js +5 -12
  31. package/lib/LocalEventTrapMixin.js +8 -14
  32. package/lib/MobileSafariClickEventPlugin.js +5 -12
  33. package/lib/Object.assign.js +45 -0
  34. package/lib/PooledClass.js +5 -12
  35. package/lib/React.js +91 -38
  36. package/lib/ReactBrowserComponentMixin.js +5 -12
  37. package/lib/ReactBrowserEventEmitter.js +7 -14
  38. package/lib/ReactCSSTransitionGroup.js +15 -17
  39. package/lib/ReactCSSTransitionGroupChild.js +9 -13
  40. package/lib/ReactChildren.js +5 -12
  41. package/lib/ReactComponent.js +61 -68
  42. package/lib/ReactComponentBrowserEnvironment.js +5 -12
  43. package/lib/ReactComponentWithPureRenderMixin.js +5 -12
  44. package/lib/ReactCompositeComponent.js +199 -180
  45. package/lib/ReactContext.js +8 -15
  46. package/lib/ReactCurrentOwner.js +5 -12
  47. package/lib/ReactDOM.js +145 -175
  48. package/lib/ReactDOMButton.js +8 -14
  49. package/lib/ReactDOMComponent.js +103 -38
  50. package/lib/ReactDOMForm.js +9 -15
  51. package/lib/ReactDOMIDOperations.js +5 -12
  52. package/lib/ReactDOMImg.js +8 -14
  53. package/lib/ReactDOMInput.js +30 -38
  54. package/lib/ReactDOMOption.js +8 -14
  55. package/lib/ReactDOMSelect.js +25 -24
  56. package/lib/ReactDOMSelection.js +11 -18
  57. package/lib/ReactDOMTextarea.js +19 -24
  58. package/lib/ReactDefaultBatchingStrategy.js +14 -18
  59. package/lib/ReactDefaultInjection.js +23 -26
  60. package/lib/ReactDefaultPerf.js +13 -16
  61. package/lib/ReactDefaultPerfAnalysis.js +18 -17
  62. package/lib/ReactElement.js +242 -0
  63. package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +48 -65
  64. package/lib/ReactEmptyComponent.js +8 -13
  65. package/lib/ReactErrorUtils.js +5 -12
  66. package/lib/ReactEventEmitterMixin.js +5 -12
  67. package/lib/ReactEventListener.js +7 -14
  68. package/lib/ReactInjection.js +7 -14
  69. package/lib/ReactInputSelection.js +5 -12
  70. package/lib/ReactInstanceHandles.js +5 -12
  71. package/lib/ReactLegacyElement.js +243 -0
  72. package/lib/ReactLink.js +5 -12
  73. package/lib/ReactMarkupChecksum.js +5 -12
  74. package/lib/ReactMount.js +45 -32
  75. package/lib/ReactMultiChild.js +14 -18
  76. package/lib/ReactMultiChildUpdateTypes.js +5 -12
  77. package/lib/ReactNativeComponent.js +69 -0
  78. package/lib/ReactOwner.js +5 -12
  79. package/lib/ReactPerf.js +8 -13
  80. package/lib/ReactPropTransferer.js +34 -33
  81. package/lib/ReactPropTypeLocationNames.js +5 -12
  82. package/lib/ReactPropTypeLocations.js +5 -12
  83. package/lib/ReactPropTypes.js +38 -29
  84. package/lib/ReactPutListenerQueue.js +7 -14
  85. package/lib/ReactReconcileTransaction.js +7 -15
  86. package/lib/ReactRootIndex.js +5 -12
  87. package/lib/ReactServerRendering.js +21 -34
  88. package/lib/ReactServerRenderingTransaction.js +11 -15
  89. package/lib/ReactStateSetters.js +5 -12
  90. package/lib/ReactTestUtils.js +31 -33
  91. package/lib/ReactTextComponent.js +18 -21
  92. package/lib/ReactTransitionChildMapping.js +6 -13
  93. package/lib/ReactTransitionEvents.js +5 -12
  94. package/lib/ReactTransitionGroup.js +14 -17
  95. package/lib/ReactUpdates.js +43 -22
  96. package/lib/ReactWithAddons.js +7 -13
  97. package/lib/SVGDOMPropertyConfig.js +5 -12
  98. package/lib/SelectEventPlugin.js +13 -20
  99. package/lib/ServerReactRootIndex.js +5 -12
  100. package/lib/SimpleEventPlugin.js +20 -15
  101. package/lib/SyntheticClipboardEvent.js +5 -12
  102. package/lib/SyntheticCompositionEvent.js +5 -12
  103. package/lib/SyntheticDragEvent.js +5 -12
  104. package/lib/SyntheticEvent.js +9 -17
  105. package/lib/SyntheticFocusEvent.js +5 -12
  106. package/lib/SyntheticInputEvent.js +4 -11
  107. package/lib/SyntheticKeyboardEvent.js +17 -19
  108. package/lib/SyntheticMouseEvent.js +6 -13
  109. package/lib/SyntheticTouchEvent.js +5 -12
  110. package/lib/SyntheticUIEvent.js +5 -12
  111. package/lib/SyntheticWheelEvent.js +5 -12
  112. package/lib/Transaction.js +5 -12
  113. package/lib/ViewportMetrics.js +5 -12
  114. package/lib/accumulateInto.js +62 -0
  115. package/lib/adler32.js +6 -13
  116. package/lib/camelize.js +30 -0
  117. package/lib/camelizeStyleName.js +40 -0
  118. package/lib/cloneWithProps.js +9 -15
  119. package/lib/containsNode.js +5 -12
  120. package/lib/copyProperties.js +12 -12
  121. package/lib/createArrayFrom.js +5 -12
  122. package/lib/createFullPageComponent.js +12 -18
  123. package/lib/createNodesFromMarkup.js +5 -12
  124. package/lib/cx.js +5 -12
  125. package/lib/dangerousStyleValue.js +5 -12
  126. package/lib/deprecated.js +47 -0
  127. package/lib/emptyFunction.js +11 -22
  128. package/lib/emptyObject.js +5 -12
  129. package/lib/escapeTextForBrowser.js +5 -12
  130. package/lib/flattenChildren.js +19 -13
  131. package/lib/focusNode.js +10 -16
  132. package/lib/forEachAccumulated.js +5 -12
  133. package/lib/getActiveElement.js +5 -12
  134. package/lib/getEventCharCode.js +50 -0
  135. package/lib/getEventKey.js +9 -21
  136. package/lib/getEventModifierState.js +10 -17
  137. package/lib/getEventTarget.js +5 -12
  138. package/lib/getMarkupWrap.js +5 -12
  139. package/lib/getNodeForCharacterOffset.js +5 -12
  140. package/lib/getReactRootElementInContainer.js +5 -12
  141. package/lib/getTextContentAccessor.js +5 -12
  142. package/lib/getUnboundedScrollPosition.js +5 -12
  143. package/lib/hyphenate.js +5 -12
  144. package/lib/hyphenateStyleName.js +8 -15
  145. package/lib/instantiateReactComponent.js +90 -42
  146. package/lib/invariant.js +5 -12
  147. package/lib/isEventSupported.js +5 -12
  148. package/lib/isNode.js +5 -12
  149. package/lib/isTextInputElement.js +5 -12
  150. package/lib/isTextNode.js +5 -12
  151. package/lib/joinClasses.js +8 -13
  152. package/lib/keyMirror.js +5 -12
  153. package/lib/keyOf.js +5 -12
  154. package/lib/mapObject.js +35 -36
  155. package/lib/memoizeStringOnly.js +5 -12
  156. package/lib/merge.js +14 -17
  157. package/lib/mergeInto.js +13 -35
  158. package/lib/monitorCodeUse.js +5 -12
  159. package/lib/onlyChild.js +8 -15
  160. package/lib/performance.js +5 -12
  161. package/lib/performanceNow.js +5 -12
  162. package/lib/setInnerHTML.js +19 -20
  163. package/lib/shallowEqual.js +6 -13
  164. package/lib/shouldUpdateReactComponent.js +14 -22
  165. package/lib/toArray.js +5 -12
  166. package/lib/traverseAllChildren.js +34 -48
  167. package/lib/update.js +8 -15
  168. package/lib/warning.js +5 -12
  169. package/package.json +3 -8
  170. package/lib/ReactDescriptor.js +0 -251
  171. package/lib/accumulate.js +0 -54
  172. package/lib/mergeHelpers.js +0 -147
  173. package/lib/mixInto.js +0 -34
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @typechecks
17
10
  * @providesModule ReactCSSTransitionGroupChild
@@ -56,7 +49,10 @@ var ReactCSSTransitionGroupChild = React.createClass({
56
49
  var activeClassName = className + '-active';
57
50
  var noEventTimeout = null;
58
51
 
59
- var endListener = function() {
52
+ var endListener = function(e) {
53
+ if (e && e.target !== node) {
54
+ return;
55
+ }
60
56
  if ("production" !== process.env.NODE_ENV) {
61
57
  clearTimeout(noEventTimeout);
62
58
  }
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @providesModule ReactChildren
17
10
  */
@@ -1,30 +1,23 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @providesModule ReactComponent
17
10
  */
18
11
 
19
12
  "use strict";
20
13
 
21
- var ReactDescriptor = require("./ReactDescriptor");
14
+ var ReactElement = require("./ReactElement");
22
15
  var ReactOwner = require("./ReactOwner");
23
16
  var ReactUpdates = require("./ReactUpdates");
24
17
 
18
+ var assign = require("./Object.assign");
25
19
  var invariant = require("./invariant");
26
20
  var keyMirror = require("./keyMirror");
27
- var merge = require("./merge");
28
21
 
29
22
  /**
30
23
  * Every React component is in one of these life cycles.
@@ -147,11 +140,11 @@ var ReactComponent = {
147
140
  * @public
148
141
  */
149
142
  setProps: function(partialProps, callback) {
150
- // Merge with the pending descriptor if it exists, otherwise with existing
151
- // descriptor props.
152
- var descriptor = this._pendingDescriptor || this._descriptor;
143
+ // Merge with the pending element if it exists, otherwise with existing
144
+ // element props.
145
+ var element = this._pendingElement || this._currentElement;
153
146
  this.replaceProps(
154
- merge(descriptor.props, partialProps),
147
+ assign({}, element.props, partialProps),
155
148
  callback
156
149
  );
157
150
  },
@@ -177,10 +170,10 @@ var ReactComponent = {
177
170
  '`render` method to pass the correct value as props to the component ' +
178
171
  'where it is created.'
179
172
  ) : invariant(this._mountDepth === 0));
180
- // This is a deoptimized path. We optimize for always having a descriptor.
181
- // This creates an extra internal descriptor.
182
- this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps(
183
- this._pendingDescriptor || this._descriptor,
173
+ // This is a deoptimized path. We optimize for always having a element.
174
+ // This creates an extra internal element.
175
+ this._pendingElement = ReactElement.cloneAndReplaceProps(
176
+ this._pendingElement || this._currentElement,
184
177
  props
185
178
  );
186
179
  ReactUpdates.enqueueUpdate(this, callback);
@@ -195,12 +188,12 @@ var ReactComponent = {
195
188
  * @internal
196
189
  */
197
190
  _setPropsInternal: function(partialProps, callback) {
198
- // This is a deoptimized path. We optimize for always having a descriptor.
199
- // This creates an extra internal descriptor.
200
- var descriptor = this._pendingDescriptor || this._descriptor;
201
- this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps(
202
- descriptor,
203
- merge(descriptor.props, partialProps)
191
+ // This is a deoptimized path. We optimize for always having a element.
192
+ // This creates an extra internal element.
193
+ var element = this._pendingElement || this._currentElement;
194
+ this._pendingElement = ReactElement.cloneAndReplaceProps(
195
+ element,
196
+ assign({}, element.props, partialProps)
204
197
  );
205
198
  ReactUpdates.enqueueUpdate(this, callback);
206
199
  },
@@ -211,19 +204,19 @@ var ReactComponent = {
211
204
  * Subclasses that override this method should make sure to invoke
212
205
  * `ReactComponent.Mixin.construct.call(this, ...)`.
213
206
  *
214
- * @param {ReactDescriptor} descriptor
207
+ * @param {ReactElement} element
215
208
  * @internal
216
209
  */
217
- construct: function(descriptor) {
210
+ construct: function(element) {
218
211
  // This is the public exposed props object after it has been processed
219
- // with default props. The descriptor's props represents the true internal
212
+ // with default props. The element's props represents the true internal
220
213
  // state of the props.
221
- this.props = descriptor.props;
214
+ this.props = element.props;
222
215
  // Record the component responsible for creating this component.
223
- // This is accessible through the descriptor but we maintain an extra
216
+ // This is accessible through the element but we maintain an extra
224
217
  // field for compatibility with devtools and as a way to make an
225
218
  // incremental update. TODO: Consider deprecating this field.
226
- this._owner = descriptor._owner;
219
+ this._owner = element._owner;
227
220
 
228
221
  // All components start unmounted.
229
222
  this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
@@ -231,10 +224,10 @@ var ReactComponent = {
231
224
  // See ReactUpdates.
232
225
  this._pendingCallbacks = null;
233
226
 
234
- // We keep the old descriptor and a reference to the pending descriptor
227
+ // We keep the old element and a reference to the pending element
235
228
  // to track updates.
236
- this._descriptor = descriptor;
237
- this._pendingDescriptor = null;
229
+ this._currentElement = element;
230
+ this._pendingElement = null;
238
231
  },
239
232
 
240
233
  /**
@@ -259,10 +252,10 @@ var ReactComponent = {
259
252
  'single component instance in multiple places.',
260
253
  rootID
261
254
  ) : invariant(!this.isMounted()));
262
- var props = this._descriptor.props;
263
- if (props.ref != null) {
264
- var owner = this._descriptor._owner;
265
- ReactOwner.addComponentAsRefTo(this, props.ref, owner);
255
+ var ref = this._currentElement.ref;
256
+ if (ref != null) {
257
+ var owner = this._currentElement._owner;
258
+ ReactOwner.addComponentAsRefTo(this, ref, owner);
266
259
  }
267
260
  this._rootNodeID = rootID;
268
261
  this._lifeCycleState = ComponentLifeCycle.MOUNTED;
@@ -285,9 +278,9 @@ var ReactComponent = {
285
278
  this.isMounted(),
286
279
  'unmountComponent(): Can only unmount a mounted component.'
287
280
  ) : invariant(this.isMounted()));
288
- var props = this.props;
289
- if (props.ref != null) {
290
- ReactOwner.removeComponentAsRefFrom(this, props.ref, this._owner);
281
+ var ref = this._currentElement.ref;
282
+ if (ref != null) {
283
+ ReactOwner.removeComponentAsRefFrom(this, ref, this._owner);
291
284
  }
292
285
  unmountIDFromEnvironment(this._rootNodeID);
293
286
  this._rootNodeID = null;
@@ -305,49 +298,49 @@ var ReactComponent = {
305
298
  * @param {ReactReconcileTransaction} transaction
306
299
  * @internal
307
300
  */
308
- receiveComponent: function(nextDescriptor, transaction) {
301
+ receiveComponent: function(nextElement, transaction) {
309
302
  ("production" !== process.env.NODE_ENV ? invariant(
310
303
  this.isMounted(),
311
304
  'receiveComponent(...): Can only update a mounted component.'
312
305
  ) : invariant(this.isMounted()));
313
- this._pendingDescriptor = nextDescriptor;
306
+ this._pendingElement = nextElement;
314
307
  this.performUpdateIfNecessary(transaction);
315
308
  },
316
309
 
317
310
  /**
318
- * If `_pendingDescriptor` is set, update the component.
311
+ * If `_pendingElement` is set, update the component.
319
312
  *
320
313
  * @param {ReactReconcileTransaction} transaction
321
314
  * @internal
322
315
  */
323
316
  performUpdateIfNecessary: function(transaction) {
324
- if (this._pendingDescriptor == null) {
317
+ if (this._pendingElement == null) {
325
318
  return;
326
319
  }
327
- var prevDescriptor = this._descriptor;
328
- var nextDescriptor = this._pendingDescriptor;
329
- this._descriptor = nextDescriptor;
330
- this.props = nextDescriptor.props;
331
- this._owner = nextDescriptor._owner;
332
- this._pendingDescriptor = null;
333
- this.updateComponent(transaction, prevDescriptor);
320
+ var prevElement = this._currentElement;
321
+ var nextElement = this._pendingElement;
322
+ this._currentElement = nextElement;
323
+ this.props = nextElement.props;
324
+ this._owner = nextElement._owner;
325
+ this._pendingElement = null;
326
+ this.updateComponent(transaction, prevElement);
334
327
  },
335
328
 
336
329
  /**
337
330
  * Updates the component's currently mounted representation.
338
331
  *
339
332
  * @param {ReactReconcileTransaction} transaction
340
- * @param {object} prevDescriptor
333
+ * @param {object} prevElement
341
334
  * @internal
342
335
  */
343
- updateComponent: function(transaction, prevDescriptor) {
344
- var nextDescriptor = this._descriptor;
336
+ updateComponent: function(transaction, prevElement) {
337
+ var nextElement = this._currentElement;
345
338
 
346
339
  // If either the owner or a `ref` has changed, make sure the newest owner
347
340
  // has stored a reference to `this`, and the previous owner (if different)
348
- // has forgotten the reference to `this`. We use the descriptor instead
341
+ // has forgotten the reference to `this`. We use the element instead
349
342
  // of the public this.props because the post processing cannot determine
350
- // a ref. The ref conceptually lives on the descriptor.
343
+ // a ref. The ref conceptually lives on the element.
351
344
 
352
345
  // TODO: Should this even be possible? The owner cannot change because
353
346
  // it's forbidden by shouldUpdateReactComponent. The ref can change
@@ -355,19 +348,19 @@ var ReactComponent = {
355
348
  // is made. It probably belongs where the key checking and
356
349
  // instantiateReactComponent is done.
357
350
 
358
- if (nextDescriptor._owner !== prevDescriptor._owner ||
359
- nextDescriptor.props.ref !== prevDescriptor.props.ref) {
360
- if (prevDescriptor.props.ref != null) {
351
+ if (nextElement._owner !== prevElement._owner ||
352
+ nextElement.ref !== prevElement.ref) {
353
+ if (prevElement.ref != null) {
361
354
  ReactOwner.removeComponentAsRefFrom(
362
- this, prevDescriptor.props.ref, prevDescriptor._owner
355
+ this, prevElement.ref, prevElement._owner
363
356
  );
364
357
  }
365
358
  // Correct, even if the owner is the same, and only the ref has changed.
366
- if (nextDescriptor.props.ref != null) {
359
+ if (nextElement.ref != null) {
367
360
  ReactOwner.addComponentAsRefTo(
368
361
  this,
369
- nextDescriptor.props.ref,
370
- nextDescriptor._owner
362
+ nextElement.ref,
363
+ nextElement._owner
371
364
  );
372
365
  }
373
366
  }
@@ -381,7 +374,7 @@ var ReactComponent = {
381
374
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
382
375
  * @final
383
376
  * @internal
384
- * @see {ReactMount.renderComponent}
377
+ * @see {ReactMount.render}
385
378
  */
386
379
  mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
387
380
  var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @providesModule ReactComponentBrowserEnvironment
17
10
  */
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @providesModule ReactComponentWithPureRenderMixin
17
10
  */
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
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.
15
8
  *
16
9
  * @providesModule ReactCompositeComponent
17
10
  */
@@ -21,10 +14,11 @@
21
14
  var ReactComponent = require("./ReactComponent");
22
15
  var ReactContext = require("./ReactContext");
23
16
  var ReactCurrentOwner = require("./ReactCurrentOwner");
24
- var ReactDescriptor = require("./ReactDescriptor");
25
- var ReactDescriptorValidator = require("./ReactDescriptorValidator");
17
+ var ReactElement = require("./ReactElement");
18
+ var ReactElementValidator = require("./ReactElementValidator");
26
19
  var ReactEmptyComponent = require("./ReactEmptyComponent");
27
20
  var ReactErrorUtils = require("./ReactErrorUtils");
21
+ var ReactLegacyElement = require("./ReactLegacyElement");
28
22
  var ReactOwner = require("./ReactOwner");
29
23
  var ReactPerf = require("./ReactPerf");
30
24
  var ReactPropTransferer = require("./ReactPropTransferer");
@@ -32,16 +26,18 @@ var ReactPropTypeLocations = require("./ReactPropTypeLocations");
32
26
  var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
33
27
  var ReactUpdates = require("./ReactUpdates");
34
28
 
29
+ var assign = require("./Object.assign");
35
30
  var instantiateReactComponent = require("./instantiateReactComponent");
36
31
  var invariant = require("./invariant");
37
32
  var keyMirror = require("./keyMirror");
38
- var merge = require("./merge");
39
- var mixInto = require("./mixInto");
33
+ var keyOf = require("./keyOf");
40
34
  var monitorCodeUse = require("./monitorCodeUse");
41
35
  var mapObject = require("./mapObject");
42
36
  var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
43
37
  var warning = require("./warning");
44
38
 
39
+ var MIXINS_KEY = keyOf({mixins: null});
40
+
45
41
  /**
46
42
  * Policies that describe methods in `ReactCompositeComponentInterface`.
47
43
  */
@@ -345,7 +341,8 @@ var RESERVED_SPEC_KEYS = {
345
341
  childContextTypes,
346
342
  ReactPropTypeLocations.childContext
347
343
  );
348
- Constructor.childContextTypes = merge(
344
+ Constructor.childContextTypes = assign(
345
+ {},
349
346
  Constructor.childContextTypes,
350
347
  childContextTypes
351
348
  );
@@ -356,7 +353,11 @@ var RESERVED_SPEC_KEYS = {
356
353
  contextTypes,
357
354
  ReactPropTypeLocations.context
358
355
  );
359
- Constructor.contextTypes = merge(Constructor.contextTypes, contextTypes);
356
+ Constructor.contextTypes = assign(
357
+ {},
358
+ Constructor.contextTypes,
359
+ contextTypes
360
+ );
360
361
  },
361
362
  /**
362
363
  * Special case getDefaultProps which should move into statics but requires
@@ -378,7 +379,11 @@ var RESERVED_SPEC_KEYS = {
378
379
  propTypes,
379
380
  ReactPropTypeLocations.prop
380
381
  );
381
- Constructor.propTypes = merge(Constructor.propTypes, propTypes);
382
+ Constructor.propTypes = assign(
383
+ {},
384
+ Constructor.propTypes,
385
+ propTypes
386
+ );
382
387
  },
383
388
  statics: function(Constructor, statics) {
384
389
  mixStaticSpecIntoComponent(Constructor, statics);
@@ -447,11 +452,12 @@ function validateLifeCycleOnReplaceState(instance) {
447
452
  'replaceState(...): Can only update a mounted or mounting component.'
448
453
  ) : invariant(instance.isMounted() ||
449
454
  compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
450
- ("production" !== process.env.NODE_ENV ? invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE,
455
+ ("production" !== process.env.NODE_ENV ? invariant(
456
+ ReactCurrentOwner.current == null,
451
457
  'replaceState(...): Cannot update during an existing state transition ' +
452
- '(such as within `render`). This could potentially cause an infinite ' +
453
- 'loop so it is forbidden.'
454
- ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE));
458
+ '(such as within `render`). Render methods should be a pure function ' +
459
+ 'of props and state.'
460
+ ) : invariant(ReactCurrentOwner.current == null));
455
461
  ("production" !== process.env.NODE_ENV ? invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
456
462
  'replaceState(...): Cannot update while unmounting component. This ' +
457
463
  'usually means you called setState() on an unmounted component.'
@@ -459,28 +465,45 @@ function validateLifeCycleOnReplaceState(instance) {
459
465
  }
460
466
 
461
467
  /**
462
- * Custom version of `mixInto` which handles policy validation and reserved
468
+ * Mixin helper which handles policy validation and reserved
463
469
  * specification keys when building `ReactCompositeComponent` classses.
464
470
  */
465
471
  function mixSpecIntoComponent(Constructor, spec) {
472
+ if (!spec) {
473
+ return;
474
+ }
475
+
466
476
  ("production" !== process.env.NODE_ENV ? invariant(
467
- !ReactDescriptor.isValidFactory(spec),
477
+ !ReactLegacyElement.isValidFactory(spec),
468
478
  'ReactCompositeComponent: You\'re attempting to ' +
469
479
  'use a component class as a mixin. Instead, just use a regular object.'
470
- ) : invariant(!ReactDescriptor.isValidFactory(spec)));
480
+ ) : invariant(!ReactLegacyElement.isValidFactory(spec)));
471
481
  ("production" !== process.env.NODE_ENV ? invariant(
472
- !ReactDescriptor.isValidDescriptor(spec),
482
+ !ReactElement.isValidElement(spec),
473
483
  'ReactCompositeComponent: You\'re attempting to ' +
474
484
  'use a component as a mixin. Instead, just use a regular object.'
475
- ) : invariant(!ReactDescriptor.isValidDescriptor(spec)));
485
+ ) : invariant(!ReactElement.isValidElement(spec)));
476
486
 
477
487
  var proto = Constructor.prototype;
488
+
489
+ // By handling mixins before any other properties, we ensure the same
490
+ // chaining order is applied to methods with DEFINE_MANY policy, whether
491
+ // mixins are listed before or after these methods in the spec.
492
+ if (spec.hasOwnProperty(MIXINS_KEY)) {
493
+ RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
494
+ }
495
+
478
496
  for (var name in spec) {
479
- var property = spec[name];
480
497
  if (!spec.hasOwnProperty(name)) {
481
498
  continue;
482
499
  }
483
500
 
501
+ if (name === MIXINS_KEY) {
502
+ // We have already handled mixins in a special case above
503
+ continue;
504
+ }
505
+
506
+ var property = spec[name];
484
507
  validateMethodOverride(proto, name);
485
508
 
486
509
  if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
@@ -558,23 +581,25 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
558
581
  continue;
559
582
  }
560
583
 
584
+ var isReserved = name in RESERVED_SPEC_KEYS;
585
+ ("production" !== process.env.NODE_ENV ? invariant(
586
+ !isReserved,
587
+ 'ReactCompositeComponent: You are attempting to define a reserved ' +
588
+ 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
589
+ 'as an instance property instead; it will still be accessible on the ' +
590
+ 'constructor.',
591
+ name
592
+ ) : invariant(!isReserved));
593
+
561
594
  var isInherited = name in Constructor;
562
- var result = property;
563
- if (isInherited) {
564
- var existingProperty = Constructor[name];
565
- var existingType = typeof existingProperty;
566
- var propertyType = typeof property;
567
- ("production" !== process.env.NODE_ENV ? invariant(
568
- existingType === 'function' && propertyType === 'function',
569
- 'ReactCompositeComponent: You are attempting to define ' +
570
- '`%s` on your component more than once, but that is only supported ' +
571
- 'for functions, which are chained together. This conflict may be ' +
572
- 'due to a mixin.',
573
- name
574
- ) : invariant(existingType === 'function' && propertyType === 'function'));
575
- result = createChainedFunction(existingProperty, property);
576
- }
577
- Constructor[name] = result;
595
+ ("production" !== process.env.NODE_ENV ? invariant(
596
+ !isInherited,
597
+ 'ReactCompositeComponent: You are attempting to define ' +
598
+ '`%s` on your component more than once. This conflict may be ' +
599
+ 'due to a mixin.',
600
+ name
601
+ ) : invariant(!isInherited));
602
+ Constructor[name] = property;
578
603
  }
579
604
  }
580
605
 
@@ -595,7 +620,10 @@ function mergeObjectsWithNoDuplicateKeys(one, two) {
595
620
  ("production" !== process.env.NODE_ENV ? invariant(
596
621
  one[key] === undefined,
597
622
  'mergeObjectsWithNoDuplicateKeys(): ' +
598
- 'Tried to merge two objects with the same key: %s',
623
+ 'Tried to merge two objects with the same key: `%s`. This conflict ' +
624
+ 'may be due to a mixin; in particular, this may be caused by two ' +
625
+ 'getInitialState() or getDefaultProps() methods returning objects ' +
626
+ 'with clashing keys.',
599
627
  key
600
628
  ) : invariant(one[key] === undefined));
601
629
  one[key] = value;
@@ -651,19 +679,19 @@ function createChainedFunction(one, two) {
651
679
  * Top Row: ReactComponent.ComponentLifeCycle
652
680
  * Low Row: ReactComponent.CompositeLifeCycle
653
681
  *
654
- * +-------+------------------------------------------------------+--------+
655
- * | UN | MOUNTED | UN |
656
- * |MOUNTED| | MOUNTED|
657
- * +-------+------------------------------------------------------+--------+
658
- * | ^--------+ +------+ +------+ +------+ +--------^ |
659
- * | | | | | | | | | | | |
660
- * | 0--|MOUNTING|-0-|RECEIV|-0-|RECEIV|-0-|RECEIV|-0-| UN |--->0 |
661
- * | | | |PROPS | | PROPS| | STATE| |MOUNTING| |
662
- * | | | | | | | | | | | |
663
- * | | | | | | | | | | | |
664
- * | +--------+ +------+ +------+ +------+ +--------+ |
665
- * | | | |
666
- * +-------+------------------------------------------------------+--------+
682
+ * +-------+---------------------------------+--------+
683
+ * | UN | MOUNTED | UN |
684
+ * |MOUNTED| | MOUNTED|
685
+ * +-------+---------------------------------+--------+
686
+ * | ^--------+ +-------+ +--------^ |
687
+ * | | | | | | | |
688
+ * | 0--|MOUNTING|-0-|RECEIVE|-0-| UN |--->0 |
689
+ * | | | |PROPS | |MOUNTING| |
690
+ * | | | | | | | |
691
+ * | | | | | | | |
692
+ * | +--------+ +-------+ +--------+ |
693
+ * | | | |
694
+ * +-------+---------------------------------+--------+
667
695
  */
668
696
  var CompositeLifeCycle = keyMirror({
669
697
  /**
@@ -680,12 +708,7 @@ var CompositeLifeCycle = keyMirror({
680
708
  * Components that are mounted and receiving new props respond to state
681
709
  * changes differently.
682
710
  */
683
- RECEIVING_PROPS: null,
684
- /**
685
- * Components that are mounted and receiving new state are guarded against
686
- * additional state changes.
687
- */
688
- RECEIVING_STATE: null
711
+ RECEIVING_PROPS: null
689
712
  });
690
713
 
691
714
  /**
@@ -696,11 +719,11 @@ var ReactCompositeComponentMixin = {
696
719
  /**
697
720
  * Base constructor for all composite component.
698
721
  *
699
- * @param {ReactDescriptor} descriptor
722
+ * @param {ReactElement} element
700
723
  * @final
701
724
  * @internal
702
725
  */
703
- construct: function(descriptor) {
726
+ construct: function(element) {
704
727
  // Children can be either an array or more than one argument
705
728
  ReactComponent.Mixin.construct.apply(this, arguments);
706
729
  ReactOwner.Mixin.construct.apply(this, arguments);
@@ -709,7 +732,7 @@ var ReactCompositeComponentMixin = {
709
732
  this._pendingState = null;
710
733
 
711
734
  // This is the public post-processed context. The real context and pending
712
- // context lives on the descriptor.
735
+ // context lives on the element.
713
736
  this.context = null;
714
737
 
715
738
  this._compositeLifeCycleState = null;
@@ -752,7 +775,7 @@ var ReactCompositeComponentMixin = {
752
775
  this._bindAutoBindMethods();
753
776
  }
754
777
 
755
- this.context = this._processContext(this._descriptor._context);
778
+ this.context = this._processContext(this._currentElement._context);
756
779
  this.props = this._processProps(this.props);
757
780
 
758
781
  this.state = this.getInitialState ? this.getInitialState() : null;
@@ -776,7 +799,8 @@ var ReactCompositeComponentMixin = {
776
799
  }
777
800
 
778
801
  this._renderedComponent = instantiateReactComponent(
779
- this._renderValidatedComponent()
802
+ this._renderValidatedComponent(),
803
+ this._currentElement.type // The wrapping type
780
804
  );
781
805
 
782
806
  // Done with mounting, `setState` will now trigger UI changes.
@@ -848,7 +872,7 @@ var ReactCompositeComponentMixin = {
848
872
  }
849
873
  // Merge with `_pendingState` if it exists, otherwise with existing state.
850
874
  this.replaceState(
851
- merge(this._pendingState || this.state, partialState),
875
+ assign({}, this._pendingState || this.state, partialState),
852
876
  callback
853
877
  );
854
878
  },
@@ -868,7 +892,15 @@ var ReactCompositeComponentMixin = {
868
892
  replaceState: function(completeState, callback) {
869
893
  validateLifeCycleOnReplaceState(this);
870
894
  this._pendingState = completeState;
871
- ReactUpdates.enqueueUpdate(this, callback);
895
+ if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) {
896
+ // If we're in a componentWillMount handler, don't enqueue a rerender
897
+ // because ReactUpdates assumes we're in a browser context (which is wrong
898
+ // for server rendering) and we're about to do a render anyway.
899
+ // TODO: The callback here is ignored when setState is called from
900
+ // componentWillMount. Either fix it or disallow doing so completely in
901
+ // favor of getInitialState.
902
+ ReactUpdates.enqueueUpdate(this, callback);
903
+ }
872
904
  },
873
905
 
874
906
  /**
@@ -928,7 +960,7 @@ var ReactCompositeComponentMixin = {
928
960
  name
929
961
  ) : invariant(name in this.constructor.childContextTypes));
930
962
  }
931
- return merge(currentContext, childContext);
963
+ return assign({}, currentContext, childContext);
932
964
  }
933
965
  return currentContext;
934
966
  },
@@ -943,25 +975,13 @@ var ReactCompositeComponentMixin = {
943
975
  * @private
944
976
  */
945
977
  _processProps: function(newProps) {
946
- var defaultProps = this.constructor.defaultProps;
947
- var props;
948
- if (defaultProps) {
949
- props = merge(newProps);
950
- for (var propName in defaultProps) {
951
- if (typeof props[propName] === 'undefined') {
952
- props[propName] = defaultProps[propName];
953
- }
954
- }
955
- } else {
956
- props = newProps;
957
- }
958
978
  if ("production" !== process.env.NODE_ENV) {
959
979
  var propTypes = this.constructor.propTypes;
960
980
  if (propTypes) {
961
- this._checkPropTypes(propTypes, props, ReactPropTypeLocations.prop);
981
+ this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
962
982
  }
963
983
  }
964
- return props;
984
+ return newProps;
965
985
  },
966
986
 
967
987
  /**
@@ -973,7 +993,7 @@ var ReactCompositeComponentMixin = {
973
993
  * @private
974
994
  */
975
995
  _checkPropTypes: function(propTypes, props, location) {
976
- // TODO: Stop validating prop types here and only use the descriptor
996
+ // TODO: Stop validating prop types here and only use the element
977
997
  // validation.
978
998
  var componentName = this.constructor.displayName;
979
999
  for (var propName in propTypes) {
@@ -992,7 +1012,7 @@ var ReactCompositeComponentMixin = {
992
1012
  },
993
1013
 
994
1014
  /**
995
- * If any of `_pendingDescriptor`, `_pendingState`, or `_pendingForceUpdate`
1015
+ * If any of `_pendingElement`, `_pendingState`, or `_pendingForceUpdate`
996
1016
  * is set, update the component.
997
1017
  *
998
1018
  * @param {ReactReconcileTransaction} transaction
@@ -1007,7 +1027,7 @@ var ReactCompositeComponentMixin = {
1007
1027
  return;
1008
1028
  }
1009
1029
 
1010
- if (this._pendingDescriptor == null &&
1030
+ if (this._pendingElement == null &&
1011
1031
  this._pendingState == null &&
1012
1032
  !this._pendingForceUpdate) {
1013
1033
  return;
@@ -1015,12 +1035,12 @@ var ReactCompositeComponentMixin = {
1015
1035
 
1016
1036
  var nextContext = this.context;
1017
1037
  var nextProps = this.props;
1018
- var nextDescriptor = this._descriptor;
1019
- if (this._pendingDescriptor != null) {
1020
- nextDescriptor = this._pendingDescriptor;
1021
- nextContext = this._processContext(nextDescriptor._context);
1022
- nextProps = this._processProps(nextDescriptor.props);
1023
- this._pendingDescriptor = null;
1038
+ var nextElement = this._currentElement;
1039
+ if (this._pendingElement != null) {
1040
+ nextElement = this._pendingElement;
1041
+ nextContext = this._processContext(nextElement._context);
1042
+ nextProps = this._processProps(nextElement.props);
1043
+ this._pendingElement = null;
1024
1044
 
1025
1045
  this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
1026
1046
  if (this.componentWillReceiveProps) {
@@ -1028,51 +1048,47 @@ var ReactCompositeComponentMixin = {
1028
1048
  }
1029
1049
  }
1030
1050
 
1031
- this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_STATE;
1051
+ this._compositeLifeCycleState = null;
1032
1052
 
1033
1053
  var nextState = this._pendingState || this.state;
1034
1054
  this._pendingState = null;
1035
1055
 
1036
- try {
1037
- var shouldUpdate =
1038
- this._pendingForceUpdate ||
1039
- !this.shouldComponentUpdate ||
1040
- this.shouldComponentUpdate(nextProps, nextState, nextContext);
1056
+ var shouldUpdate =
1057
+ this._pendingForceUpdate ||
1058
+ !this.shouldComponentUpdate ||
1059
+ this.shouldComponentUpdate(nextProps, nextState, nextContext);
1041
1060
 
1042
- if ("production" !== process.env.NODE_ENV) {
1043
- if (typeof shouldUpdate === "undefined") {
1044
- console.warn(
1045
- (this.constructor.displayName || 'ReactCompositeComponent') +
1046
- '.shouldComponentUpdate(): Returned undefined instead of a ' +
1047
- 'boolean value. Make sure to return true or false.'
1048
- );
1049
- }
1050
- }
1051
-
1052
- if (shouldUpdate) {
1053
- this._pendingForceUpdate = false;
1054
- // Will set `this.props`, `this.state` and `this.context`.
1055
- this._performComponentUpdate(
1056
- nextDescriptor,
1057
- nextProps,
1058
- nextState,
1059
- nextContext,
1060
- transaction
1061
+ if ("production" !== process.env.NODE_ENV) {
1062
+ if (typeof shouldUpdate === "undefined") {
1063
+ console.warn(
1064
+ (this.constructor.displayName || 'ReactCompositeComponent') +
1065
+ '.shouldComponentUpdate(): Returned undefined instead of a ' +
1066
+ 'boolean value. Make sure to return true or false.'
1061
1067
  );
1062
- } else {
1063
- // If it's determined that a component should not update, we still want
1064
- // to set props and state.
1065
- this._descriptor = nextDescriptor;
1066
- this.props = nextProps;
1067
- this.state = nextState;
1068
- this.context = nextContext;
1069
-
1070
- // Owner cannot change because shouldUpdateReactComponent doesn't allow
1071
- // it. TODO: Remove this._owner completely.
1072
- this._owner = nextDescriptor._owner;
1073
1068
  }
1074
- } finally {
1075
- this._compositeLifeCycleState = null;
1069
+ }
1070
+
1071
+ if (shouldUpdate) {
1072
+ this._pendingForceUpdate = false;
1073
+ // Will set `this.props`, `this.state` and `this.context`.
1074
+ this._performComponentUpdate(
1075
+ nextElement,
1076
+ nextProps,
1077
+ nextState,
1078
+ nextContext,
1079
+ transaction
1080
+ );
1081
+ } else {
1082
+ // If it's determined that a component should not update, we still want
1083
+ // to set props and state.
1084
+ this._currentElement = nextElement;
1085
+ this.props = nextProps;
1086
+ this.state = nextState;
1087
+ this.context = nextContext;
1088
+
1089
+ // Owner cannot change because shouldUpdateReactComponent doesn't allow
1090
+ // it. TODO: Remove this._owner completely.
1091
+ this._owner = nextElement._owner;
1076
1092
  }
1077
1093
  },
1078
1094
 
@@ -1080,7 +1096,7 @@ var ReactCompositeComponentMixin = {
1080
1096
  * Merges new props and state, notifies delegate methods of update and
1081
1097
  * performs update.
1082
1098
  *
1083
- * @param {ReactDescriptor} nextDescriptor Next descriptor
1099
+ * @param {ReactElement} nextElement Next element
1084
1100
  * @param {object} nextProps Next public object to set as properties.
1085
1101
  * @param {?object} nextState Next object to set as state.
1086
1102
  * @param {?object} nextContext Next public object to set as context.
@@ -1088,13 +1104,13 @@ var ReactCompositeComponentMixin = {
1088
1104
  * @private
1089
1105
  */
1090
1106
  _performComponentUpdate: function(
1091
- nextDescriptor,
1107
+ nextElement,
1092
1108
  nextProps,
1093
1109
  nextState,
1094
1110
  nextContext,
1095
1111
  transaction
1096
1112
  ) {
1097
- var prevDescriptor = this._descriptor;
1113
+ var prevElement = this._currentElement;
1098
1114
  var prevProps = this.props;
1099
1115
  var prevState = this.state;
1100
1116
  var prevContext = this.context;
@@ -1103,18 +1119,18 @@ var ReactCompositeComponentMixin = {
1103
1119
  this.componentWillUpdate(nextProps, nextState, nextContext);
1104
1120
  }
1105
1121
 
1106
- this._descriptor = nextDescriptor;
1122
+ this._currentElement = nextElement;
1107
1123
  this.props = nextProps;
1108
1124
  this.state = nextState;
1109
1125
  this.context = nextContext;
1110
1126
 
1111
1127
  // Owner cannot change because shouldUpdateReactComponent doesn't allow
1112
1128
  // it. TODO: Remove this._owner completely.
1113
- this._owner = nextDescriptor._owner;
1129
+ this._owner = nextElement._owner;
1114
1130
 
1115
1131
  this.updateComponent(
1116
1132
  transaction,
1117
- prevDescriptor
1133
+ prevElement
1118
1134
  );
1119
1135
 
1120
1136
  if (this.componentDidUpdate) {
@@ -1125,22 +1141,22 @@ var ReactCompositeComponentMixin = {
1125
1141
  }
1126
1142
  },
1127
1143
 
1128
- receiveComponent: function(nextDescriptor, transaction) {
1129
- if (nextDescriptor === this._descriptor &&
1130
- nextDescriptor._owner != null) {
1131
- // Since descriptors are immutable after the owner is rendered,
1144
+ receiveComponent: function(nextElement, transaction) {
1145
+ if (nextElement === this._currentElement &&
1146
+ nextElement._owner != null) {
1147
+ // Since elements are immutable after the owner is rendered,
1132
1148
  // we can do a cheap identity compare here to determine if this is a
1133
1149
  // superfluous reconcile. It's possible for state to be mutable but such
1134
1150
  // change should trigger an update of the owner which would recreate
1135
- // the descriptor. We explicitly check for the existence of an owner since
1136
- // it's possible for a descriptor created outside a composite to be
1151
+ // the element. We explicitly check for the existence of an owner since
1152
+ // it's possible for a element created outside a composite to be
1137
1153
  // deeply mutated and reused.
1138
1154
  return;
1139
1155
  }
1140
1156
 
1141
1157
  ReactComponent.Mixin.receiveComponent.call(
1142
1158
  this,
1143
- nextDescriptor,
1159
+ nextElement,
1144
1160
  transaction
1145
1161
  );
1146
1162
  },
@@ -1152,31 +1168,34 @@ var ReactCompositeComponentMixin = {
1152
1168
  * Sophisticated clients may wish to override this.
1153
1169
  *
1154
1170
  * @param {ReactReconcileTransaction} transaction
1155
- * @param {ReactDescriptor} prevDescriptor
1171
+ * @param {ReactElement} prevElement
1156
1172
  * @internal
1157
1173
  * @overridable
1158
1174
  */
1159
1175
  updateComponent: ReactPerf.measure(
1160
1176
  'ReactCompositeComponent',
1161
1177
  'updateComponent',
1162
- function(transaction, prevParentDescriptor) {
1178
+ function(transaction, prevParentElement) {
1163
1179
  ReactComponent.Mixin.updateComponent.call(
1164
1180
  this,
1165
1181
  transaction,
1166
- prevParentDescriptor
1182
+ prevParentElement
1167
1183
  );
1168
1184
 
1169
1185
  var prevComponentInstance = this._renderedComponent;
1170
- var prevDescriptor = prevComponentInstance._descriptor;
1171
- var nextDescriptor = this._renderValidatedComponent();
1172
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
1173
- prevComponentInstance.receiveComponent(nextDescriptor, transaction);
1186
+ var prevElement = prevComponentInstance._currentElement;
1187
+ var nextElement = this._renderValidatedComponent();
1188
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
1189
+ prevComponentInstance.receiveComponent(nextElement, transaction);
1174
1190
  } else {
1175
1191
  // These two IDs are actually the same! But nothing should rely on that.
1176
1192
  var thisID = this._rootNodeID;
1177
1193
  var prevComponentID = prevComponentInstance._rootNodeID;
1178
1194
  prevComponentInstance.unmountComponent();
1179
- this._renderedComponent = instantiateReactComponent(nextDescriptor);
1195
+ this._renderedComponent = instantiateReactComponent(
1196
+ nextElement,
1197
+ this._currentElement.type
1198
+ );
1180
1199
  var nextMarkup = this._renderedComponent.mountComponent(
1181
1200
  thisID,
1182
1201
  transaction,
@@ -1214,12 +1233,12 @@ var ReactCompositeComponentMixin = {
1214
1233
  ) : invariant(this.isMounted() ||
1215
1234
  compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
1216
1235
  ("production" !== process.env.NODE_ENV ? invariant(
1217
- compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
1218
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
1236
+ compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
1237
+ ReactCurrentOwner.current == null,
1219
1238
  'forceUpdate(...): Cannot force an update while unmounting component ' +
1220
- 'or during an existing state transition (such as within `render`).'
1221
- ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
1222
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
1239
+ 'or within a `render` function.'
1240
+ ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
1241
+ ReactCurrentOwner.current == null));
1223
1242
  this._pendingForceUpdate = true;
1224
1243
  ReactUpdates.enqueueUpdate(this, callback);
1225
1244
  },
@@ -1234,7 +1253,7 @@ var ReactCompositeComponentMixin = {
1234
1253
  var renderedComponent;
1235
1254
  var previousContext = ReactContext.current;
1236
1255
  ReactContext.current = this._processChildContext(
1237
- this._descriptor._context
1256
+ this._currentElement._context
1238
1257
  );
1239
1258
  ReactCurrentOwner.current = this;
1240
1259
  try {
@@ -1250,11 +1269,11 @@ var ReactCompositeComponentMixin = {
1250
1269
  ReactCurrentOwner.current = null;
1251
1270
  }
1252
1271
  ("production" !== process.env.NODE_ENV ? invariant(
1253
- ReactDescriptor.isValidDescriptor(renderedComponent),
1272
+ ReactElement.isValidElement(renderedComponent),
1254
1273
  '%s.render(): A valid ReactComponent must be returned. You may have ' +
1255
1274
  'returned undefined, an array or some other invalid object.',
1256
1275
  this.constructor.displayName || 'ReactCompositeComponent'
1257
- ) : invariant(ReactDescriptor.isValidDescriptor(renderedComponent)));
1276
+ ) : invariant(ReactElement.isValidElement(renderedComponent)));
1258
1277
  return renderedComponent;
1259
1278
  }
1260
1279
  ),
@@ -1283,9 +1302,7 @@ var ReactCompositeComponentMixin = {
1283
1302
  */
1284
1303
  _bindAutoBindMethod: function(method) {
1285
1304
  var component = this;
1286
- var boundMethod = function() {
1287
- return method.apply(component, arguments);
1288
- };
1305
+ var boundMethod = method.bind(component);
1289
1306
  if ("production" !== process.env.NODE_ENV) {
1290
1307
  boundMethod.__reactBoundContext = component;
1291
1308
  boundMethod.__reactBoundMethod = method;
@@ -1323,10 +1340,13 @@ var ReactCompositeComponentMixin = {
1323
1340
  };
1324
1341
 
1325
1342
  var ReactCompositeComponentBase = function() {};
1326
- mixInto(ReactCompositeComponentBase, ReactComponent.Mixin);
1327
- mixInto(ReactCompositeComponentBase, ReactOwner.Mixin);
1328
- mixInto(ReactCompositeComponentBase, ReactPropTransferer.Mixin);
1329
- mixInto(ReactCompositeComponentBase, ReactCompositeComponentMixin);
1343
+ assign(
1344
+ ReactCompositeComponentBase.prototype,
1345
+ ReactComponent.Mixin,
1346
+ ReactOwner.Mixin,
1347
+ ReactPropTransferer.Mixin,
1348
+ ReactCompositeComponentMixin
1349
+ );
1330
1350
 
1331
1351
  /**
1332
1352
  * Module for creating composite components.
@@ -1350,8 +1370,10 @@ var ReactCompositeComponent = {
1350
1370
  * @public
1351
1371
  */
1352
1372
  createClass: function(spec) {
1353
- var Constructor = function(props, owner) {
1354
- this.construct(props, owner);
1373
+ var Constructor = function(props) {
1374
+ // This constructor is overridden by mocks. The argument is used
1375
+ // by mocks to assert on what gets mounted. This will later be used
1376
+ // by the stand-alone class implementation.
1355
1377
  };
1356
1378
  Constructor.prototype = new ReactCompositeComponentBase();
1357
1379
  Constructor.prototype.constructor = Constructor;
@@ -1394,17 +1416,14 @@ var ReactCompositeComponent = {
1394
1416
  }
1395
1417
  }
1396
1418
 
1397
- var descriptorFactory = ReactDescriptor.createFactory(Constructor);
1398
-
1399
1419
  if ("production" !== process.env.NODE_ENV) {
1400
- return ReactDescriptorValidator.createFactory(
1401
- descriptorFactory,
1402
- Constructor.propTypes,
1403
- Constructor.contextTypes
1420
+ return ReactLegacyElement.wrapFactory(
1421
+ ReactElementValidator.createFactory(Constructor)
1404
1422
  );
1405
1423
  }
1406
-
1407
- return descriptorFactory;
1424
+ return ReactLegacyElement.wrapFactory(
1425
+ ReactElement.createFactory(Constructor)
1426
+ );
1408
1427
  },
1409
1428
 
1410
1429
  injection: {