react 0.14.0-alpha2 → 0.14.0-beta3

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 (196) hide show
  1. package/README.md +5 -2
  2. package/addons.js +6 -3
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5350 -4954
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +4777 -4408
  7. package/dist/react.min.js +6 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  9. package/lib/BeforeInputEventPlugin.js +13 -13
  10. package/lib/CSSProperty.js +3 -0
  11. package/lib/CSSPropertyOperations.js +13 -13
  12. package/lib/CallbackQueue.js +4 -4
  13. package/lib/ChangeEventPlugin.js +16 -14
  14. package/lib/DOMChildrenOperations.js +10 -6
  15. package/lib/DOMProperty.js +82 -117
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -14
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +8 -8
  20. package/lib/EventConstants.js +23 -1
  21. package/lib/EventPluginHub.js +13 -13
  22. package/lib/EventPluginRegistry.js +8 -8
  23. package/lib/EventPluginUtils.js +17 -17
  24. package/lib/EventPropagators.js +7 -7
  25. package/lib/FallbackCompositionState.js +3 -3
  26. package/lib/HTMLDOMPropertyConfig.js +13 -3
  27. package/lib/LinkedStateMixin.js +2 -2
  28. package/lib/LinkedValueUtils.js +50 -38
  29. package/lib/MetaMatchers.js +118 -0
  30. package/lib/OrderedMap.js +453 -0
  31. package/lib/PooledClass.js +14 -2
  32. package/lib/React.js +6 -6
  33. package/lib/ReactBrowserComponentMixin.js +4 -4
  34. package/lib/ReactBrowserEventEmitter.js +30 -7
  35. package/lib/ReactCSSTransitionGroup.js +16 -5
  36. package/lib/ReactCSSTransitionGroupChild.js +20 -11
  37. package/lib/ReactChildReconciler.js +25 -18
  38. package/lib/ReactChildren.js +9 -9
  39. package/lib/ReactClass.js +65 -83
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  42. package/lib/ReactComponentEnvironment.js +2 -2
  43. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  44. package/lib/ReactCompositeComponent.js +80 -111
  45. package/lib/ReactDOM.js +72 -158
  46. package/lib/ReactDOMButton.js +15 -26
  47. package/lib/ReactDOMComponent.js +378 -56
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -23
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +25 -45
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +2 -2
  55. package/lib/ReactDOMTextComponent.js +11 -11
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +24 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +22 -83
  62. package/lib/ReactElementValidator.js +48 -117
  63. package/lib/ReactEmptyComponent.js +4 -4
  64. package/lib/ReactErrorUtils.js +1 -1
  65. package/lib/ReactEventEmitterMixin.js +3 -4
  66. package/lib/ReactEventListener.js +57 -12
  67. package/lib/ReactFragment.js +22 -17
  68. package/lib/ReactInjection.js +11 -11
  69. package/lib/ReactInputSelection.js +8 -7
  70. package/lib/ReactInstanceHandles.js +12 -12
  71. package/lib/ReactIsomorphic.js +11 -11
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +88 -88
  75. package/lib/ReactMultiChild.js +83 -22
  76. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  77. package/lib/ReactNativeComponent.js +3 -8
  78. package/lib/ReactNoopUpdateQueue.js +118 -0
  79. package/lib/ReactOwner.js +3 -3
  80. package/lib/ReactPerf.js +2 -2
  81. package/lib/ReactPropTransferer.js +3 -3
  82. package/lib/ReactPropTypeLocationNames.js +1 -1
  83. package/lib/ReactPropTypeLocations.js +1 -1
  84. package/lib/ReactPropTypes.js +49 -11
  85. package/lib/ReactReconcileTransaction.js +8 -8
  86. package/lib/ReactReconciler.js +18 -20
  87. package/lib/ReactRef.js +1 -1
  88. package/lib/ReactServerBatchingStrategy.js +23 -0
  89. package/lib/ReactServerRendering.js +22 -9
  90. package/lib/ReactServerRenderingTransaction.js +7 -7
  91. package/lib/ReactTestUtils.js +80 -58
  92. package/lib/ReactTransitionChildMapping.js +2 -2
  93. package/lib/ReactTransitionEvents.js +1 -1
  94. package/lib/ReactTransitionGroup.js +5 -6
  95. package/lib/ReactUpdateQueue.js +61 -36
  96. package/lib/ReactUpdates.js +14 -17
  97. package/lib/ReactWithAddons.js +14 -16
  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 +14 -15
  103. package/lib/SimpleEventPlugin.js +205 -29
  104. package/lib/SyntheticClipboardEvent.js +3 -3
  105. package/lib/SyntheticCompositionEvent.js +3 -3
  106. package/lib/SyntheticDragEvent.js +3 -3
  107. package/lib/SyntheticEvent.js +9 -8
  108. package/lib/SyntheticFocusEvent.js +3 -3
  109. package/lib/SyntheticInputEvent.js +3 -3
  110. package/lib/SyntheticKeyboardEvent.js +6 -6
  111. package/lib/SyntheticMouseEvent.js +5 -5
  112. package/lib/SyntheticTouchEvent.js +4 -4
  113. package/lib/SyntheticUIEvent.js +4 -4
  114. package/lib/SyntheticWheelEvent.js +3 -3
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +16 -10
  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 +12 -7
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +47 -0
  124. package/lib/findDOMNode.js +11 -12
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +0 -1
  130. package/lib/getTestDocument.js +28 -0
  131. package/lib/getTextContentAccessor.js +1 -1
  132. package/lib/instantiateReactComponent.js +24 -20
  133. package/lib/isEventSupported.js +1 -1
  134. package/lib/isTextInputElement.js +2 -1
  135. package/lib/joinClasses.js +1 -1
  136. package/lib/onlyChild.js +3 -3
  137. package/lib/quoteAttributeValueForBrowser.js +1 -1
  138. package/lib/reactComponentExpect.js +210 -0
  139. package/lib/renderSubtreeIntoContainer.js +1 -1
  140. package/lib/setInnerHTML.js +2 -2
  141. package/lib/setTextContent.js +3 -3
  142. package/lib/shallowCompare.js +1 -1
  143. package/lib/sliceChildren.js +51 -0
  144. package/lib/traverseAllChildren.js +15 -14
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +14 -6
  147. package/lib/webcomponents.js +6379 -0
  148. package/package.json +4 -6
  149. package/react.js +53 -1
  150. package/addons/CSSTransitionGroup.js +0 -1
  151. package/addons/LinkedStateMixin.js +0 -1
  152. package/addons/Perf.js +0 -1
  153. package/addons/PureRenderMixin.js +0 -1
  154. package/addons/TestUtils.js +0 -1
  155. package/addons/TransitionGroup.js +0 -1
  156. package/addons/batchedUpdates.js +0 -1
  157. package/addons/cloneWithProps.js +0 -1
  158. package/addons/createFragment.js +0 -1
  159. package/addons/renderSubtreeIntoContainer.js +0 -1
  160. package/addons/shallowCompare.js +0 -1
  161. package/addons/update.js +0 -1
  162. package/lib/CSSCore.js +0 -97
  163. package/lib/EventListener.js +0 -84
  164. package/lib/ExecutionEnvironment.js +0 -38
  165. package/lib/LocalEventTrapMixin.js +0 -46
  166. package/lib/ReactContext.js +0 -32
  167. package/lib/ReactDOMClient.js +0 -85
  168. package/lib/ReactDOMForm.js +0 -47
  169. package/lib/ReactDOMIframe.js +0 -43
  170. package/lib/ReactDOMImg.js +0 -44
  171. package/lib/ReactLifeCycle.js +0 -35
  172. package/lib/camelize.js +0 -32
  173. package/lib/camelizeStyleName.js +0 -40
  174. package/lib/containsNode.js +0 -55
  175. package/lib/createArrayFromMixed.js +0 -85
  176. package/lib/createFullPageComponent.js +0 -51
  177. package/lib/createNodesFromMarkup.js +0 -84
  178. package/lib/emptyFunction.js +0 -38
  179. package/lib/emptyObject.js +0 -20
  180. package/lib/focusNode.js +0 -26
  181. package/lib/getActiveElement.js +0 -29
  182. package/lib/getMarkupWrap.js +0 -115
  183. package/lib/getUnboundedScrollPosition.js +0 -38
  184. package/lib/hyphenate.js +0 -33
  185. package/lib/hyphenateStyleName.js +0 -39
  186. package/lib/invariant.js +0 -49
  187. package/lib/isNode.js +0 -23
  188. package/lib/isTextNode.js +0 -25
  189. package/lib/keyMirror.js +0 -48
  190. package/lib/keyOf.js +0 -35
  191. package/lib/mapObject.js +0 -51
  192. package/lib/performance.js +0 -23
  193. package/lib/performanceNow.js +0 -28
  194. package/lib/shallowEqual.js +0 -48
  195. package/lib/toArray.js +0 -57
  196. package/lib/warning.js +0 -61
@@ -11,96 +11,76 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
15
- var ReactChildren = require("./ReactChildren");
16
- var ReactClass = require("./ReactClass");
17
- var ReactDOMSelect = require("./ReactDOMSelect");
18
- var ReactElement = require("./ReactElement");
19
- var ReactInstanceMap = require("./ReactInstanceMap");
20
- var ReactPropTypes = require("./ReactPropTypes");
14
+ var ReactChildren = require('./ReactChildren');
15
+ var ReactDOMSelect = require('./ReactDOMSelect');
21
16
 
22
- var assign = require("./Object.assign");
23
- var warning = require("./warning");
24
-
25
- var option = ReactElement.createFactory('option');
17
+ var assign = require('./Object.assign');
18
+ var warning = require('fbjs/lib/warning');
26
19
 
27
20
  var valueContextKey = ReactDOMSelect.valueContextKey;
28
21
 
29
22
  /**
30
23
  * Implements an <option> native component that warns when `selected` is set.
31
24
  */
32
- var ReactDOMOption = ReactClass.createClass({
33
- displayName: 'ReactDOMOption',
34
- tagName: 'OPTION',
35
-
36
- mixins: [ReactBrowserComponentMixin],
37
-
38
- getInitialState: function () {
39
- return { selected: null };
40
- },
41
-
42
- contextTypes: (function () {
43
- var obj = {};
44
- obj[valueContextKey] = ReactPropTypes.any;
45
- return obj;
46
- })(),
47
-
48
- componentWillMount: function () {
25
+ var ReactDOMOption = {
26
+ mountWrapper: function (inst, props, context) {
49
27
  // TODO (yungsters): Remove support for `selected` in <option>.
50
- if ('production' !== process.env.NODE_ENV) {
51
- 'production' !== process.env.NODE_ENV ? warning(this.props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : null;
28
+ if (process.env.NODE_ENV !== 'production') {
29
+ process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : undefined;
52
30
  }
53
31
 
54
- // Look up whether this option is 'selected' via parent-based context
55
- var context = ReactInstanceMap.get(this)._context;
32
+ // Look up whether this option is 'selected' via context
56
33
  var selectValue = context[valueContextKey];
57
34
 
58
35
  // If context key is null (e.g., no specified value or after initial mount)
59
- // or missing (e.g., for <datalist>) skip props
36
+ // or missing (e.g., for <datalist>), we don't change props.selected
37
+ var selected = null;
60
38
  if (selectValue != null) {
61
- var selected = false;
39
+ selected = false;
62
40
  if (Array.isArray(selectValue)) {
63
41
  // multiple
64
42
  for (var i = 0; i < selectValue.length; i++) {
65
- if ('' + selectValue[i] === '' + this.props.value) {
43
+ if ('' + selectValue[i] === '' + props.value) {
66
44
  selected = true;
67
45
  break;
68
46
  }
69
47
  }
70
48
  } else {
71
- selected = '' + selectValue === '' + this.props.value;
49
+ selected = '' + selectValue === '' + props.value;
72
50
  }
73
- this.setState({ selected: selected });
74
51
  }
52
+
53
+ inst._wrapperState = { selected: selected };
75
54
  },
76
55
 
77
- render: function () {
78
- var props = this.props;
56
+ getNativeProps: function (inst, props, context) {
57
+ var nativeProps = assign({ selected: undefined, children: undefined }, props);
79
58
 
80
59
  // Read state only from initial mount because <select> updates value
81
60
  // manually; we need the initial state only for server rendering
82
- if (this.state.selected != null) {
83
- props = assign({}, props, { selected: this.state.selected });
61
+ if (inst._wrapperState.selected != null) {
62
+ nativeProps.selected = inst._wrapperState.selected;
84
63
  }
85
64
 
86
65
  var content = '';
87
66
 
88
67
  // Flatten children and warn if they aren't strings or numbers;
89
68
  // invalid types are ignored.
90
- ReactChildren.forEach(this.props.children, function (child) {
69
+ ReactChildren.forEach(props.children, function (child) {
91
70
  if (child == null) {
92
71
  return;
93
72
  }
94
73
  if (typeof child === 'string' || typeof child === 'number') {
95
74
  content += child;
96
75
  } else {
97
- 'production' !== process.env.NODE_ENV ? warning(false, 'Only strings and numbers are supported as <option> children.') : null;
76
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : undefined;
98
77
  }
99
78
  });
100
79
 
101
- return option(props, content);
80
+ nativeProps.children = content;
81
+ return nativeProps;
102
82
  }
103
83
 
104
- });
84
+ };
105
85
 
106
86
  module.exports = ReactDOMOption;
@@ -11,61 +11,72 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var AutoFocusMixin = require("./AutoFocusMixin");
15
- var LinkedValueUtils = require("./LinkedValueUtils");
16
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
17
- var ReactClass = require("./ReactClass");
18
- var ReactElement = require("./ReactElement");
19
- var ReactUpdates = require("./ReactUpdates");
20
- var ReactPropTypes = require("./ReactPropTypes");
14
+ var LinkedValueUtils = require('./LinkedValueUtils');
15
+ var ReactMount = require('./ReactMount');
16
+ var ReactUpdates = require('./ReactUpdates');
21
17
 
22
- var assign = require("./Object.assign");
23
- var findDOMNode = require("./findDOMNode");
24
-
25
- var select = ReactElement.createFactory('select');
18
+ var assign = require('./Object.assign');
19
+ var warning = require('fbjs/lib/warning');
26
20
 
27
21
  var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2);
28
22
 
29
23
  function updateOptionsIfPendingUpdateAndMounted() {
30
- /*jshint validthis:true */
31
- if (this._pendingUpdate) {
32
- this._pendingUpdate = false;
33
- var value = LinkedValueUtils.getValue(this.props);
34
- if (value != null && this.isMounted()) {
35
- updateOptions(this, value);
24
+ if (this._wrapperState.pendingUpdate && this._rootNodeID) {
25
+ this._wrapperState.pendingUpdate = false;
26
+
27
+ var props = this._currentElement.props;
28
+ var value = LinkedValueUtils.getValue(props);
29
+
30
+ if (value != null) {
31
+ updateOptions(this, props, value);
36
32
  }
37
33
  }
38
34
  }
39
35
 
36
+ function getDeclarationErrorAddendum(owner) {
37
+ if (owner) {
38
+ var name = owner.getName();
39
+ if (name) {
40
+ return ' Check the render method of `' + name + '`.';
41
+ }
42
+ }
43
+ return '';
44
+ }
45
+
46
+ var valuePropNames = ['value', 'defaultValue'];
47
+
40
48
  /**
41
49
  * Validation function for `value` and `defaultValue`.
42
50
  * @private
43
51
  */
44
- function selectValueType(props, propName, componentName) {
45
- if (props[propName] == null) {
46
- return null;
47
- }
48
- if (props.multiple) {
49
- if (!Array.isArray(props[propName])) {
50
- return new Error('The `' + propName + '` prop supplied to <select> must be an array if ' + '`multiple` is true.');
52
+ function checkSelectPropTypes(inst, props) {
53
+ var owner = inst._currentElement._owner;
54
+ LinkedValueUtils.checkPropTypes('select', props, owner);
55
+
56
+ for (var i = 0; i < valuePropNames.length; i++) {
57
+ var propName = valuePropNames[i];
58
+ if (props[propName] == null) {
59
+ continue;
51
60
  }
52
- } else {
53
- if (Array.isArray(props[propName])) {
54
- return new Error('The `' + propName + '` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.');
61
+ if (props.multiple) {
62
+ process.env.NODE_ENV !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
63
+ } else {
64
+ process.env.NODE_ENV !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
55
65
  }
56
66
  }
57
67
  }
58
68
 
59
69
  /**
60
- * @param {ReactComponent} component Instance of ReactDOMSelect
70
+ * @param {ReactDOMComponent} inst
71
+ * @param {boolean} multiple
61
72
  * @param {*} propValue A stringable (with `multiple`, a list of stringables).
62
73
  * @private
63
74
  */
64
- function updateOptions(component, propValue) {
75
+ function updateOptions(inst, multiple, propValue) {
65
76
  var selectedValue, i;
66
- var options = findDOMNode(component).options;
77
+ var options = ReactMount.getNode(inst._rootNodeID).options;
67
78
 
68
- if (component.props.multiple) {
79
+ if (multiple) {
69
80
  selectedValue = {};
70
81
  for (i = 0; i < propValue.length; i++) {
71
82
  selectedValue['' + propValue[i]] = true;
@@ -107,92 +118,71 @@ function updateOptions(component, propValue) {
107
118
  * If `defaultValue` is provided, any options with the supplied values will be
108
119
  * selected.
109
120
  */
110
- var ReactDOMSelect = ReactClass.createClass({
111
- displayName: 'ReactDOMSelect',
112
- tagName: 'SELECT',
113
-
114
- mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
115
-
116
- statics: {
117
- valueContextKey: valueContextKey
121
+ var ReactDOMSelect = {
122
+ valueContextKey: valueContextKey,
123
+
124
+ getNativeProps: function (inst, props, context) {
125
+ return assign({}, props, {
126
+ onChange: inst._wrapperState.onChange,
127
+ value: undefined
128
+ });
118
129
  },
119
130
 
120
- propTypes: {
121
- defaultValue: selectValueType,
122
- value: selectValueType
123
- },
124
-
125
- getInitialState: function () {
126
- // Pass down initial value so initial generated markup has correct
127
- // `selected` attributes
128
- var value = LinkedValueUtils.getValue(this.props);
129
- if (value != null) {
130
- return { initialValue: value };
131
- } else {
132
- return { initialValue: this.props.defaultValue };
131
+ mountWrapper: function (inst, props) {
132
+ if (process.env.NODE_ENV !== 'production') {
133
+ checkSelectPropTypes(inst, props);
133
134
  }
134
- },
135
135
 
136
- childContextTypes: (function () {
137
- var obj = {};
138
- obj[valueContextKey] = ReactPropTypes.any;
139
- return obj;
140
- })(),
141
-
142
- getChildContext: function () {
143
- var obj = {};
144
- obj[valueContextKey] = this.state.initialValue;
145
- return obj;
136
+ var value = LinkedValueUtils.getValue(props);
137
+ inst._wrapperState = {
138
+ pendingUpdate: false,
139
+ initialValue: value != null ? value : props.defaultValue,
140
+ onChange: _handleChange.bind(inst),
141
+ wasMultiple: Boolean(props.multiple)
142
+ };
146
143
  },
147
144
 
148
- render: function () {
149
- // Clone `this.props` so we don't mutate the input.
150
- var props = assign({}, this.props);
151
-
152
- props.onChange = this._handleChange;
153
- props.value = null;
154
-
155
- return select(props, this.props.children);
145
+ processChildContext: function (inst, props, context) {
146
+ // Pass down initial value so initial generated markup has correct
147
+ // `selected` attributes
148
+ var childContext = assign({}, context);
149
+ childContext[valueContextKey] = inst._wrapperState.initialValue;
150
+ return childContext;
156
151
  },
157
152
 
158
- componentWillMount: function () {
159
- this._pendingUpdate = false;
160
- },
153
+ postUpdateWrapper: function (inst) {
154
+ var props = inst._currentElement.props;
161
155
 
162
- componentWillReceiveProps: function (nextProps) {
163
156
  // After the initial mount, we control selected-ness manually so don't pass
164
157
  // the context value down
165
- this.setState({ initialValue: null });
166
- },
158
+ inst._wrapperState.initialValue = undefined;
159
+
160
+ var wasMultiple = inst._wrapperState.wasMultiple;
161
+ inst._wrapperState.wasMultiple = Boolean(props.multiple);
167
162
 
168
- componentDidUpdate: function (prevProps) {
169
- var value = LinkedValueUtils.getValue(this.props);
163
+ var value = LinkedValueUtils.getValue(props);
170
164
  if (value != null) {
171
- this._pendingUpdate = false;
172
- updateOptions(this, value);
173
- } else if (!prevProps.multiple !== !this.props.multiple) {
165
+ inst._wrapperState.pendingUpdate = false;
166
+ updateOptions(inst, Boolean(props.multiple), value);
167
+ } else if (wasMultiple !== Boolean(props.multiple)) {
174
168
  // For simplicity, reapply `defaultValue` if `multiple` is toggled.
175
- if (this.props.defaultValue != null) {
176
- updateOptions(this, this.props.defaultValue);
169
+ if (props.defaultValue != null) {
170
+ updateOptions(inst, Boolean(props.multiple), props.defaultValue);
177
171
  } else {
178
172
  // Revert the select back to its default unselected state.
179
- updateOptions(this, this.props.multiple ? [] : '');
173
+ updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
180
174
  }
181
175
  }
182
- },
183
-
184
- _handleChange: function (event) {
185
- var returnValue;
186
- var onChange = LinkedValueUtils.getOnChange(this.props);
187
- if (onChange) {
188
- returnValue = onChange.call(this, event);
189
- }
190
-
191
- this._pendingUpdate = true;
192
- ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
193
- return returnValue;
194
176
  }
177
+ };
195
178
 
196
- });
179
+ function _handleChange(event) {
180
+ var props = this._currentElement.props;
181
+ var returnValue = LinkedValueUtils.executeOnChange(props, event);
182
+
183
+ this._wrapperState.pendingUpdate = true;
184
+ ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
185
+ return returnValue;
186
+ }
197
187
 
198
188
  module.exports = ReactDOMSelect;
@@ -11,10 +11,10 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ExecutionEnvironment = require("./ExecutionEnvironment");
14
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
15
 
16
- var getNodeForCharacterOffset = require("./getNodeForCharacterOffset");
17
- var getTextContentAccessor = require("./getTextContentAccessor");
16
+ var getNodeForCharacterOffset = require('./getNodeForCharacterOffset');
17
+ var getTextContentAccessor = require('./getTextContentAccessor');
18
18
 
19
19
  /**
20
20
  * While `isCollapsed` is available on the Selection object and `collapsed`
@@ -11,8 +11,8 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactDefaultInjection = require("./ReactDefaultInjection");
15
- var ReactServerRendering = require("./ReactServerRendering");
14
+ var ReactDefaultInjection = require('./ReactDefaultInjection');
15
+ var ReactServerRendering = require('./ReactServerRendering');
16
16
 
17
17
  ReactDefaultInjection.inject();
18
18
 
@@ -12,13 +12,13 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var DOMPropertyOperations = require("./DOMPropertyOperations");
16
- var ReactComponentBrowserEnvironment = require("./ReactComponentBrowserEnvironment");
17
- var ReactDOMComponent = require("./ReactDOMComponent");
15
+ var DOMPropertyOperations = require('./DOMPropertyOperations');
16
+ var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
17
+ var ReactDOMComponent = require('./ReactDOMComponent');
18
18
 
19
- var assign = require("./Object.assign");
20
- var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
21
- var validateDOMNesting = require("./validateDOMNesting");
19
+ var assign = require('./Object.assign');
20
+ var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
21
+ var validateDOMNesting = require('./validateDOMNesting');
22
22
 
23
23
  /**
24
24
  * Text nodes violate a couple assumptions that React makes about components:
@@ -35,7 +35,9 @@ var validateDOMNesting = require("./validateDOMNesting");
35
35
  * @extends ReactComponent
36
36
  * @internal
37
37
  */
38
- var ReactDOMTextComponent = function (props) {};
38
+ var ReactDOMTextComponent = function (props) {
39
+ // This constructor and its argument is currently used by mocks.
40
+ };
39
41
 
40
42
  assign(ReactDOMTextComponent.prototype, {
41
43
 
@@ -63,7 +65,7 @@ assign(ReactDOMTextComponent.prototype, {
63
65
  * @internal
64
66
  */
65
67
  mountComponent: function (rootID, transaction, context) {
66
- if ('production' !== process.env.NODE_ENV) {
68
+ if (process.env.NODE_ENV !== 'production') {
67
69
  if (context[validateDOMNesting.ancestorInfoContextKey]) {
68
70
  validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
69
71
  }
@@ -109,6 +111,4 @@ assign(ReactDOMTextComponent.prototype, {
109
111
 
110
112
  });
111
113
 
112
- module.exports = ReactDOMTextComponent;
113
-
114
- // This constructor and its argument is currently used by mocks.
114
+ module.exports = ReactDOMTextComponent;
@@ -11,26 +11,18 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var AutoFocusMixin = require("./AutoFocusMixin");
15
- var DOMPropertyOperations = require("./DOMPropertyOperations");
16
- var LinkedValueUtils = require("./LinkedValueUtils");
17
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
18
- var ReactClass = require("./ReactClass");
19
- var ReactElement = require("./ReactElement");
20
- var ReactUpdates = require("./ReactUpdates");
14
+ var LinkedValueUtils = require('./LinkedValueUtils');
15
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
16
+ var ReactUpdates = require('./ReactUpdates');
21
17
 
22
- var assign = require("./Object.assign");
23
- var findDOMNode = require("./findDOMNode");
24
- var invariant = require("./invariant");
25
-
26
- var warning = require("./warning");
27
-
28
- var textarea = ReactElement.createFactory('textarea');
18
+ var assign = require('./Object.assign');
19
+ var invariant = require('fbjs/lib/invariant');
20
+ var warning = require('fbjs/lib/warning');
29
21
 
30
22
  function forceUpdateIfMounted() {
31
- /*jshint validthis:true */
32
- if (this.isMounted()) {
33
- this.forceUpdate();
23
+ if (this._rootNodeID) {
24
+ // DOM component is still mounted; update
25
+ ReactDOMTextarea.updateWrapper(this);
34
26
  }
35
27
  }
36
28
 
@@ -49,23 +41,35 @@ function forceUpdateIfMounted() {
49
41
  * The rendered element will be initialized with an empty value, the prop
50
42
  * `defaultValue` if specified, or the children content (deprecated).
51
43
  */
52
- var ReactDOMTextarea = ReactClass.createClass({
53
- displayName: 'ReactDOMTextarea',
54
- tagName: 'TEXTAREA',
44
+ var ReactDOMTextarea = {
45
+ getNativeProps: function (inst, props, context) {
46
+ !(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
55
47
 
56
- mixins: [AutoFocusMixin, LinkedValueUtils.Mixin, ReactBrowserComponentMixin],
48
+ // Always set children to the same thing. In IE9, the selection range will
49
+ // get reset if `textContent` is mutated.
50
+ var nativeProps = assign({}, props, {
51
+ defaultValue: undefined,
52
+ value: undefined,
53
+ children: inst._wrapperState.initialValue,
54
+ onChange: inst._wrapperState.onChange
55
+ });
56
+
57
+ return nativeProps;
58
+ },
57
59
 
58
- getInitialState: function () {
59
- var defaultValue = this.props.defaultValue;
60
+ mountWrapper: function (inst, props) {
61
+ LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
62
+
63
+ var defaultValue = props.defaultValue;
60
64
  // TODO (yungsters): Remove support for children content in <textarea>.
61
- var children = this.props.children;
65
+ var children = props.children;
62
66
  if (children != null) {
63
- if ('production' !== process.env.NODE_ENV) {
64
- 'production' !== process.env.NODE_ENV ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : null;
67
+ if (process.env.NODE_ENV !== 'production') {
68
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
65
69
  }
66
- 'production' !== process.env.NODE_ENV ? invariant(defaultValue == null, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(defaultValue == null);
70
+ !(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
67
71
  if (Array.isArray(children)) {
68
- 'production' !== process.env.NODE_ENV ? invariant(children.length <= 1, '<textarea> can only have at most one child.') : invariant(children.length <= 1);
72
+ !(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
69
73
  children = children[0];
70
74
  }
71
75
 
@@ -74,51 +78,34 @@ var ReactDOMTextarea = ReactClass.createClass({
74
78
  if (defaultValue == null) {
75
79
  defaultValue = '';
76
80
  }
77
- var value = LinkedValueUtils.getValue(this.props);
78
- return {
81
+ var value = LinkedValueUtils.getValue(props);
82
+
83
+ inst._wrapperState = {
79
84
  // We save the initial value so that `ReactDOMComponent` doesn't update
80
85
  // `textContent` (unnecessary since we update value).
81
86
  // The initial value can be a boolean or object so that's why it's
82
87
  // forced to be a string.
83
- initialValue: '' + (value != null ? value : defaultValue)
88
+ initialValue: '' + (value != null ? value : defaultValue),
89
+ onChange: _handleChange.bind(inst)
84
90
  };
85
91
  },
86
92
 
87
- render: function () {
88
- // Clone `this.props` so we don't mutate the input.
89
- var props = assign({}, this.props);
90
-
91
- 'production' !== process.env.NODE_ENV ? invariant(props.dangerouslySetInnerHTML == null, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(props.dangerouslySetInnerHTML == null);
92
-
93
- props.defaultValue = null;
94
- props.value = null;
95
- props.onChange = this._handleChange;
96
-
97
- // Always set children to the same thing. In IE9, the selection range will
98
- // get reset if `textContent` is mutated.
99
- return textarea(props, this.state.initialValue);
100
- },
101
-
102
- componentDidUpdate: function (prevProps, prevState, prevContext) {
103
- var value = LinkedValueUtils.getValue(this.props);
93
+ updateWrapper: function (inst) {
94
+ var props = inst._currentElement.props;
95
+ var value = LinkedValueUtils.getValue(props);
104
96
  if (value != null) {
105
- var rootNode = findDOMNode(this);
106
97
  // Cast `value` to a string to ensure the value is set correctly. While
107
98
  // browsers typically do this as necessary, jsdom doesn't.
108
- DOMPropertyOperations.setValueForProperty(rootNode, 'value', '' + value);
99
+ ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
109
100
  }
110
- },
111
-
112
- _handleChange: function (event) {
113
- var returnValue;
114
- var onChange = LinkedValueUtils.getOnChange(this.props);
115
- if (onChange) {
116
- returnValue = onChange.call(this, event);
117
- }
118
- ReactUpdates.asap(forceUpdateIfMounted, this);
119
- return returnValue;
120
101
  }
102
+ };
121
103
 
122
- });
104
+ function _handleChange(event) {
105
+ var props = this._currentElement.props;
106
+ var returnValue = LinkedValueUtils.executeOnChange(props, event);
107
+ ReactUpdates.asap(forceUpdateIfMounted, this);
108
+ return returnValue;
109
+ }
123
110
 
124
111
  module.exports = ReactDOMTextarea;