react 0.14.10 → 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 (183) hide show
  1. package/LICENSE +1 -1
  2. package/dist/react-with-addons.js +2944 -3425
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +2769 -3045
  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 +2 -3
  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 +95 -30
  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 +2 -2
  75. package/lib/ReactEmptyComponent.js +8 -33
  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 +12 -6
  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 +22 -32
  172. package/cjs/react-jsx-dev-runtime.development.js +0 -861
  173. package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
  174. package/cjs/react-jsx-runtime.development.js +0 -883
  175. package/cjs/react-jsx-runtime.production.min.js +0 -10
  176. package/jsx-dev-runtime.js +0 -7
  177. package/jsx-runtime.js +0 -7
  178. package/lib/ReactBrowserComponentMixin.js +0 -36
  179. package/lib/ReactEmptyComponentRegistry.js +0 -48
  180. package/lib/ReactRootIndex.js +0 -29
  181. package/lib/ServerReactRootIndex.js +0 -29
  182. package/lib/cloneWithProps.js +0 -54
  183. package/lib/webcomponents.js +0 -6379
@@ -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,14 +11,19 @@
11
11
 
12
12
  'use strict';
13
13
 
14
+ var DOMPropertyOperations = require('./DOMPropertyOperations');
14
15
  var LinkedValueUtils = require('./LinkedValueUtils');
15
- var ReactDOMIDOperations = require('./ReactDOMIDOperations');
16
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
17
  var ReactUpdates = require('./ReactUpdates');
17
18
 
18
19
  var assign = require('./Object.assign');
19
20
  var invariant = require('fbjs/lib/invariant');
20
21
  var warning = require('fbjs/lib/warning');
21
22
 
23
+ var didWarnValueLink = false;
24
+ var didWarnValueNull = false;
25
+ var didWarnValDefaultVal = false;
26
+
22
27
  function forceUpdateIfMounted() {
23
28
  if (this._rootNodeID) {
24
29
  // DOM component is still mounted; update
@@ -26,6 +31,14 @@ function forceUpdateIfMounted() {
26
31
  }
27
32
  }
28
33
 
34
+ function warnIfValueIsNull(props) {
35
+ if (props != null && props.value === null && !didWarnValueNull) {
36
+ process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `textarea` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.') : undefined;
37
+
38
+ didWarnValueNull = true;
39
+ }
40
+ }
41
+
29
42
  /**
30
43
  * Implements a <textarea> native component that allows setting `value`, and
31
44
  * `defaultValue`. This differs from the traditional DOM API because value is
@@ -42,7 +55,7 @@ function forceUpdateIfMounted() {
42
55
  * `defaultValue` if specified, or the children content (deprecated).
43
56
  */
44
57
  var ReactDOMTextarea = {
45
- getNativeProps: function (inst, props, context) {
58
+ getNativeProps: function (inst, props) {
46
59
  !(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
47
60
 
48
61
  // Always set children to the same thing. In IE9, the selection range will
@@ -60,6 +73,15 @@ var ReactDOMTextarea = {
60
73
  mountWrapper: function (inst, props) {
61
74
  if (process.env.NODE_ENV !== 'production') {
62
75
  LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
76
+ if (props.valueLink !== undefined && !didWarnValueLink) {
77
+ process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.') : undefined;
78
+ didWarnValueLink = true;
79
+ }
80
+ if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
81
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : undefined;
82
+ didWarnValDefaultVal = true;
83
+ }
84
+ warnIfValueIsNull(props);
63
85
  }
64
86
 
65
87
  var defaultValue = props.defaultValue;
@@ -81,24 +103,29 @@ var ReactDOMTextarea = {
81
103
  defaultValue = '';
82
104
  }
83
105
  var value = LinkedValueUtils.getValue(props);
84
-
85
106
  inst._wrapperState = {
86
107
  // We save the initial value so that `ReactDOMComponent` doesn't update
87
108
  // `textContent` (unnecessary since we update value).
88
109
  // The initial value can be a boolean or object so that's why it's
89
110
  // forced to be a string.
90
111
  initialValue: '' + (value != null ? value : defaultValue),
112
+ listeners: null,
91
113
  onChange: _handleChange.bind(inst)
92
114
  };
93
115
  },
94
116
 
95
117
  updateWrapper: function (inst) {
96
118
  var props = inst._currentElement.props;
119
+
120
+ if (process.env.NODE_ENV !== 'production') {
121
+ warnIfValueIsNull(props);
122
+ }
123
+
97
124
  var value = LinkedValueUtils.getValue(props);
98
125
  if (value != null) {
99
126
  // Cast `value` to a string to ensure the value is set correctly. While
100
127
  // browsers typically do this as necessary, jsdom doesn't.
101
- ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
128
+ DOMPropertyOperations.setValueForProperty(ReactDOMComponentTree.getNodeFromInstance(inst), 'value', '' + value);
102
129
  }
103
130
  }
104
131
  };
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Copyright 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactDOMTreeTraversal
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var invariant = require('fbjs/lib/invariant');
15
+
16
+ /**
17
+ * Return the lowest common ancestor of A and B, or null if they are in
18
+ * different trees.
19
+ */
20
+ function getLowestCommonAncestor(instA, instB) {
21
+ !('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : undefined;
22
+ !('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : undefined;
23
+
24
+ var depthA = 0;
25
+ for (var tempA = instA; tempA; tempA = tempA._nativeParent) {
26
+ depthA++;
27
+ }
28
+ var depthB = 0;
29
+ for (var tempB = instB; tempB; tempB = tempB._nativeParent) {
30
+ depthB++;
31
+ }
32
+
33
+ // If A is deeper, crawl up.
34
+ while (depthA - depthB > 0) {
35
+ instA = instA._nativeParent;
36
+ depthA--;
37
+ }
38
+
39
+ // If B is deeper, crawl up.
40
+ while (depthB - depthA > 0) {
41
+ instB = instB._nativeParent;
42
+ depthB--;
43
+ }
44
+
45
+ // Walk in lockstep until we find a match.
46
+ var depth = depthA;
47
+ while (depth--) {
48
+ if (instA === instB) {
49
+ return instA;
50
+ }
51
+ instA = instA._nativeParent;
52
+ instB = instB._nativeParent;
53
+ }
54
+ return null;
55
+ }
56
+
57
+ /**
58
+ * Return if A is an ancestor of B.
59
+ */
60
+ function isAncestor(instA, instB) {
61
+ !('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : undefined;
62
+ !('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : invariant(false) : undefined;
63
+
64
+ while (instB) {
65
+ if (instB === instA) {
66
+ return true;
67
+ }
68
+ instB = instB._nativeParent;
69
+ }
70
+ return false;
71
+ }
72
+
73
+ /**
74
+ * Return the parent instance of the passed-in instance.
75
+ */
76
+ function getParentInstance(inst) {
77
+ !('_nativeNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : invariant(false) : undefined;
78
+
79
+ return inst._nativeParent;
80
+ }
81
+
82
+ /**
83
+ * Simulates the traversal of a two-phase, capture/bubble event dispatch.
84
+ */
85
+ function traverseTwoPhase(inst, fn, arg) {
86
+ var path = [];
87
+ while (inst) {
88
+ path.push(inst);
89
+ inst = inst._nativeParent;
90
+ }
91
+ var i;
92
+ for (i = path.length; i-- > 0;) {
93
+ fn(path[i], false, arg);
94
+ }
95
+ for (i = 0; i < path.length; i++) {
96
+ fn(path[i], true, arg);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
102
+ * should would receive a `mouseEnter` or `mouseLeave` event.
103
+ *
104
+ * Does not invoke the callback on the nearest common ancestor because nothing
105
+ * "entered" or "left" that element.
106
+ */
107
+ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
108
+ var common = from && to ? getLowestCommonAncestor(from, to) : null;
109
+ var pathFrom = [];
110
+ while (from && from !== common) {
111
+ pathFrom.push(from);
112
+ from = from._nativeParent;
113
+ }
114
+ var pathTo = [];
115
+ while (to && to !== common) {
116
+ pathTo.push(to);
117
+ to = to._nativeParent;
118
+ }
119
+ var i;
120
+ for (i = 0; i < pathFrom.length; i++) {
121
+ fn(pathFrom[i], true, argFrom);
122
+ }
123
+ for (i = pathTo.length; i-- > 0;) {
124
+ fn(pathTo[i], false, argTo);
125
+ }
126
+ }
127
+
128
+ module.exports = {
129
+ isAncestor: isAncestor,
130
+ getLowestCommonAncestor: getLowestCommonAncestor,
131
+ getParentInstance: getParentInstance,
132
+ traverseTwoPhase: traverseTwoPhase,
133
+ traverseEnterLeave: traverseEnterLeave
134
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactDOMUnknownPropertyDevtool
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var DOMProperty = require('./DOMProperty');
15
+ var EventPluginRegistry = require('./EventPluginRegistry');
16
+
17
+ var warning = require('fbjs/lib/warning');
18
+
19
+ if (process.env.NODE_ENV !== 'production') {
20
+ var reactProps = {
21
+ children: true,
22
+ dangerouslySetInnerHTML: true,
23
+ key: true,
24
+ ref: true
25
+ };
26
+ var warnedProperties = {};
27
+
28
+ var warnUnknownProperty = function (name) {
29
+ if (DOMProperty.properties.hasOwnProperty(name) || DOMProperty.isCustomAttribute(name)) {
30
+ return;
31
+ }
32
+ if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
33
+ return;
34
+ }
35
+
36
+ warnedProperties[name] = true;
37
+ var lowerCasedName = name.toLowerCase();
38
+
39
+ // data-* attributes should be lowercase; suggest the lowercase version
40
+ var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
41
+
42
+ // For now, only warn when we have a suggested correction. This prevents
43
+ // logging too much when using transferPropsTo.
44
+ process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
45
+
46
+ var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry.possibleRegistrationNames[lowerCasedName] : null;
47
+
48
+ process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?', name, registrationName) : undefined;
49
+ };
50
+ }
51
+
52
+ var ReactDOMUnknownPropertyDevtool = {
53
+ onCreateMarkupForProperty: function (name, value) {
54
+ warnUnknownProperty(name);
55
+ },
56
+ onSetValueForProperty: function (node, name, value) {
57
+ warnUnknownProperty(name);
58
+ },
59
+ onDeleteValueForProperty: function (node, name) {
60
+ warnUnknownProperty(name);
61
+ }
62
+ };
63
+
64
+ module.exports = ReactDOMUnknownPropertyDevtool;
@@ -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
@@ -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
@@ -13,25 +13,23 @@
13
13
 
14
14
  var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
15
15
  var ChangeEventPlugin = require('./ChangeEventPlugin');
16
- var ClientReactRootIndex = require('./ClientReactRootIndex');
17
16
  var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
18
17
  var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
19
18
  var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
20
19
  var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
21
- var ReactBrowserComponentMixin = require('./ReactBrowserComponentMixin');
22
20
  var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
23
- var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
24
21
  var ReactDOMComponent = require('./ReactDOMComponent');
22
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
23
+ var ReactDOMEmptyComponent = require('./ReactDOMEmptyComponent');
24
+ var ReactDOMTreeTraversal = require('./ReactDOMTreeTraversal');
25
25
  var ReactDOMTextComponent = require('./ReactDOMTextComponent');
26
+ var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
26
27
  var ReactEventListener = require('./ReactEventListener');
27
28
  var ReactInjection = require('./ReactInjection');
28
- var ReactInstanceHandles = require('./ReactInstanceHandles');
29
- var ReactMount = require('./ReactMount');
30
29
  var ReactReconcileTransaction = require('./ReactReconcileTransaction');
30
+ var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
31
31
  var SelectEventPlugin = require('./SelectEventPlugin');
32
- var ServerReactRootIndex = require('./ServerReactRootIndex');
33
32
  var SimpleEventPlugin = require('./SimpleEventPlugin');
34
- var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
35
33
 
36
34
  var alreadyInjected = false;
37
35
 
@@ -50,8 +48,8 @@ function inject() {
50
48
  * Inject modules for resolving DOM hierarchy and plugin ordering.
51
49
  */
52
50
  ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
53
- ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
54
- ReactInjection.EventPluginHub.injectMount(ReactMount);
51
+ ReactInjection.EventPluginUtils.injectComponentTree(ReactDOMComponentTree);
52
+ ReactInjection.EventPluginUtils.injectTreeTraversal(ReactDOMTreeTraversal);
55
53
 
56
54
  /**
57
55
  * Some important event plugins included by default (without having to require
@@ -69,18 +67,16 @@ function inject() {
69
67
 
70
68
  ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent);
71
69
 
72
- ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
73
-
74
70
  ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
75
71
  ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
76
72
 
77
- ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
73
+ ReactInjection.EmptyComponent.injectEmptyComponentFactory(function (instantiate) {
74
+ return new ReactDOMEmptyComponent(instantiate);
75
+ });
78
76
 
79
77
  ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
80
78
  ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
81
79
 
82
- ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
83
-
84
80
  ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
85
81
 
86
82
  if (process.env.NODE_ENV !== 'production') {
@@ -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
@@ -7,12 +7,12 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  *
9
9
  * @providesModule ReactDefaultPerf
10
- * @typechecks static-only
11
10
  */
12
11
 
13
12
  'use strict';
14
13
 
15
14
  var DOMProperty = require('./DOMProperty');
15
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
16
  var ReactDefaultPerfAnalysis = require('./ReactDefaultPerfAnalysis');
17
17
  var ReactMount = require('./ReactMount');
18
18
  var ReactPerf = require('./ReactPerf');
@@ -27,9 +27,26 @@ function addValue(obj, key, val) {
27
27
  obj[key] = (obj[key] || 0) + val;
28
28
  }
29
29
 
30
+ // Composites don't have any built-in ID: we have to make our own
31
+ var compositeIDMap;
32
+ var compositeIDCounter = 17000;
33
+ function getIDOfComposite(inst) {
34
+ if (!compositeIDMap) {
35
+ compositeIDMap = new WeakMap();
36
+ }
37
+ if (compositeIDMap.has(inst)) {
38
+ return compositeIDMap.get(inst);
39
+ } else {
40
+ var id = compositeIDCounter++;
41
+ compositeIDMap.set(inst, id);
42
+ return id;
43
+ }
44
+ }
45
+
30
46
  var ReactDefaultPerf = {
31
47
  _allMeasurements: [], // last item in the list is the current one
32
48
  _mountStack: [0],
49
+ _compositeStack: [],
33
50
  _injected: false,
34
51
 
35
52
  start: function () {
@@ -112,7 +129,8 @@ var ReactDefaultPerf = {
112
129
 
113
130
  _recordWrite: function (id, fnName, totalTime, args) {
114
131
  // TODO: totalTime isn't that useful since it doesn't count paints/reflows
115
- var writes = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].writes;
132
+ var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
133
+ var writes = entry.writes;
116
134
  writes[id] = writes[id] || [];
117
135
  writes[id].push({
118
136
  type: fnName,
@@ -131,36 +149,38 @@ var ReactDefaultPerf = {
131
149
  var rv;
132
150
  var start;
133
151
 
152
+ var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
153
+
134
154
  if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') {
135
155
  // A "measurement" is a set of metrics recorded for each flush. We want
136
156
  // to group the metrics for a given flush together so we can look at the
137
157
  // components that rendered and the DOM operations that actually
138
158
  // happened to determine the amount of "wasted work" performed.
139
- ReactDefaultPerf._allMeasurements.push({
159
+ ReactDefaultPerf._allMeasurements.push(entry = {
140
160
  exclusive: {},
141
161
  inclusive: {},
142
162
  render: {},
143
163
  counts: {},
144
164
  writes: {},
145
165
  displayNames: {},
166
+ hierarchy: {},
146
167
  totalTime: 0,
147
168
  created: {}
148
169
  });
149
170
  start = performanceNow();
150
171
  rv = func.apply(this, args);
151
- ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].totalTime = performanceNow() - start;
172
+ entry.totalTime = performanceNow() - start;
152
173
  return rv;
153
- } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactBrowserEventEmitter' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations') {
174
+ } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations' || moduleName === 'ReactComponentBrowserEnvironment') {
154
175
  start = performanceNow();
155
176
  rv = func.apply(this, args);
156
177
  totalTime = performanceNow() - start;
157
178
 
158
179
  if (fnName === '_mountImageIntoNode') {
159
- var mountID = ReactMount.getID(args[1]);
160
- ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
180
+ ReactDefaultPerf._recordWrite('', fnName, totalTime, args[0]);
161
181
  } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
162
182
  // special format
163
- args[0].forEach(function (update) {
183
+ args[1].forEach(function (update) {
164
184
  var writeArgs = {};
165
185
  if (update.fromIndex !== null) {
166
186
  writeArgs.fromIndex = update.fromIndex;
@@ -168,19 +188,21 @@ var ReactDefaultPerf = {
168
188
  if (update.toIndex !== null) {
169
189
  writeArgs.toIndex = update.toIndex;
170
190
  }
171
- if (update.textContent !== null) {
172
- writeArgs.textContent = update.textContent;
173
- }
174
- if (update.markupIndex !== null) {
175
- writeArgs.markup = args[1][update.markupIndex];
191
+ if (update.content !== null) {
192
+ writeArgs.content = update.content;
176
193
  }
177
- ReactDefaultPerf._recordWrite(update.parentID, update.type, totalTime, writeArgs);
194
+ ReactDefaultPerf._recordWrite(args[0]._rootNodeID, update.type, totalTime, writeArgs);
178
195
  });
179
196
  } else {
180
197
  // basic format
181
198
  var id = args[0];
182
- if (typeof id === 'object') {
183
- id = ReactMount.getID(args[0]);
199
+ if (moduleName === 'EventPluginHub') {
200
+ id = id._rootNodeID;
201
+ } else if (fnName === 'replaceNodeWithMarkup') {
202
+ // Old node is already unmounted; can't get its instance
203
+ id = ReactDOMComponentTree.getInstanceFromNode(args[1].node)._rootNodeID;
204
+ } else if (typeof id === 'object') {
205
+ id = ReactDOMComponentTree.getInstanceFromNode(args[0])._rootNodeID;
184
206
  }
185
207
  ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
186
208
  }
@@ -192,12 +214,11 @@ var ReactDefaultPerf = {
192
214
  return func.apply(this, args);
193
215
  }
194
216
 
195
- var rootNodeID = fnName === 'mountComponent' ? args[0] : this._rootNodeID;
217
+ var rootNodeID = getIDOfComposite(this);
196
218
  var isRender = fnName === '_renderValidatedComponent';
197
219
  var isMount = fnName === 'mountComponent';
198
220
 
199
221
  var mountStack = ReactDefaultPerf._mountStack;
200
- var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
201
222
 
202
223
  if (isRender) {
203
224
  addValue(entry.counts, rootNodeID, 1);
@@ -206,10 +227,14 @@ var ReactDefaultPerf = {
206
227
  mountStack.push(0);
207
228
  }
208
229
 
230
+ ReactDefaultPerf._compositeStack.push(rootNodeID);
231
+
209
232
  start = performanceNow();
210
233
  rv = func.apply(this, args);
211
234
  totalTime = performanceNow() - start;
212
235
 
236
+ ReactDefaultPerf._compositeStack.pop();
237
+
213
238
  if (isRender) {
214
239
  addValue(entry.render, rootNodeID, totalTime);
215
240
  } else if (isMount) {
@@ -226,6 +251,11 @@ var ReactDefaultPerf = {
226
251
  owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>'
227
252
  };
228
253
 
254
+ return rv;
255
+ } else if ((moduleName === 'ReactDOMComponent' || moduleName === 'ReactDOMTextComponent') && (fnName === 'mountComponent' || fnName === 'receiveComponent')) {
256
+
257
+ rv = func.apply(this, args);
258
+ entry.hierarchy[this._rootNodeID] = ReactDefaultPerf._compositeStack.slice();
229
259
  return rv;
230
260
  } else {
231
261
  return func.apply(this, args);