react 15.0.3-alpha.1 → 15.2.0-rc.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 (122) hide show
  1. package/dist/react-with-addons.js +3311 -2007
  2. package/dist/react-with-addons.min.js +7 -6
  3. package/dist/react.js +2734 -2014
  4. package/dist/react.min.js +6 -6
  5. package/lib/CSSPropertyOperations.js +5 -5
  6. package/lib/CallbackQueue.js +3 -2
  7. package/lib/DOMChildrenOperations.js +42 -7
  8. package/lib/DOMLazyTree.js +18 -5
  9. package/lib/DOMProperty.js +6 -4
  10. package/lib/DOMPropertyOperations.js +35 -12
  11. package/lib/Danger.js +10 -8
  12. package/lib/DisabledInputUtils.js +5 -5
  13. package/lib/EventPluginHub.js +8 -2
  14. package/lib/EventPluginRegistry.js +13 -7
  15. package/lib/EventPluginUtils.js +3 -1
  16. package/lib/HTMLDOMPropertyConfig.js +1 -2
  17. package/lib/LinkedStateMixin.js +1 -0
  18. package/lib/LinkedValueUtils.js +5 -3
  19. package/lib/NativeMethodsMixin.js +6 -4
  20. package/lib/PooledClass.js +3 -1
  21. package/lib/React.js +1 -1
  22. package/lib/ReactCSSTransitionGroup.js +5 -0
  23. package/lib/ReactCSSTransitionGroupChild.js +15 -8
  24. package/lib/ReactChildReconciler.js +15 -6
  25. package/lib/ReactChildren.js +9 -1
  26. package/lib/ReactClass.js +15 -13
  27. package/lib/ReactComponent.js +3 -6
  28. package/lib/ReactComponentBrowserEnvironment.js +0 -5
  29. package/lib/ReactComponentEnvironment.js +3 -1
  30. package/lib/ReactComponentTreeDevtool.js +223 -0
  31. package/lib/ReactComponentTreeTestUtils.js +87 -0
  32. package/lib/ReactComponentWithPureRenderMixin.js +2 -0
  33. package/lib/ReactCompositeComponent.js +208 -119
  34. package/lib/ReactDOM.js +3 -6
  35. package/lib/ReactDOMButton.js +2 -2
  36. package/lib/ReactDOMComponent.js +165 -71
  37. package/lib/ReactDOMComponentTree.js +23 -21
  38. package/lib/ReactDOMDebugTool.js +7 -1
  39. package/lib/ReactDOMEmptyComponent.js +9 -9
  40. package/lib/ReactDOMFactories.js +1 -1
  41. package/lib/ReactDOMIDOperations.js +0 -5
  42. package/lib/ReactDOMInput.js +57 -19
  43. package/lib/ReactDOMOption.js +40 -26
  44. package/lib/ReactDOMSelect.js +3 -3
  45. package/lib/ReactDOMTextComponent.js +28 -26
  46. package/lib/ReactDOMTextarea.js +59 -32
  47. package/lib/ReactDOMTreeTraversal.js +18 -16
  48. package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
  49. package/lib/ReactDebugTool.js +250 -11
  50. package/lib/ReactDefaultInjection.js +2 -11
  51. package/lib/ReactElement.js +90 -25
  52. package/lib/ReactElementValidator.js +26 -81
  53. package/lib/ReactEventListener.js +2 -2
  54. package/lib/ReactFragment.js +8 -3
  55. package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
  56. package/lib/ReactHostOperationHistoryDevtool.js +37 -0
  57. package/lib/ReactInjection.js +2 -4
  58. package/lib/ReactInstanceHandles.js +8 -6
  59. package/lib/ReactLink.js +3 -0
  60. package/lib/ReactMount.js +43 -20
  61. package/lib/ReactMultiChild.js +51 -8
  62. package/lib/ReactNativeAttributePayload.js +5 -2
  63. package/lib/ReactNativeBaseComponent.js +7 -7
  64. package/lib/ReactNativeBridgeEventPlugin.js +1 -1
  65. package/lib/ReactNativeComponentTree.js +8 -6
  66. package/lib/ReactNativeDOMIDOperations.js +4 -8
  67. package/lib/ReactNativeDefaultInjection.js +9 -7
  68. package/lib/ReactNativeGlobalResponderHandler.js +1 -1
  69. package/lib/ReactNativeMount.js +25 -8
  70. package/lib/ReactNativeTagHandles.js +3 -1
  71. package/lib/ReactNativeTextComponent.js +18 -9
  72. package/lib/ReactNativeTreeTraversal.js +11 -11
  73. package/lib/ReactNodeTypes.js +5 -3
  74. package/lib/ReactNoop.js +76 -0
  75. package/lib/ReactOwner.js +4 -2
  76. package/lib/ReactPerf.js +473 -75
  77. package/lib/ReactPropTypes.js +23 -0
  78. package/lib/ReactReconcileTransaction.js +1 -1
  79. package/lib/ReactReconciler.js +57 -11
  80. package/lib/ReactServerRendering.js +24 -3
  81. package/lib/ReactServerRenderingTransaction.js +5 -1
  82. package/lib/ReactSimpleEmptyComponent.js +4 -4
  83. package/lib/ReactTestMount.js +126 -0
  84. package/lib/ReactTestReconcileTransaction.js +100 -0
  85. package/lib/ReactTestRenderer.js +133 -0
  86. package/lib/ReactTestUtils.js +25 -10
  87. package/lib/ReactTransitionChildMapping.js +7 -1
  88. package/lib/ReactTransitionGroup.js +44 -5
  89. package/lib/ReactUpdateQueue.js +9 -1
  90. package/lib/ReactUpdates.js +30 -11
  91. package/lib/ReactVersion.js +1 -1
  92. package/lib/ReactWithAddons.js +1 -1
  93. package/lib/ResponderEventPlugin.js +8 -6
  94. package/lib/ResponderTouchHistoryStore.js +6 -4
  95. package/lib/SimpleEventPlugin.js +3 -1
  96. package/lib/SyntheticEvent.js +2 -3
  97. package/lib/SyntheticUIEvent.js +1 -1
  98. package/lib/Transaction.js +4 -2
  99. package/lib/accumulate.js +3 -1
  100. package/lib/accumulateInto.js +3 -1
  101. package/lib/checkReactTypeSpec.js +71 -0
  102. package/lib/createReactNativeComponentClass.js +2 -2
  103. package/lib/dangerousStyleValue.js +3 -1
  104. package/lib/escapeTextContentForBrowser.js +96 -12
  105. package/lib/findDOMNode.js +8 -4
  106. package/lib/findNodeHandle.js +5 -3
  107. package/lib/flattenChildren.js +13 -4
  108. package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
  109. package/lib/instantiateReactComponent.js +44 -10
  110. package/lib/onlyChild.js +10 -5
  111. package/lib/reactComponentExpect.js +3 -3
  112. package/lib/reactProdInvariant.js +38 -0
  113. package/lib/setInnerHTML.js +17 -1
  114. package/lib/setTextContent.js +8 -0
  115. package/lib/shallowCompare.js +1 -0
  116. package/lib/traverseAllChildren.js +3 -1
  117. package/lib/update.js +16 -11
  118. package/package.json +2 -2
  119. package/lib/MetaMatchers.js +0 -118
  120. package/lib/ReactDebugInstanceMap.js +0 -102
  121. package/lib/ReactDefaultPerf.js +0 -316
  122. package/lib/ReactDefaultPerfAnalysis.js +0 -210
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react",
3
3
  "description": "React is a JavaScript library for building user interfaces.",
4
- "version": "15.0.3-alpha.1",
4
+ "version": "15.2.0-rc.1",
5
5
  "keywords": [
6
6
  "react"
7
7
  ],
@@ -23,7 +23,7 @@
23
23
  "node": ">=0.10.0"
24
24
  },
25
25
  "dependencies": {
26
- "fbjs": "^0.8.0",
26
+ "fbjs": "^0.8.1",
27
27
  "loose-envify": "^1.1.0",
28
28
  "object-assign": "^4.1.0"
29
29
  },
@@ -1,118 +0,0 @@
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 MetaMatchers
10
- */
11
-
12
- 'use strict';
13
-
14
- /**
15
- * This modules adds a jasmine matcher toEqualSpecsIn that can be used to
16
- * compare the specs in two different "describe" functions and their result.
17
- * It can be used to test a test.
18
- */
19
-
20
- function getRunnerWithResults(describeFunction) {
21
- if (describeFunction._cachedRunner) {
22
- // Cached result of execution. This is a convenience way to test against
23
- // the same authoritative function multiple times.
24
- return describeFunction._cachedRunner;
25
- }
26
- // Patch the current global environment.
27
- var env = new jasmine.Env();
28
- // Execute the tests synchronously.
29
- env.updateInterval = 0;
30
- var outerGetEnv = jasmine.getEnv;
31
- jasmine.getEnv = function () {
32
- return env;
33
- };
34
- // TODO: Bring over matchers from the existing environment.
35
- var runner = env.currentRunner();
36
- try {
37
- env.describe('', describeFunction);
38
- env.execute();
39
- } finally {
40
- // Restore the environment.
41
- jasmine.getEnv = outerGetEnv;
42
- }
43
- describeFunction._cachedRunner = runner;
44
- return runner;
45
- }
46
-
47
- function compareSpec(actual, expected) {
48
- if (actual.results().totalCount !== expected.results().totalCount) {
49
- return 'Expected ' + expected.results().totalCount + ' expects, ' + 'but got ' + actual.results().totalCount + ':' + actual.getFullName();
50
- }
51
- return null;
52
- }
53
-
54
- function includesDescription(specs, description, startIndex) {
55
- for (var i = startIndex; i < specs.length; i++) {
56
- if (specs[i].description === description) {
57
- return true;
58
- }
59
- }
60
- return false;
61
- }
62
-
63
- function compareSpecs(actualSpecs, expectedSpecs) {
64
- for (var i = 0; i < actualSpecs.length && i < expectedSpecs.length; i++) {
65
- var actual = actualSpecs[i];
66
- var expected = expectedSpecs[i];
67
- if (actual.description === expected.description) {
68
- var errorMessage = compareSpec(actual, expected);
69
- if (errorMessage) {
70
- return errorMessage;
71
- }
72
- continue;
73
- } else if (includesDescription(actualSpecs, expected.description, i)) {
74
- return 'Did not expect the spec:' + actualSpecs[i].getFullName();
75
- } else {
76
- return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
77
- }
78
- }
79
- if (i < actualSpecs.length) {
80
- return 'Did not expect the spec:' + actualSpecs[i].getFullName();
81
- }
82
- if (i < expectedSpecs.length) {
83
- return 'Expected an equivalent to:' + expectedSpecs[i].getFullName();
84
- }
85
- return null;
86
- }
87
-
88
- function compareDescription(a, b) {
89
- if (a.description === b.description) {
90
- return 0;
91
- }
92
- return a.description < b.description ? -1 : 1;
93
- }
94
-
95
- function compareRunners(actual, expected) {
96
- return compareSpecs(actual.specs().sort(compareDescription), expected.specs().sort(compareDescription));
97
- }
98
-
99
- var MetaMatchers = {
100
- toEqualSpecsIn: function (expectedDescribeFunction) {
101
- var actualDescribeFunction = this.actual;
102
- if (typeof actualDescribeFunction !== 'function') {
103
- throw Error('toEqualSpecsIn() should be used on a describe function');
104
- }
105
- if (typeof expectedDescribeFunction !== 'function') {
106
- throw Error('toEqualSpecsIn() should be passed a describe function');
107
- }
108
- var actual = getRunnerWithResults(actualDescribeFunction);
109
- var expected = getRunnerWithResults(expectedDescribeFunction);
110
- var errorMessage = compareRunners(actual, expected);
111
- this.message = function () {
112
- return [errorMessage, 'The specs are equal. Expected them to be different.'];
113
- };
114
- return !errorMessage;
115
- }
116
- };
117
-
118
- module.exports = MetaMatchers;
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright 2016-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 ReactDebugInstanceMap
10
- */
11
-
12
- 'use strict';
13
-
14
- var warning = require('fbjs/lib/warning');
15
-
16
- function checkValidInstance(internalInstance) {
17
- if (!internalInstance) {
18
- process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received %s. ' + 'Please report this as a bug in React.', internalInstance) : void 0;
19
- return false;
20
- }
21
- var isValid = typeof internalInstance.mountComponent === 'function';
22
- process.env.NODE_ENV !== 'production' ? warning(isValid, 'There is an internal error in the React developer tools integration. ' + 'Instead of an internal instance, received an object with the following ' + 'keys: %s. Please report this as a bug in React.', Object.keys(internalInstance).join(', ')) : void 0;
23
- return isValid;
24
- }
25
-
26
- var idCounter = 1;
27
- var instancesByIDs = {};
28
- var instancesToIDs;
29
-
30
- function getIDForInstance(internalInstance) {
31
- if (!instancesToIDs) {
32
- instancesToIDs = new WeakMap();
33
- }
34
- if (instancesToIDs.has(internalInstance)) {
35
- return instancesToIDs.get(internalInstance);
36
- } else {
37
- var instanceID = (idCounter++).toString();
38
- instancesToIDs.set(internalInstance, instanceID);
39
- return instanceID;
40
- }
41
- }
42
-
43
- function getInstanceByID(instanceID) {
44
- return instancesByIDs[instanceID] || null;
45
- }
46
-
47
- function isRegisteredInstance(internalInstance) {
48
- var instanceID = getIDForInstance(internalInstance);
49
- if (instanceID) {
50
- return instancesByIDs.hasOwnProperty(instanceID);
51
- } else {
52
- return false;
53
- }
54
- }
55
-
56
- function registerInstance(internalInstance) {
57
- var instanceID = getIDForInstance(internalInstance);
58
- if (instanceID) {
59
- instancesByIDs[instanceID] = internalInstance;
60
- }
61
- }
62
-
63
- function unregisterInstance(internalInstance) {
64
- var instanceID = getIDForInstance(internalInstance);
65
- if (instanceID) {
66
- delete instancesByIDs[instanceID];
67
- }
68
- }
69
-
70
- var ReactDebugInstanceMap = {
71
- getIDForInstance: function (internalInstance) {
72
- if (!checkValidInstance(internalInstance)) {
73
- return null;
74
- }
75
- return getIDForInstance(internalInstance);
76
- },
77
- getInstanceByID: function (instanceID) {
78
- return getInstanceByID(instanceID);
79
- },
80
- isRegisteredInstance: function (internalInstance) {
81
- if (!checkValidInstance(internalInstance)) {
82
- return false;
83
- }
84
- return isRegisteredInstance(internalInstance);
85
- },
86
- registerInstance: function (internalInstance) {
87
- if (!checkValidInstance(internalInstance)) {
88
- return;
89
- }
90
- process.env.NODE_ENV !== 'production' ? warning(!isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'A registered instance should not be registered again. ' + 'Please report this as a bug in React.') : void 0;
91
- registerInstance(internalInstance);
92
- },
93
- unregisterInstance: function (internalInstance) {
94
- if (!checkValidInstance(internalInstance)) {
95
- return;
96
- }
97
- process.env.NODE_ENV !== 'production' ? warning(isRegisteredInstance(internalInstance), 'There is an internal error in the React developer tools integration. ' + 'An unregistered instance should not be unregistered again. ' + 'Please report this as a bug in React.') : void 0;
98
- unregisterInstance(internalInstance);
99
- }
100
- };
101
-
102
- module.exports = ReactDebugInstanceMap;
@@ -1,316 +0,0 @@
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 ReactDefaultPerf
10
- */
11
-
12
- 'use strict';
13
-
14
- var DOMProperty = require('./DOMProperty');
15
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
- var ReactDefaultPerfAnalysis = require('./ReactDefaultPerfAnalysis');
17
- var ReactMount = require('./ReactMount');
18
- var ReactPerf = require('./ReactPerf');
19
-
20
- var performanceNow = require('fbjs/lib/performanceNow');
21
- var warning = require('fbjs/lib/warning');
22
-
23
- function roundFloat(val) {
24
- return Math.floor(val * 100) / 100;
25
- }
26
-
27
- function addValue(obj, key, val) {
28
- obj[key] = (obj[key] || 0) + val;
29
- }
30
-
31
- // Composite/text components don't have any built-in ID: we have to make our own
32
- var compositeIDMap;
33
- var compositeIDCounter = 17000;
34
- function getIDOfComposite(inst) {
35
- if (!compositeIDMap) {
36
- compositeIDMap = new WeakMap();
37
- }
38
- if (compositeIDMap.has(inst)) {
39
- return compositeIDMap.get(inst);
40
- } else {
41
- var id = compositeIDCounter++;
42
- compositeIDMap.set(inst, id);
43
- return id;
44
- }
45
- }
46
-
47
- function getID(inst) {
48
- if (inst.hasOwnProperty('_rootNodeID')) {
49
- return inst._rootNodeID;
50
- } else {
51
- return getIDOfComposite(inst);
52
- }
53
- }
54
-
55
- function stripComplexValues(key, value) {
56
- if (typeof value !== 'object' || Array.isArray(value) || value == null) {
57
- return value;
58
- }
59
- var prototype = Object.getPrototypeOf(value);
60
- if (!prototype || prototype === Object.prototype) {
61
- return value;
62
- }
63
- return '<not serializable>';
64
- }
65
-
66
- // This implementation of ReactPerf is going away some time mid 15.x.
67
- // While we plan to keep most of the API, the actual format of measurements
68
- // will change dramatically. To signal this, we wrap them into an opaque-ish
69
- // object to discourage reaching into it until the API stabilizes.
70
- function wrapLegacyMeasurements(measurements) {
71
- return { __unstable_this_format_will_change: measurements };
72
- }
73
- function unwrapLegacyMeasurements(measurements) {
74
- return measurements && measurements.__unstable_this_format_will_change || measurements;
75
- }
76
-
77
- var warnedAboutPrintDOM = false;
78
- var warnedAboutGetMeasurementsSummaryMap = false;
79
-
80
- var ReactDefaultPerf = {
81
- _allMeasurements: [], // last item in the list is the current one
82
- _mountStack: [0],
83
- _compositeStack: [],
84
- _injected: false,
85
-
86
- start: function () {
87
- if (!ReactDefaultPerf._injected) {
88
- ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
89
- }
90
-
91
- ReactDefaultPerf._allMeasurements.length = 0;
92
- ReactPerf.enableMeasure = true;
93
- },
94
-
95
- stop: function () {
96
- ReactPerf.enableMeasure = false;
97
- },
98
-
99
- getLastMeasurements: function () {
100
- return wrapLegacyMeasurements(ReactDefaultPerf._allMeasurements);
101
- },
102
-
103
- printExclusive: function (measurements) {
104
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
105
- var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
106
- console.table(summary.map(function (item) {
107
- return {
108
- 'Component class name': item.componentName,
109
- 'Total inclusive time (ms)': roundFloat(item.inclusive),
110
- 'Exclusive mount time (ms)': roundFloat(item.exclusive),
111
- 'Exclusive render time (ms)': roundFloat(item.render),
112
- 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
113
- 'Render time per instance (ms)': roundFloat(item.render / item.count),
114
- 'Instances': item.count
115
- };
116
- }));
117
- // TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
118
- // number.
119
- },
120
-
121
- printInclusive: function (measurements) {
122
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
123
- var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
124
- console.table(summary.map(function (item) {
125
- return {
126
- 'Owner > component': item.componentName,
127
- 'Inclusive time (ms)': roundFloat(item.time),
128
- 'Instances': item.count
129
- };
130
- }));
131
- console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
132
- },
133
-
134
- getMeasurementsSummaryMap: function (measurements) {
135
- process.env.NODE_ENV !== 'production' ? warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.') : void 0;
136
- warnedAboutGetMeasurementsSummaryMap = true;
137
- return ReactDefaultPerf.getWasted(measurements);
138
- },
139
-
140
- getWasted: function (measurements) {
141
- measurements = unwrapLegacyMeasurements(measurements);
142
- var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true);
143
- return summary.map(function (item) {
144
- return {
145
- 'Owner > component': item.componentName,
146
- 'Wasted time (ms)': item.time,
147
- 'Instances': item.count
148
- };
149
- });
150
- },
151
-
152
- printWasted: function (measurements) {
153
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
154
- console.table(ReactDefaultPerf.getWasted(measurements));
155
- console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
156
- },
157
-
158
- printDOM: function (measurements) {
159
- process.env.NODE_ENV !== 'production' ? warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.') : void 0;
160
- warnedAboutPrintDOM = true;
161
- return ReactDefaultPerf.printOperations(measurements);
162
- },
163
-
164
- printOperations: function (measurements) {
165
- measurements = unwrapLegacyMeasurements(measurements || ReactDefaultPerf._allMeasurements);
166
- var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
167
- console.table(summary.map(function (item) {
168
- var result = {};
169
- result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
170
- result.type = item.type;
171
- result.args = JSON.stringify(item.args, stripComplexValues);
172
- return result;
173
- }));
174
- console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
175
- },
176
-
177
- _recordWrite: function (id, fnName, totalTime, args) {
178
- // TODO: totalTime isn't that useful since it doesn't count paints/reflows
179
- var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
180
- var writes = entry.writes;
181
- writes[id] = writes[id] || [];
182
- writes[id].push({
183
- type: fnName,
184
- time: totalTime,
185
- args: args
186
- });
187
- },
188
-
189
- measure: function (moduleName, fnName, func) {
190
- return function () {
191
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
192
- args[_key] = arguments[_key];
193
- }
194
-
195
- var totalTime;
196
- var rv;
197
- var start;
198
-
199
- var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
200
-
201
- if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') {
202
- // A "measurement" is a set of metrics recorded for each flush. We want
203
- // to group the metrics for a given flush together so we can look at the
204
- // components that rendered and the DOM operations that actually
205
- // happened to determine the amount of "wasted work" performed.
206
- ReactDefaultPerf._allMeasurements.push(entry = {
207
- exclusive: {},
208
- inclusive: {},
209
- render: {},
210
- counts: {},
211
- writes: {},
212
- displayNames: {},
213
- hierarchy: {},
214
- totalTime: 0,
215
- created: {}
216
- });
217
- start = performanceNow();
218
- rv = func.apply(this, args);
219
- entry.totalTime = performanceNow() - start;
220
- return rv;
221
- } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations' || moduleName === 'ReactComponentBrowserEnvironment') {
222
- start = performanceNow();
223
- rv = func.apply(this, args);
224
- totalTime = performanceNow() - start;
225
-
226
- if (fnName === '_mountImageIntoNode') {
227
- ReactDefaultPerf._recordWrite('', fnName, totalTime, args[0]);
228
- } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
229
- // special format
230
- args[1].forEach(function (update) {
231
- var writeArgs = {};
232
- if (update.fromIndex !== null) {
233
- writeArgs.fromIndex = update.fromIndex;
234
- }
235
- if (update.toIndex !== null) {
236
- writeArgs.toIndex = update.toIndex;
237
- }
238
- if (update.content !== null) {
239
- writeArgs.content = update.content;
240
- }
241
- ReactDefaultPerf._recordWrite(args[0]._rootNodeID, update.type, totalTime, writeArgs);
242
- });
243
- } else {
244
- // basic format
245
- var id = args[0];
246
- if (moduleName === 'EventPluginHub') {
247
- id = id._rootNodeID;
248
- } else if (fnName === 'replaceNodeWithMarkup') {
249
- // Old node is already unmounted; can't get its instance
250
- id = ReactDOMComponentTree.getInstanceFromNode(args[1].node)._rootNodeID;
251
- } else if (fnName === 'replaceDelimitedText') {
252
- id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
253
- } else if (typeof id === 'object') {
254
- id = getID(ReactDOMComponentTree.getInstanceFromNode(args[0]));
255
- }
256
- ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
257
- }
258
- return rv;
259
- } else if (moduleName === 'ReactCompositeComponent' && (fnName === 'mountComponent' || fnName === 'updateComponent' || // TODO: receiveComponent()?
260
- fnName === '_renderValidatedComponent')) {
261
-
262
- if (this._currentElement.type === ReactMount.TopLevelWrapper) {
263
- return func.apply(this, args);
264
- }
265
-
266
- var rootNodeID = getIDOfComposite(this);
267
- var isRender = fnName === '_renderValidatedComponent';
268
- var isMount = fnName === 'mountComponent';
269
-
270
- var mountStack = ReactDefaultPerf._mountStack;
271
-
272
- if (isRender) {
273
- addValue(entry.counts, rootNodeID, 1);
274
- } else if (isMount) {
275
- entry.created[rootNodeID] = true;
276
- mountStack.push(0);
277
- }
278
-
279
- ReactDefaultPerf._compositeStack.push(rootNodeID);
280
-
281
- start = performanceNow();
282
- rv = func.apply(this, args);
283
- totalTime = performanceNow() - start;
284
-
285
- ReactDefaultPerf._compositeStack.pop();
286
-
287
- if (isRender) {
288
- addValue(entry.render, rootNodeID, totalTime);
289
- } else if (isMount) {
290
- var subMountTime = mountStack.pop();
291
- mountStack[mountStack.length - 1] += totalTime;
292
- addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
293
- addValue(entry.inclusive, rootNodeID, totalTime);
294
- } else {
295
- addValue(entry.inclusive, rootNodeID, totalTime);
296
- }
297
-
298
- entry.displayNames[rootNodeID] = {
299
- current: this.getName(),
300
- owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>'
301
- };
302
-
303
- return rv;
304
- } else if ((moduleName === 'ReactDOMComponent' || moduleName === 'ReactDOMTextComponent') && (fnName === 'mountComponent' || fnName === 'receiveComponent')) {
305
-
306
- rv = func.apply(this, args);
307
- entry.hierarchy[getID(this)] = ReactDefaultPerf._compositeStack.slice();
308
- return rv;
309
- } else {
310
- return func.apply(this, args);
311
- }
312
- };
313
- }
314
- };
315
-
316
- module.exports = ReactDefaultPerf;