react 0.13.0 → 0.14.0-alpha1

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 (194) 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 +3134 -5113
  17. package/dist/react-with-addons.min.js +6 -6
  18. package/dist/react.js +2812 -4567
  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 -65
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -60
  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 +12 -18
  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 +20 -38
  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 +7 -16
  55. package/lib/ReactClass.js +78 -231
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -6
  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/ReactDOMComponent.js +185 -146
  66. package/lib/ReactDOMForm.js +3 -3
  67. package/lib/ReactDOMIDOperations.js +11 -20
  68. package/lib/ReactDOMIframe.js +3 -3
  69. package/lib/ReactDOMImg.js +3 -3
  70. package/lib/ReactDOMInput.js +22 -35
  71. package/lib/ReactDOMOption.js +52 -10
  72. package/lib/ReactDOMSelect.js +53 -29
  73. package/lib/ReactDOMSelection.js +5 -20
  74. package/lib/ReactDOMTextComponent.js +17 -18
  75. package/lib/ReactDOMTextarea.js +15 -27
  76. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  77. package/lib/ReactDefaultInjection.js +21 -40
  78. package/lib/ReactDefaultPerf.js +41 -72
  79. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  80. package/lib/ReactElement.js +35 -72
  81. package/lib/ReactElementValidator.js +51 -110
  82. package/lib/ReactEmptyComponent.js +7 -11
  83. package/lib/ReactErrorUtils.js +2 -2
  84. package/lib/ReactEventEmitterMixin.js +3 -12
  85. package/lib/ReactEventListener.js +16 -38
  86. package/lib/ReactFragment.js +23 -54
  87. package/lib/ReactInjection.js +1 -1
  88. package/lib/ReactInputSelection.js +11 -21
  89. package/lib/ReactInstanceHandles.js +27 -57
  90. package/lib/ReactInstanceMap.js +5 -5
  91. package/lib/ReactLifeCycle.js +1 -1
  92. package/lib/ReactLink.js +2 -4
  93. package/lib/ReactMarkupChecksum.js +5 -10
  94. package/lib/ReactMount.js +136 -260
  95. package/lib/ReactMultiChild.js +19 -45
  96. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  97. package/lib/ReactNativeComponent.js +7 -11
  98. package/lib/ReactOwner.js +7 -24
  99. package/lib/ReactPerf.js +8 -12
  100. package/lib/ReactPropTransferer.js +4 -4
  101. package/lib/ReactPropTypeLocationNames.js +2 -2
  102. package/lib/ReactPropTypeLocations.js +1 -1
  103. package/lib/ReactPropTypes.js +13 -46
  104. package/lib/ReactReconcileTransaction.js +9 -34
  105. package/lib/ReactReconciler.js +9 -19
  106. package/lib/ReactRef.js +5 -8
  107. package/lib/ReactRootIndex.js +2 -2
  108. package/lib/ReactServerRendering.js +7 -15
  109. package/lib/ReactServerRenderingTransaction.js +7 -32
  110. package/lib/ReactStateSetters.js +6 -6
  111. package/lib/ReactTestUtils.js +94 -166
  112. package/lib/ReactTransitionChildMapping.js +5 -7
  113. package/lib/ReactTransitionEvents.js +5 -5
  114. package/lib/ReactTransitionGroup.js +30 -52
  115. package/lib/ReactUpdateQueue.js +27 -90
  116. package/lib/ReactUpdates.js +27 -79
  117. package/lib/ReactWithAddons.js +7 -6
  118. package/lib/SVGDOMPropertyConfig.js +41 -2
  119. package/lib/SelectEventPlugin.js +28 -29
  120. package/lib/ServerReactRootIndex.js +2 -2
  121. package/lib/SimpleEventPlugin.js +136 -128
  122. package/lib/SyntheticClipboardEvent.js +3 -7
  123. package/lib/SyntheticCompositionEvent.js +3 -9
  124. package/lib/SyntheticDragEvent.js +1 -1
  125. package/lib/SyntheticEvent.js +8 -10
  126. package/lib/SyntheticFocusEvent.js +1 -1
  127. package/lib/SyntheticInputEvent.js +3 -9
  128. package/lib/SyntheticKeyboardEvent.js +4 -4
  129. package/lib/SyntheticMouseEvent.js +8 -14
  130. package/lib/SyntheticTouchEvent.js +1 -1
  131. package/lib/SyntheticUIEvent.js +3 -3
  132. package/lib/SyntheticWheelEvent.js +11 -15
  133. package/lib/Transaction.js +12 -24
  134. package/lib/ViewportMetrics.js +2 -2
  135. package/lib/accumulateInto.js +2 -5
  136. package/lib/adler32.js +2 -2
  137. package/lib/camelize.js +4 -2
  138. package/lib/camelizeStyleName.js +2 -2
  139. package/lib/cloneWithProps.js +5 -11
  140. package/lib/containsNode.js +29 -16
  141. package/lib/createArrayFromMixed.js +17 -16
  142. package/lib/createFullPageComponent.js +5 -11
  143. package/lib/createNodesFromMarkup.js +6 -8
  144. package/lib/dangerousStyleValue.js +2 -3
  145. package/lib/emptyFunction.js +10 -4
  146. package/lib/emptyObject.js +1 -1
  147. package/lib/escapeTextContentForBrowser.js +1 -1
  148. package/lib/findDOMNode.js +5 -24
  149. package/lib/flattenChildren.js +4 -10
  150. package/lib/focusNode.js +2 -3
  151. package/lib/forEachAccumulated.js +2 -2
  152. package/lib/getActiveElement.js +4 -2
  153. package/lib/getEventCharCode.js +1 -1
  154. package/lib/getEventKey.js +1 -1
  155. package/lib/getEventModifierState.js +1 -1
  156. package/lib/getEventTarget.js +1 -1
  157. package/lib/getIteratorFn.js +2 -4
  158. package/lib/getMarkupWrap.js +7 -5
  159. package/lib/getNodeForCharacterOffset.js +1 -1
  160. package/lib/getTextContentAccessor.js +2 -4
  161. package/lib/getUnboundedScrollPosition.js +1 -1
  162. package/lib/hyphenate.js +3 -1
  163. package/lib/hyphenateStyleName.js +2 -2
  164. package/lib/instantiateReactComponent.js +14 -37
  165. package/lib/invariant.js +8 -12
  166. package/lib/isEventSupported.js +7 -10
  167. package/lib/isNode.js +4 -6
  168. package/lib/isTextInputElement.js +2 -4
  169. package/lib/isTextNode.js +3 -1
  170. package/lib/joinClasses.js +2 -2
  171. package/lib/keyMirror.js +3 -6
  172. package/lib/keyOf.js +4 -3
  173. package/lib/mapObject.js +1 -1
  174. package/lib/memoizeStringOnly.js +2 -2
  175. package/lib/onlyChild.js +2 -5
  176. package/lib/performance.js +2 -5
  177. package/lib/performanceNow.js +3 -1
  178. package/lib/quoteAttributeValueForBrowser.js +1 -1
  179. package/lib/renderSubtreeIntoContainer.js +16 -0
  180. package/lib/setInnerHTML.js +11 -8
  181. package/lib/setTextContent.js +3 -3
  182. package/lib/shallowCompare.js +24 -0
  183. package/lib/shallowEqual.js +17 -11
  184. package/lib/shouldUpdateReactComponent.js +3 -64
  185. package/lib/toArray.js +8 -19
  186. package/lib/traverseAllChildren.js +19 -82
  187. package/lib/update.js +33 -90
  188. package/lib/validateDOMNesting.js +264 -0
  189. package/lib/warning.js +17 -15
  190. package/package.json +3 -3
  191. package/lib/MobileSafariClickEventPlugin.js +0 -56
  192. package/lib/ReactPutListenerQueue.js +0 -54
  193. package/lib/cx.js +0 -52
  194. 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;
@@ -21,29 +21,17 @@ var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
21
21
  var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
22
22
  var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
23
23
  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;
24
+ var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
25
+ var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
28
26
 
29
27
  var hasSVG;
30
28
  if (ExecutionEnvironment.canUseDOM) {
31
29
  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
- );
30
+ hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
40
31
  }
41
32
 
42
-
43
33
  var HTMLDOMPropertyConfig = {
44
- isCustomAttribute: RegExp.prototype.test.bind(
45
- /^(data|aria)-[a-z_][a-z\d_.\-]*$/
46
- ),
34
+ isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/),
47
35
  Properties: {
48
36
  /**
49
37
  * Standard Properties
@@ -97,6 +85,7 @@ var HTMLDOMPropertyConfig = {
97
85
  headers: null,
98
86
  height: MUST_USE_ATTRIBUTE,
99
87
  hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
88
+ high: null,
100
89
  href: null,
101
90
  hrefLang: null,
102
91
  htmlFor: null,
@@ -107,6 +96,7 @@ var HTMLDOMPropertyConfig = {
107
96
  lang: null,
108
97
  list: MUST_USE_ATTRIBUTE,
109
98
  loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
99
+ low: null,
110
100
  manifest: MUST_USE_ATTRIBUTE,
111
101
  marginHeight: null,
112
102
  marginWidth: null,
@@ -121,6 +111,7 @@ var HTMLDOMPropertyConfig = {
121
111
  name: null,
122
112
  noValidate: HAS_BOOLEAN_VALUE,
123
113
  open: HAS_BOOLEAN_VALUE,
114
+ optimum: null,
124
115
  pattern: null,
125
116
  placeholder: null,
126
117
  poster: null,
@@ -134,6 +125,7 @@ var HTMLDOMPropertyConfig = {
134
125
  rowSpan: null,
135
126
  sandbox: null,
136
127
  scope: null,
128
+ scoped: HAS_BOOLEAN_VALUE,
137
129
  scrolling: null,
138
130
  seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
139
131
  selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
@@ -175,7 +167,9 @@ var HTMLDOMPropertyConfig = {
175
167
  itemID: MUST_USE_ATTRIBUTE,
176
168
  itemRef: MUST_USE_ATTRIBUTE,
177
169
  // property is supported for OpenGraph in meta tags.
178
- property: null
170
+ property: null,
171
+ // IE-only attribute that controls focus behavior
172
+ unselectable: MUST_USE_ATTRIBUTE
179
173
  },
180
174
  DOMAttributeNames: {
181
175
  acceptCharset: 'accept-charset',
@@ -200,4 +194,4 @@ var HTMLDOMPropertyConfig = {
200
194
  }
201
195
  };
202
196
 
203
- module.exports = HTMLDOMPropertyConfig;
197
+ 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;