react 0.14.0-beta1 → 0.14.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/addons.js +8 -3
  2. package/dist/react-with-addons.js +5048 -4095
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +4555 -3729
  5. package/dist/react.min.js +6 -5
  6. package/lib/AutoFocusUtils.js +3 -3
  7. package/lib/BeforeInputEventPlugin.js +13 -13
  8. package/lib/CSSProperty.js +18 -3
  9. package/lib/CSSPropertyOperations.js +27 -14
  10. package/lib/CallbackQueue.js +4 -4
  11. package/lib/ChangeEventPlugin.js +15 -14
  12. package/lib/DOMChildrenOperations.js +22 -7
  13. package/lib/DOMProperty.js +8 -8
  14. package/lib/DOMPropertyOperations.js +23 -10
  15. package/lib/Danger.js +21 -16
  16. package/lib/DefaultEventPluginOrder.js +2 -2
  17. package/lib/EnterLeaveEventPlugin.js +18 -10
  18. package/lib/EventConstants.js +23 -1
  19. package/lib/EventPluginHub.js +29 -21
  20. package/lib/EventPluginRegistry.js +8 -8
  21. package/lib/EventPluginUtils.js +34 -38
  22. package/lib/EventPropagators.js +8 -8
  23. package/lib/FallbackCompositionState.js +9 -3
  24. package/lib/HTMLDOMPropertyConfig.js +24 -4
  25. package/lib/LinkedStateMixin.js +2 -2
  26. package/lib/LinkedValueUtils.js +8 -8
  27. package/lib/MetaMatchers.js +118 -0
  28. package/lib/OrderedMap.js +453 -0
  29. package/lib/PooledClass.js +3 -5
  30. package/lib/React.js +18 -7
  31. package/lib/ReactBrowserComponentMixin.js +4 -4
  32. package/lib/ReactBrowserEventEmitter.js +36 -7
  33. package/lib/ReactCSSTransitionGroup.js +35 -9
  34. package/lib/ReactCSSTransitionGroupChild.js +48 -30
  35. package/lib/ReactChildReconciler.js +24 -19
  36. package/lib/ReactChildren.js +72 -32
  37. package/lib/ReactClass.js +46 -46
  38. package/lib/ReactComponent.js +18 -16
  39. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  40. package/lib/ReactComponentEnvironment.js +2 -2
  41. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  42. package/lib/ReactCompositeComponent.js +95 -44
  43. package/lib/ReactDOM.js +74 -159
  44. package/lib/ReactDOMComponent.js +235 -93
  45. package/lib/ReactDOMFactories.js +177 -0
  46. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  47. package/lib/ReactDOMIDOperations.js +8 -81
  48. package/lib/ReactDOMInput.js +18 -9
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +9 -9
  51. package/lib/ReactDOMSelection.js +19 -3
  52. package/lib/ReactDOMServer.js +5 -3
  53. package/lib/ReactDOMTextComponent.js +33 -20
  54. package/lib/ReactDOMTextarea.js +14 -12
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +23 -25
  57. package/lib/ReactDefaultPerf.js +17 -11
  58. package/lib/ReactDefaultPerfAnalysis.js +13 -12
  59. package/lib/ReactElement.js +85 -39
  60. package/lib/ReactElementValidator.js +47 -90
  61. package/lib/ReactEmptyComponent.js +26 -62
  62. package/lib/ReactEmptyComponentRegistry.js +48 -0
  63. package/lib/ReactErrorUtils.js +53 -9
  64. package/lib/ReactEventEmitterMixin.js +2 -2
  65. package/lib/ReactEventListener.js +33 -21
  66. package/lib/ReactFragment.js +27 -118
  67. package/lib/ReactInjection.js +10 -12
  68. package/lib/ReactInputSelection.js +4 -4
  69. package/lib/ReactInstanceHandles.js +10 -11
  70. package/lib/ReactIsomorphic.js +15 -11
  71. package/lib/ReactLink.js +2 -2
  72. package/lib/ReactMarkupChecksum.js +6 -2
  73. package/lib/ReactMount.js +186 -85
  74. package/lib/ReactMultiChild.js +119 -25
  75. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  76. package/lib/ReactNativeComponent.js +3 -3
  77. package/lib/ReactNoopUpdateQueue.js +3 -3
  78. package/lib/ReactOwner.js +3 -3
  79. package/lib/ReactPerf.js +2 -2
  80. package/lib/ReactPropTransferer.js +3 -3
  81. package/lib/ReactPropTypeLocationNames.js +1 -1
  82. package/lib/ReactPropTypeLocations.js +1 -1
  83. package/lib/ReactPropTypes.js +38 -9
  84. package/lib/ReactReconcileTransaction.js +10 -8
  85. package/lib/ReactReconciler.js +5 -6
  86. package/lib/ReactRef.js +14 -2
  87. package/lib/ReactServerBatchingStrategy.js +5 -5
  88. package/lib/ReactServerRendering.js +12 -12
  89. package/lib/ReactServerRenderingTransaction.js +6 -5
  90. package/lib/ReactTestUtils.js +47 -39
  91. package/lib/ReactTransitionChildMapping.js +3 -6
  92. package/lib/ReactTransitionEvents.js +1 -1
  93. package/lib/ReactTransitionGroup.js +5 -6
  94. package/lib/ReactUpdateQueue.js +19 -19
  95. package/lib/ReactUpdates.js +15 -15
  96. package/lib/{performance.js → ReactVersion.js} +3 -12
  97. package/lib/ReactWithAddons.js +24 -15
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -1
  102. package/lib/SelectEventPlugin.js +19 -9
  103. package/lib/SimpleEventPlugin.js +198 -43
  104. package/lib/SyntheticClipboardEvent.js +1 -1
  105. package/lib/SyntheticCompositionEvent.js +1 -1
  106. package/lib/SyntheticDragEvent.js +1 -1
  107. package/lib/SyntheticEvent.js +18 -4
  108. package/lib/SyntheticFocusEvent.js +1 -1
  109. package/lib/SyntheticInputEvent.js +1 -1
  110. package/lib/SyntheticKeyboardEvent.js +4 -4
  111. package/lib/SyntheticMouseEvent.js +3 -3
  112. package/lib/SyntheticTouchEvent.js +2 -2
  113. package/lib/SyntheticUIEvent.js +2 -2
  114. package/lib/SyntheticWheelEvent.js +1 -1
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +7 -7
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -7
  120. package/lib/cloneWithProps.js +11 -6
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +7 -6
  124. package/lib/findDOMNode.js +9 -9
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/getEventKey.js +1 -1
  127. package/lib/{isTextNode.js → getTestDocument.js} +7 -11
  128. package/lib/getTextContentAccessor.js +1 -1
  129. package/lib/instantiateReactComponent.js +15 -17
  130. package/lib/isEventSupported.js +1 -1
  131. package/lib/onlyChild.js +3 -3
  132. package/lib/quoteAttributeValueForBrowser.js +1 -1
  133. package/lib/reactComponentExpect.js +216 -0
  134. package/lib/renderSubtreeIntoContainer.js +1 -1
  135. package/lib/setInnerHTML.js +1 -1
  136. package/lib/setTextContent.js +3 -3
  137. package/lib/shallowCompare.js +1 -1
  138. package/lib/shouldUpdateReactComponent.js +12 -8
  139. package/lib/sliceChildren.js +34 -0
  140. package/lib/traverseAllChildren.js +25 -18
  141. package/lib/update.js +13 -13
  142. package/lib/validateDOMNesting.js +6 -6
  143. package/lib/webcomponents.js +6379 -0
  144. package/package.json +4 -6
  145. package/react.js +1 -51
  146. package/dist/JSXTransformer.js +0 -17588
  147. package/lib/CSSCore.js +0 -97
  148. package/lib/EventListener.js +0 -84
  149. package/lib/ExecutionEnvironment.js +0 -38
  150. package/lib/ReactDOMClient.js +0 -90
  151. package/lib/camelize.js +0 -32
  152. package/lib/camelizeStyleName.js +0 -40
  153. package/lib/containsNode.js +0 -55
  154. package/lib/createArrayFromMixed.js +0 -85
  155. package/lib/createNodesFromMarkup.js +0 -84
  156. package/lib/emptyFunction.js +0 -38
  157. package/lib/focusNode.js +0 -26
  158. package/lib/getActiveElement.js +0 -29
  159. package/lib/getMarkupWrap.js +0 -93
  160. package/lib/getUnboundedScrollPosition.js +0 -38
  161. package/lib/hyphenate.js +0 -33
  162. package/lib/hyphenateStyleName.js +0 -39
  163. package/lib/invariant.js +0 -49
  164. package/lib/isNode.js +0 -23
  165. package/lib/joinClasses.js +0 -39
  166. package/lib/keyMirror.js +0 -48
  167. package/lib/keyOf.js +0 -35
  168. package/lib/mapObject.js +0 -51
  169. package/lib/memoizeStringOnly.js +0 -31
  170. package/lib/performanceNow.js +0 -28
  171. package/lib/shallowEqual.js +0 -48
  172. package/lib/toArray.js +0 -57
  173. package/lib/warning.js +0 -57
@@ -11,7 +11,9 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var adler32 = require("./adler32");
14
+ var adler32 = require('./adler32');
15
+
16
+ var TAG_END = /\/?>/;
15
17
 
16
18
  var ReactMarkupChecksum = {
17
19
  CHECKSUM_ATTR_NAME: 'data-react-checksum',
@@ -22,7 +24,9 @@ var ReactMarkupChecksum = {
22
24
  */
23
25
  addChecksumToMarkup: function (markup) {
24
26
  var checksum = adler32(markup);
25
- return markup.replace('>', ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '">');
27
+
28
+ // Add checksum (handle both parent tags and self-closing tags)
29
+ return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
26
30
  },
27
31
 
28
32
  /**
package/lib/ReactMount.js CHANGED
@@ -11,29 +11,29 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var DOMProperty = require("./DOMProperty");
15
- var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
16
- var ReactCurrentOwner = require("./ReactCurrentOwner");
17
- var ReactElement = require("./ReactElement");
18
- var ReactEmptyComponent = require("./ReactEmptyComponent");
19
- var ReactInstanceHandles = require("./ReactInstanceHandles");
20
- var ReactInstanceMap = require("./ReactInstanceMap");
21
- var ReactMarkupChecksum = require("./ReactMarkupChecksum");
22
- var ReactPerf = require("./ReactPerf");
23
- var ReactReconciler = require("./ReactReconciler");
24
- var ReactUpdateQueue = require("./ReactUpdateQueue");
25
- var ReactUpdates = require("./ReactUpdates");
26
-
27
- var emptyObject = require("./emptyObject");
28
- var containsNode = require("./containsNode");
29
- var instantiateReactComponent = require("./instantiateReactComponent");
30
- var invariant = require("./invariant");
31
- var setInnerHTML = require("./setInnerHTML");
32
- var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
33
- var validateDOMNesting = require("./validateDOMNesting");
34
- var warning = require("./warning");
35
-
36
- var SEPARATOR = ReactInstanceHandles.SEPARATOR;
14
+ var DOMProperty = require('./DOMProperty');
15
+ var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
16
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
17
+ var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
18
+ var ReactElement = require('./ReactElement');
19
+ var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
20
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
21
+ var ReactInstanceMap = require('./ReactInstanceMap');
22
+ var ReactMarkupChecksum = require('./ReactMarkupChecksum');
23
+ var ReactPerf = require('./ReactPerf');
24
+ var ReactReconciler = require('./ReactReconciler');
25
+ var ReactUpdateQueue = require('./ReactUpdateQueue');
26
+ var ReactUpdates = require('./ReactUpdates');
27
+
28
+ var assign = require('./Object.assign');
29
+ var emptyObject = require('fbjs/lib/emptyObject');
30
+ var containsNode = require('fbjs/lib/containsNode');
31
+ var instantiateReactComponent = require('./instantiateReactComponent');
32
+ var invariant = require('fbjs/lib/invariant');
33
+ var setInnerHTML = require('./setInnerHTML');
34
+ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
35
+ var validateDOMNesting = require('./validateDOMNesting');
36
+ var warning = require('fbjs/lib/warning');
37
37
 
38
38
  var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
39
39
  var nodeCache = {};
@@ -42,13 +42,15 @@ var ELEMENT_NODE_TYPE = 1;
42
42
  var DOC_NODE_TYPE = 9;
43
43
  var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
44
44
 
45
+ var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
46
+
45
47
  /** Mapping from reactRootID to React component instance. */
46
48
  var instancesByReactRootID = {};
47
49
 
48
50
  /** Mapping from reactRootID to `container` nodes. */
49
51
  var containersByReactRootID = {};
50
52
 
51
- if ('production' !== process.env.NODE_ENV) {
53
+ if (process.env.NODE_ENV !== 'production') {
52
54
  /** __DEV__-only mapping from reactRootID to root elements. */
53
55
  var rootElementsByReactRootID = {};
54
56
  }
@@ -114,7 +116,7 @@ function getID(node) {
114
116
  if (nodeCache.hasOwnProperty(id)) {
115
117
  var cached = nodeCache[id];
116
118
  if (cached !== node) {
117
- !!isValid(cached, id) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
119
+ !!isValid(cached, id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
118
120
 
119
121
  nodeCache[id] = node;
120
122
  }
@@ -171,7 +173,7 @@ function getNode(id) {
171
173
  */
172
174
  function getNodeFromInstance(instance) {
173
175
  var id = ReactInstanceMap.get(instance)._rootNodeID;
174
- if (ReactEmptyComponent.isNullComponentID(id)) {
176
+ if (ReactEmptyComponentRegistry.isNullComponentID(id)) {
175
177
  return null;
176
178
  }
177
179
  if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
@@ -192,7 +194,7 @@ function getNodeFromInstance(instance) {
192
194
  */
193
195
  function isValid(node, id) {
194
196
  if (node) {
195
- !(internalGetID(node) === id) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
197
+ !(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
196
198
 
197
199
  var container = ReactMount.findReactContainerForID(id);
198
200
  if (container && containsNode(container, node)) {
@@ -246,7 +248,15 @@ function findDeepestCachedAncestor(targetID) {
246
248
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
247
249
  */
248
250
  function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
249
- if ('production' !== process.env.NODE_ENV) {
251
+ if (ReactDOMFeatureFlags.useCreateElement) {
252
+ context = assign({}, context);
253
+ if (container.nodeType === DOC_NODE_TYPE) {
254
+ context[ownerDocumentContextKey] = container;
255
+ } else {
256
+ context[ownerDocumentContextKey] = container.ownerDocument;
257
+ }
258
+ }
259
+ if (process.env.NODE_ENV !== 'production') {
250
260
  if (context === emptyObject) {
251
261
  context = {};
252
262
  }
@@ -255,7 +265,7 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
255
265
  }
256
266
  var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
257
267
  componentInstance._renderedComponent._topLevelWrapper = componentInstance;
258
- ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup);
268
+ ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction);
259
269
  }
260
270
 
261
271
  /**
@@ -267,7 +277,8 @@ function mountComponentIntoNode(componentInstance, rootID, container, transactio
267
277
  * @param {boolean} shouldReuseMarkup If true, do not insert markup
268
278
  */
269
279
  function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
270
- var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
280
+ var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
281
+ /* forceHTML */shouldReuseMarkup);
271
282
  transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
272
283
  ReactUpdates.ReactReconcileTransaction.release(transaction);
273
284
  }
@@ -294,12 +305,72 @@ function unmountComponentFromNode(instance, container) {
294
305
  }
295
306
  }
296
307
 
308
+ /**
309
+ * True if the supplied DOM node has a direct React-rendered child that is
310
+ * not a React root element. Useful for warning in `render`,
311
+ * `unmountComponentAtNode`, etc.
312
+ *
313
+ * @param {?DOMElement} node The candidate DOM node.
314
+ * @return {boolean} True if the DOM element contains a direct child that was
315
+ * rendered by React but is not a root element.
316
+ * @internal
317
+ */
318
+ function hasNonRootReactChild(node) {
319
+ var reactRootID = getReactRootID(node);
320
+ return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false;
321
+ }
322
+
323
+ /**
324
+ * Returns the first (deepest) ancestor of a node which is rendered by this copy
325
+ * of React.
326
+ */
327
+ function findFirstReactDOMImpl(node) {
328
+ // This node might be from another React instance, so we make sure not to
329
+ // examine the node cache here
330
+ for (; node && node.parentNode !== node; node = node.parentNode) {
331
+ if (node.nodeType !== 1) {
332
+ // Not a DOMElement, therefore not a React component
333
+ continue;
334
+ }
335
+ var nodeID = internalGetID(node);
336
+ if (!nodeID) {
337
+ continue;
338
+ }
339
+ var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
340
+
341
+ // If containersByReactRootID contains the container we find by crawling up
342
+ // the tree, we know that this instance of React rendered the node.
343
+ // nb. isValid's strategy (with containsNode) does not work because render
344
+ // trees may be nested and we don't want a false positive in that case.
345
+ var current = node;
346
+ var lastID;
347
+ do {
348
+ lastID = internalGetID(current);
349
+ current = current.parentNode;
350
+ if (current == null) {
351
+ // The passed-in node has been detached from the container it was
352
+ // originally rendered into.
353
+ return null;
354
+ }
355
+ } while (lastID !== reactRootID);
356
+
357
+ if (current === containersByReactRootID[reactRootID]) {
358
+ return node;
359
+ }
360
+ }
361
+ return null;
362
+ }
363
+
297
364
  /**
298
365
  * Temporary (?) hack so that we can store all top-level pending updates on
299
366
  * composites instead of having to worry about different types of components
300
367
  * here.
301
368
  */
302
369
  var TopLevelWrapper = function () {};
370
+ TopLevelWrapper.prototype.isReactComponent = {};
371
+ if (process.env.NODE_ENV !== 'production') {
372
+ TopLevelWrapper.displayName = 'TopLevelWrapper';
373
+ }
303
374
  TopLevelWrapper.prototype.render = function () {
304
375
  // this.props is actually a ReactElement
305
376
  return this.props;
@@ -324,6 +395,9 @@ TopLevelWrapper.prototype.render = function () {
324
395
  * Inside of `container`, the first element rendered is the "reactRoot".
325
396
  */
326
397
  var ReactMount = {
398
+
399
+ TopLevelWrapper: TopLevelWrapper,
400
+
327
401
  /** Exposed for debugging purposes **/
328
402
  _instancesByReactRootID: instancesByReactRootID,
329
403
 
@@ -354,7 +428,7 @@ var ReactMount = {
354
428
  }
355
429
  });
356
430
 
357
- if ('production' !== process.env.NODE_ENV) {
431
+ if (process.env.NODE_ENV !== 'production') {
358
432
  // Record the root element in case it later gets transplanted.
359
433
  rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
360
434
  }
@@ -370,7 +444,7 @@ var ReactMount = {
370
444
  * @return {string} reactRoot ID prefix
371
445
  */
372
446
  _registerComponent: function (nextComponent, container) {
373
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
447
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
374
448
 
375
449
  ReactBrowserEventEmitter.ensureScrollValueMonitoring();
376
450
 
@@ -390,7 +464,7 @@ var ReactMount = {
390
464
  // Various parts of our code (such as ReactCompositeComponent's
391
465
  // _renderValidatedComponent) assume that calls to render aren't nested;
392
466
  // verify that that's the case.
393
- 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
467
+ process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
394
468
 
395
469
  var componentInstance = instantiateReactComponent(nextElement, null);
396
470
  var reactRootID = ReactMount._registerComponent(componentInstance, container);
@@ -401,7 +475,7 @@ var ReactMount = {
401
475
 
402
476
  ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
403
477
 
404
- if ('production' !== process.env.NODE_ENV) {
478
+ if (process.env.NODE_ENV !== 'production') {
405
479
  // Record the root element in case it later gets transplanted.
406
480
  rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
407
481
  }
@@ -423,18 +497,18 @@ var ReactMount = {
423
497
  * @return {ReactComponent} Component instance rendered in `container`.
424
498
  */
425
499
  renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
426
- !(parentComponent != null && parentComponent._reactInternalInstance != null) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
500
+ !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
427
501
  return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
428
502
  },
429
503
 
430
504
  _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
431
- !ReactElement.isValidElement(nextElement) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'React.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
505
+ !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
432
506
  // Check if it quacks like an element
433
507
  nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
434
508
 
435
- 'production' !== process.env.NODE_ENV ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
509
+ process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
436
510
 
437
- var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, nextElement);
511
+ var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
438
512
 
439
513
  var prevComponent = instancesByReactRootID[getReactRootID(container)];
440
514
 
@@ -449,23 +523,25 @@ var ReactMount = {
449
523
  }
450
524
 
451
525
  var reactRootElement = getReactRootElementInContainer(container);
452
- var containerHasReactMarkup = reactRootElement && ReactMount.isRenderedByReact(reactRootElement);
526
+ var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement);
527
+ var containerHasNonRootReactChild = hasNonRootReactChild(container);
528
+
529
+ if (process.env.NODE_ENV !== 'production') {
530
+ process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : undefined;
453
531
 
454
- if ('production' !== process.env.NODE_ENV) {
455
532
  if (!containerHasReactMarkup || reactRootElement.nextSibling) {
456
533
  var rootElementSibling = reactRootElement;
457
534
  while (rootElementSibling) {
458
- if (ReactMount.isRenderedByReact(rootElementSibling)) {
459
- 'production' !== process.env.NODE_ENV ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined;
535
+ if (internalGetID(rootElementSibling)) {
536
+ process.env.NODE_ENV !== 'production' ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined;
460
537
  break;
461
538
  }
462
-
463
539
  rootElementSibling = rootElementSibling.nextSibling;
464
540
  }
465
541
  }
466
542
  }
467
543
 
468
- var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
544
+ var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
469
545
  var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
470
546
  if (callback) {
471
547
  callback.call(component);
@@ -523,19 +599,31 @@ var ReactMount = {
523
599
  // _renderValidatedComponent) assume that calls to render aren't nested;
524
600
  // verify that that's the case. (Strictly speaking, unmounting won't cause a
525
601
  // render but we still don't expect to be in a render call here.)
526
- 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
602
+ process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
527
603
 
528
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
604
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
529
605
 
530
606
  var reactRootID = getReactRootID(container);
531
607
  var component = instancesByReactRootID[reactRootID];
532
608
  if (!component) {
609
+ // Check if the node being unmounted was rendered by React, but isn't a
610
+ // root node.
611
+ var containerHasNonRootReactChild = hasNonRootReactChild(container);
612
+
613
+ // Check if the container itself is a React root node.
614
+ var containerID = internalGetID(container);
615
+ var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID);
616
+
617
+ if (process.env.NODE_ENV !== 'production') {
618
+ process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : undefined;
619
+ }
620
+
533
621
  return false;
534
622
  }
535
623
  ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
536
624
  delete instancesByReactRootID[reactRootID];
537
625
  delete containersByReactRootID[reactRootID];
538
- if ('production' !== process.env.NODE_ENV) {
626
+ if (process.env.NODE_ENV !== 'production') {
539
627
  delete rootElementsByReactRootID[reactRootID];
540
628
  }
541
629
  return true;
@@ -552,10 +640,10 @@ var ReactMount = {
552
640
  var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
553
641
  var container = containersByReactRootID[reactRootID];
554
642
 
555
- if ('production' !== process.env.NODE_ENV) {
643
+ if (process.env.NODE_ENV !== 'production') {
556
644
  var rootElement = rootElementsByReactRootID[reactRootID];
557
645
  if (rootElement && rootElement.parentNode !== container) {
558
- 'production' !== process.env.NODE_ENV ? warning(
646
+ process.env.NODE_ENV !== 'production' ? warning(
559
647
  // Call internalGetID here because getID calls isValid which calls
560
648
  // findReactContainerForID (this function).
561
649
  internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
@@ -567,7 +655,7 @@ var ReactMount = {
567
655
  // warning is when the container is empty.
568
656
  rootElementsByReactRootID[reactRootID] = containerChild;
569
657
  } else {
570
- 'production' !== process.env.NODE_ENV ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
658
+ process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
571
659
  }
572
660
  }
573
661
  }
@@ -586,39 +674,16 @@ var ReactMount = {
586
674
  return ReactMount.findComponentRoot(reactRoot, id);
587
675
  },
588
676
 
589
- /**
590
- * True if the supplied `node` is rendered by React.
591
- *
592
- * @param {*} node DOM Element to check.
593
- * @return {boolean} True if the DOM Element appears to be rendered by React.
594
- * @internal
595
- */
596
- isRenderedByReact: function (node) {
597
- if (node.nodeType !== 1) {
598
- // Not a DOMElement, therefore not a React component
599
- return false;
600
- }
601
- var id = ReactMount.getID(node);
602
- return id ? id.charAt(0) === SEPARATOR : false;
603
- },
604
-
605
677
  /**
606
678
  * Traverses up the ancestors of the supplied node to find a node that is a
607
- * DOM representation of a React component.
679
+ * DOM representation of a React component rendered by this copy of React.
608
680
  *
609
681
  * @param {*} node
610
682
  * @return {?DOMEventTarget}
611
683
  * @internal
612
684
  */
613
685
  getFirstReactDOM: function (node) {
614
- var current = node;
615
- while (current && current.parentNode !== current) {
616
- if (ReactMount.isRenderedByReact(current)) {
617
- return current;
618
- }
619
- current = current.parentNode;
620
- }
621
- return null;
686
+ return findFirstReactDOMImpl(node);
622
687
  },
623
688
 
624
689
  /**
@@ -637,6 +702,11 @@ var ReactMount = {
637
702
 
638
703
  var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
639
704
 
705
+ if (process.env.NODE_ENV !== 'production') {
706
+ // This will throw on the next line; give an early warning
707
+ process.env.NODE_ENV !== 'production' ? warning(deepestAncestor != null, 'React can\'t find the root component node for data-reactid value ' + '`%s`. If you\'re seeing this message, it probably means that ' + 'you\'ve loaded two copies of React on the page. At this time, only ' + 'a single copy of React can be loaded at a time.', targetID) : undefined;
708
+ }
709
+
640
710
  firstChildren[0] = deepestAncestor.firstChild;
641
711
  firstChildren.length = 1;
642
712
 
@@ -686,11 +756,11 @@ var ReactMount = {
686
756
 
687
757
  firstChildren.length = 0;
688
758
 
689
- !false ? 'production' !== process.env.NODE_ENV ? invariant(false, 'findComponentRoot(..., %s): Unable to find element. This probably ' + 'means the DOM was unexpectedly mutated (e.g., by the browser), ' + 'usually due to forgetting a <tbody> when using tables, nesting tags ' + 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' + 'parent. ' + 'Try inspecting the child nodes of the element with React ID `%s`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false) : undefined;
759
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findComponentRoot(..., %s): Unable to find element. This probably ' + 'means the DOM was unexpectedly mutated (e.g., by the browser), ' + 'usually due to forgetting a <tbody> when using tables, nesting tags ' + 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' + 'parent. ' + 'Try inspecting the child nodes of the element with React ID `%s`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false) : undefined;
690
760
  },
691
761
 
692
- _mountImageIntoNode: function (markup, container, shouldReuseMarkup) {
693
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
762
+ _mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) {
763
+ !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
694
764
 
695
765
  if (shouldReuseMarkup) {
696
766
  var rootElement = getReactRootElementInContainer(container);
@@ -703,22 +773,51 @@ var ReactMount = {
703
773
  var rootMarkup = rootElement.outerHTML;
704
774
  rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
705
775
 
706
- var diffIndex = firstDifferenceIndex(markup, rootMarkup);
707
- var difference = ' (client) ' + markup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
776
+ var normalizedMarkup = markup;
777
+ if (process.env.NODE_ENV !== 'production') {
778
+ // because rootMarkup is retrieved from the DOM, various normalizations
779
+ // will have occurred which will not be present in `markup`. Here,
780
+ // insert markup into a <div> or <iframe> depending on the container
781
+ // type to perform the same normalizations before comparing.
782
+ var normalizer;
783
+ if (container.nodeType === ELEMENT_NODE_TYPE) {
784
+ normalizer = document.createElement('div');
785
+ normalizer.innerHTML = markup;
786
+ normalizedMarkup = normalizer.innerHTML;
787
+ } else {
788
+ normalizer = document.createElement('iframe');
789
+ document.body.appendChild(normalizer);
790
+ normalizer.contentDocument.write(markup);
791
+ normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
792
+ document.body.removeChild(normalizer);
793
+ }
794
+ }
795
+
796
+ var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
797
+ var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
708
798
 
709
- !(container.nodeType !== DOC_NODE_TYPE) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : undefined;
799
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : undefined;
710
800
 
711
- if ('production' !== process.env.NODE_ENV) {
712
- 'production' !== process.env.NODE_ENV ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : undefined;
801
+ if (process.env.NODE_ENV !== 'production') {
802
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : undefined;
713
803
  }
714
804
  }
715
805
  }
716
806
 
717
- !(container.nodeType !== DOC_NODE_TYPE) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See React.renderToString() for server rendering.') : invariant(false) : undefined;
807
+ !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
718
808
 
719
- setInnerHTML(container, markup);
809
+ if (transaction.useCreateElement) {
810
+ while (container.lastChild) {
811
+ container.removeChild(container.lastChild);
812
+ }
813
+ container.appendChild(markup);
814
+ } else {
815
+ setInnerHTML(container, markup);
816
+ }
720
817
  },
721
818
 
819
+ ownerDocumentContextKey: ownerDocumentContextKey,
820
+
722
821
  /**
723
822
  * React ID utilities.
724
823
  */
@@ -733,6 +832,8 @@ var ReactMount = {
733
832
 
734
833
  getNodeFromInstance: getNodeFromInstance,
735
834
 
835
+ isValid: isValid,
836
+
736
837
  purgeID: purgeID
737
838
  };
738
839