react 0.14.0-beta1 → 0.14.0-beta2

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 (169) hide show
  1. package/addons.js +5 -2
  2. package/dist/JSXTransformer.js +588 -227
  3. package/dist/react-with-addons.js +3118 -2707
  4. package/dist/react-with-addons.min.js +6 -6
  5. package/dist/react.js +3713 -3317
  6. package/dist/react.min.js +6 -5
  7. package/lib/AutoFocusUtils.js +3 -3
  8. package/lib/BeforeInputEventPlugin.js +13 -13
  9. package/lib/CSSProperty.js +3 -0
  10. package/lib/CSSPropertyOperations.js +13 -13
  11. package/lib/CallbackQueue.js +4 -4
  12. package/lib/ChangeEventPlugin.js +12 -12
  13. package/lib/DOMChildrenOperations.js +10 -6
  14. package/lib/DOMProperty.js +8 -8
  15. package/lib/DOMPropertyOperations.js +9 -9
  16. package/lib/Danger.js +14 -14
  17. package/lib/DefaultEventPluginOrder.js +2 -2
  18. package/lib/EnterLeaveEventPlugin.js +5 -5
  19. package/lib/EventConstants.js +23 -1
  20. package/lib/EventPluginHub.js +11 -11
  21. package/lib/EventPluginRegistry.js +8 -8
  22. package/lib/EventPluginUtils.js +11 -11
  23. package/lib/EventPropagators.js +7 -7
  24. package/lib/FallbackCompositionState.js +3 -3
  25. package/lib/HTMLDOMPropertyConfig.js +4 -2
  26. package/lib/LinkedStateMixin.js +2 -2
  27. package/lib/LinkedValueUtils.js +8 -8
  28. package/lib/MetaMatchers.js +118 -0
  29. package/lib/OrderedMap.js +453 -0
  30. package/lib/PooledClass.js +2 -2
  31. package/lib/React.js +6 -6
  32. package/lib/ReactBrowserComponentMixin.js +4 -4
  33. package/lib/ReactBrowserEventEmitter.js +30 -7
  34. package/lib/ReactCSSTransitionGroup.js +16 -5
  35. package/lib/ReactCSSTransitionGroupChild.js +12 -11
  36. package/lib/ReactChildReconciler.js +25 -18
  37. package/lib/ReactChildren.js +6 -6
  38. package/lib/ReactClass.js +42 -42
  39. package/lib/ReactComponent.js +13 -13
  40. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  41. package/lib/ReactComponentEnvironment.js +2 -2
  42. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  43. package/lib/ReactCompositeComponent.js +38 -38
  44. package/lib/ReactDOM.js +72 -159
  45. package/lib/ReactDOMComponent.js +104 -60
  46. package/lib/ReactDOMFactories.js +177 -0
  47. package/lib/ReactDOMIDOperations.js +10 -24
  48. package/lib/ReactDOMInput.js +8 -8
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +8 -8
  51. package/lib/ReactDOMSelection.js +3 -3
  52. package/lib/ReactDOMServer.js +2 -2
  53. package/lib/ReactDOMTextComponent.js +11 -11
  54. package/lib/ReactDOMTextarea.js +11 -11
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +24 -24
  57. package/lib/ReactDefaultPerf.js +7 -7
  58. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  59. package/lib/ReactElement.js +4 -4
  60. package/lib/ReactElementValidator.js +21 -21
  61. package/lib/ReactEmptyComponent.js +4 -4
  62. package/lib/ReactEventEmitterMixin.js +1 -1
  63. package/lib/ReactEventListener.js +19 -14
  64. package/lib/ReactFragment.js +11 -11
  65. package/lib/ReactInjection.js +11 -11
  66. package/lib/ReactInputSelection.js +4 -4
  67. package/lib/ReactInstanceHandles.js +10 -11
  68. package/lib/ReactIsomorphic.js +11 -11
  69. package/lib/ReactLink.js +1 -1
  70. package/lib/ReactMarkupChecksum.js +6 -2
  71. package/lib/ReactMount.js +68 -48
  72. package/lib/ReactMultiChild.js +83 -22
  73. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  74. package/lib/ReactNativeComponent.js +3 -3
  75. package/lib/ReactNoopUpdateQueue.js +3 -3
  76. package/lib/ReactOwner.js +3 -3
  77. package/lib/ReactPerf.js +2 -2
  78. package/lib/ReactPropTransferer.js +3 -3
  79. package/lib/ReactPropTypeLocationNames.js +1 -1
  80. package/lib/ReactPropTypeLocations.js +1 -1
  81. package/lib/ReactPropTypes.js +34 -8
  82. package/lib/ReactReconcileTransaction.js +6 -6
  83. package/lib/ReactReconciler.js +12 -12
  84. package/lib/ReactRef.js +1 -1
  85. package/lib/ReactServerBatchingStrategy.js +5 -5
  86. package/lib/ReactServerRendering.js +12 -12
  87. package/lib/ReactServerRenderingTransaction.js +5 -5
  88. package/lib/ReactTestUtils.js +26 -27
  89. package/lib/ReactTransitionChildMapping.js +2 -2
  90. package/lib/ReactTransitionEvents.js +1 -1
  91. package/lib/ReactTransitionGroup.js +5 -6
  92. package/lib/ReactUpdateQueue.js +17 -17
  93. package/lib/ReactUpdates.js +14 -14
  94. package/lib/ReactWithAddons.js +14 -14
  95. package/lib/ResponderEventPlugin.js +514 -0
  96. package/lib/ResponderSyntheticEvent.js +40 -0
  97. package/lib/ResponderTouchHistoryStore.js +180 -0
  98. package/lib/SVGDOMPropertyConfig.js +1 -1
  99. package/lib/SelectEventPlugin.js +9 -9
  100. package/lib/SimpleEventPlugin.js +201 -25
  101. package/lib/SyntheticClipboardEvent.js +1 -1
  102. package/lib/SyntheticCompositionEvent.js +1 -1
  103. package/lib/SyntheticDragEvent.js +1 -1
  104. package/lib/SyntheticEvent.js +3 -3
  105. package/lib/SyntheticFocusEvent.js +1 -1
  106. package/lib/SyntheticInputEvent.js +1 -1
  107. package/lib/SyntheticKeyboardEvent.js +4 -4
  108. package/lib/SyntheticMouseEvent.js +3 -3
  109. package/lib/SyntheticTouchEvent.js +2 -2
  110. package/lib/SyntheticUIEvent.js +2 -2
  111. package/lib/SyntheticWheelEvent.js +1 -1
  112. package/lib/TapEventPlugin.js +119 -0
  113. package/lib/Transaction.js +6 -6
  114. package/lib/accumulate.js +44 -0
  115. package/lib/accumulateInto.js +2 -2
  116. package/lib/adler32.js +19 -7
  117. package/lib/cloneWithProps.js +11 -6
  118. package/lib/createHierarchyRenderer.js +85 -0
  119. package/lib/dangerousStyleValue.js +1 -1
  120. package/lib/deprecated.js +4 -4
  121. package/lib/findDOMNode.js +9 -9
  122. package/lib/flattenChildren.js +4 -4
  123. package/lib/getEventKey.js +1 -1
  124. package/lib/getTestDocument.js +28 -0
  125. package/lib/getTextContentAccessor.js +1 -1
  126. package/lib/instantiateReactComponent.js +12 -12
  127. package/lib/isEventSupported.js +1 -1
  128. package/lib/onlyChild.js +3 -3
  129. package/lib/quoteAttributeValueForBrowser.js +1 -1
  130. package/lib/reactComponentExpect.js +210 -0
  131. package/lib/renderSubtreeIntoContainer.js +1 -1
  132. package/lib/setInnerHTML.js +1 -1
  133. package/lib/setTextContent.js +3 -3
  134. package/lib/shallowCompare.js +1 -1
  135. package/lib/sliceChildren.js +51 -0
  136. package/lib/traverseAllChildren.js +14 -13
  137. package/lib/update.js +13 -13
  138. package/lib/validateDOMNesting.js +6 -6
  139. package/lib/webcomponents.js +6379 -0
  140. package/package.json +4 -6
  141. package/react.js +1 -1
  142. package/lib/CSSCore.js +0 -97
  143. package/lib/EventListener.js +0 -84
  144. package/lib/ExecutionEnvironment.js +0 -38
  145. package/lib/ReactDOMClient.js +0 -90
  146. package/lib/camelize.js +0 -32
  147. package/lib/camelizeStyleName.js +0 -40
  148. package/lib/containsNode.js +0 -55
  149. package/lib/createArrayFromMixed.js +0 -85
  150. package/lib/createNodesFromMarkup.js +0 -84
  151. package/lib/emptyFunction.js +0 -38
  152. package/lib/emptyObject.js +0 -20
  153. package/lib/focusNode.js +0 -26
  154. package/lib/getActiveElement.js +0 -29
  155. package/lib/getMarkupWrap.js +0 -93
  156. package/lib/getUnboundedScrollPosition.js +0 -38
  157. package/lib/hyphenate.js +0 -33
  158. package/lib/hyphenateStyleName.js +0 -39
  159. package/lib/invariant.js +0 -49
  160. package/lib/isNode.js +0 -23
  161. package/lib/isTextNode.js +0 -25
  162. package/lib/keyMirror.js +0 -48
  163. package/lib/keyOf.js +0 -35
  164. package/lib/mapObject.js +0 -51
  165. package/lib/performance.js +0 -23
  166. package/lib/performanceNow.js +0 -28
  167. package/lib/shallowEqual.js +0 -48
  168. package/lib/toArray.js +0 -57
  169. package/lib/warning.js +0 -57
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticEvent = require("./SyntheticEvent");
15
+ var SyntheticEvent = require('./SyntheticEvent');
16
16
 
17
17
  /**
18
18
  * @interface Event
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticEvent = require("./SyntheticEvent");
15
+ var SyntheticEvent = require('./SyntheticEvent');
16
16
 
17
17
  /**
18
18
  * @interface Event
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticMouseEvent = require("./SyntheticMouseEvent");
15
+ var SyntheticMouseEvent = require('./SyntheticMouseEvent');
16
16
 
17
17
  /**
18
18
  * @interface DragEvent
@@ -12,10 +12,10 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var PooledClass = require("./PooledClass");
15
+ var PooledClass = require('./PooledClass');
16
16
 
17
- var assign = require("./Object.assign");
18
- var emptyFunction = require("./emptyFunction");
17
+ var assign = require('./Object.assign');
18
+ var emptyFunction = require('fbjs/lib/emptyFunction');
19
19
 
20
20
  /**
21
21
  * @interface Event
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticUIEvent = require("./SyntheticUIEvent");
15
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
16
16
 
17
17
  /**
18
18
  * @interface FocusEvent
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticEvent = require("./SyntheticEvent");
15
+ var SyntheticEvent = require('./SyntheticEvent');
16
16
 
17
17
  /**
18
18
  * @interface Event
@@ -12,11 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticUIEvent = require("./SyntheticUIEvent");
15
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
16
16
 
17
- var getEventCharCode = require("./getEventCharCode");
18
- var getEventKey = require("./getEventKey");
19
- var getEventModifierState = require("./getEventModifierState");
17
+ var getEventCharCode = require('./getEventCharCode');
18
+ var getEventKey = require('./getEventKey');
19
+ var getEventModifierState = require('./getEventModifierState');
20
20
 
21
21
  /**
22
22
  * @interface KeyboardEvent
@@ -12,10 +12,10 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticUIEvent = require("./SyntheticUIEvent");
16
- var ViewportMetrics = require("./ViewportMetrics");
15
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
16
+ var ViewportMetrics = require('./ViewportMetrics');
17
17
 
18
- var getEventModifierState = require("./getEventModifierState");
18
+ var getEventModifierState = require('./getEventModifierState');
19
19
 
20
20
  /**
21
21
  * @interface MouseEvent
@@ -12,9 +12,9 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticUIEvent = require("./SyntheticUIEvent");
15
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
16
16
 
17
- var getEventModifierState = require("./getEventModifierState");
17
+ var getEventModifierState = require('./getEventModifierState');
18
18
 
19
19
  /**
20
20
  * @interface TouchEvent
@@ -12,9 +12,9 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticEvent = require("./SyntheticEvent");
15
+ var SyntheticEvent = require('./SyntheticEvent');
16
16
 
17
- var getEventTarget = require("./getEventTarget");
17
+ var getEventTarget = require('./getEventTarget');
18
18
 
19
19
  /**
20
20
  * @interface UIEvent
@@ -12,7 +12,7 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var SyntheticMouseEvent = require("./SyntheticMouseEvent");
15
+ var SyntheticMouseEvent = require('./SyntheticMouseEvent');
16
16
 
17
17
  /**
18
18
  * @interface WheelEvent
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 TapEventPlugin
10
+ * @typechecks static-only
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ var EventConstants = require('./EventConstants');
16
+ var EventPluginUtils = require('./EventPluginUtils');
17
+ var EventPropagators = require('./EventPropagators');
18
+ var SyntheticUIEvent = require('./SyntheticUIEvent');
19
+ var TouchEventUtils = require('fbjs/lib/TouchEventUtils');
20
+ var ViewportMetrics = require('./ViewportMetrics');
21
+
22
+ var keyOf = require('fbjs/lib/keyOf');
23
+ var topLevelTypes = EventConstants.topLevelTypes;
24
+
25
+ var isStartish = EventPluginUtils.isStartish;
26
+ var isEndish = EventPluginUtils.isEndish;
27
+
28
+ /**
29
+ * Number of pixels that are tolerated in between a `touchStart` and `touchEnd`
30
+ * in order to still be considered a 'tap' event.
31
+ */
32
+ var tapMoveThreshold = 10;
33
+ var startCoords = { x: null, y: null };
34
+
35
+ var Axis = {
36
+ x: { page: 'pageX', client: 'clientX', envScroll: 'currentPageScrollLeft' },
37
+ y: { page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop' }
38
+ };
39
+
40
+ function getAxisCoordOfEvent(axis, nativeEvent) {
41
+ var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
42
+ if (singleTouch) {
43
+ return singleTouch[axis.page];
44
+ }
45
+ return axis.page in nativeEvent ? nativeEvent[axis.page] : nativeEvent[axis.client] + ViewportMetrics[axis.envScroll];
46
+ }
47
+
48
+ function getDistance(coords, nativeEvent) {
49
+ var pageX = getAxisCoordOfEvent(Axis.x, nativeEvent);
50
+ var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent);
51
+ return Math.pow(Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2), 0.5);
52
+ }
53
+
54
+ var touchEvents = [topLevelTypes.topTouchStart, topLevelTypes.topTouchCancel, topLevelTypes.topTouchEnd, topLevelTypes.topTouchMove];
55
+
56
+ var dependencies = [topLevelTypes.topMouseDown, topLevelTypes.topMouseMove, topLevelTypes.topMouseUp].concat(touchEvents);
57
+
58
+ var eventTypes = {
59
+ touchTap: {
60
+ phasedRegistrationNames: {
61
+ bubbled: keyOf({ onTouchTap: null }),
62
+ captured: keyOf({ onTouchTapCapture: null })
63
+ },
64
+ dependencies: dependencies
65
+ }
66
+ };
67
+
68
+ var usedTouch = false;
69
+ var usedTouchTime = 0;
70
+ var TOUCH_DELAY = 1000;
71
+
72
+ var TapEventPlugin = {
73
+
74
+ tapMoveThreshold: tapMoveThreshold,
75
+
76
+ eventTypes: eventTypes,
77
+
78
+ /**
79
+ * @param {string} topLevelType Record from `EventConstants`.
80
+ * @param {DOMEventTarget} topLevelTarget The listening component root node.
81
+ * @param {string} topLevelTargetID ID of `topLevelTarget`.
82
+ * @param {object} nativeEvent Native browser event.
83
+ * @return {*} An accumulation of synthetic events.
84
+ * @see {EventPluginHub.extractEvents}
85
+ */
86
+ extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
87
+ if (!isStartish(topLevelType) && !isEndish(topLevelType)) {
88
+ return null;
89
+ }
90
+ // on ios, there is a delay after touch event and synthetic
91
+ // mouse events, so that user can perform double tap
92
+ // solution: ignore mouse events following touchevent within small timeframe
93
+ if (touchEvents.indexOf(topLevelType) !== -1) {
94
+ usedTouch = true;
95
+ usedTouchTime = Date.now();
96
+ } else {
97
+ if (usedTouch && Date.now() - usedTouchTime < TOUCH_DELAY) {
98
+ return null;
99
+ }
100
+ }
101
+ var event = null;
102
+ var distance = getDistance(startCoords, nativeEvent);
103
+ if (isEndish(topLevelType) && distance < tapMoveThreshold) {
104
+ event = SyntheticUIEvent.getPooled(eventTypes.touchTap, topLevelTargetID, nativeEvent, nativeEventTarget);
105
+ }
106
+ if (isStartish(topLevelType)) {
107
+ startCoords.x = getAxisCoordOfEvent(Axis.x, nativeEvent);
108
+ startCoords.y = getAxisCoordOfEvent(Axis.y, nativeEvent);
109
+ } else if (isEndish(topLevelType)) {
110
+ startCoords.x = 0;
111
+ startCoords.y = 0;
112
+ }
113
+ EventPropagators.accumulateTwoPhaseDispatches(event);
114
+ return event;
115
+ }
116
+
117
+ };
118
+
119
+ module.exports = TapEventPlugin;
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var invariant = require("./invariant");
14
+ var invariant = require('fbjs/lib/invariant');
15
15
 
16
16
  /**
17
17
  * `Transaction` creates a black box that is able to wrap any method such that
@@ -84,10 +84,10 @@ var Mixin = {
84
84
  */
85
85
  reinitializeTransaction: function () {
86
86
  this.transactionWrappers = this.getTransactionWrappers();
87
- if (!this.wrapperInitData) {
88
- this.wrapperInitData = [];
89
- } else {
87
+ if (this.wrapperInitData) {
90
88
  this.wrapperInitData.length = 0;
89
+ } else {
90
+ this.wrapperInitData = [];
91
91
  }
92
92
  this._isInTransaction = false;
93
93
  },
@@ -122,7 +122,7 @@ var Mixin = {
122
122
  * @return {*} Return value from `method`.
123
123
  */
124
124
  perform: function (method, scope, a, b, c, d, e, f) {
125
- !!this.isInTransaction() ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : undefined;
125
+ !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : undefined;
126
126
  var errorThrown;
127
127
  var ret;
128
128
  try {
@@ -186,7 +186,7 @@ var Mixin = {
186
186
  * invoked).
187
187
  */
188
188
  closeAll: function (startIndex) {
189
- !this.isInTransaction() ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : undefined;
189
+ !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : undefined;
190
190
  var transactionWrappers = this.transactionWrappers;
191
191
  for (var i = startIndex; i < transactionWrappers.length; i++) {
192
192
  var wrapper = transactionWrappers[i];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 accumulate
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var invariant = require('fbjs/lib/invariant');
15
+
16
+ /**
17
+ * Accumulates items that must not be null or undefined.
18
+ *
19
+ * This is used to conserve memory by avoiding array allocations.
20
+ *
21
+ * @return {*|array<*>} An accumulation of items.
22
+ */
23
+ function accumulate(current, next) {
24
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : invariant(false) : undefined;
25
+ if (current == null) {
26
+ return next;
27
+ } else {
28
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
29
+ // certain that x is an Array (x could be a string with concat method).
30
+ var currentIsArray = Array.isArray(current);
31
+ var nextIsArray = Array.isArray(next);
32
+ if (currentIsArray) {
33
+ return current.concat(next);
34
+ } else {
35
+ if (nextIsArray) {
36
+ return [current].concat(next);
37
+ } else {
38
+ return [current, next];
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ module.exports = accumulate;
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var invariant = require("./invariant");
14
+ var invariant = require('fbjs/lib/invariant');
15
15
 
16
16
  /**
17
17
  *
@@ -28,7 +28,7 @@ var invariant = require("./invariant");
28
28
  */
29
29
 
30
30
  function accumulateInto(current, next) {
31
- !(next != null) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : undefined;
31
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : undefined;
32
32
  if (current == null) {
33
33
  return next;
34
34
  }
package/lib/adler32.js CHANGED
@@ -13,17 +13,29 @@
13
13
 
14
14
  var MOD = 65521;
15
15
 
16
- // This is a clean-room implementation of adler32 designed for detecting
17
- // if markup is not what we expect it to be. It does not need to be
18
- // cryptographically strong, only reasonably good at detecting if markup
19
- // generated on the server is different than that on the client.
16
+ // adler32 is not cryptographically strong, and is only used to sanity check that
17
+ // markup generated on the server matches the markup generated on the client.
18
+ // This implementation (a modified version of the SheetJS version) has been optimized
19
+ // for our use case, at the expense of conforming to the adler32 specification
20
+ // for non-ascii inputs.
20
21
  function adler32(data) {
21
22
  var a = 1;
22
23
  var b = 0;
23
- for (var i = 0; i < data.length; i++) {
24
- a = (a + data.charCodeAt(i)) % MOD;
25
- b = (b + a) % MOD;
24
+ var i = 0;
25
+ var l = data.length;
26
+ var m = l & ~0x3;
27
+ while (i < m) {
28
+ for (; i < Math.min(i + 4096, m); i += 4) {
29
+ b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3));
30
+ }
31
+ a %= MOD;
32
+ b %= MOD;
26
33
  }
34
+ for (; i < l; i++) {
35
+ b += a += data.charCodeAt(i);
36
+ }
37
+ a %= MOD;
38
+ b %= MOD;
27
39
  return a | b << 16;
28
40
  }
29
41
 
@@ -12,14 +12,16 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var ReactElement = require("./ReactElement");
16
- var ReactPropTransferer = require("./ReactPropTransferer");
15
+ var ReactElement = require('./ReactElement');
16
+ var ReactPropTransferer = require('./ReactPropTransferer');
17
17
 
18
- var keyOf = require("./keyOf");
19
- var warning = require("./warning");
18
+ var keyOf = require('fbjs/lib/keyOf');
19
+ var warning = require('fbjs/lib/warning');
20
20
 
21
21
  var CHILDREN_PROP = keyOf({ children: null });
22
22
 
23
+ var didDeprecatedWarn = false;
24
+
23
25
  /**
24
26
  * Sometimes you want to change the props of a child passed to you. Usually
25
27
  * this is to add a CSS class.
@@ -28,10 +30,13 @@ var CHILDREN_PROP = keyOf({ children: null });
28
30
  * @param {object} props props you'd like to modify. className and style will be
29
31
  * merged automatically.
30
32
  * @return {ReactElement} a clone of child with props merged in.
33
+ * @deprecated
31
34
  */
32
35
  function cloneWithProps(child, props) {
33
- if ('production' !== process.env.NODE_ENV) {
34
- 'production' !== process.env.NODE_ENV ? warning(!child.ref, 'You are calling cloneWithProps() on a child with a ref. This is ' + 'dangerous because you\'re creating a new child which will not be ' + 'added as a ref to its parent.') : undefined;
36
+ if (process.env.NODE_ENV !== 'production') {
37
+ process.env.NODE_ENV !== 'production' ? warning(didDeprecatedWarn, 'cloneWithProps(...) is deprecated. ' + 'Please use React.cloneElement instead.') : undefined;
38
+ didDeprecatedWarn = true;
39
+ process.env.NODE_ENV !== 'production' ? warning(!child.ref, 'You are calling cloneWithProps() on a child with a ref. This is ' + 'dangerous because you\'re creating a new child which will not be ' + 'added as a ref to its parent.') : undefined;
35
40
  }
36
41
 
37
42
  var newProps = ReactPropTransferer.mergeProps(props, child.props);
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Copyright 2013-2015, 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 createHierarchyRenderer
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var React = require('./React');
15
+
16
+ /**
17
+ * Creates a render method that makes it easier to create, render, and inspect a
18
+ * hierarchy of mock React component classes.
19
+ *
20
+ * A component class is created for each of the supplied render methods. Each
21
+ * render method is invoked with the classes created using the render methods
22
+ * that come after it in the supplied list of render methods.
23
+ *
24
+ * var renderHierarchy = createHierarchyRenderer(
25
+ * function ComponentA(ComponentB, ComponentC) {...},
26
+ * function ComponentB(ComponentC) {...},
27
+ * function ComponentC() {...}
28
+ * );
29
+ *
30
+ * When the hierarchy is invoked, a two-dimensional array is returned. Each
31
+ * array corresponds to a supplied render method and contains the instances
32
+ * returned by that render method in the order it was invoked.
33
+ *
34
+ * var instances = renderHierarchy(
35
+ * function(ComponentA[, ComponentB, ComponentC]) {
36
+ * React.render(<ComponentA />, ...);
37
+ * })
38
+ * );
39
+ * instances[0][0]; // First return value of first render method.
40
+ * instances[1][0]; // First return value of second render method.
41
+ * instances[1][1]; // Second return value of second render method.
42
+ *
43
+ * Refs should be used to reference components that are not the return value of
44
+ * render methods.
45
+ *
46
+ * expect(instances[0][0].refs.X).toBe(...);
47
+ *
48
+ * NOTE: The component classes created for each render method are re-used for
49
+ * each invocation of the hierarchy renderer. If new classes are needed, you
50
+ * should re-execute `createHierarchyRenderer` with the same arguments.
51
+ *
52
+ * @param {array<function>} ...renderMethods
53
+ * @return {function}
54
+ */
55
+ function createHierarchyRenderer() {
56
+ for (var _len = arguments.length, renderMethods = Array(_len), _key = 0; _key < _len; _key++) {
57
+ renderMethods[_key] = arguments[_key];
58
+ }
59
+
60
+ var instances;
61
+ var Components = renderMethods.reduceRight(function (ComponentsAccumulator, renderMethod, depth) {
62
+ var Component = React.createClass({
63
+ displayName: renderMethod.name,
64
+ render: function () {
65
+ instances[depth].push(this);
66
+ return renderMethod.apply(this, ComponentsAccumulator);
67
+ }
68
+ });
69
+ return [Component].concat(ComponentsAccumulator);
70
+ }, []);
71
+ /**
72
+ * @param {function} renderComponent
73
+ * @return {array<array<*>>}
74
+ */
75
+ function renderHierarchy(renderComponent) {
76
+ instances = renderMethods.map(function () {
77
+ return [];
78
+ });
79
+ renderComponent.apply(null, Components);
80
+ return instances;
81
+ }
82
+ return renderHierarchy;
83
+ }
84
+
85
+ module.exports = createHierarchyRenderer;