react 0.12.2 → 0.13.0-beta.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 (184) hide show
  1. package/dist/JSXTransformer.js +986 -511
  2. package/dist/react-with-addons.js +6076 -4560
  3. package/dist/react-with-addons.min.js +6 -7
  4. package/dist/react.js +5386 -4170
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +388 -115
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +2 -2
  10. package/lib/CSSPropertyOperations.js +58 -11
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +4 -4
  13. package/lib/ClientReactRootIndex.js +2 -2
  14. package/lib/DOMChildrenOperations.js +10 -47
  15. package/lib/DOMProperty.js +2 -2
  16. package/lib/DOMPropertyOperations.js +11 -16
  17. package/lib/Danger.js +8 -7
  18. package/lib/DefaultEventPluginOrder.js +3 -4
  19. package/lib/EnterLeaveEventPlugin.js +2 -2
  20. package/lib/EventConstants.js +2 -2
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +10 -8
  23. package/lib/EventPluginRegistry.js +2 -2
  24. package/lib/EventPluginUtils.js +4 -4
  25. package/lib/EventPropagators.js +2 -2
  26. package/lib/ExecutionEnvironment.js +3 -4
  27. package/lib/FallbackCompositionState.js +89 -0
  28. package/lib/HTMLDOMPropertyConfig.js +23 -10
  29. package/lib/LinkedStateMixin.js +2 -2
  30. package/lib/LinkedValueUtils.js +4 -4
  31. package/lib/LocalEventTrapMixin.js +10 -3
  32. package/lib/MobileSafariClickEventPlugin.js +2 -2
  33. package/lib/Object.assign.js +4 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +19 -58
  36. package/lib/ReactBrowserComponentMixin.js +4 -14
  37. package/lib/ReactBrowserEventEmitter.js +6 -8
  38. package/lib/ReactCSSTransitionGroup.js +5 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +20 -7
  40. package/lib/ReactChildReconciler.js +125 -0
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +918 -0
  43. package/lib/ReactComponent.js +98 -406
  44. package/lib/ReactComponentBrowserEnvironment.js +11 -84
  45. package/lib/ReactComponentEnvironment.js +57 -0
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +574 -1140
  48. package/lib/ReactContext.js +17 -3
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +4 -9
  51. package/lib/ReactDOMButton.js +6 -7
  52. package/lib/ReactDOMComponent.js +123 -105
  53. package/lib/ReactDOMForm.js +6 -7
  54. package/lib/ReactDOMIDOperations.js +59 -77
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +5 -7
  57. package/lib/ReactDOMInput.js +6 -7
  58. package/lib/ReactDOMOption.js +6 -7
  59. package/lib/ReactDOMSelect.js +58 -66
  60. package/lib/ReactDOMSelection.js +7 -3
  61. package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
  62. package/lib/ReactDOMTextarea.js +6 -7
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +39 -9
  65. package/lib/ReactDefaultPerf.js +17 -8
  66. package/lib/ReactDefaultPerfAnalysis.js +2 -2
  67. package/lib/ReactElement.js +23 -15
  68. package/lib/ReactElementValidator.js +206 -89
  69. package/lib/ReactEmptyComponent.js +33 -15
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +2 -2
  72. package/lib/ReactEventListener.js +4 -5
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +8 -6
  75. package/lib/ReactInputSelection.js +4 -5
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +47 -0
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +2 -2
  80. package/lib/ReactMarkupChecksum.js +2 -2
  81. package/lib/ReactMount.js +264 -71
  82. package/lib/ReactMultiChild.js +50 -48
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +59 -25
  85. package/lib/ReactOwner.js +5 -49
  86. package/lib/ReactPerf.js +22 -2
  87. package/lib/ReactPropTransferer.js +3 -58
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +17 -25
  91. package/lib/ReactPutListenerQueue.js +2 -2
  92. package/lib/ReactReconcileTransaction.js +2 -2
  93. package/lib/ReactReconciler.js +121 -0
  94. package/lib/ReactRef.js +69 -0
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +6 -4
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +113 -27
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +53 -12
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +54 -62
  105. package/lib/ReactWithAddons.js +4 -2
  106. package/lib/SVGDOMPropertyConfig.js +2 -2
  107. package/lib/SelectEventPlugin.js +4 -4
  108. package/lib/ServerReactRootIndex.js +2 -2
  109. package/lib/SimpleEventPlugin.js +4 -4
  110. package/lib/SyntheticClipboardEvent.js +2 -3
  111. package/lib/SyntheticCompositionEvent.js +2 -3
  112. package/lib/SyntheticDragEvent.js +2 -2
  113. package/lib/SyntheticEvent.js +12 -4
  114. package/lib/SyntheticFocusEvent.js +2 -2
  115. package/lib/SyntheticInputEvent.js +2 -3
  116. package/lib/SyntheticKeyboardEvent.js +2 -2
  117. package/lib/SyntheticMouseEvent.js +3 -5
  118. package/lib/SyntheticTouchEvent.js +2 -2
  119. package/lib/SyntheticUIEvent.js +2 -2
  120. package/lib/SyntheticWheelEvent.js +2 -2
  121. package/lib/Transaction.js +4 -4
  122. package/lib/ViewportMetrics.js +3 -6
  123. package/lib/accumulateInto.js +2 -2
  124. package/lib/adler32.js +2 -2
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +4 -4
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +2 -2
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
  137. package/lib/findDOMNode.js +51 -0
  138. package/lib/flattenChildren.js +12 -23
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +2 -2
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +2 -2
  143. package/lib/getEventKey.js +2 -2
  144. package/lib/getEventModifierState.js +2 -2
  145. package/lib/getEventTarget.js +2 -2
  146. package/lib/getIteratorFn.js +42 -0
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +3 -3
  149. package/lib/getReactRootElementInContainer.js +2 -2
  150. package/lib/getTextContentAccessor.js +2 -2
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +90 -68
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +4 -5
  158. package/lib/isTextInputElement.js +3 -4
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +2 -2
  161. package/lib/keyMirror.js +2 -2
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +5 -6
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +13 -2
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +2 -2
  172. package/lib/shouldUpdateReactComponent.js +71 -7
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +114 -56
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/CompositionEventPlugin.js +0 -257
  179. package/lib/ReactLegacyElement.js +0 -243
  180. package/lib/copyProperties.js +0 -54
  181. package/lib/deprecated.js +0 -47
  182. package/lib/merge.js +0 -34
  183. package/lib/mergeInto.js +0 -24
  184. package/lib/monitorCodeUse.js +0 -30
package/lib/ReactMount.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,28 +9,31 @@
9
9
  * @providesModule ReactMount
10
10
  */
11
11
 
12
- "use strict";
12
+ 'use strict';
13
13
 
14
14
  var DOMProperty = require("./DOMProperty");
15
15
  var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
16
16
  var ReactCurrentOwner = require("./ReactCurrentOwner");
17
17
  var ReactElement = require("./ReactElement");
18
- var ReactLegacyElement = require("./ReactLegacyElement");
18
+ var ReactElementValidator = require("./ReactElementValidator");
19
+ var ReactEmptyComponent = require("./ReactEmptyComponent");
19
20
  var ReactInstanceHandles = require("./ReactInstanceHandles");
21
+ var ReactInstanceMap = require("./ReactInstanceMap");
22
+ var ReactMarkupChecksum = require("./ReactMarkupChecksum");
20
23
  var ReactPerf = require("./ReactPerf");
24
+ var ReactReconciler = require("./ReactReconciler");
25
+ var ReactUpdateQueue = require("./ReactUpdateQueue");
26
+ var ReactUpdates = require("./ReactUpdates");
21
27
 
28
+ var emptyObject = require("./emptyObject");
22
29
  var containsNode = require("./containsNode");
23
- var deprecated = require("./deprecated");
24
30
  var getReactRootElementInContainer = require("./getReactRootElementInContainer");
25
31
  var instantiateReactComponent = require("./instantiateReactComponent");
26
32
  var invariant = require("./invariant");
33
+ var setInnerHTML = require("./setInnerHTML");
27
34
  var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
28
35
  var warning = require("./warning");
29
36
 
30
- var createElement = ReactLegacyElement.wrapCreateElement(
31
- ReactElement.createElement
32
- );
33
-
34
37
  var SEPARATOR = ReactInstanceHandles.SEPARATOR;
35
38
 
36
39
  var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
@@ -53,6 +56,22 @@ if ("production" !== process.env.NODE_ENV) {
53
56
  // Used to store breadth-first search state in findComponentRoot.
54
57
  var findComponentRootReusableArray = [];
55
58
 
59
+ /**
60
+ * Finds the index of the first character
61
+ * that's not common between the two given strings.
62
+ *
63
+ * @return {number} the index of the character where the strings diverge
64
+ */
65
+ function firstDifferenceIndex(string1, string2) {
66
+ var minLen = Math.min(string1.length, string2.length);
67
+ for (var i = 0; i < minLen; i++) {
68
+ if (string1.charAt(i) !== string2.charAt(i)) {
69
+ return i;
70
+ }
71
+ }
72
+ return string1.length === string2.length ? -1 : minLen;
73
+ }
74
+
56
75
  /**
57
76
  * @param {DOMElement} container DOM element that may contain a React component.
58
77
  * @return {?string} A "reactRoot" ID, if a React component is rendered.
@@ -130,6 +149,24 @@ function getNode(id) {
130
149
  return nodeCache[id];
131
150
  }
132
151
 
152
+ /**
153
+ * Finds the node with the supplied public React instance.
154
+ *
155
+ * @param {*} instance A public React instance.
156
+ * @return {?DOMElement} DOM node with the suppled `id`.
157
+ * @internal
158
+ */
159
+ function getNodeFromInstance(instance) {
160
+ var id = ReactInstanceMap.get(instance)._rootNodeID;
161
+ if (ReactEmptyComponent.isNullComponentID(id)) {
162
+ return null;
163
+ }
164
+ if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
165
+ nodeCache[id] = ReactMount.findReactNodeByID(id);
166
+ }
167
+ return nodeCache[id];
168
+ }
169
+
133
170
  /**
134
171
  * A node is "valid" if it is contained by a currently mounted container.
135
172
  *
@@ -193,6 +230,54 @@ function findDeepestCachedAncestor(targetID) {
193
230
  return foundNode;
194
231
  }
195
232
 
233
+ /**
234
+ * Mounts this component and inserts it into the DOM.
235
+ *
236
+ * @param {ReactComponent} componentInstance The instance to mount.
237
+ * @param {string} rootID DOM ID of the root node.
238
+ * @param {DOMElement} container DOM element to mount into.
239
+ * @param {ReactReconcileTransaction} transaction
240
+ * @param {boolean} shouldReuseMarkup If true, do not insert markup
241
+ */
242
+ function mountComponentIntoNode(
243
+ componentInstance,
244
+ rootID,
245
+ container,
246
+ transaction,
247
+ shouldReuseMarkup) {
248
+ var markup = ReactReconciler.mountComponent(
249
+ componentInstance, rootID, transaction, emptyObject
250
+ );
251
+ componentInstance._isTopLevel = true;
252
+ ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
253
+ }
254
+
255
+ /**
256
+ * Batched mount.
257
+ *
258
+ * @param {ReactComponent} componentInstance The instance to mount.
259
+ * @param {string} rootID DOM ID of the root node.
260
+ * @param {DOMElement} container DOM element to mount into.
261
+ * @param {boolean} shouldReuseMarkup If true, do not insert markup
262
+ */
263
+ function batchedMountComponentIntoNode(
264
+ componentInstance,
265
+ rootID,
266
+ container,
267
+ shouldReuseMarkup) {
268
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
269
+ transaction.perform(
270
+ mountComponentIntoNode,
271
+ null,
272
+ componentInstance,
273
+ rootID,
274
+ container,
275
+ transaction,
276
+ shouldReuseMarkup
277
+ );
278
+ ReactUpdates.ReactReconcileTransaction.release(transaction);
279
+ }
280
+
196
281
  /**
197
282
  * Mounting is the process of initializing a React component by creatings its
198
283
  * representative DOM elements and inserting them into a supplied `container`.
@@ -230,18 +315,24 @@ var ReactMount = {
230
315
  /**
231
316
  * Take a component that's already mounted into the DOM and replace its props
232
317
  * @param {ReactComponent} prevComponent component instance already in the DOM
233
- * @param {ReactComponent} nextComponent component instance to render
318
+ * @param {ReactElement} nextElement component instance to render
234
319
  * @param {DOMElement} container container to render into
235
320
  * @param {?function} callback function triggered on completion
236
321
  */
237
322
  _updateRootComponent: function(
238
323
  prevComponent,
239
- nextComponent,
324
+ nextElement,
240
325
  container,
241
326
  callback) {
242
- var nextProps = nextComponent.props;
327
+ if ("production" !== process.env.NODE_ENV) {
328
+ ReactElementValidator.checkAndWarnForMutatedProps(nextElement);
329
+ }
330
+
243
331
  ReactMount.scrollMonitor(container, function() {
244
- prevComponent.replaceProps(nextProps, callback);
332
+ ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
333
+ if (callback) {
334
+ ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
335
+ }
245
336
  });
246
337
 
247
338
  if ("production" !== process.env.NODE_ENV) {
@@ -263,13 +354,11 @@ var ReactMount = {
263
354
  _registerComponent: function(nextComponent, container) {
264
355
  ("production" !== process.env.NODE_ENV ? invariant(
265
356
  container && (
266
- container.nodeType === ELEMENT_NODE_TYPE ||
267
- container.nodeType === DOC_NODE_TYPE
357
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
268
358
  ),
269
359
  '_registerComponent(...): Target container is not a DOM element.'
270
360
  ) : invariant(container && (
271
- container.nodeType === ELEMENT_NODE_TYPE ||
272
- container.nodeType === DOC_NODE_TYPE
361
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
273
362
  )));
274
363
 
275
364
  ReactBrowserEventEmitter.ensureScrollValueMonitoring();
@@ -286,44 +375,48 @@ var ReactMount = {
286
375
  * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
287
376
  * @return {ReactComponent} nextComponent
288
377
  */
289
- _renderNewRootComponent: ReactPerf.measure(
290
- 'ReactMount',
291
- '_renderNewRootComponent',
292
- function(
293
- nextComponent,
294
- container,
295
- shouldReuseMarkup) {
296
- // Various parts of our code (such as ReactCompositeComponent's
297
- // _renderValidatedComponent) assume that calls to render aren't nested;
298
- // verify that that's the case.
299
- ("production" !== process.env.NODE_ENV ? warning(
300
- ReactCurrentOwner.current == null,
301
- '_renderNewRootComponent(): Render methods should be a pure function ' +
302
- 'of props and state; triggering nested component updates from ' +
303
- 'render is not allowed. If necessary, trigger nested updates in ' +
304
- 'componentDidUpdate.'
305
- ) : null);
306
-
307
- var componentInstance = instantiateReactComponent(nextComponent, null);
308
- var reactRootID = ReactMount._registerComponent(
309
- componentInstance,
310
- container
311
- );
312
- componentInstance.mountComponentIntoNode(
313
- reactRootID,
314
- container,
315
- shouldReuseMarkup
316
- );
317
-
318
- if ("production" !== process.env.NODE_ENV) {
319
- // Record the root element in case it later gets transplanted.
320
- rootElementsByReactRootID[reactRootID] =
321
- getReactRootElementInContainer(container);
322
- }
378
+ _renderNewRootComponent: function(
379
+ nextComponent,
380
+ container,
381
+ shouldReuseMarkup
382
+ ) {
383
+ // Various parts of our code (such as ReactCompositeComponent's
384
+ // _renderValidatedComponent) assume that calls to render aren't nested;
385
+ // verify that that's the case.
386
+ ("production" !== process.env.NODE_ENV ? warning(
387
+ ReactCurrentOwner.current == null,
388
+ '_renderNewRootComponent(): Render methods should be a pure function ' +
389
+ 'of props and state; triggering nested component updates from ' +
390
+ 'render is not allowed. If necessary, trigger nested updates in ' +
391
+ 'componentDidUpdate.'
392
+ ) : null);
393
+
394
+ var componentInstance = instantiateReactComponent(nextComponent, null);
395
+ var reactRootID = ReactMount._registerComponent(
396
+ componentInstance,
397
+ container
398
+ );
323
399
 
324
- return componentInstance;
400
+ // The initial render is synchronous but any updates that happen during
401
+ // rendering, in componentWillMount or componentDidMount, will be batched
402
+ // according to the current batching strategy.
403
+
404
+ ReactUpdates.batchedUpdates(
405
+ batchedMountComponentIntoNode,
406
+ componentInstance,
407
+ reactRootID,
408
+ container,
409
+ shouldReuseMarkup
410
+ );
411
+
412
+ if ("production" !== process.env.NODE_ENV) {
413
+ // Record the root element in case it later gets transplanted.
414
+ rootElementsByReactRootID[reactRootID] =
415
+ getReactRootElementInContainer(container);
325
416
  }
326
- ),
417
+
418
+ return componentInstance;
419
+ },
327
420
 
328
421
  /**
329
422
  * Renders a React component into the DOM in the supplied `container`.
@@ -340,16 +433,16 @@ var ReactMount = {
340
433
  render: function(nextElement, container, callback) {
341
434
  ("production" !== process.env.NODE_ENV ? invariant(
342
435
  ReactElement.isValidElement(nextElement),
343
- 'renderComponent(): Invalid component element.%s',
436
+ 'React.render(): Invalid component element.%s',
344
437
  (
345
438
  typeof nextElement === 'string' ?
346
439
  ' Instead of passing an element string, make sure to instantiate ' +
347
440
  'it by passing it to React.createElement.' :
348
- ReactLegacyElement.isValidFactory(nextElement) ?
441
+ typeof nextElement === 'function' ?
349
442
  ' Instead of passing a component class, make sure to instantiate ' +
350
443
  'it by passing it to React.createElement.' :
351
- // Check if it quacks like a element
352
- typeof nextElement.props !== "undefined" ?
444
+ // Check if it quacks like an element
445
+ nextElement != null && nextElement.props !== undefined ?
353
446
  ' This may be caused by unintentionally loading two independent ' +
354
447
  'copies of React.' :
355
448
  ''
@@ -366,7 +459,7 @@ var ReactMount = {
366
459
  nextElement,
367
460
  container,
368
461
  callback
369
- );
462
+ ).getPublicInstance();
370
463
  } else {
371
464
  ReactMount.unmountComponentAtNode(container);
372
465
  }
@@ -376,14 +469,35 @@ var ReactMount = {
376
469
  var containerHasReactMarkup =
377
470
  reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
378
471
 
472
+ if ("production" !== process.env.NODE_ENV) {
473
+ if (!containerHasReactMarkup || reactRootElement.nextSibling) {
474
+ var rootElementSibling = reactRootElement;
475
+ while (rootElementSibling) {
476
+ if (ReactMount.isRenderedByReact(rootElementSibling)) {
477
+ ("production" !== process.env.NODE_ENV ? warning(
478
+ false,
479
+ 'render(): Target node has markup rendered by React, but there ' +
480
+ 'are unrelated nodes as well. This is most commonly caused by ' +
481
+ 'white-space inserted around server-rendered markup.'
482
+ ) : null);
483
+ break;
484
+ }
485
+
486
+ rootElementSibling = rootElementSibling.nextSibling;
487
+ }
488
+ }
489
+ }
490
+
379
491
  var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
380
492
 
381
493
  var component = ReactMount._renderNewRootComponent(
382
494
  nextElement,
383
495
  container,
384
496
  shouldReuseMarkup
385
- );
386
- callback && callback.call(component);
497
+ ).getPublicInstance();
498
+ if (callback) {
499
+ callback.call(component);
500
+ }
387
501
  return component;
388
502
  },
389
503
 
@@ -397,7 +511,7 @@ var ReactMount = {
397
511
  * @return {ReactComponent} Component instance rendered in `container`.
398
512
  */
399
513
  constructAndRenderComponent: function(constructor, props, container) {
400
- var element = createElement(constructor, props);
514
+ var element = ReactElement.createElement(constructor, props);
401
515
  return ReactMount.render(element, container);
402
516
  },
403
517
 
@@ -462,6 +576,15 @@ var ReactMount = {
462
576
  'componentDidUpdate.'
463
577
  ) : null);
464
578
 
579
+ ("production" !== process.env.NODE_ENV ? invariant(
580
+ container && (
581
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
582
+ ),
583
+ 'unmountComponentAtNode(...): Target container is not a DOM element.'
584
+ ) : invariant(container && (
585
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
586
+ )));
587
+
465
588
  var reactRootID = getReactRootID(container);
466
589
  var component = instancesByReactRootID[reactRootID];
467
590
  if (!component) {
@@ -486,7 +609,7 @@ var ReactMount = {
486
609
  * @see {ReactMount.unmountComponentAtNode}
487
610
  */
488
611
  unmountComponentFromNode: function(instance, container) {
489
- instance.unmountComponent();
612
+ ReactReconciler.unmountComponent(instance);
490
613
 
491
614
  if (container.nodeType === DOC_NODE_TYPE) {
492
615
  container = container.documentElement;
@@ -530,10 +653,11 @@ var ReactMount = {
530
653
  // warning is when the container is empty.
531
654
  rootElementsByReactRootID[reactRootID] = containerChild;
532
655
  } else {
533
- console.warn(
656
+ ("production" !== process.env.NODE_ENV ? warning(
657
+ false,
534
658
  'ReactMount: Root element has been removed from its original ' +
535
659
  'container. New container:', rootElement.parentNode
536
- );
660
+ ) : null);
537
661
  }
538
662
  }
539
663
  }
@@ -666,6 +790,77 @@ var ReactMount = {
666
790
  ) : invariant(false));
667
791
  },
668
792
 
793
+ _mountImageIntoNode: function(markup, container, shouldReuseMarkup) {
794
+ ("production" !== process.env.NODE_ENV ? invariant(
795
+ container && (
796
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
797
+ ),
798
+ 'mountComponentIntoNode(...): Target container is not valid.'
799
+ ) : invariant(container && (
800
+ (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE)
801
+ )));
802
+
803
+ if (shouldReuseMarkup) {
804
+ var rootElement = getReactRootElementInContainer(container);
805
+ if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
806
+ return;
807
+ } else {
808
+ var checksum = rootElement.getAttribute(
809
+ ReactMarkupChecksum.CHECKSUM_ATTR_NAME
810
+ );
811
+ rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
812
+
813
+ var rootMarkup = rootElement.outerHTML;
814
+ rootElement.setAttribute(
815
+ ReactMarkupChecksum.CHECKSUM_ATTR_NAME,
816
+ checksum
817
+ );
818
+
819
+ var diffIndex = firstDifferenceIndex(markup, rootMarkup);
820
+ var difference = ' (client) ' +
821
+ markup.substring(diffIndex - 20, diffIndex + 20) +
822
+ '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
823
+
824
+ ("production" !== process.env.NODE_ENV ? invariant(
825
+ container.nodeType !== DOC_NODE_TYPE,
826
+ 'You\'re trying to render a component to the document using ' +
827
+ 'server rendering but the checksum was invalid. This usually ' +
828
+ 'means you rendered a different component type or props on ' +
829
+ 'the client from the one on the server, or your render() ' +
830
+ 'methods are impure. React cannot handle this case due to ' +
831
+ 'cross-browser quirks by rendering at the document root. You ' +
832
+ 'should look for environment dependent code in your components ' +
833
+ 'and ensure the props are the same client and server side:\n%s',
834
+ difference
835
+ ) : invariant(container.nodeType !== DOC_NODE_TYPE));
836
+
837
+ if ("production" !== process.env.NODE_ENV) {
838
+ ("production" !== process.env.NODE_ENV ? warning(
839
+ false,
840
+ 'React attempted to reuse markup in a container but the ' +
841
+ 'checksum was invalid. This generally means that you are ' +
842
+ 'using server rendering and the markup generated on the ' +
843
+ 'server was not what the client was expecting. React injected ' +
844
+ 'new markup to compensate which works but you have lost many ' +
845
+ 'of the benefits of server rendering. Instead, figure out ' +
846
+ 'why the markup being generated is different on the client ' +
847
+ 'or server:\n%s',
848
+ difference
849
+ ) : null);
850
+ }
851
+ }
852
+ }
853
+
854
+ ("production" !== process.env.NODE_ENV ? invariant(
855
+ container.nodeType !== DOC_NODE_TYPE,
856
+ 'You\'re trying to render a component to the document but ' +
857
+ 'you didn\'t use server rendering. We can\'t do this ' +
858
+ 'without using server rendering due to cross-browser quirks. ' +
859
+ 'See React.renderToString() for server rendering.'
860
+ ) : invariant(container.nodeType !== DOC_NODE_TYPE));
861
+
862
+ setInnerHTML(container, markup);
863
+ },
669
864
 
670
865
  /**
671
866
  * React ID utilities.
@@ -679,16 +874,14 @@ var ReactMount = {
679
874
 
680
875
  getNode: getNode,
681
876
 
877
+ getNodeFromInstance: getNodeFromInstance,
878
+
682
879
  purgeID: purgeID
683
880
  };
684
881
 
685
- // Deprecations (remove for 0.13)
686
- ReactMount.renderComponent = deprecated(
687
- 'ReactMount',
688
- 'renderComponent',
689
- 'render',
690
- this,
691
- ReactMount.render
692
- );
882
+ ReactPerf.measureMethods(ReactMount, 'ReactMount', {
883
+ _renderNewRootComponent: '_renderNewRootComponent',
884
+ _mountImageIntoNode: '_mountImageIntoNode'
885
+ });
693
886
 
694
887
  module.exports = ReactMount;