react 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +15 -228
  2. package/ReactJSErrors.js +40 -0
  3. package/addons.js +4 -0
  4. package/lib/$.js +46 -0
  5. package/lib/CSSCore.js +114 -0
  6. package/lib/CSSProperty.js +90 -0
  7. package/lib/CSSPropertyOperations.js +97 -0
  8. package/lib/CallbackRegistry.js +91 -0
  9. package/lib/ChangeEventPlugin.js +365 -0
  10. package/lib/CompositionEventPlugin.js +212 -0
  11. package/lib/DOMChildrenOperations.js +135 -0
  12. package/lib/DOMProperty.js +266 -0
  13. package/lib/DOMPropertyOperations.js +168 -0
  14. package/lib/Danger.js +186 -0
  15. package/lib/DefaultDOMPropertyConfig.js +187 -0
  16. package/lib/DefaultEventPluginOrder.js +44 -0
  17. package/lib/EnterLeaveEventPlugin.js +112 -0
  18. package/lib/EventConstants.js +73 -0
  19. package/lib/EventListener.js +61 -0
  20. package/lib/EventPluginHub.js +190 -0
  21. package/lib/EventPluginRegistry.js +237 -0
  22. package/lib/EventPluginUtils.js +185 -0
  23. package/lib/EventPropagators.js +179 -0
  24. package/lib/ExecutionEnvironment.js +41 -0
  25. package/lib/LinkedStateMixin.js +46 -0
  26. package/lib/LinkedValueMixin.js +68 -0
  27. package/lib/MobileSafariClickEventPlugin.js +63 -0
  28. package/lib/PooledClass.js +113 -0
  29. package/lib/React.js +71 -0
  30. package/lib/ReactChildren.js +132 -0
  31. package/lib/ReactComponent.js +515 -0
  32. package/lib/ReactComponentBrowserEnvironment.js +140 -0
  33. package/lib/ReactComponentEnvironment.js +24 -0
  34. package/lib/ReactCompositeComponent.js +1020 -0
  35. package/lib/ReactCurrentOwner.js +39 -0
  36. package/lib/ReactDOM.js +194 -0
  37. package/lib/ReactDOMButton.js +64 -0
  38. package/lib/ReactDOMComponent.js +374 -0
  39. package/lib/ReactDOMForm.js +52 -0
  40. package/lib/ReactDOMIDOperations.js +173 -0
  41. package/lib/ReactDOMInput.js +169 -0
  42. package/lib/ReactDOMOption.js +50 -0
  43. package/lib/ReactDOMSelect.js +160 -0
  44. package/lib/ReactDOMSelection.js +189 -0
  45. package/lib/ReactDOMTextarea.js +136 -0
  46. package/lib/ReactDefaultBatchingStrategy.js +75 -0
  47. package/lib/ReactDefaultInjection.js +91 -0
  48. package/lib/ReactDefaultPerf.js +407 -0
  49. package/lib/ReactErrorUtils.js +46 -0
  50. package/lib/ReactEventEmitter.js +341 -0
  51. package/lib/ReactEventEmitterMixin.js +89 -0
  52. package/lib/ReactEventTopLevelCallback.js +89 -0
  53. package/lib/ReactInputSelection.js +140 -0
  54. package/lib/ReactInstanceHandles.js +322 -0
  55. package/lib/ReactLink.js +54 -0
  56. package/lib/ReactMarkupChecksum.js +53 -0
  57. package/lib/ReactMount.js +617 -0
  58. package/lib/ReactMountReady.js +95 -0
  59. package/lib/ReactMultiChild.js +441 -0
  60. package/lib/ReactMultiChildUpdateTypes.js +36 -0
  61. package/lib/ReactOwner.js +146 -0
  62. package/lib/ReactPerf.js +88 -0
  63. package/lib/ReactPropTransferer.js +128 -0
  64. package/lib/ReactPropTypes.js +158 -0
  65. package/lib/ReactReconcileTransaction.js +161 -0
  66. package/lib/ReactServerRendering.js +62 -0
  67. package/lib/ReactStateSetters.js +111 -0
  68. package/lib/ReactTextComponent.js +94 -0
  69. package/lib/ReactTransitionEvents.js +97 -0
  70. package/lib/ReactTransitionGroup.js +112 -0
  71. package/lib/ReactTransitionKeySet.js +111 -0
  72. package/lib/ReactTransitionableChild.js +152 -0
  73. package/lib/ReactUpdates.js +145 -0
  74. package/lib/ReactWithAddons.js +41 -0
  75. package/lib/SelectEventPlugin.js +217 -0
  76. package/lib/SimpleEventPlugin.js +365 -0
  77. package/lib/SyntheticClipboardEvent.js +45 -0
  78. package/lib/SyntheticCompositionEvent.js +51 -0
  79. package/lib/SyntheticEvent.js +163 -0
  80. package/lib/SyntheticFocusEvent.js +44 -0
  81. package/lib/SyntheticKeyboardEvent.js +56 -0
  82. package/lib/SyntheticMouseEvent.js +85 -0
  83. package/lib/SyntheticTouchEvent.js +50 -0
  84. package/lib/SyntheticUIEvent.js +45 -0
  85. package/lib/SyntheticWheelEvent.js +63 -0
  86. package/lib/Transaction.js +251 -0
  87. package/lib/ViewportMetrics.js +37 -0
  88. package/lib/accumulate.js +54 -0
  89. package/lib/adler32.js +39 -0
  90. package/lib/containsNode.js +49 -0
  91. package/lib/copyProperties.js +54 -0
  92. package/lib/createArrayFrom.js +94 -0
  93. package/lib/createNodesFromMarkup.js +93 -0
  94. package/lib/createObjectFrom.js +61 -0
  95. package/lib/cx.js +44 -0
  96. package/lib/dangerousStyleValue.js +57 -0
  97. package/lib/emptyFunction.js +43 -0
  98. package/lib/escapeTextForBrowser.js +47 -0
  99. package/lib/ex.js +49 -0
  100. package/lib/filterAttributes.js +45 -0
  101. package/lib/flattenChildren.js +54 -0
  102. package/lib/forEachAccumulated.js +36 -0
  103. package/lib/ge.js +76 -0
  104. package/lib/getActiveElement.js +33 -0
  105. package/lib/getEventTarget.js +36 -0
  106. package/lib/getMarkupWrap.js +108 -0
  107. package/lib/getNodeForCharacterOffset.js +80 -0
  108. package/lib/getReactRootElementInContainer.js +40 -0
  109. package/lib/getTextContentAccessor.js +40 -0
  110. package/lib/getUnboundedScrollPosition.js +45 -0
  111. package/lib/hyphenate.js +35 -0
  112. package/lib/invariant.js +54 -0
  113. package/lib/isEventSupported.js +74 -0
  114. package/lib/isNode.js +33 -0
  115. package/lib/isTextInputElement.js +49 -0
  116. package/lib/isTextNode.js +30 -0
  117. package/lib/joinClasses.js +44 -0
  118. package/lib/keyMirror.js +58 -0
  119. package/lib/keyOf.js +41 -0
  120. package/lib/memoizeStringOnly.js +39 -0
  121. package/lib/merge.js +37 -0
  122. package/lib/mergeHelpers.js +137 -0
  123. package/lib/mergeInto.js +45 -0
  124. package/lib/mixInto.js +34 -0
  125. package/lib/mutateHTMLNodeWithMarkup.js +100 -0
  126. package/lib/objMap.js +47 -0
  127. package/lib/objMapKeyVal.js +47 -0
  128. package/lib/performanceNow.js +42 -0
  129. package/lib/shallowEqual.js +49 -0
  130. package/lib/traverseAllChildren.js +127 -0
  131. package/package.json +33 -31
  132. package/react.js +4 -0
  133. package/.npmignore +0 -7
  134. package/.travis.yml +0 -7
  135. package/Jakefile.js +0 -39
  136. package/LICENSE +0 -19
  137. package/browser-test/dist.html +0 -90
  138. package/browser-test/index.html +0 -86
  139. package/browser-test/min.html +0 -90
  140. package/dist/react.js +0 -3141
  141. package/dist/react.min.js +0 -22
  142. package/doc/advanced.md +0 -175
  143. package/doc/color-def.graffle +0 -938
  144. package/doc/color-def.png +0 -0
  145. package/doc/simple.dot +0 -25
  146. package/doc/simple.png +0 -0
  147. package/examples/longer-example.js +0 -41
  148. package/examples/simple.js +0 -45
  149. package/examples/using-ast-directly.js +0 -30
  150. package/examples/using-events1.js +0 -79
  151. package/examples/using-log-events.js +0 -43
  152. package/lib/base-task.js +0 -120
  153. package/lib/cb-task.js +0 -84
  154. package/lib/core.js +0 -138
  155. package/lib/dsl.js +0 -138
  156. package/lib/error.js +0 -55
  157. package/lib/event-collector.js +0 -81
  158. package/lib/event-manager.js +0 -89
  159. package/lib/eventemitter.js +0 -20
  160. package/lib/finalcb-first-task.js +0 -68
  161. package/lib/finalcb-task.js +0 -65
  162. package/lib/id.js +0 -22
  163. package/lib/input-parser.js +0 -56
  164. package/lib/log-events.js +0 -101
  165. package/lib/parse.js +0 -41
  166. package/lib/promise-resolve.js +0 -50
  167. package/lib/promise-task.js +0 -93
  168. package/lib/react.js +0 -59
  169. package/lib/ret-task.js +0 -71
  170. package/lib/sprintf.js +0 -18
  171. package/lib/status.js +0 -14
  172. package/lib/task.js +0 -251
  173. package/lib/track-tasks.js +0 -74
  174. package/lib/validate.js +0 -159
  175. package/lib/vcon.js +0 -113
  176. package/lib/when-task.js +0 -84
  177. package/src/dist.build.requirejs +0 -20
  178. package/test/ast.mocha.js +0 -136
  179. package/test/cb-task.mocha.js +0 -220
  180. package/test/core-deferred.mocha.js +0 -143
  181. package/test/core-when.mocha.js +0 -96
  182. package/test/core.mocha.js +0 -589
  183. package/test/dsl.mocha.js +0 -352
  184. package/test/event-manager.mocha.js +0 -119
  185. package/test/exec-options.mocha.js +0 -48
  186. package/test/finalcb-task.mocha.js +0 -58
  187. package/test/input-parser.mocha.js +0 -86
  188. package/test/log-events.mocha.js +0 -88
  189. package/test/mocha.opts +0 -2
  190. package/test/module-use.mocha.js +0 -164
  191. package/test/promise-auto-resolve.mocha.js +0 -68
  192. package/test/ret-task.mocha.js +0 -220
  193. package/test/task.mocha.js +0 -42
  194. package/test/validate-cb-task.mocha.js +0 -100
  195. package/test/validate-ret-task.mocha.js +0 -110
  196. package/test/validate.mocha.js +0 -324
  197. package/test/vcon.mocha.js +0 -193
  198. package/vendor/chai/chai.js +0 -4251
  199. package/vendor/jquery/jquery-1.7.1.js +0 -9266
  200. package/vendor/jquery/jquery-1.7.1.min.js +0 -4
  201. package/vendor/node/util.js +0 -531
  202. package/vendor/requirejs/require.js +0 -2045
  203. package/vendor/requirejs/require.min.js +0 -36
@@ -0,0 +1,407 @@
1
+ /**
2
+ * Copyright 2013 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule ReactDefaultPerf
17
+ * @typechecks static-only
18
+ */
19
+
20
+ "use strict";
21
+
22
+ var performanceNow = require("./performanceNow");
23
+
24
+ var ReactDefaultPerf = {};
25
+
26
+ if ("production" !== process.env.NODE_ENV) {
27
+ ReactDefaultPerf = {
28
+ /**
29
+ * Gets the stored information for a given object's function.
30
+ *
31
+ * @param {string} objName
32
+ * @param {string} fnName
33
+ * @return {?object}
34
+ */
35
+ getInfo: function(objName, fnName) {
36
+ if (!this.info[objName] || !this.info[objName][fnName]) {
37
+ return null;
38
+ }
39
+ return this.info[objName][fnName];
40
+ },
41
+
42
+ /**
43
+ * Gets the logs pertaining to a given object's function.
44
+ *
45
+ * @param {string} objName
46
+ * @param {string} fnName
47
+ * @return {?array<object>}
48
+ */
49
+ getLogs: function(objName, fnName) {
50
+ if (!this.getInfo(objName, fnName)) {
51
+ return null;
52
+ }
53
+ return this.logs.filter(function(log) {
54
+ return log.objName === objName && log.fnName === fnName;
55
+ });
56
+ },
57
+
58
+ /**
59
+ * Runs through the logs and builds an array of arrays, where each array
60
+ * walks through the mounting/updating of each component underneath.
61
+ *
62
+ * @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
63
+ * @return {array<array>}
64
+ */
65
+ getRawRenderHistory: function(rootID) {
66
+ var history = [];
67
+ /**
68
+ * Since logs are added after the method returns, the logs are in a sense
69
+ * upside-down: the inner-most elements from mounting/updating are logged
70
+ * first, and the last addition to the log is the top renderComponent.
71
+ * Therefore, we flip the logs upside down for ease of processing, and
72
+ * reverse the history array at the end so the earliest event has index 0.
73
+ */
74
+ var logs = this.logs.filter(function(log) {
75
+ return log.reactID.indexOf(rootID) === 0;
76
+ }).reverse();
77
+
78
+ var subHistory = [];
79
+ logs.forEach(function(log, i) {
80
+ if (i && log.reactID === rootID && logs[i - 1].reactID !== rootID) {
81
+ subHistory.length && history.push(subHistory);
82
+ subHistory = [];
83
+ }
84
+ subHistory.push(log);
85
+ });
86
+ if (subHistory.length) {
87
+ history.push(subHistory);
88
+ }
89
+ return history.reverse();
90
+ },
91
+
92
+ /**
93
+ * Runs through the logs and builds an array of strings, where each string
94
+ * is a multiline formatted way of walking through the mounting/updating
95
+ * underneath.
96
+ *
97
+ * @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
98
+ * @return {array<string>}
99
+ */
100
+ getRenderHistory: function(rootID) {
101
+ var history = this.getRawRenderHistory(rootID);
102
+
103
+ return history.map(function(subHistory) {
104
+ var headerString = (
105
+ 'log# Component (execution time) [bloat from logging]\n' +
106
+ '================================================================\n'
107
+ );
108
+ return headerString + subHistory.map(function(log) {
109
+ // Add two spaces for every layer in the reactID.
110
+ var indents = '\t' + Array(log.reactID.split('.[').length).join(' ');
111
+ var delta = _microTime(log.timing.delta);
112
+ var bloat = _microTime(log.timing.timeToLog);
113
+
114
+ return log.index + indents + log.name + ' (' + delta + 'ms)' +
115
+ ' [' + bloat + 'ms]';
116
+ }).join('\n');
117
+ });
118
+ },
119
+
120
+ /**
121
+ * Print the render history from `getRenderHistory` using console.log.
122
+ * This is currently the best way to display perf data from
123
+ * any React component; working on that.
124
+ *
125
+ * @param {string} rootID The reactID of the root node, e.g. '.r[2cpyq]'
126
+ * @param {number} index
127
+ */
128
+ printRenderHistory: function(rootID, index) {
129
+ var history = this.getRenderHistory(rootID);
130
+ if (!history[index]) {
131
+ console.warn(
132
+ 'Index', index, 'isn\'t available! ' +
133
+ 'The render history is', history.length, 'long.'
134
+ );
135
+ return;
136
+ }
137
+ console.log(
138
+ 'Loading render history #' + (index + 1) +
139
+ ' of ' + history.length + ':\n' + history[index]
140
+ );
141
+ },
142
+
143
+ /**
144
+ * Prints the heatmap legend to console, showing how the colors correspond
145
+ * with render times. This relies on console.log styles.
146
+ */
147
+ printHeatmapLegend: function() {
148
+ if (!this.options.heatmap.enabled) {
149
+ return;
150
+ }
151
+ var max = this.info.React
152
+ && this.info.React.renderComponent
153
+ && this.info.React.renderComponent.max;
154
+ if (max) {
155
+ var logStr = 'Heatmap: ';
156
+ for (var ii = 0; ii <= 10 * max; ii += max) {
157
+ logStr += '%c ' + (Math.round(ii) / 10) + 'ms ';
158
+ }
159
+ console.log(
160
+ logStr,
161
+ 'background-color: hsla(100, 100%, 50%, 0.6);',
162
+ 'background-color: hsla( 90, 100%, 50%, 0.6);',
163
+ 'background-color: hsla( 80, 100%, 50%, 0.6);',
164
+ 'background-color: hsla( 70, 100%, 50%, 0.6);',
165
+ 'background-color: hsla( 60, 100%, 50%, 0.6);',
166
+ 'background-color: hsla( 50, 100%, 50%, 0.6);',
167
+ 'background-color: hsla( 40, 100%, 50%, 0.6);',
168
+ 'background-color: hsla( 30, 100%, 50%, 0.6);',
169
+ 'background-color: hsla( 20, 100%, 50%, 0.6);',
170
+ 'background-color: hsla( 10, 100%, 50%, 0.6);',
171
+ 'background-color: hsla( 0, 100%, 50%, 0.6);'
172
+ );
173
+ }
174
+ },
175
+
176
+ /**
177
+ * Measure a given function with logging information, and calls a callback
178
+ * if there is one.
179
+ *
180
+ * @param {string} objName
181
+ * @param {string} fnName
182
+ * @param {function} func
183
+ * @return {function}
184
+ */
185
+ measure: function(objName, fnName, func) {
186
+ var info = _getNewInfo(objName, fnName);
187
+
188
+ var fnArgs = _getFnArguments(func);
189
+
190
+ return function() {
191
+ var timeBeforeFn = performanceNow();
192
+ var fnReturn = func.apply(this, arguments);
193
+ var timeAfterFn = performanceNow();
194
+
195
+ /**
196
+ * Hold onto arguments in a readable way: args[1] -> args.component.
197
+ * args is also passed to the callback, so if you want to save an
198
+ * argument in the log, do so in the callback.
199
+ */
200
+ var args = {};
201
+ for (var i = 0; i < arguments.length; i++) {
202
+ args[fnArgs[i]] = arguments[i];
203
+ }
204
+
205
+ var log = {
206
+ index: ReactDefaultPerf.logs.length,
207
+ fnName: fnName,
208
+ objName: objName,
209
+ timing: {
210
+ before: timeBeforeFn,
211
+ after: timeAfterFn,
212
+ delta: timeAfterFn - timeBeforeFn
213
+ }
214
+ };
215
+
216
+ ReactDefaultPerf.logs.push(log);
217
+
218
+ /**
219
+ * The callback gets:
220
+ * - this (the component)
221
+ * - the original method's arguments
222
+ * - what the method returned
223
+ * - the log object, and
224
+ * - the wrapped method's info object.
225
+ */
226
+ var callback = _getCallback(objName, fnName);
227
+ callback && callback(this, args, fnReturn, log, info);
228
+
229
+ log.timing.timeToLog = performanceNow() - timeAfterFn;
230
+
231
+ return fnReturn;
232
+ };
233
+ },
234
+
235
+ /**
236
+ * Holds information on wrapped objects/methods.
237
+ * For instance, ReactDefaultPerf.info.React.renderComponent
238
+ */
239
+ info: {},
240
+
241
+ /**
242
+ * Holds all of the logs. Filter this to pull desired information.
243
+ */
244
+ logs: [],
245
+
246
+ /**
247
+ * Toggle settings for ReactDefaultPerf
248
+ */
249
+ options: {
250
+ /**
251
+ * The heatmap sets the background color of the React containers
252
+ * according to how much total time has been spent rendering them.
253
+ * The most temporally expensive component is set as pure red,
254
+ * and the others are colored from green to red as a fraction
255
+ * of that max component time.
256
+ */
257
+ heatmap: {
258
+ enabled: true
259
+ }
260
+ }
261
+ };
262
+
263
+ /**
264
+ * Gets a info area for a given object's function, adding a new one if
265
+ * necessary.
266
+ *
267
+ * @param {string} objName
268
+ * @param {string} fnName
269
+ * @return {object}
270
+ */
271
+ var _getNewInfo = function(objName, fnName) {
272
+ var info = ReactDefaultPerf.getInfo(objName, fnName);
273
+ if (info) {
274
+ return info;
275
+ }
276
+ ReactDefaultPerf.info[objName] = ReactDefaultPerf.info[objName] || {};
277
+
278
+ return ReactDefaultPerf.info[objName][fnName] = {
279
+ getLogs: function() {
280
+ return ReactDefaultPerf.getLogs(objName, fnName);
281
+ }
282
+ };
283
+ };
284
+
285
+ /**
286
+ * Gets a list of the argument names from a function's definition.
287
+ * This is useful for storing arguments by their names within wrapFn().
288
+ *
289
+ * @param {function} fn
290
+ * @return {array<string>}
291
+ */
292
+ var _getFnArguments = function(fn) {
293
+ var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
294
+ var fnStr = fn.toString().replace(STRIP_COMMENTS, '');
295
+ fnStr = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')'));
296
+ return fnStr.match(/([^\s,]+)/g);
297
+ };
298
+
299
+ /**
300
+ * Store common callbacks within ReactDefaultPerf.
301
+ *
302
+ * @param {string} objName
303
+ * @param {string} fnName
304
+ * @return {?function}
305
+ */
306
+ var _getCallback = function(objName, fnName) {
307
+ switch (objName + '.' + fnName) {
308
+ case 'React.renderComponent':
309
+ return _renderComponentCallback;
310
+ case 'ReactDOMComponent.mountComponent':
311
+ case 'ReactDOMComponent.updateComponent':
312
+ return _nativeComponentCallback;
313
+ case 'ReactCompositeComponent.mountComponent':
314
+ case 'ReactCompositeComponent.updateComponent':
315
+ return _compositeComponentCallback;
316
+ default:
317
+ return null;
318
+ }
319
+ };
320
+
321
+ /**
322
+ * Callback function for React.renderComponent
323
+ *
324
+ * @param {object} component
325
+ * @param {object} args
326
+ * @param {?object} fnReturn
327
+ * @param {object} log
328
+ * @param {object} info
329
+ */
330
+ var _renderComponentCallback =
331
+ function(component, args, fnReturn, log, info) {
332
+ log.name = args.nextComponent.constructor.displayName || '[unknown]';
333
+ log.reactID = fnReturn._rootNodeID || null;
334
+
335
+ if (ReactDefaultPerf.options.heatmap.enabled) {
336
+ var container = args.container;
337
+ if (!container.loggedByReactDefaultPerf) {
338
+ container.loggedByReactDefaultPerf = true;
339
+ info.components = info.components || [];
340
+ info.components.push(container);
341
+ }
342
+
343
+ container.count = container.count || 0;
344
+ container.count += log.timing.delta;
345
+ info.max = info.max || 0;
346
+ if (container.count > info.max) {
347
+ info.max = container.count;
348
+ info.components.forEach(function(component) {
349
+ _setHue(component, 100 - 100 * component.count / info.max);
350
+ });
351
+ } else {
352
+ _setHue(container, 100 - 100 * container.count / info.max);
353
+ }
354
+ }
355
+ };
356
+
357
+ /**
358
+ * Callback function for ReactDOMComponent
359
+ *
360
+ * @param {object} component
361
+ * @param {object} args
362
+ * @param {?object} fnReturn
363
+ * @param {object} log
364
+ * @param {object} info
365
+ */
366
+ var _nativeComponentCallback =
367
+ function(component, args, fnReturn, log, info) {
368
+ log.name = component.tagName || '[unknown]';
369
+ log.reactID = component._rootNodeID;
370
+ };
371
+
372
+ /**
373
+ * Callback function for ReactCompositeComponent
374
+ *
375
+ * @param {object} component
376
+ * @param {object} args
377
+ * @param {?object} fnReturn
378
+ * @param {object} log
379
+ * @param {object} info
380
+ */
381
+ var _compositeComponentCallback =
382
+ function(component, args, fnReturn, log, info) {
383
+ log.name = component.constructor.displayName || '[unknown]';
384
+ log.reactID = component._rootNodeID;
385
+ };
386
+
387
+ /**
388
+ * Using the hsl() background-color attribute, colors an element.
389
+ *
390
+ * @param {DOMElement} el
391
+ * @param {number} hue [0 for red, 120 for green, 240 for blue]
392
+ */
393
+ var _setHue = function(el, hue) {
394
+ el.style.backgroundColor = 'hsla(' + hue + ', 100%, 50%, 0.6)';
395
+ };
396
+
397
+ /**
398
+ * Round to the thousandth place.
399
+ * @param {number} time
400
+ * @return {number}
401
+ */
402
+ var _microTime = function(time) {
403
+ return Math.round(time * 1000) / 1000;
404
+ };
405
+ }
406
+
407
+ module.exports = ReactDefaultPerf;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright 2013 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule ReactErrorUtils
17
+ * @typechecks
18
+ */
19
+
20
+ var ReactErrorUtils = {
21
+ /**
22
+ * Creates a guarded version of a function. This is supposed to make debugging
23
+ * of event handlers easier. This implementation provides only basic error
24
+ * logging and re-throws the error.
25
+ *
26
+ * @param {function} func Function to be executed
27
+ * @param {string} name The name of the guard
28
+ * @return {function}
29
+ */
30
+ guard: function(func, name) {
31
+ if ("production" !== process.env.NODE_ENV) {
32
+ return function guarded() {
33
+ try {
34
+ return func.apply(this, arguments);
35
+ } catch(ex) {
36
+ console.error(name + ': ' + ex.message);
37
+ throw ex;
38
+ }
39
+ };
40
+ } else {
41
+ return func;
42
+ }
43
+ }
44
+ };
45
+
46
+ module.exports = ReactErrorUtils;