react 0.13.1 → 0.14.0-alpha2

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 (197) hide show
  1. package/README.md +1 -1
  2. package/addons.js +7 -0
  3. package/addons/CSSTransitionGroup.js +1 -0
  4. package/addons/LinkedStateMixin.js +1 -0
  5. package/addons/Perf.js +1 -0
  6. package/addons/PureRenderMixin.js +1 -0
  7. package/addons/TestUtils.js +1 -0
  8. package/addons/TransitionGroup.js +1 -0
  9. package/addons/batchedUpdates.js +1 -0
  10. package/addons/cloneWithProps.js +1 -0
  11. package/addons/createFragment.js +1 -0
  12. package/addons/renderSubtreeIntoContainer.js +1 -0
  13. package/addons/shallowCompare.js +1 -0
  14. package/addons/update.js +1 -0
  15. package/dist/JSXTransformer.js +3336 -1671
  16. package/dist/react-with-addons.js +3320 -5125
  17. package/dist/react-with-addons.min.js +6 -6
  18. package/dist/react.js +2952 -4533
  19. package/dist/react.min.js +5 -5
  20. package/lib/AutoFocusMixin.js +4 -3
  21. package/lib/BeforeInputEventPlugin.js +30 -118
  22. package/lib/CSSCore.js +12 -23
  23. package/lib/CSSProperty.js +9 -4
  24. package/lib/CSSPropertyOperations.js +14 -30
  25. package/lib/CallbackQueue.js +7 -10
  26. package/lib/ChangeEventPlugin.js +24 -88
  27. package/lib/ClientReactRootIndex.js +2 -2
  28. package/lib/DOMChildrenOperations.js +13 -33
  29. package/lib/DOMProperty.js +41 -67
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -62
  32. package/lib/DefaultEventPluginOrder.js +2 -12
  33. package/lib/EnterLeaveEventPlugin.js +11 -33
  34. package/lib/EventConstants.js +2 -2
  35. package/lib/EventListener.js +11 -13
  36. package/lib/EventPluginHub.js +44 -47
  37. package/lib/EventPluginRegistry.js +18 -74
  38. package/lib/EventPluginUtils.js +27 -38
  39. package/lib/EventPropagators.js +23 -26
  40. package/lib/ExecutionEnvironment.js +4 -8
  41. package/lib/FallbackCompositionState.js +3 -3
  42. package/lib/HTMLDOMPropertyConfig.js +13 -20
  43. package/lib/LinkedStateMixin.js +3 -6
  44. package/lib/LinkedValueUtils.js +34 -64
  45. package/lib/LocalEventTrapMixin.js +9 -16
  46. package/lib/Object.assign.js +1 -1
  47. package/lib/PooledClass.js +8 -11
  48. package/lib/React.js +9 -129
  49. package/lib/ReactBrowserComponentMixin.js +9 -2
  50. package/lib/ReactBrowserEventEmitter.js +26 -82
  51. package/lib/ReactCSSTransitionGroup.js +13 -24
  52. package/lib/ReactCSSTransitionGroupChild.js +18 -28
  53. package/lib/ReactChildReconciler.js +11 -19
  54. package/lib/ReactChildren.js +21 -28
  55. package/lib/ReactClass.js +81 -234
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  58. package/lib/ReactComponentEnvironment.js +6 -12
  59. package/lib/ReactComponentWithPureRenderMixin.js +4 -5
  60. package/lib/ReactCompositeComponent.js +85 -297
  61. package/lib/ReactContext.js +2 -44
  62. package/lib/ReactCurrentOwner.js +1 -3
  63. package/lib/ReactDOM.js +4 -2
  64. package/lib/ReactDOMButton.js +3 -4
  65. package/lib/ReactDOMClient.js +85 -0
  66. package/lib/ReactDOMComponent.js +184 -146
  67. package/lib/ReactDOMForm.js +3 -3
  68. package/lib/ReactDOMIDOperations.js +11 -22
  69. package/lib/ReactDOMIframe.js +3 -3
  70. package/lib/ReactDOMImg.js +3 -3
  71. package/lib/ReactDOMInput.js +22 -35
  72. package/lib/ReactDOMOption.js +68 -10
  73. package/lib/ReactDOMSelect.js +50 -28
  74. package/lib/ReactDOMSelection.js +5 -20
  75. package/lib/ReactDOMServer.js +24 -0
  76. package/lib/ReactDOMTextComponent.js +17 -18
  77. package/lib/ReactDOMTextarea.js +15 -27
  78. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  79. package/lib/ReactDefaultInjection.js +31 -40
  80. package/lib/ReactDefaultPerf.js +36 -69
  81. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  82. package/lib/ReactElement.js +24 -57
  83. package/lib/ReactElementValidator.js +38 -105
  84. package/lib/ReactEmptyComponent.js +7 -11
  85. package/lib/ReactErrorUtils.js +2 -2
  86. package/lib/ReactEventEmitterMixin.js +3 -12
  87. package/lib/ReactEventListener.js +16 -38
  88. package/lib/ReactFragment.js +23 -54
  89. package/lib/ReactInjection.js +1 -1
  90. package/lib/ReactInputSelection.js +11 -21
  91. package/lib/ReactInstanceHandles.js +27 -57
  92. package/lib/ReactInstanceMap.js +5 -5
  93. package/lib/ReactIsomorphic.js +70 -0
  94. package/lib/ReactLifeCycle.js +1 -1
  95. package/lib/ReactLink.js +2 -4
  96. package/lib/ReactMarkupChecksum.js +5 -10
  97. package/lib/ReactMount.js +137 -260
  98. package/lib/ReactMultiChild.js +19 -45
  99. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  100. package/lib/ReactNativeComponent.js +7 -11
  101. package/lib/ReactOwner.js +7 -24
  102. package/lib/ReactPerf.js +8 -12
  103. package/lib/ReactPropTransferer.js +4 -4
  104. package/lib/ReactPropTypeLocationNames.js +2 -2
  105. package/lib/ReactPropTypeLocations.js +1 -1
  106. package/lib/ReactPropTypes.js +29 -61
  107. package/lib/ReactReconcileTransaction.js +9 -34
  108. package/lib/ReactReconciler.js +9 -19
  109. package/lib/ReactRef.js +5 -8
  110. package/lib/ReactRootIndex.js +2 -2
  111. package/lib/ReactServerRendering.js +7 -15
  112. package/lib/ReactServerRenderingTransaction.js +7 -32
  113. package/lib/ReactStateSetters.js +6 -6
  114. package/lib/ReactTestUtils.js +93 -165
  115. package/lib/ReactTransitionChildMapping.js +5 -7
  116. package/lib/ReactTransitionEvents.js +5 -5
  117. package/lib/ReactTransitionGroup.js +30 -52
  118. package/lib/ReactUpdateQueue.js +27 -90
  119. package/lib/ReactUpdates.js +27 -79
  120. package/lib/ReactWithAddons.js +7 -6
  121. package/lib/SVGDOMPropertyConfig.js +41 -4
  122. package/lib/SelectEventPlugin.js +28 -29
  123. package/lib/ServerReactRootIndex.js +2 -2
  124. package/lib/SimpleEventPlugin.js +136 -128
  125. package/lib/SyntheticClipboardEvent.js +3 -7
  126. package/lib/SyntheticCompositionEvent.js +3 -9
  127. package/lib/SyntheticDragEvent.js +1 -1
  128. package/lib/SyntheticEvent.js +8 -10
  129. package/lib/SyntheticFocusEvent.js +1 -1
  130. package/lib/SyntheticInputEvent.js +3 -9
  131. package/lib/SyntheticKeyboardEvent.js +4 -4
  132. package/lib/SyntheticMouseEvent.js +8 -14
  133. package/lib/SyntheticTouchEvent.js +1 -1
  134. package/lib/SyntheticUIEvent.js +3 -3
  135. package/lib/SyntheticWheelEvent.js +11 -15
  136. package/lib/Transaction.js +12 -24
  137. package/lib/ViewportMetrics.js +2 -2
  138. package/lib/accumulateInto.js +2 -5
  139. package/lib/adler32.js +2 -4
  140. package/lib/camelize.js +4 -2
  141. package/lib/camelizeStyleName.js +2 -2
  142. package/lib/cloneWithProps.js +5 -11
  143. package/lib/containsNode.js +29 -16
  144. package/lib/createArrayFromMixed.js +17 -16
  145. package/lib/createFullPageComponent.js +4 -11
  146. package/lib/createNodesFromMarkup.js +6 -8
  147. package/lib/dangerousStyleValue.js +2 -3
  148. package/lib/emptyFunction.js +10 -4
  149. package/lib/emptyObject.js +1 -1
  150. package/lib/escapeTextContentForBrowser.js +1 -1
  151. package/lib/findDOMNode.js +5 -24
  152. package/lib/flattenChildren.js +4 -10
  153. package/lib/focusNode.js +2 -3
  154. package/lib/forEachAccumulated.js +2 -2
  155. package/lib/getActiveElement.js +4 -2
  156. package/lib/getEventCharCode.js +1 -1
  157. package/lib/getEventKey.js +1 -1
  158. package/lib/getEventModifierState.js +1 -1
  159. package/lib/getEventTarget.js +1 -1
  160. package/lib/getIteratorFn.js +2 -4
  161. package/lib/getMarkupWrap.js +7 -5
  162. package/lib/getNodeForCharacterOffset.js +1 -1
  163. package/lib/getTextContentAccessor.js +2 -4
  164. package/lib/getUnboundedScrollPosition.js +1 -1
  165. package/lib/hyphenate.js +3 -1
  166. package/lib/hyphenateStyleName.js +2 -2
  167. package/lib/instantiateReactComponent.js +14 -37
  168. package/lib/invariant.js +8 -12
  169. package/lib/isEventSupported.js +7 -10
  170. package/lib/isNode.js +4 -6
  171. package/lib/isTextInputElement.js +2 -4
  172. package/lib/isTextNode.js +3 -1
  173. package/lib/joinClasses.js +2 -2
  174. package/lib/keyMirror.js +3 -6
  175. package/lib/keyOf.js +4 -3
  176. package/lib/mapObject.js +1 -1
  177. package/lib/memoizeStringOnly.js +2 -2
  178. package/lib/onlyChild.js +2 -5
  179. package/lib/performance.js +2 -5
  180. package/lib/performanceNow.js +3 -1
  181. package/lib/quoteAttributeValueForBrowser.js +1 -1
  182. package/lib/renderSubtreeIntoContainer.js +16 -0
  183. package/lib/setInnerHTML.js +11 -8
  184. package/lib/setTextContent.js +3 -3
  185. package/lib/shallowCompare.js +24 -0
  186. package/lib/shallowEqual.js +17 -11
  187. package/lib/shouldUpdateReactComponent.js +3 -64
  188. package/lib/toArray.js +8 -19
  189. package/lib/traverseAllChildren.js +22 -89
  190. package/lib/update.js +33 -90
  191. package/lib/validateDOMNesting.js +355 -0
  192. package/lib/warning.js +17 -15
  193. package/package.json +3 -3
  194. package/lib/MobileSafariClickEventPlugin.js +0 -56
  195. package/lib/ReactPutListenerQueue.js +0 -54
  196. package/lib/cx.js +0 -52
  197. package/lib/getReactRootElementInContainer.js +0 -33
@@ -14,6 +14,8 @@
14
14
  var EventConstants = require("./EventConstants");
15
15
  var EventPluginHub = require("./EventPluginHub");
16
16
 
17
+ var warning = require("./warning");
18
+
17
19
  var accumulateInto = require("./accumulateInto");
18
20
  var forEachAccumulated = require("./forEachAccumulated");
19
21
 
@@ -25,8 +27,7 @@ var getListener = EventPluginHub.getListener;
25
27
  * "phases" of propagation. This finds listeners by a given phase.
26
28
  */
27
29
  function listenerAtPhase(id, event, propagationPhase) {
28
- var registrationName =
29
- event.dispatchConfig.phasedRegistrationNames[propagationPhase];
30
+ var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
30
31
  return getListener(id, registrationName);
31
32
  }
32
33
 
@@ -37,16 +38,13 @@ function listenerAtPhase(id, event, propagationPhase) {
37
38
  * "dispatch" object that pairs the event with the listener.
38
39
  */
39
40
  function accumulateDirectionalDispatches(domID, upwards, event) {
40
- if ("production" !== process.env.NODE_ENV) {
41
- if (!domID) {
42
- throw new Error('Dispatching id must not be null');
43
- }
41
+ if ('production' !== process.env.NODE_ENV) {
42
+ 'production' !== process.env.NODE_ENV ? warning(domID, 'Dispatching id must not be null') : null;
44
43
  }
45
44
  var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
46
45
  var listener = listenerAtPhase(domID, event, phase);
47
46
  if (listener) {
48
- event._dispatchListeners =
49
- accumulateInto(event._dispatchListeners, listener);
47
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
50
48
  event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
51
49
  }
52
50
  }
@@ -60,14 +58,18 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
60
58
  */
61
59
  function accumulateTwoPhaseDispatchesSingle(event) {
62
60
  if (event && event.dispatchConfig.phasedRegistrationNames) {
63
- EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(
64
- event.dispatchMarker,
65
- accumulateDirectionalDispatches,
66
- event
67
- );
61
+ EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event);
68
62
  }
69
63
  }
70
64
 
65
+ /**
66
+ * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
67
+ */
68
+ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
69
+ if (event && event.dispatchConfig.phasedRegistrationNames) {
70
+ EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event);
71
+ }
72
+ }
71
73
 
72
74
  /**
73
75
  * Accumulates without regard to direction, does not look for phased
@@ -79,8 +81,7 @@ function accumulateDispatches(id, ignoredDirection, event) {
79
81
  var registrationName = event.dispatchConfig.registrationName;
80
82
  var listener = getListener(id, registrationName);
81
83
  if (listener) {
82
- event._dispatchListeners =
83
- accumulateInto(event._dispatchListeners, listener);
84
+ event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
84
85
  event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
85
86
  }
86
87
  }
@@ -101,23 +102,18 @@ function accumulateTwoPhaseDispatches(events) {
101
102
  forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
102
103
  }
103
104
 
104
- function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
105
- EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(
106
- fromID,
107
- toID,
108
- accumulateDispatches,
109
- leave,
110
- enter
111
- );
105
+ function accumulateTwoPhaseDispatchesSkipTarget(events) {
106
+ forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
112
107
  }
113
108
 
109
+ function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
110
+ EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter);
111
+ }
114
112
 
115
113
  function accumulateDirectDispatches(events) {
116
114
  forEachAccumulated(events, accumulateDirectDispatchesSingle);
117
115
  }
118
116
 
119
-
120
-
121
117
  /**
122
118
  * A small set of propagation patterns, each of which will accept a small amount
123
119
  * of information, and generate a set of "dispatch ready event objects" - which
@@ -131,8 +127,9 @@ function accumulateDirectDispatches(events) {
131
127
  */
132
128
  var EventPropagators = {
133
129
  accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
130
+ accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
134
131
  accumulateDirectDispatches: accumulateDirectDispatches,
135
132
  accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
136
133
  };
137
134
 
138
- module.exports = EventPropagators;
135
+ module.exports = EventPropagators;
@@ -11,12 +11,9 @@
11
11
 
12
12
  /*jslint evil: true */
13
13
 
14
- "use strict";
14
+ 'use strict';
15
15
 
16
- var canUseDOM = !!(
17
- (typeof window !== 'undefined' &&
18
- window.document && window.document.createElement)
19
- );
16
+ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
20
17
 
21
18
  /**
22
19
  * Simple, lightweight module assisting with the detection and context of
@@ -30,8 +27,7 @@ var ExecutionEnvironment = {
30
27
 
31
28
  canUseWorkers: typeof Worker !== 'undefined',
32
29
 
33
- canUseEventListeners:
34
- canUseDOM && !!(window.addEventListener || window.attachEvent),
30
+ canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
35
31
 
36
32
  canUseViewport: canUseDOM && !!window.screen,
37
33
 
@@ -39,4 +35,4 @@ var ExecutionEnvironment = {
39
35
 
40
36
  };
41
37
 
42
- module.exports = ExecutionEnvironment;
38
+ module.exports = ExecutionEnvironment;
@@ -40,7 +40,7 @@ assign(FallbackCompositionState.prototype, {
40
40
  *
41
41
  * @return {string}
42
42
  */
43
- getText: function() {
43
+ getText: function () {
44
44
  if ('value' in this._root) {
45
45
  return this._root.value;
46
46
  }
@@ -53,7 +53,7 @@ assign(FallbackCompositionState.prototype, {
53
53
  *
54
54
  * @return {string}
55
55
  */
56
- getData: function() {
56
+ getData: function () {
57
57
  if (this._fallbackText) {
58
58
  return this._fallbackText;
59
59
  }
@@ -86,4 +86,4 @@ assign(FallbackCompositionState.prototype, {
86
86
 
87
87
  PooledClass.addPoolingTo(FallbackCompositionState);
88
88
 
89
- module.exports = FallbackCompositionState;
89
+ module.exports = FallbackCompositionState;
@@ -9,8 +9,6 @@
9
9
  * @providesModule HTMLDOMPropertyConfig
10
10
  */
11
11
 
12
- /*jslint bitwise: true*/
13
-
14
12
  'use strict';
15
13
 
16
14
  var DOMProperty = require("./DOMProperty");
@@ -21,29 +19,17 @@ var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
21
19
  var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
22
20
  var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
23
21
  var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
24
- var HAS_POSITIVE_NUMERIC_VALUE =
25
- DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
26
- var HAS_OVERLOADED_BOOLEAN_VALUE =
27
- DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
22
+ var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
23
+ var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
28
24
 
29
25
  var hasSVG;
30
26
  if (ExecutionEnvironment.canUseDOM) {
31
27
  var implementation = document.implementation;
32
- hasSVG = (
33
- implementation &&
34
- implementation.hasFeature &&
35
- implementation.hasFeature(
36
- 'http://www.w3.org/TR/SVG11/feature#BasicStructure',
37
- '1.1'
38
- )
39
- );
28
+ hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
40
29
  }
41
30
 
42
-
43
31
  var HTMLDOMPropertyConfig = {
44
- isCustomAttribute: RegExp.prototype.test.bind(
45
- /^(data|aria)-[a-z_][a-z\d_.\-]*$/
46
- ),
32
+ isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/),
47
33
  Properties: {
48
34
  /**
49
35
  * Standard Properties
@@ -97,6 +83,7 @@ var HTMLDOMPropertyConfig = {
97
83
  headers: null,
98
84
  height: MUST_USE_ATTRIBUTE,
99
85
  hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
86
+ high: null,
100
87
  href: null,
101
88
  hrefLang: null,
102
89
  htmlFor: null,
@@ -107,6 +94,7 @@ var HTMLDOMPropertyConfig = {
107
94
  lang: null,
108
95
  list: MUST_USE_ATTRIBUTE,
109
96
  loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
97
+ low: null,
110
98
  manifest: MUST_USE_ATTRIBUTE,
111
99
  marginHeight: null,
112
100
  marginWidth: null,
@@ -116,11 +104,13 @@ var HTMLDOMPropertyConfig = {
116
104
  mediaGroup: null,
117
105
  method: null,
118
106
  min: null,
107
+ minLength: MUST_USE_ATTRIBUTE,
119
108
  multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
120
109
  muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
121
110
  name: null,
122
111
  noValidate: HAS_BOOLEAN_VALUE,
123
112
  open: HAS_BOOLEAN_VALUE,
113
+ optimum: null,
124
114
  pattern: null,
125
115
  placeholder: null,
126
116
  poster: null,
@@ -134,6 +124,7 @@ var HTMLDOMPropertyConfig = {
134
124
  rowSpan: null,
135
125
  sandbox: null,
136
126
  scope: null,
127
+ scoped: HAS_BOOLEAN_VALUE,
137
128
  scrolling: null,
138
129
  seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
139
130
  selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
@@ -175,7 +166,9 @@ var HTMLDOMPropertyConfig = {
175
166
  itemID: MUST_USE_ATTRIBUTE,
176
167
  itemRef: MUST_USE_ATTRIBUTE,
177
168
  // property is supported for OpenGraph in meta tags.
178
- property: null
169
+ property: null,
170
+ // IE-only attribute that controls focus behavior
171
+ unselectable: MUST_USE_ATTRIBUTE
179
172
  },
180
173
  DOMAttributeNames: {
181
174
  acceptCharset: 'accept-charset',
@@ -200,4 +193,4 @@ var HTMLDOMPropertyConfig = {
200
193
  }
201
194
  };
202
195
 
203
- module.exports = HTMLDOMPropertyConfig;
196
+ module.exports = HTMLDOMPropertyConfig;
@@ -28,12 +28,9 @@ var LinkedStateMixin = {
28
28
  * if you're using Google Closure Compiler advanced mode.
29
29
  * @return {ReactLink} ReactLink instance linking to the state.
30
30
  */
31
- linkState: function(key) {
32
- return new ReactLink(
33
- this.state[key],
34
- ReactStateSetters.createStateKeySetter(this, key)
35
- );
31
+ linkState: function (key) {
32
+ return new ReactLink(this.state[key], ReactStateSetters.createStateKeySetter(this, key));
36
33
  }
37
34
  };
38
35
 
39
- module.exports = LinkedStateMixin;
36
+ module.exports = LinkedStateMixin;
@@ -26,30 +26,17 @@ var hasReadOnlyValue = {
26
26
  'submit': true
27
27
  };
28
28
 
29
- function _assertSingleLink(input) {
30
- ("production" !== process.env.NODE_ENV ? invariant(
31
- input.props.checkedLink == null || input.props.valueLink == null,
32
- 'Cannot provide a checkedLink and a valueLink. If you want to use ' +
33
- 'checkedLink, you probably don\'t want to use valueLink and vice versa.'
34
- ) : invariant(input.props.checkedLink == null || input.props.valueLink == null));
29
+ function _assertSingleLink(inputProps) {
30
+ 'production' !== process.env.NODE_ENV ? invariant(inputProps.checkedLink == null || inputProps.valueLink == null, 'Cannot provide a checkedLink and a valueLink. If you want to use ' + 'checkedLink, you probably don\'t want to use valueLink and vice versa.') : invariant(inputProps.checkedLink == null || inputProps.valueLink == null);
35
31
  }
36
- function _assertValueLink(input) {
37
- _assertSingleLink(input);
38
- ("production" !== process.env.NODE_ENV ? invariant(
39
- input.props.value == null && input.props.onChange == null,
40
- 'Cannot provide a valueLink and a value or onChange event. If you want ' +
41
- 'to use value or onChange, you probably don\'t want to use valueLink.'
42
- ) : invariant(input.props.value == null && input.props.onChange == null));
32
+ function _assertValueLink(inputProps) {
33
+ _assertSingleLink(inputProps);
34
+ 'production' !== process.env.NODE_ENV ? invariant(inputProps.value == null && inputProps.onChange == null, 'Cannot provide a valueLink and a value or onChange event. If you want ' + 'to use value or onChange, you probably don\'t want to use valueLink.') : invariant(inputProps.value == null && inputProps.onChange == null);
43
35
  }
44
36
 
45
- function _assertCheckedLink(input) {
46
- _assertSingleLink(input);
47
- ("production" !== process.env.NODE_ENV ? invariant(
48
- input.props.checked == null && input.props.onChange == null,
49
- 'Cannot provide a checkedLink and a checked property or onChange event. ' +
50
- 'If you want to use checked or onChange, you probably don\'t want to ' +
51
- 'use checkedLink'
52
- ) : invariant(input.props.checked == null && input.props.onChange == null));
37
+ function _assertCheckedLink(inputProps) {
38
+ _assertSingleLink(inputProps);
39
+ 'production' !== process.env.NODE_ENV ? invariant(inputProps.checked == null && inputProps.onChange == null, 'Cannot provide a checkedLink and a checked property or onChange event. ' + 'If you want to use checked or onChange, you probably don\'t want to ' + 'use checkedLink') : invariant(inputProps.checked == null && inputProps.onChange == null);
53
40
  }
54
41
 
55
42
  /**
@@ -75,78 +62,61 @@ function _handleLinkedCheckChange(e) {
75
62
  var LinkedValueUtils = {
76
63
  Mixin: {
77
64
  propTypes: {
78
- value: function(props, propName, componentName) {
79
- if (!props[propName] ||
80
- hasReadOnlyValue[props.type] ||
81
- props.onChange ||
82
- props.readOnly ||
83
- props.disabled) {
65
+ value: function (props, propName, componentName) {
66
+ if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
84
67
  return null;
85
68
  }
86
- return new Error(
87
- 'You provided a `value` prop to a form field without an ' +
88
- '`onChange` handler. This will render a read-only field. If ' +
89
- 'the field should be mutable use `defaultValue`. Otherwise, ' +
90
- 'set either `onChange` or `readOnly`.'
91
- );
69
+ return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
92
70
  },
93
- checked: function(props, propName, componentName) {
94
- if (!props[propName] ||
95
- props.onChange ||
96
- props.readOnly ||
97
- props.disabled) {
71
+ checked: function (props, propName, componentName) {
72
+ if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
98
73
  return null;
99
74
  }
100
- return new Error(
101
- 'You provided a `checked` prop to a form field without an ' +
102
- '`onChange` handler. This will render a read-only field. If ' +
103
- 'the field should be mutable use `defaultChecked`. Otherwise, ' +
104
- 'set either `onChange` or `readOnly`.'
105
- );
75
+ return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
106
76
  },
107
77
  onChange: ReactPropTypes.func
108
78
  }
109
79
  },
110
80
 
111
81
  /**
112
- * @param {ReactComponent} input Form component
82
+ * @param {object} inputProps Props for form component
113
83
  * @return {*} current value of the input either from value prop or link.
114
84
  */
115
- getValue: function(input) {
116
- if (input.props.valueLink) {
117
- _assertValueLink(input);
118
- return input.props.valueLink.value;
85
+ getValue: function (inputProps) {
86
+ if (inputProps.valueLink) {
87
+ _assertValueLink(inputProps);
88
+ return inputProps.valueLink.value;
119
89
  }
120
- return input.props.value;
90
+ return inputProps.value;
121
91
  },
122
92
 
123
93
  /**
124
- * @param {ReactComponent} input Form component
94
+ * @param {object} inputProps Props for form component
125
95
  * @return {*} current checked status of the input either from checked prop
126
96
  * or link.
127
97
  */
128
- getChecked: function(input) {
129
- if (input.props.checkedLink) {
130
- _assertCheckedLink(input);
131
- return input.props.checkedLink.value;
98
+ getChecked: function (inputProps) {
99
+ if (inputProps.checkedLink) {
100
+ _assertCheckedLink(inputProps);
101
+ return inputProps.checkedLink.value;
132
102
  }
133
- return input.props.checked;
103
+ return inputProps.checked;
134
104
  },
135
105
 
136
106
  /**
137
- * @param {ReactComponent} input Form component
107
+ * @param {object} inputProps Props for form component
138
108
  * @return {function} change callback either from onChange prop or link.
139
109
  */
140
- getOnChange: function(input) {
141
- if (input.props.valueLink) {
142
- _assertValueLink(input);
110
+ getOnChange: function (inputProps) {
111
+ if (inputProps.valueLink) {
112
+ _assertValueLink(inputProps);
143
113
  return _handleLinkedValueChange;
144
- } else if (input.props.checkedLink) {
145
- _assertCheckedLink(input);
114
+ } else if (inputProps.checkedLink) {
115
+ _assertCheckedLink(inputProps);
146
116
  return _handleLinkedCheckChange;
147
117
  }
148
- return input.props.onChange;
118
+ return inputProps.onChange;
149
119
  }
150
120
  };
151
121
 
152
- module.exports = LinkedValueUtils;
122
+ module.exports = LinkedValueUtils;
@@ -14,6 +14,7 @@
14
14
  var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
15
15
 
16
16
  var accumulateInto = require("./accumulateInto");
17
+ var findDOMNode = require("./findDOMNode");
17
18
  var forEachAccumulated = require("./forEachAccumulated");
18
19
  var invariant = require("./invariant");
19
20
 
@@ -22,32 +23,24 @@ function remove(event) {
22
23
  }
23
24
 
24
25
  var LocalEventTrapMixin = {
25
- trapBubbledEvent:function(topLevelType, handlerBaseName) {
26
- ("production" !== process.env.NODE_ENV ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
26
+ trapBubbledEvent: function (topLevelType, handlerBaseName) {
27
+ 'production' !== process.env.NODE_ENV ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted());
27
28
  // If a component renders to null or if another component fatals and causes
28
29
  // the state of the tree to be corrupted, `node` here can be null.
29
- var node = this.getDOMNode();
30
- ("production" !== process.env.NODE_ENV ? invariant(
31
- node,
32
- 'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
33
- ) : invariant(node));
34
- var listener = ReactBrowserEventEmitter.trapBubbledEvent(
35
- topLevelType,
36
- handlerBaseName,
37
- node
38
- );
39
- this._localEventListeners =
40
- accumulateInto(this._localEventListeners, listener);
30
+ var node = findDOMNode(this);
31
+ 'production' !== process.env.NODE_ENV ? invariant(node, 'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.') : invariant(node);
32
+ var listener = ReactBrowserEventEmitter.trapBubbledEvent(topLevelType, handlerBaseName, node);
33
+ this._localEventListeners = accumulateInto(this._localEventListeners, listener);
41
34
  },
42
35
 
43
36
  // trapCapturedEvent would look nearly identical. We don't implement that
44
37
  // method because it isn't currently needed.
45
38
 
46
- componentWillUnmount:function() {
39
+ componentWillUnmount: function () {
47
40
  if (this._localEventListeners) {
48
41
  forEachAccumulated(this._localEventListeners, remove);
49
42
  }
50
43
  }
51
44
  };
52
45
 
53
- module.exports = LocalEventTrapMixin;
46
+ module.exports = LocalEventTrapMixin;