react 0.14.0-beta1 → 0.14.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 (173) hide show
  1. package/addons.js +8 -3
  2. package/dist/react-with-addons.js +5048 -4095
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +4555 -3729
  5. package/dist/react.min.js +6 -5
  6. package/lib/AutoFocusUtils.js +3 -3
  7. package/lib/BeforeInputEventPlugin.js +13 -13
  8. package/lib/CSSProperty.js +18 -3
  9. package/lib/CSSPropertyOperations.js +27 -14
  10. package/lib/CallbackQueue.js +4 -4
  11. package/lib/ChangeEventPlugin.js +15 -14
  12. package/lib/DOMChildrenOperations.js +22 -7
  13. package/lib/DOMProperty.js +8 -8
  14. package/lib/DOMPropertyOperations.js +23 -10
  15. package/lib/Danger.js +21 -16
  16. package/lib/DefaultEventPluginOrder.js +2 -2
  17. package/lib/EnterLeaveEventPlugin.js +18 -10
  18. package/lib/EventConstants.js +23 -1
  19. package/lib/EventPluginHub.js +29 -21
  20. package/lib/EventPluginRegistry.js +8 -8
  21. package/lib/EventPluginUtils.js +34 -38
  22. package/lib/EventPropagators.js +8 -8
  23. package/lib/FallbackCompositionState.js +9 -3
  24. package/lib/HTMLDOMPropertyConfig.js +24 -4
  25. package/lib/LinkedStateMixin.js +2 -2
  26. package/lib/LinkedValueUtils.js +8 -8
  27. package/lib/MetaMatchers.js +118 -0
  28. package/lib/OrderedMap.js +453 -0
  29. package/lib/PooledClass.js +3 -5
  30. package/lib/React.js +18 -7
  31. package/lib/ReactBrowserComponentMixin.js +4 -4
  32. package/lib/ReactBrowserEventEmitter.js +36 -7
  33. package/lib/ReactCSSTransitionGroup.js +35 -9
  34. package/lib/ReactCSSTransitionGroupChild.js +48 -30
  35. package/lib/ReactChildReconciler.js +24 -19
  36. package/lib/ReactChildren.js +72 -32
  37. package/lib/ReactClass.js +46 -46
  38. package/lib/ReactComponent.js +18 -16
  39. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  40. package/lib/ReactComponentEnvironment.js +2 -2
  41. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  42. package/lib/ReactCompositeComponent.js +95 -44
  43. package/lib/ReactDOM.js +74 -159
  44. package/lib/ReactDOMComponent.js +235 -93
  45. package/lib/ReactDOMFactories.js +177 -0
  46. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  47. package/lib/ReactDOMIDOperations.js +8 -81
  48. package/lib/ReactDOMInput.js +18 -9
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +9 -9
  51. package/lib/ReactDOMSelection.js +19 -3
  52. package/lib/ReactDOMServer.js +5 -3
  53. package/lib/ReactDOMTextComponent.js +33 -20
  54. package/lib/ReactDOMTextarea.js +14 -12
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +23 -25
  57. package/lib/ReactDefaultPerf.js +17 -11
  58. package/lib/ReactDefaultPerfAnalysis.js +13 -12
  59. package/lib/ReactElement.js +85 -39
  60. package/lib/ReactElementValidator.js +47 -90
  61. package/lib/ReactEmptyComponent.js +26 -62
  62. package/lib/ReactEmptyComponentRegistry.js +48 -0
  63. package/lib/ReactErrorUtils.js +53 -9
  64. package/lib/ReactEventEmitterMixin.js +2 -2
  65. package/lib/ReactEventListener.js +33 -21
  66. package/lib/ReactFragment.js +27 -118
  67. package/lib/ReactInjection.js +10 -12
  68. package/lib/ReactInputSelection.js +4 -4
  69. package/lib/ReactInstanceHandles.js +10 -11
  70. package/lib/ReactIsomorphic.js +15 -11
  71. package/lib/ReactLink.js +2 -2
  72. package/lib/ReactMarkupChecksum.js +6 -2
  73. package/lib/ReactMount.js +186 -85
  74. package/lib/ReactMultiChild.js +119 -25
  75. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  76. package/lib/ReactNativeComponent.js +3 -3
  77. package/lib/ReactNoopUpdateQueue.js +3 -3
  78. package/lib/ReactOwner.js +3 -3
  79. package/lib/ReactPerf.js +2 -2
  80. package/lib/ReactPropTransferer.js +3 -3
  81. package/lib/ReactPropTypeLocationNames.js +1 -1
  82. package/lib/ReactPropTypeLocations.js +1 -1
  83. package/lib/ReactPropTypes.js +38 -9
  84. package/lib/ReactReconcileTransaction.js +10 -8
  85. package/lib/ReactReconciler.js +5 -6
  86. package/lib/ReactRef.js +14 -2
  87. package/lib/ReactServerBatchingStrategy.js +5 -5
  88. package/lib/ReactServerRendering.js +12 -12
  89. package/lib/ReactServerRenderingTransaction.js +6 -5
  90. package/lib/ReactTestUtils.js +47 -39
  91. package/lib/ReactTransitionChildMapping.js +3 -6
  92. package/lib/ReactTransitionEvents.js +1 -1
  93. package/lib/ReactTransitionGroup.js +5 -6
  94. package/lib/ReactUpdateQueue.js +19 -19
  95. package/lib/ReactUpdates.js +15 -15
  96. package/lib/{performance.js → ReactVersion.js} +3 -12
  97. package/lib/ReactWithAddons.js +24 -15
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -1
  102. package/lib/SelectEventPlugin.js +19 -9
  103. package/lib/SimpleEventPlugin.js +198 -43
  104. package/lib/SyntheticClipboardEvent.js +1 -1
  105. package/lib/SyntheticCompositionEvent.js +1 -1
  106. package/lib/SyntheticDragEvent.js +1 -1
  107. package/lib/SyntheticEvent.js +18 -4
  108. package/lib/SyntheticFocusEvent.js +1 -1
  109. package/lib/SyntheticInputEvent.js +1 -1
  110. package/lib/SyntheticKeyboardEvent.js +4 -4
  111. package/lib/SyntheticMouseEvent.js +3 -3
  112. package/lib/SyntheticTouchEvent.js +2 -2
  113. package/lib/SyntheticUIEvent.js +2 -2
  114. package/lib/SyntheticWheelEvent.js +1 -1
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +7 -7
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -7
  120. package/lib/cloneWithProps.js +11 -6
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +7 -6
  124. package/lib/findDOMNode.js +9 -9
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/getEventKey.js +1 -1
  127. package/lib/{isTextNode.js → getTestDocument.js} +7 -11
  128. package/lib/getTextContentAccessor.js +1 -1
  129. package/lib/instantiateReactComponent.js +15 -17
  130. package/lib/isEventSupported.js +1 -1
  131. package/lib/onlyChild.js +3 -3
  132. package/lib/quoteAttributeValueForBrowser.js +1 -1
  133. package/lib/reactComponentExpect.js +216 -0
  134. package/lib/renderSubtreeIntoContainer.js +1 -1
  135. package/lib/setInnerHTML.js +1 -1
  136. package/lib/setTextContent.js +3 -3
  137. package/lib/shallowCompare.js +1 -1
  138. package/lib/shouldUpdateReactComponent.js +12 -8
  139. package/lib/sliceChildren.js +34 -0
  140. package/lib/traverseAllChildren.js +25 -18
  141. package/lib/update.js +13 -13
  142. package/lib/validateDOMNesting.js +6 -6
  143. package/lib/webcomponents.js +6379 -0
  144. package/package.json +4 -6
  145. package/react.js +1 -51
  146. package/dist/JSXTransformer.js +0 -17588
  147. package/lib/CSSCore.js +0 -97
  148. package/lib/EventListener.js +0 -84
  149. package/lib/ExecutionEnvironment.js +0 -38
  150. package/lib/ReactDOMClient.js +0 -90
  151. package/lib/camelize.js +0 -32
  152. package/lib/camelizeStyleName.js +0 -40
  153. package/lib/containsNode.js +0 -55
  154. package/lib/createArrayFromMixed.js +0 -85
  155. package/lib/createNodesFromMarkup.js +0 -84
  156. package/lib/emptyFunction.js +0 -38
  157. package/lib/focusNode.js +0 -26
  158. package/lib/getActiveElement.js +0 -29
  159. package/lib/getMarkupWrap.js +0 -93
  160. package/lib/getUnboundedScrollPosition.js +0 -38
  161. package/lib/hyphenate.js +0 -33
  162. package/lib/hyphenateStyleName.js +0 -39
  163. package/lib/invariant.js +0 -49
  164. package/lib/isNode.js +0 -23
  165. package/lib/joinClasses.js +0 -39
  166. package/lib/keyMirror.js +0 -48
  167. package/lib/keyOf.js +0 -35
  168. package/lib/mapObject.js +0 -51
  169. package/lib/memoizeStringOnly.js +0 -31
  170. package/lib/performanceNow.js +0 -28
  171. package/lib/shallowEqual.js +0 -48
  172. package/lib/toArray.js +0 -57
  173. 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,17 +12,17 @@
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
+ var warning = require('fbjs/lib/warning');
19
20
 
20
21
  /**
21
22
  * @interface Event
22
23
  * @see http://www.w3.org/TR/DOM-Level-3-Events/
23
24
  */
24
25
  var EventInterface = {
25
- path: null,
26
26
  type: null,
27
27
  // currentTarget is set when dispatching; no use in copying it here
28
28
  currentTarget: emptyFunction.thatReturnsNull,
@@ -87,6 +87,13 @@ assign(SyntheticEvent.prototype, {
87
87
  preventDefault: function () {
88
88
  this.defaultPrevented = true;
89
89
  var event = this.nativeEvent;
90
+ if (process.env.NODE_ENV !== 'production') {
91
+ process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
92
+ }
93
+ if (!event) {
94
+ return;
95
+ }
96
+
90
97
  if (event.preventDefault) {
91
98
  event.preventDefault();
92
99
  } else {
@@ -97,6 +104,13 @@ assign(SyntheticEvent.prototype, {
97
104
 
98
105
  stopPropagation: function () {
99
106
  var event = this.nativeEvent;
107
+ if (process.env.NODE_ENV !== 'production') {
108
+ process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
109
+ }
110
+ if (!event) {
111
+ return;
112
+ }
113
+
100
114
  if (event.stopPropagation) {
101
115
  event.stopPropagation();
102
116
  } else {
@@ -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];
@@ -222,7 +222,7 @@ var Transaction = {
222
222
  Mixin: Mixin,
223
223
 
224
224
  /**
225
- * Token to look for to determine if an error occured.
225
+ * Token to look for to determine if an error occurred.
226
226
  */
227
227
  OBSERVED_ERROR: {}
228
228
 
@@ -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);