react 0.14.7 → 0.15.0-alpha.1

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 (177) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +2937 -3414
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +2762 -3034
  5. package/dist/react.min.js +7 -7
  6. package/lib/AutoFocusUtils.js +3 -15
  7. package/lib/BeforeInputEventPlugin.js +8 -25
  8. package/lib/CSSProperty.js +3 -1
  9. package/lib/CSSPropertyOperations.js +20 -6
  10. package/lib/CallbackQueue.js +12 -1
  11. package/lib/ChangeEventPlugin.js +58 -54
  12. package/lib/DOMChildrenOperations.js +21 -60
  13. package/lib/DOMLazyTree.js +95 -0
  14. package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
  15. package/lib/DOMProperty.js +7 -2
  16. package/lib/DOMPropertyOperations.js +66 -36
  17. package/lib/Danger.js +6 -7
  18. package/lib/DefaultEventPluginOrder.js +1 -1
  19. package/lib/EnterLeaveEventPlugin.js +24 -43
  20. package/lib/EventConstants.js +2 -1
  21. package/lib/EventPluginHub.js +15 -59
  22. package/lib/EventPluginRegistry.js +23 -2
  23. package/lib/EventPluginUtils.js +60 -35
  24. package/lib/EventPropagators.js +19 -17
  25. package/lib/FallbackCompositionState.js +1 -2
  26. package/lib/HTMLDOMPropertyConfig.js +21 -23
  27. package/lib/LinkedInput.js +49 -0
  28. package/lib/LinkedStateMixin.js +1 -2
  29. package/lib/LinkedValueUtils.js +1 -2
  30. package/lib/MetaMatchers.js +2 -2
  31. package/lib/Object.assign.js +1 -1
  32. package/lib/OrderedMap.js +1 -1
  33. package/lib/PooledClass.js +1 -1
  34. package/lib/React.js +1 -13
  35. package/lib/ReactBrowserEventEmitter.js +3 -23
  36. package/lib/ReactCSSTransitionGroup.js +1 -2
  37. package/lib/ReactCSSTransitionGroupChild.js +1 -6
  38. package/lib/ReactChildReconciler.js +12 -10
  39. package/lib/ReactChildren.js +3 -3
  40. package/lib/ReactClass.js +18 -67
  41. package/lib/ReactComponent.js +2 -5
  42. package/lib/ReactComponentBrowserEnvironment.js +9 -6
  43. package/lib/ReactComponentEnvironment.js +3 -3
  44. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  45. package/lib/ReactCompositeComponent.js +94 -29
  46. package/lib/ReactCurrentOwner.js +1 -1
  47. package/lib/ReactDOM.js +26 -14
  48. package/lib/ReactDOMButton.js +2 -2
  49. package/lib/ReactDOMComponent.js +156 -218
  50. package/lib/ReactDOMComponentFlags.js +18 -0
  51. package/lib/ReactDOMComponentTree.js +186 -0
  52. package/lib/ReactDOMContainerInfo.js +32 -0
  53. package/lib/ReactDOMDebugTool.js +69 -0
  54. package/lib/ReactDOMEmptyComponent.js +61 -0
  55. package/lib/ReactDOMFactories.js +1 -2
  56. package/lib/ReactDOMFeatureFlags.js +2 -2
  57. package/lib/ReactDOMIDOperations.js +5 -60
  58. package/lib/ReactDOMInput.js +52 -23
  59. package/lib/ReactDOMInstrumentation.js +16 -0
  60. package/lib/ReactDOMOption.js +9 -8
  61. package/lib/ReactDOMSVGDeprecatedAttributeDevtool.js +57 -0
  62. package/lib/ReactDOMSelect.js +35 -14
  63. package/lib/ReactDOMSelection.js +2 -2
  64. package/lib/ReactDOMServer.js +1 -1
  65. package/lib/ReactDOMTextComponent.js +41 -21
  66. package/lib/ReactDOMTextarea.js +32 -5
  67. package/lib/ReactDOMTreeTraversal.js +134 -0
  68. package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
  69. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  70. package/lib/ReactDefaultInjection.js +11 -15
  71. package/lib/ReactDefaultPerf.js +49 -19
  72. package/lib/ReactDefaultPerfAnalysis.js +16 -9
  73. package/lib/ReactElement.js +9 -5
  74. package/lib/ReactElementValidator.js +1 -1
  75. package/lib/ReactEmptyComponent.js +8 -29
  76. package/lib/ReactErrorUtils.js +1 -2
  77. package/lib/ReactEventEmitterMixin.js +3 -8
  78. package/lib/ReactEventListener.js +20 -75
  79. package/lib/ReactFeatureFlags.js +21 -0
  80. package/lib/ReactFragment.js +2 -2
  81. package/lib/ReactInjection.js +3 -3
  82. package/lib/ReactInputSelection.js +3 -3
  83. package/lib/ReactInstanceHandles.js +4 -6
  84. package/lib/ReactInstanceMap.js +1 -1
  85. package/lib/ReactIsomorphic.js +1 -1
  86. package/lib/ReactLink.js +1 -2
  87. package/lib/ReactMarkupChecksum.js +1 -1
  88. package/lib/ReactMount.js +67 -445
  89. package/lib/ReactMultiChild.js +104 -198
  90. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  91. package/lib/ReactNativeComponent.js +1 -1
  92. package/lib/ReactNodeTypes.js +37 -0
  93. package/lib/ReactNoopUpdateQueue.js +1 -24
  94. package/lib/ReactOwner.js +1 -1
  95. package/lib/ReactPerf.js +1 -2
  96. package/lib/ReactPropTransferer.js +1 -1
  97. package/lib/ReactPropTypeLocationNames.js +1 -1
  98. package/lib/ReactPropTypeLocations.js +1 -1
  99. package/lib/ReactPropTypes.js +8 -2
  100. package/lib/ReactReconcileTransaction.js +17 -6
  101. package/lib/ReactReconciler.js +14 -5
  102. package/lib/ReactRef.js +1 -1
  103. package/lib/ReactServerBatchingStrategy.js +1 -2
  104. package/lib/ReactServerRendering.js +15 -33
  105. package/lib/ReactServerRenderingTransaction.js +8 -26
  106. package/lib/ReactSimpleEmptyComponent.js +37 -0
  107. package/lib/ReactStateSetters.js +1 -1
  108. package/lib/ReactTestUtils.js +25 -15
  109. package/lib/ReactTransitionChildMapping.js +1 -2
  110. package/lib/ReactTransitionEvents.js +1 -1
  111. package/lib/ReactTransitionGroup.js +1 -1
  112. package/lib/ReactUpdateQueue.js +4 -4
  113. package/lib/ReactUpdates.js +19 -2
  114. package/lib/ReactVersion.js +2 -2
  115. package/lib/ReactWithAddons.js +1 -3
  116. package/lib/ResponderEventPlugin.js +53 -65
  117. package/lib/ResponderSyntheticEvent.js +1 -2
  118. package/lib/ResponderTouchHistoryStore.js +1 -1
  119. package/lib/SVGDOMPropertyConfig.js +2 -39
  120. package/lib/SelectEventPlugin.js +13 -18
  121. package/lib/SimpleEventPlugin.js +18 -16
  122. package/lib/SyntheticClipboardEvent.js +1 -2
  123. package/lib/SyntheticCompositionEvent.js +1 -2
  124. package/lib/SyntheticDragEvent.js +1 -2
  125. package/lib/SyntheticEvent.js +10 -7
  126. package/lib/SyntheticFocusEvent.js +1 -2
  127. package/lib/SyntheticInputEvent.js +1 -2
  128. package/lib/SyntheticKeyboardEvent.js +1 -2
  129. package/lib/SyntheticMouseEvent.js +1 -2
  130. package/lib/SyntheticTouchEvent.js +1 -2
  131. package/lib/SyntheticUIEvent.js +1 -2
  132. package/lib/SyntheticWheelEvent.js +1 -2
  133. package/lib/TapEventPlugin.js +3 -12
  134. package/lib/Transaction.js +1 -1
  135. package/lib/ViewportMetrics.js +1 -1
  136. package/lib/accumulate.js +1 -1
  137. package/lib/accumulateInto.js +1 -1
  138. package/lib/adler32.js +3 -2
  139. package/lib/canDefineProperty.js +1 -1
  140. package/lib/createHierarchyRenderer.js +1 -1
  141. package/lib/dangerousStyleValue.js +25 -3
  142. package/lib/deprecated.js +1 -1
  143. package/lib/escapeTextContentForBrowser.js +1 -1
  144. package/lib/findDOMNode.js +15 -8
  145. package/lib/flattenChildren.js +1 -1
  146. package/lib/forEachAccumulated.js +1 -1
  147. package/lib/getEventCharCode.js +1 -2
  148. package/lib/getEventKey.js +1 -2
  149. package/lib/getEventModifierState.js +1 -2
  150. package/lib/getEventTarget.js +1 -2
  151. package/lib/getIteratorFn.js +1 -2
  152. package/lib/getNativeComponentFromComposite.js +30 -0
  153. package/lib/getNodeForCharacterOffset.js +1 -1
  154. package/lib/getTestDocument.js +1 -1
  155. package/lib/getTextContentAccessor.js +1 -1
  156. package/lib/instantiateReactComponent.js +3 -4
  157. package/lib/isEventSupported.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/onlyChild.js +1 -1
  160. package/lib/quoteAttributeValueForBrowser.js +1 -1
  161. package/lib/reactComponentExpect.js +1 -1
  162. package/lib/renderSubtreeIntoContainer.js +1 -1
  163. package/lib/setInnerHTML.js +1 -1
  164. package/lib/setTextContent.js +1 -1
  165. package/lib/shallowCompare.js +1 -1
  166. package/lib/shouldUpdateReactComponent.js +1 -3
  167. package/lib/sliceChildren.js +1 -1
  168. package/lib/traverseAllChildren.js +6 -6
  169. package/lib/update.js +1 -1
  170. package/lib/validateDOMNesting.js +8 -9
  171. package/package.json +2 -2
  172. package/lib/ReactBrowserComponentMixin.js +0 -36
  173. package/lib/ReactEmptyComponentRegistry.js +0 -48
  174. package/lib/ReactRootIndex.js +0 -29
  175. package/lib/ServerReactRootIndex.js +0 -29
  176. package/lib/cloneWithProps.js +0 -54
  177. package/lib/webcomponents.js +0 -6379
@@ -1,12 +1,11 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
- * @typechecks
10
9
  * @providesModule ReactCSSTransitionGroup
11
10
  */
12
11
 
@@ -1,12 +1,11 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
6
6
  * LICENSE file in the root directory of this source tree. An additional grant
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
- * @typechecks
10
9
  * @providesModule ReactCSSTransitionGroupChild
11
10
  */
12
11
 
@@ -20,10 +19,6 @@ var ReactTransitionEvents = require('./ReactTransitionEvents');
20
19
 
21
20
  var onlyChild = require('./onlyChild');
22
21
 
23
- // We don't remove the element from the DOM until we receive an animationend or
24
- // transitionend event. If the user screws up and forgets to add an animation
25
- // their node will be stuck in the DOM forever, so we detect if an animation
26
- // does not start and if it doesn't, we just call the end listener immediately.
27
22
  var TICK = 17;
28
23
 
29
24
  var ReactCSSTransitionGroupChild = React.createClass({
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014-2015, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,7 +7,6 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactChildReconciler
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
@@ -26,7 +25,7 @@ function instantiateChild(childInstances, child, name) {
26
25
  process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
27
26
  }
28
27
  if (child != null && keyUnique) {
29
- childInstances[name] = instantiateReactComponent(child, null);
28
+ childInstances[name] = instantiateReactComponent(child);
30
29
  }
31
30
  }
32
31
 
@@ -63,21 +62,22 @@ var ReactChildReconciler = {
63
62
  * @return {?object} A new set of child instances.
64
63
  * @internal
65
64
  */
66
- updateChildren: function (prevChildren, nextChildren, transaction, context) {
65
+ updateChildren: function (prevChildren, nextChildren, removedNodes, transaction, context) {
67
66
  // We currently don't have a way to track moves here but if we use iterators
68
67
  // instead of for..in we can zip the iterators and check if an item has
69
68
  // moved.
70
69
  // TODO: If nothing has changed, return the prevChildren object so that we
71
70
  // can quickly bailout if nothing has changed.
72
71
  if (!nextChildren && !prevChildren) {
73
- return null;
72
+ return;
74
73
  }
75
74
  var name;
75
+ var prevChild;
76
76
  for (name in nextChildren) {
77
77
  if (!nextChildren.hasOwnProperty(name)) {
78
78
  continue;
79
79
  }
80
- var prevChild = prevChildren && prevChildren[name];
80
+ prevChild = prevChildren && prevChildren[name];
81
81
  var prevElement = prevChild && prevChild._currentElement;
82
82
  var nextElement = nextChildren[name];
83
83
  if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
@@ -85,20 +85,22 @@ var ReactChildReconciler = {
85
85
  nextChildren[name] = prevChild;
86
86
  } else {
87
87
  if (prevChild) {
88
- ReactReconciler.unmountComponent(prevChild, name);
88
+ removedNodes[name] = ReactReconciler.getNativeNode(prevChild);
89
+ ReactReconciler.unmountComponent(prevChild);
89
90
  }
90
91
  // The child must be instantiated before it's mounted.
91
- var nextChildInstance = instantiateReactComponent(nextElement, null);
92
+ var nextChildInstance = instantiateReactComponent(nextElement);
92
93
  nextChildren[name] = nextChildInstance;
93
94
  }
94
95
  }
95
96
  // Unmount children that are no longer present.
96
97
  for (name in prevChildren) {
97
98
  if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
98
- ReactReconciler.unmountComponent(prevChildren[name]);
99
+ prevChild = prevChildren[name];
100
+ removedNodes[name] = ReactReconciler.getNativeNode(prevChild);
101
+ ReactReconciler.unmountComponent(prevChild);
99
102
  }
100
103
  }
101
- return nextChildren;
102
104
  },
103
105
 
104
106
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -20,9 +20,9 @@ var traverseAllChildren = require('./traverseAllChildren');
20
20
  var twoArgumentPooler = PooledClass.twoArgumentPooler;
21
21
  var fourArgumentPooler = PooledClass.fourArgumentPooler;
22
22
 
23
- var userProvidedKeyEscapeRegex = /\/(?!\/)/g;
23
+ var userProvidedKeyEscapeRegex = /\/+/g;
24
24
  function escapeUserProvidedKey(text) {
25
- return ('' + text).replace(userProvidedKeyEscapeRegex, '//');
25
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
26
26
  }
27
27
 
28
28
  /**
package/lib/ReactClass.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -53,14 +53,6 @@ var SpecPolicy = keyMirror({
53
53
 
54
54
  var injectedMixins = [];
55
55
 
56
- var warnedSetProps = false;
57
- function warnSetProps() {
58
- if (!warnedSetProps) {
59
- warnedSetProps = true;
60
- process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
61
- }
62
- }
63
-
64
56
  /**
65
57
  * Composite components are higher-level components that compose other composite
66
58
  * or native components.
@@ -365,13 +357,13 @@ function validateTypeDef(Constructor, typeDef, location) {
365
357
  for (var propName in typeDef) {
366
358
  if (typeDef.hasOwnProperty(propName)) {
367
359
  // use a warning instead of an invariant so components
368
- // don't show up in prod but not in __DEV__
360
+ // don't show up in prod but only in __DEV__
369
361
  process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
370
362
  }
371
363
  }
372
364
  }
373
365
 
374
- function validateMethodOverride(proto, name) {
366
+ function validateMethodOverride(isAlreadyDefined, name) {
375
367
  var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
376
368
 
377
369
  // Disallow overriding of base class methods unless explicitly allowed.
@@ -380,24 +372,25 @@ function validateMethodOverride(proto, name) {
380
372
  }
381
373
 
382
374
  // Disallow defining methods more than once unless explicitly allowed.
383
- if (proto.hasOwnProperty(name)) {
375
+ if (isAlreadyDefined) {
384
376
  !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined;
385
377
  }
386
378
  }
387
379
 
388
380
  /**
389
381
  * Mixin helper which handles policy validation and reserved
390
- * specification keys when building React classses.
382
+ * specification keys when building React classes.
391
383
  */
392
384
  function mixSpecIntoComponent(Constructor, spec) {
393
385
  if (!spec) {
394
386
  return;
395
387
  }
396
388
 
397
- !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
389
+ !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.') : invariant(false) : undefined;
398
390
  !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
399
391
 
400
392
  var proto = Constructor.prototype;
393
+ var autoBindPairs = proto.__reactAutoBindPairs;
401
394
 
402
395
  // By handling mixins before any other properties, we ensure the same
403
396
  // chaining order is applied to methods with DEFINE_MANY policy, whether
@@ -417,7 +410,8 @@ function mixSpecIntoComponent(Constructor, spec) {
417
410
  }
418
411
 
419
412
  var property = spec[name];
420
- validateMethodOverride(proto, name);
413
+ var isAlreadyDefined = proto.hasOwnProperty(name);
414
+ validateMethodOverride(isAlreadyDefined, name);
421
415
 
422
416
  if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
423
417
  RESERVED_SPEC_KEYS[name](Constructor, property);
@@ -427,15 +421,11 @@ function mixSpecIntoComponent(Constructor, spec) {
427
421
  // 1. Expected ReactClass methods (in the "interface").
428
422
  // 2. Overridden methods (that were mixed in).
429
423
  var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
430
- var isAlreadyDefined = proto.hasOwnProperty(name);
431
424
  var isFunction = typeof property === 'function';
432
425
  var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
433
426
 
434
427
  if (shouldAutoBind) {
435
- if (!proto.__reactAutoBindMap) {
436
- proto.__reactAutoBindMap = {};
437
- }
438
- proto.__reactAutoBindMap[name] = property;
428
+ autoBindPairs.push(name, property);
439
429
  proto[name] = property;
440
430
  } else {
441
431
  if (isAlreadyDefined) {
@@ -558,7 +548,6 @@ function bindAutoBindMethod(component, method) {
558
548
  boundMethod.__reactBoundArguments = null;
559
549
  var componentName = component.constructor.displayName;
560
550
  var _bind = boundMethod.bind;
561
- /* eslint-disable block-scoped-var, no-undef */
562
551
  boundMethod.bind = function (newThis) {
563
552
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
564
553
  args[_key - 1] = arguments[_key];
@@ -578,7 +567,6 @@ function bindAutoBindMethod(component, method) {
578
567
  reboundMethod.__reactBoundMethod = method;
579
568
  reboundMethod.__reactBoundArguments = args;
580
569
  return reboundMethod;
581
- /* eslint-enable */
582
570
  };
583
571
  }
584
572
  return boundMethod;
@@ -590,11 +578,11 @@ function bindAutoBindMethod(component, method) {
590
578
  * @param {object} component Component whose method is going to be bound.
591
579
  */
592
580
  function bindAutoBindMethods(component) {
593
- for (var autoBindKey in component.__reactAutoBindMap) {
594
- if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
595
- var method = component.__reactAutoBindMap[autoBindKey];
596
- component[autoBindKey] = bindAutoBindMethod(component, method);
597
- }
581
+ var pairs = component.__reactAutoBindPairs;
582
+ for (var i = 0; i < pairs.length; i += 2) {
583
+ var autoBindKey = pairs[i];
584
+ var method = pairs[i + 1];
585
+ component[autoBindKey] = bindAutoBindMethod(component, method);
598
586
  }
599
587
  }
600
588
 
@@ -623,44 +611,6 @@ var ReactClassMixin = {
623
611
  */
624
612
  isMounted: function () {
625
613
  return this.updater.isMounted(this);
626
- },
627
-
628
- /**
629
- * Sets a subset of the props.
630
- *
631
- * @param {object} partialProps Subset of the next props.
632
- * @param {?function} callback Called after props are updated.
633
- * @final
634
- * @public
635
- * @deprecated
636
- */
637
- setProps: function (partialProps, callback) {
638
- if (process.env.NODE_ENV !== 'production') {
639
- warnSetProps();
640
- }
641
- this.updater.enqueueSetProps(this, partialProps);
642
- if (callback) {
643
- this.updater.enqueueCallback(this, callback);
644
- }
645
- },
646
-
647
- /**
648
- * Replace all the props.
649
- *
650
- * @param {object} newProps Subset of the next props.
651
- * @param {?function} callback Called after props are updated.
652
- * @final
653
- * @public
654
- * @deprecated
655
- */
656
- replaceProps: function (newProps, callback) {
657
- if (process.env.NODE_ENV !== 'production') {
658
- warnSetProps();
659
- }
660
- this.updater.enqueueReplaceProps(this, newProps);
661
- if (callback) {
662
- this.updater.enqueueCallback(this, callback);
663
- }
664
614
  }
665
615
  };
666
616
 
@@ -683,7 +633,7 @@ var ReactClass = {
683
633
  */
684
634
  createClass: function (spec) {
685
635
  var Constructor = function (props, context, updater) {
686
- // This constructor is overridden by mocks. The argument is used
636
+ // This constructor gets overridden by mocks. The argument is used
687
637
  // by mocks to assert on what gets mounted.
688
638
 
689
639
  if (process.env.NODE_ENV !== 'production') {
@@ -691,7 +641,7 @@ var ReactClass = {
691
641
  }
692
642
 
693
643
  // Wire up auto-binding
694
- if (this.__reactAutoBindMap) {
644
+ if (this.__reactAutoBindPairs.length) {
695
645
  bindAutoBindMethods(this);
696
646
  }
697
647
 
@@ -720,6 +670,7 @@ var ReactClass = {
720
670
  };
721
671
  Constructor.prototype = new ReactClassComponent();
722
672
  Constructor.prototype.constructor = Constructor;
673
+ Constructor.prototype.__reactAutoBindPairs = [];
723
674
 
724
675
  injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
725
676
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -96,11 +96,8 @@ ReactComponent.prototype.forceUpdate = function (callback) {
96
96
  */
97
97
  if (process.env.NODE_ENV !== 'production') {
98
98
  var deprecatedAPIs = {
99
- getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'],
100
99
  isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
101
- replaceProps: ['replaceProps', 'Instead, call render again at the top level.'],
102
- replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
103
- setProps: ['setProps', 'Instead, call render again at the top level.']
100
+ replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
104
101
  };
105
102
  var defineDeprecationWarning = function (methodName, info) {
106
103
  if (canDefineProperty) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -11,8 +11,9 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var DOMChildrenOperations = require('./DOMChildrenOperations');
14
15
  var ReactDOMIDOperations = require('./ReactDOMIDOperations');
15
- var ReactMount = require('./ReactMount');
16
+ var ReactPerf = require('./ReactPerf');
16
17
 
17
18
  /**
18
19
  * Abstracts away all functionality of the reconciler that requires knowledge of
@@ -23,7 +24,7 @@ var ReactComponentBrowserEnvironment = {
23
24
 
24
25
  processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
25
26
 
26
- replaceNodeWithMarkupByID: ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
27
+ replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup,
27
28
 
28
29
  /**
29
30
  * If a particular environment requires that some resources be cleaned up,
@@ -32,10 +33,12 @@ var ReactComponentBrowserEnvironment = {
32
33
  *
33
34
  * @private
34
35
  */
35
- unmountIDFromEnvironment: function (rootNodeID) {
36
- ReactMount.purgeID(rootNodeID);
37
- }
36
+ unmountIDFromEnvironment: function (rootNodeID) {}
38
37
 
39
38
  };
40
39
 
40
+ ReactPerf.measureMethods(ReactComponentBrowserEnvironment, 'ReactComponentBrowserEnvironment', {
41
+ replaceNodeWithMarkup: 'replaceNodeWithMarkup'
42
+ });
43
+
41
44
  module.exports = ReactComponentBrowserEnvironment;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014-2015, Facebook, Inc.
2
+ * Copyright 2014-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -28,7 +28,7 @@ var ReactComponentEnvironment = {
28
28
  * Optionally injectable hook for swapping out mount images in the middle of
29
29
  * the tree.
30
30
  */
31
- replaceNodeWithMarkupByID: null,
31
+ replaceNodeWithMarkup: null,
32
32
 
33
33
  /**
34
34
  * Optionally injectable hook for processing a queue of child updates. Will
@@ -40,7 +40,7 @@ var ReactComponentEnvironment = {
40
40
  injectEnvironment: function (environment) {
41
41
  !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
42
42
  ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
43
- ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
43
+ ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
44
44
  ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
45
45
  injected = true;
46
46
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -15,7 +15,7 @@ var shallowCompare = require('./shallowCompare');
15
15
 
16
16
  /**
17
17
  * If your React component's render function is "pure", e.g. it will render the
18
- * same result given the same props and state, provide this Mixin for a
18
+ * same result given the same props and state, provide this mixin for a
19
19
  * considerable performance boost.
20
20
  *
21
21
  * Most React components have pure render functions.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2015, Facebook, Inc.
2
+ * Copyright 2013-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -15,6 +15,7 @@ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
15
15
  var ReactCurrentOwner = require('./ReactCurrentOwner');
16
16
  var ReactElement = require('./ReactElement');
17
17
  var ReactInstanceMap = require('./ReactInstanceMap');
18
+ var ReactNodeTypes = require('./ReactNodeTypes');
18
19
  var ReactPerf = require('./ReactPerf');
19
20
  var ReactPropTypeLocations = require('./ReactPropTypeLocations');
20
21
  var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
@@ -95,6 +96,8 @@ var ReactCompositeComponentMixin = {
95
96
  this._currentElement = element;
96
97
  this._rootNodeID = null;
97
98
  this._instance = null;
99
+ this._nativeParent = null;
100
+ this._nativeContainerInfo = null;
98
101
 
99
102
  // See ReactUpdateQueue
100
103
  this._pendingElement = null;
@@ -102,8 +105,8 @@ var ReactCompositeComponentMixin = {
102
105
  this._pendingReplaceState = false;
103
106
  this._pendingForceUpdate = false;
104
107
 
108
+ this._renderedNodeType = null;
105
109
  this._renderedComponent = null;
106
-
107
110
  this._context = null;
108
111
  this._mountOrder = 0;
109
112
  this._topLevelWrapper = null;
@@ -115,16 +118,19 @@ var ReactCompositeComponentMixin = {
115
118
  /**
116
119
  * Initializes the component, renders markup, and registers event listeners.
117
120
  *
118
- * @param {string} rootID DOM ID of the root node.
119
121
  * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
122
+ * @param {?object} nativeParent
123
+ * @param {?object} nativeContainerInfo
124
+ * @param {?object} context
120
125
  * @return {?string} Rendered markup to be inserted into the DOM.
121
126
  * @final
122
127
  * @internal
123
128
  */
124
- mountComponent: function (rootID, transaction, context) {
129
+ mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
125
130
  this._context = context;
126
131
  this._mountOrder = nextMountID++;
127
- this._rootNodeID = rootID;
132
+ this._nativeParent = nativeParent;
133
+ this._nativeContainerInfo = nativeContainerInfo;
128
134
 
129
135
  var publicProps = this._processProps(this._currentElement.props);
130
136
  var publicContext = this._processContext(context);
@@ -169,6 +175,11 @@ var ReactCompositeComponentMixin = {
169
175
  // and stateless components, but not ES6 classes that don't extend
170
176
  process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
171
177
  }
178
+
179
+ var propsMutated = inst.props !== publicProps;
180
+ var componentName = Component.displayName || Component.name || 'Component';
181
+
182
+ process.env.NODE_ENV !== 'production' ? warning(typeof inst.props === 'undefined' || !propsMutated, '%s(...): When calling super() in `%s`, make sure to pass ' + 'up the same props that your component\'s constructor was passed.', componentName, componentName) : undefined;
172
183
  }
173
184
 
174
185
  // These should be set up in the constructor, but as a convenience for
@@ -206,6 +217,46 @@ var ReactCompositeComponentMixin = {
206
217
  this._pendingReplaceState = false;
207
218
  this._pendingForceUpdate = false;
208
219
 
220
+ var markup;
221
+ if (inst.unstable_handleError) {
222
+ markup = this.performInitialMountWithErrorHandling(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
223
+ } else {
224
+ markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
225
+ }
226
+
227
+ if (inst.componentDidMount) {
228
+ transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
229
+ }
230
+
231
+ return markup;
232
+ },
233
+
234
+ performInitialMountWithErrorHandling: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
235
+ var markup;
236
+ var checkpoint = transaction.checkpoint();
237
+ try {
238
+ markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
239
+ } catch (e) {
240
+ // Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
241
+ transaction.rollback(checkpoint);
242
+ this._instance.unstable_handleError(e);
243
+ if (this._pendingStateQueue) {
244
+ this._instance.state = this._processPendingState(this._instance.props, this._instance.context);
245
+ }
246
+ checkpoint = transaction.checkpoint();
247
+
248
+ this._renderedComponent.unmountComponent();
249
+ transaction.rollback(checkpoint);
250
+
251
+ // Try again - we've informed the component about the error, so they can render an error message this time.
252
+ // If this throws again, the error will bubble up (and can be caught by a higher error boundary).
253
+ markup = this.performInitialMount(renderedElement, nativeParent, nativeContainerInfo, transaction, context);
254
+ }
255
+ return markup;
256
+ },
257
+
258
+ performInitialMount: function (renderedElement, nativeParent, nativeContainerInfo, transaction, context) {
259
+ var inst = this._instance;
209
260
  if (inst.componentWillMount) {
210
261
  inst.componentWillMount();
211
262
  // When mounting, calls to `setState` by `componentWillMount` will set
@@ -220,16 +271,18 @@ var ReactCompositeComponentMixin = {
220
271
  renderedElement = this._renderValidatedComponent();
221
272
  }
222
273
 
274
+ this._renderedNodeType = ReactNodeTypes.getType(renderedElement);
223
275
  this._renderedComponent = this._instantiateReactComponent(renderedElement);
224
276
 
225
- var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
226
- if (inst.componentDidMount) {
227
- transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
228
- }
277
+ var markup = ReactReconciler.mountComponent(this._renderedComponent, transaction, nativeParent, nativeContainerInfo, this._processChildContext(context));
229
278
 
230
279
  return markup;
231
280
  },
232
281
 
282
+ getNativeNode: function () {
283
+ return ReactReconciler.getNativeNode(this._renderedComponent);
284
+ },
285
+
233
286
  /**
234
287
  * Releases any resources allocated by `mountComponent`.
235
288
  *
@@ -243,9 +296,12 @@ var ReactCompositeComponentMixin = {
243
296
  inst.componentWillUnmount();
244
297
  }
245
298
 
246
- ReactReconciler.unmountComponent(this._renderedComponent);
247
- this._renderedComponent = null;
248
- this._instance = null;
299
+ if (this._renderedComponent) {
300
+ ReactReconciler.unmountComponent(this._renderedComponent);
301
+ this._renderedNodeType = null;
302
+ this._renderedComponent = null;
303
+ this._instance = null;
304
+ }
249
305
 
250
306
  // Reset pending fields
251
307
  // Even if this component is scheduled for another update in ReactUpdates,
@@ -283,13 +339,12 @@ var ReactCompositeComponentMixin = {
283
339
  * @private
284
340
  */
285
341
  _maskContext: function (context) {
286
- var maskedContext = null;
287
342
  var Component = this._currentElement.type;
288
343
  var contextTypes = Component.contextTypes;
289
344
  if (!contextTypes) {
290
345
  return emptyObject;
291
346
  }
292
- maskedContext = {};
347
+ var maskedContext = {};
293
348
  for (var contextName in contextTypes) {
294
349
  maskedContext[contextName] = context[contextName];
295
350
  }
@@ -439,10 +494,18 @@ var ReactCompositeComponentMixin = {
439
494
  */
440
495
  updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
441
496
  var inst = this._instance;
442
-
443
- var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext);
497
+ var willReceive = false;
498
+ var nextContext;
444
499
  var nextProps;
445
500
 
501
+ // Determine if the context has changed or not
502
+ if (this._context === nextUnmaskedContext) {
503
+ nextContext = inst.context;
504
+ } else {
505
+ nextContext = this._processContext(nextUnmaskedContext);
506
+ willReceive = true;
507
+ }
508
+
446
509
  // Distinguish between a props update versus a simple state update
447
510
  if (prevParentElement === nextParentElement) {
448
511
  // Skip checking prop types again -- we don't read inst.props to avoid
@@ -450,13 +513,14 @@ var ReactCompositeComponentMixin = {
450
513
  nextProps = nextParentElement.props;
451
514
  } else {
452
515
  nextProps = this._processProps(nextParentElement.props);
453
- // An update here will schedule an update but immediately set
454
- // _pendingStateQueue which will ensure that any state updates gets
455
- // immediately reconciled instead of waiting for the next batch.
516
+ willReceive = true;
517
+ }
456
518
 
457
- if (inst.componentWillReceiveProps) {
458
- inst.componentWillReceiveProps(nextProps, nextContext);
459
- }
519
+ // An update here will schedule an update but immediately set
520
+ // _pendingStateQueue which will ensure that any state updates gets
521
+ // immediately reconciled instead of waiting for the next batch.
522
+ if (willReceive && inst.componentWillReceiveProps) {
523
+ inst.componentWillReceiveProps(nextProps, nextContext);
460
524
  }
461
525
 
462
526
  var nextState = this._processPendingState(nextProps, nextContext);
@@ -561,22 +625,23 @@ var ReactCompositeComponentMixin = {
561
625
  if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
562
626
  ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
563
627
  } else {
564
- // These two IDs are actually the same! But nothing should rely on that.
565
- var thisID = this._rootNodeID;
566
- var prevComponentID = prevComponentInstance._rootNodeID;
628
+ var oldNativeNode = ReactReconciler.getNativeNode(prevComponentInstance);
567
629
  ReactReconciler.unmountComponent(prevComponentInstance);
568
630
 
631
+ this._renderedNodeType = ReactNodeTypes.getType(nextRenderedElement);
569
632
  this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
570
- var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
571
- this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
633
+ var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, transaction, this._nativeParent, this._nativeContainerInfo, this._processChildContext(context));
634
+ this._replaceNodeWithMarkup(oldNativeNode, nextMarkup);
572
635
  }
573
636
  },
574
637
 
575
638
  /**
639
+ * Overridden in shallow rendering.
640
+ *
576
641
  * @protected
577
642
  */
578
- _replaceNodeWithMarkupByID: function (prevComponentID, nextMarkup) {
579
- ReactComponentEnvironment.replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
643
+ _replaceNodeWithMarkup: function (oldNativeNode, nextMarkup) {
644
+ ReactComponentEnvironment.replaceNodeWithMarkup(oldNativeNode, nextMarkup);
580
645
  },
581
646
 
582
647
  /**