react 0.11.2 → 0.12.2

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 +2714 -7859
  2. package/dist/react-with-addons.js +3139 -3593
  3. package/dist/react-with-addons.min.js +11 -17
  4. package/dist/react.js +2940 -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 +10 -14
  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 +16 -15
  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 +87 -54
  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 +191 -180
  45. package/lib/ReactContext.js +8 -15
  46. package/lib/ReactCurrentOwner.js +5 -12
  47. package/lib/ReactDOM.js +145 -177
  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 +14 -17
  61. package/lib/ReactDefaultPerfAnalysis.js +18 -17
  62. package/lib/ReactElement.js +242 -0
  63. package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
  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 +5 -12
  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 +4 -11
  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 +10 -19
  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 +6 -13
  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 ReactCSSTransitionGroup
@@ -21,8 +14,14 @@
21
14
 
22
15
  var React = require("./React");
23
16
 
24
- var ReactTransitionGroup = require("./ReactTransitionGroup");
25
- var ReactCSSTransitionGroupChild = require("./ReactCSSTransitionGroupChild");
17
+ var assign = require("./Object.assign");
18
+
19
+ var ReactTransitionGroup = React.createFactory(
20
+ require("./ReactTransitionGroup")
21
+ );
22
+ var ReactCSSTransitionGroupChild = React.createFactory(
23
+ require("./ReactCSSTransitionGroupChild")
24
+ );
26
25
 
27
26
  var ReactCSSTransitionGroup = React.createClass({
28
27
  displayName: 'ReactCSSTransitionGroup',
@@ -55,10 +54,9 @@ var ReactCSSTransitionGroup = React.createClass({
55
54
  },
56
55
 
57
56
  render: function() {
58
- return this.transferPropsTo(
57
+ return (
59
58
  ReactTransitionGroup(
60
- {childFactory: this._wrapChild},
61
- this.props.children
59
+ assign({}, this.props, {childFactory: this._wrapChild})
62
60
  )
63
61
  );
64
62
  }
@@ -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
  },
@@ -936,7 +960,7 @@ var ReactCompositeComponentMixin = {
936
960
  name
937
961
  ) : invariant(name in this.constructor.childContextTypes));
938
962
  }
939
- return merge(currentContext, childContext);
963
+ return assign({}, currentContext, childContext);
940
964
  }
941
965
  return currentContext;
942
966
  },
@@ -951,25 +975,13 @@ var ReactCompositeComponentMixin = {
951
975
  * @private
952
976
  */
953
977
  _processProps: function(newProps) {
954
- var defaultProps = this.constructor.defaultProps;
955
- var props;
956
- if (defaultProps) {
957
- props = merge(newProps);
958
- for (var propName in defaultProps) {
959
- if (typeof props[propName] === 'undefined') {
960
- props[propName] = defaultProps[propName];
961
- }
962
- }
963
- } else {
964
- props = newProps;
965
- }
966
978
  if ("production" !== process.env.NODE_ENV) {
967
979
  var propTypes = this.constructor.propTypes;
968
980
  if (propTypes) {
969
- this._checkPropTypes(propTypes, props, ReactPropTypeLocations.prop);
981
+ this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
970
982
  }
971
983
  }
972
- return props;
984
+ return newProps;
973
985
  },
974
986
 
975
987
  /**
@@ -981,7 +993,7 @@ var ReactCompositeComponentMixin = {
981
993
  * @private
982
994
  */
983
995
  _checkPropTypes: function(propTypes, props, location) {
984
- // TODO: Stop validating prop types here and only use the descriptor
996
+ // TODO: Stop validating prop types here and only use the element
985
997
  // validation.
986
998
  var componentName = this.constructor.displayName;
987
999
  for (var propName in propTypes) {
@@ -1000,7 +1012,7 @@ var ReactCompositeComponentMixin = {
1000
1012
  },
1001
1013
 
1002
1014
  /**
1003
- * If any of `_pendingDescriptor`, `_pendingState`, or `_pendingForceUpdate`
1015
+ * If any of `_pendingElement`, `_pendingState`, or `_pendingForceUpdate`
1004
1016
  * is set, update the component.
1005
1017
  *
1006
1018
  * @param {ReactReconcileTransaction} transaction
@@ -1015,7 +1027,7 @@ var ReactCompositeComponentMixin = {
1015
1027
  return;
1016
1028
  }
1017
1029
 
1018
- if (this._pendingDescriptor == null &&
1030
+ if (this._pendingElement == null &&
1019
1031
  this._pendingState == null &&
1020
1032
  !this._pendingForceUpdate) {
1021
1033
  return;
@@ -1023,12 +1035,12 @@ var ReactCompositeComponentMixin = {
1023
1035
 
1024
1036
  var nextContext = this.context;
1025
1037
  var nextProps = this.props;
1026
- var nextDescriptor = this._descriptor;
1027
- if (this._pendingDescriptor != null) {
1028
- nextDescriptor = this._pendingDescriptor;
1029
- nextContext = this._processContext(nextDescriptor._context);
1030
- nextProps = this._processProps(nextDescriptor.props);
1031
- 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;
1032
1044
 
1033
1045
  this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
1034
1046
  if (this.componentWillReceiveProps) {
@@ -1036,51 +1048,47 @@ var ReactCompositeComponentMixin = {
1036
1048
  }
1037
1049
  }
1038
1050
 
1039
- this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_STATE;
1051
+ this._compositeLifeCycleState = null;
1040
1052
 
1041
1053
  var nextState = this._pendingState || this.state;
1042
1054
  this._pendingState = null;
1043
1055
 
1044
- try {
1045
- var shouldUpdate =
1046
- this._pendingForceUpdate ||
1047
- !this.shouldComponentUpdate ||
1048
- this.shouldComponentUpdate(nextProps, nextState, nextContext);
1056
+ var shouldUpdate =
1057
+ this._pendingForceUpdate ||
1058
+ !this.shouldComponentUpdate ||
1059
+ this.shouldComponentUpdate(nextProps, nextState, nextContext);
1049
1060
 
1050
- if ("production" !== process.env.NODE_ENV) {
1051
- if (typeof shouldUpdate === "undefined") {
1052
- console.warn(
1053
- (this.constructor.displayName || 'ReactCompositeComponent') +
1054
- '.shouldComponentUpdate(): Returned undefined instead of a ' +
1055
- 'boolean value. Make sure to return true or false.'
1056
- );
1057
- }
1058
- }
1059
-
1060
- if (shouldUpdate) {
1061
- this._pendingForceUpdate = false;
1062
- // Will set `this.props`, `this.state` and `this.context`.
1063
- this._performComponentUpdate(
1064
- nextDescriptor,
1065
- nextProps,
1066
- nextState,
1067
- nextContext,
1068
- 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.'
1069
1067
  );
1070
- } else {
1071
- // If it's determined that a component should not update, we still want
1072
- // to set props and state.
1073
- this._descriptor = nextDescriptor;
1074
- this.props = nextProps;
1075
- this.state = nextState;
1076
- this.context = nextContext;
1077
-
1078
- // Owner cannot change because shouldUpdateReactComponent doesn't allow
1079
- // it. TODO: Remove this._owner completely.
1080
- this._owner = nextDescriptor._owner;
1081
1068
  }
1082
- } finally {
1083
- 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;
1084
1092
  }
1085
1093
  },
1086
1094
 
@@ -1088,7 +1096,7 @@ var ReactCompositeComponentMixin = {
1088
1096
  * Merges new props and state, notifies delegate methods of update and
1089
1097
  * performs update.
1090
1098
  *
1091
- * @param {ReactDescriptor} nextDescriptor Next descriptor
1099
+ * @param {ReactElement} nextElement Next element
1092
1100
  * @param {object} nextProps Next public object to set as properties.
1093
1101
  * @param {?object} nextState Next object to set as state.
1094
1102
  * @param {?object} nextContext Next public object to set as context.
@@ -1096,13 +1104,13 @@ var ReactCompositeComponentMixin = {
1096
1104
  * @private
1097
1105
  */
1098
1106
  _performComponentUpdate: function(
1099
- nextDescriptor,
1107
+ nextElement,
1100
1108
  nextProps,
1101
1109
  nextState,
1102
1110
  nextContext,
1103
1111
  transaction
1104
1112
  ) {
1105
- var prevDescriptor = this._descriptor;
1113
+ var prevElement = this._currentElement;
1106
1114
  var prevProps = this.props;
1107
1115
  var prevState = this.state;
1108
1116
  var prevContext = this.context;
@@ -1111,18 +1119,18 @@ var ReactCompositeComponentMixin = {
1111
1119
  this.componentWillUpdate(nextProps, nextState, nextContext);
1112
1120
  }
1113
1121
 
1114
- this._descriptor = nextDescriptor;
1122
+ this._currentElement = nextElement;
1115
1123
  this.props = nextProps;
1116
1124
  this.state = nextState;
1117
1125
  this.context = nextContext;
1118
1126
 
1119
1127
  // Owner cannot change because shouldUpdateReactComponent doesn't allow
1120
1128
  // it. TODO: Remove this._owner completely.
1121
- this._owner = nextDescriptor._owner;
1129
+ this._owner = nextElement._owner;
1122
1130
 
1123
1131
  this.updateComponent(
1124
1132
  transaction,
1125
- prevDescriptor
1133
+ prevElement
1126
1134
  );
1127
1135
 
1128
1136
  if (this.componentDidUpdate) {
@@ -1133,22 +1141,22 @@ var ReactCompositeComponentMixin = {
1133
1141
  }
1134
1142
  },
1135
1143
 
1136
- receiveComponent: function(nextDescriptor, transaction) {
1137
- if (nextDescriptor === this._descriptor &&
1138
- nextDescriptor._owner != null) {
1139
- // 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,
1140
1148
  // we can do a cheap identity compare here to determine if this is a
1141
1149
  // superfluous reconcile. It's possible for state to be mutable but such
1142
1150
  // change should trigger an update of the owner which would recreate
1143
- // the descriptor. We explicitly check for the existence of an owner since
1144
- // 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
1145
1153
  // deeply mutated and reused.
1146
1154
  return;
1147
1155
  }
1148
1156
 
1149
1157
  ReactComponent.Mixin.receiveComponent.call(
1150
1158
  this,
1151
- nextDescriptor,
1159
+ nextElement,
1152
1160
  transaction
1153
1161
  );
1154
1162
  },
@@ -1160,31 +1168,34 @@ var ReactCompositeComponentMixin = {
1160
1168
  * Sophisticated clients may wish to override this.
1161
1169
  *
1162
1170
  * @param {ReactReconcileTransaction} transaction
1163
- * @param {ReactDescriptor} prevDescriptor
1171
+ * @param {ReactElement} prevElement
1164
1172
  * @internal
1165
1173
  * @overridable
1166
1174
  */
1167
1175
  updateComponent: ReactPerf.measure(
1168
1176
  'ReactCompositeComponent',
1169
1177
  'updateComponent',
1170
- function(transaction, prevParentDescriptor) {
1178
+ function(transaction, prevParentElement) {
1171
1179
  ReactComponent.Mixin.updateComponent.call(
1172
1180
  this,
1173
1181
  transaction,
1174
- prevParentDescriptor
1182
+ prevParentElement
1175
1183
  );
1176
1184
 
1177
1185
  var prevComponentInstance = this._renderedComponent;
1178
- var prevDescriptor = prevComponentInstance._descriptor;
1179
- var nextDescriptor = this._renderValidatedComponent();
1180
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
1181
- prevComponentInstance.receiveComponent(nextDescriptor, transaction);
1186
+ var prevElement = prevComponentInstance._currentElement;
1187
+ var nextElement = this._renderValidatedComponent();
1188
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
1189
+ prevComponentInstance.receiveComponent(nextElement, transaction);
1182
1190
  } else {
1183
1191
  // These two IDs are actually the same! But nothing should rely on that.
1184
1192
  var thisID = this._rootNodeID;
1185
1193
  var prevComponentID = prevComponentInstance._rootNodeID;
1186
1194
  prevComponentInstance.unmountComponent();
1187
- this._renderedComponent = instantiateReactComponent(nextDescriptor);
1195
+ this._renderedComponent = instantiateReactComponent(
1196
+ nextElement,
1197
+ this._currentElement.type
1198
+ );
1188
1199
  var nextMarkup = this._renderedComponent.mountComponent(
1189
1200
  thisID,
1190
1201
  transaction,
@@ -1222,12 +1233,12 @@ var ReactCompositeComponentMixin = {
1222
1233
  ) : invariant(this.isMounted() ||
1223
1234
  compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
1224
1235
  ("production" !== process.env.NODE_ENV ? invariant(
1225
- compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
1226
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
1236
+ compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
1237
+ ReactCurrentOwner.current == null,
1227
1238
  'forceUpdate(...): Cannot force an update while unmounting component ' +
1228
- 'or during an existing state transition (such as within `render`).'
1229
- ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
1230
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
1239
+ 'or within a `render` function.'
1240
+ ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
1241
+ ReactCurrentOwner.current == null));
1231
1242
  this._pendingForceUpdate = true;
1232
1243
  ReactUpdates.enqueueUpdate(this, callback);
1233
1244
  },
@@ -1242,7 +1253,7 @@ var ReactCompositeComponentMixin = {
1242
1253
  var renderedComponent;
1243
1254
  var previousContext = ReactContext.current;
1244
1255
  ReactContext.current = this._processChildContext(
1245
- this._descriptor._context
1256
+ this._currentElement._context
1246
1257
  );
1247
1258
  ReactCurrentOwner.current = this;
1248
1259
  try {
@@ -1258,11 +1269,11 @@ var ReactCompositeComponentMixin = {
1258
1269
  ReactCurrentOwner.current = null;
1259
1270
  }
1260
1271
  ("production" !== process.env.NODE_ENV ? invariant(
1261
- ReactDescriptor.isValidDescriptor(renderedComponent),
1272
+ ReactElement.isValidElement(renderedComponent),
1262
1273
  '%s.render(): A valid ReactComponent must be returned. You may have ' +
1263
1274
  'returned undefined, an array or some other invalid object.',
1264
1275
  this.constructor.displayName || 'ReactCompositeComponent'
1265
- ) : invariant(ReactDescriptor.isValidDescriptor(renderedComponent)));
1276
+ ) : invariant(ReactElement.isValidElement(renderedComponent)));
1266
1277
  return renderedComponent;
1267
1278
  }
1268
1279
  ),
@@ -1291,16 +1302,14 @@ var ReactCompositeComponentMixin = {
1291
1302
  */
1292
1303
  _bindAutoBindMethod: function(method) {
1293
1304
  var component = this;
1294
- var boundMethod = function() {
1295
- return method.apply(component, arguments);
1296
- };
1305
+ var boundMethod = method.bind(component);
1297
1306
  if ("production" !== process.env.NODE_ENV) {
1298
1307
  boundMethod.__reactBoundContext = component;
1299
1308
  boundMethod.__reactBoundMethod = method;
1300
1309
  boundMethod.__reactBoundArguments = null;
1301
1310
  var componentName = component.constructor.displayName;
1302
1311
  var _bind = boundMethod.bind;
1303
- boundMethod.bind = function(newThis ) {var args=Array.prototype.slice.call(arguments,1);
1312
+ boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
1304
1313
  // User is trying to bind() an autobound method; we effectively will
1305
1314
  // ignore the value of "this" that the user is trying to use, so
1306
1315
  // let's warn.
@@ -1331,10 +1340,13 @@ var ReactCompositeComponentMixin = {
1331
1340
  };
1332
1341
 
1333
1342
  var ReactCompositeComponentBase = function() {};
1334
- mixInto(ReactCompositeComponentBase, ReactComponent.Mixin);
1335
- mixInto(ReactCompositeComponentBase, ReactOwner.Mixin);
1336
- mixInto(ReactCompositeComponentBase, ReactPropTransferer.Mixin);
1337
- mixInto(ReactCompositeComponentBase, ReactCompositeComponentMixin);
1343
+ assign(
1344
+ ReactCompositeComponentBase.prototype,
1345
+ ReactComponent.Mixin,
1346
+ ReactOwner.Mixin,
1347
+ ReactPropTransferer.Mixin,
1348
+ ReactCompositeComponentMixin
1349
+ );
1338
1350
 
1339
1351
  /**
1340
1352
  * Module for creating composite components.
@@ -1358,8 +1370,10 @@ var ReactCompositeComponent = {
1358
1370
  * @public
1359
1371
  */
1360
1372
  createClass: function(spec) {
1361
- var Constructor = function(props, owner) {
1362
- 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.
1363
1377
  };
1364
1378
  Constructor.prototype = new ReactCompositeComponentBase();
1365
1379
  Constructor.prototype.constructor = Constructor;
@@ -1402,17 +1416,14 @@ var ReactCompositeComponent = {
1402
1416
  }
1403
1417
  }
1404
1418
 
1405
- var descriptorFactory = ReactDescriptor.createFactory(Constructor);
1406
-
1407
1419
  if ("production" !== process.env.NODE_ENV) {
1408
- return ReactDescriptorValidator.createFactory(
1409
- descriptorFactory,
1410
- Constructor.propTypes,
1411
- Constructor.contextTypes
1420
+ return ReactLegacyElement.wrapFactory(
1421
+ ReactElementValidator.createFactory(Constructor)
1412
1422
  );
1413
1423
  }
1414
-
1415
- return descriptorFactory;
1424
+ return ReactLegacyElement.wrapFactory(
1425
+ ReactElement.createFactory(Constructor)
1426
+ );
1416
1427
  },
1417
1428
 
1418
1429
  injection: {