react 15.3.1 → 15.4.0-rc.2

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 (189) hide show
  1. package/dist/react-with-addons.js +3901 -21391
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2671 -19498
  4. package/dist/react.min.js +2 -6
  5. package/lib/LinkedStateMixin.js +1 -2
  6. package/lib/PooledClass.js +3 -0
  7. package/lib/ReactAddonsDOMDependencies.js +36 -0
  8. package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
  9. package/lib/ReactCSSTransitionGroup.js +60 -42
  10. package/lib/ReactCSSTransitionGroupChild.js +2 -2
  11. package/lib/ReactClass.js +38 -53
  12. package/lib/ReactComponentTreeHook.js +84 -100
  13. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
  14. package/lib/ReactCurrentOwner.js +1 -1
  15. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
  16. package/lib/ReactElement.js +6 -29
  17. package/lib/ReactElementSymbol.js +20 -0
  18. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
  19. package/lib/ReactElementValidator.js +1 -2
  20. package/lib/ReactPropTypeLocationNames.js +1 -0
  21. package/lib/ReactPropTypeLocations.js +2 -11
  22. package/lib/ReactPropTypes.js +5 -2
  23. package/lib/ReactPropTypesSecret.js +1 -0
  24. package/lib/ReactTransitionEvents.js +1 -1
  25. package/lib/ReactTransitionGroup.js +145 -141
  26. package/lib/ReactUMDEntry.js +11 -5
  27. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
  28. package/lib/ReactVersion.js +1 -1
  29. package/lib/ReactWithAddons.js +15 -2
  30. package/lib/ReactWithAddonsUMDEntry.js +11 -5
  31. package/lib/canDefineProperty.js +2 -0
  32. package/lib/traverseAllChildren.js +11 -2
  33. package/lib/update.js +6 -7
  34. package/package.json +1 -1
  35. package/lib/AutoFocusUtils.js +0 -24
  36. package/lib/BeforeInputEventPlugin.js +0 -388
  37. package/lib/CSSProperty.js +0 -148
  38. package/lib/CSSPropertyOperations.js +0 -205
  39. package/lib/CallbackQueue.js +0 -106
  40. package/lib/ChangeEventPlugin.js +0 -325
  41. package/lib/DOMChildrenOperations.js +0 -194
  42. package/lib/DOMLazyTree.js +0 -118
  43. package/lib/DOMProperty.js +0 -206
  44. package/lib/DOMPropertyOperations.js +0 -221
  45. package/lib/Danger.js +0 -48
  46. package/lib/DefaultEventPluginOrder.js +0 -27
  47. package/lib/DisabledInputUtils.js +0 -50
  48. package/lib/EnterLeaveEventPlugin.js +0 -105
  49. package/lib/EventConstants.js +0 -97
  50. package/lib/EventPluginHub.js +0 -251
  51. package/lib/EventPluginRegistry.js +0 -247
  52. package/lib/EventPluginUtils.js +0 -229
  53. package/lib/EventPropagators.js +0 -137
  54. package/lib/FallbackCompositionState.js +0 -95
  55. package/lib/HTMLDOMPropertyConfig.js +0 -209
  56. package/lib/LinkedValueUtils.js +0 -136
  57. package/lib/NativeMethodsMixin.js +0 -167
  58. package/lib/ReactBrowserEventEmitter.js +0 -317
  59. package/lib/ReactChildReconciler.js +0 -154
  60. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  61. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  62. package/lib/ReactComponentEnvironment.js +0 -45
  63. package/lib/ReactComponentTreeTestUtils.js +0 -87
  64. package/lib/ReactCompositeComponent.js +0 -920
  65. package/lib/ReactDOM.js +0 -110
  66. package/lib/ReactDOMButton.js +0 -24
  67. package/lib/ReactDOMComponent.js +0 -1005
  68. package/lib/ReactDOMComponentTree.js +0 -188
  69. package/lib/ReactDOMContainerInfo.js +0 -33
  70. package/lib/ReactDOMEmptyComponent.js +0 -60
  71. package/lib/ReactDOMFiber.js +0 -76
  72. package/lib/ReactDOMIDOperations.js +0 -34
  73. package/lib/ReactDOMInput.js +0 -269
  74. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  75. package/lib/ReactDOMOption.js +0 -123
  76. package/lib/ReactDOMSelect.js +0 -201
  77. package/lib/ReactDOMSelection.js +0 -212
  78. package/lib/ReactDOMServer.js +0 -26
  79. package/lib/ReactDOMTextComponent.js +0 -164
  80. package/lib/ReactDOMTextarea.js +0 -155
  81. package/lib/ReactDOMTreeTraversal.js +0 -136
  82. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  83. package/lib/ReactDebugTool.js +0 -307
  84. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  85. package/lib/ReactDefaultInjection.js +0 -84
  86. package/lib/ReactEmptyComponent.js +0 -30
  87. package/lib/ReactErrorUtils.js +0 -76
  88. package/lib/ReactEventEmitterMixin.js +0 -33
  89. package/lib/ReactEventListener.js +0 -157
  90. package/lib/ReactFeatureFlags.js +0 -22
  91. package/lib/ReactHostComponent.js +0 -76
  92. package/lib/ReactHostOperationHistoryHook.js +0 -37
  93. package/lib/ReactInjection.js +0 -36
  94. package/lib/ReactInputSelection.js +0 -124
  95. package/lib/ReactInstanceHandles.js +0 -302
  96. package/lib/ReactInstanceMap.js +0 -48
  97. package/lib/ReactInstrumentation.js +0 -21
  98. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  99. package/lib/ReactMarkupChecksum.js +0 -50
  100. package/lib/ReactMount.js +0 -534
  101. package/lib/ReactMultiChild.js +0 -451
  102. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  103. package/lib/ReactNative.js +0 -71
  104. package/lib/ReactNativeAttributePayload.js +0 -371
  105. package/lib/ReactNativeBaseComponent.js +0 -198
  106. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  107. package/lib/ReactNativeComponentEnvironment.js +0 -31
  108. package/lib/ReactNativeComponentTree.js +0 -68
  109. package/lib/ReactNativeContainerInfo.js +0 -21
  110. package/lib/ReactNativeDOMIDOperations.js +0 -79
  111. package/lib/ReactNativeDefaultInjection.js +0 -101
  112. package/lib/ReactNativeEventEmitter.js +0 -191
  113. package/lib/ReactNativeEventPluginOrder.js +0 -16
  114. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  115. package/lib/ReactNativeMount.js +0 -193
  116. package/lib/ReactNativePropRegistry.js +0 -52
  117. package/lib/ReactNativeReconcileTransaction.js +0 -116
  118. package/lib/ReactNativeTagHandles.js +0 -56
  119. package/lib/ReactNativeTextComponent.js +0 -71
  120. package/lib/ReactNativeTreeTraversal.js +0 -127
  121. package/lib/ReactNodeTypes.js +0 -40
  122. package/lib/ReactNoop.js +0 -173
  123. package/lib/ReactOwner.js +0 -94
  124. package/lib/ReactPerf.js +0 -494
  125. package/lib/ReactReconcileTransaction.js +0 -178
  126. package/lib/ReactReconciler.js +0 -168
  127. package/lib/ReactRef.js +0 -80
  128. package/lib/ReactServerBatchingStrategy.js +0 -22
  129. package/lib/ReactServerRendering.js +0 -90
  130. package/lib/ReactServerRenderingTransaction.js +0 -90
  131. package/lib/ReactServerUpdateQueue.js +0 -141
  132. package/lib/ReactSimpleEmptyComponent.js +0 -37
  133. package/lib/ReactTestMount.js +0 -126
  134. package/lib/ReactTestReconcileTransaction.js +0 -108
  135. package/lib/ReactTestRenderer.js +0 -144
  136. package/lib/ReactTestUtils.js +0 -518
  137. package/lib/ReactUpdateQueue.js +0 -226
  138. package/lib/ReactUpdates.js +0 -251
  139. package/lib/ResponderEventPlugin.js +0 -510
  140. package/lib/ResponderSyntheticEvent.js +0 -39
  141. package/lib/ResponderTouchHistoryStore.js +0 -184
  142. package/lib/SVGDOMPropertyConfig.js +0 -302
  143. package/lib/SelectEventPlugin.js +0 -196
  144. package/lib/SimpleEventPlugin.js +0 -635
  145. package/lib/SyntheticAnimationEvent.js +0 -39
  146. package/lib/SyntheticClipboardEvent.js +0 -38
  147. package/lib/SyntheticCompositionEvent.js +0 -36
  148. package/lib/SyntheticDragEvent.js +0 -36
  149. package/lib/SyntheticEvent.js +0 -267
  150. package/lib/SyntheticFocusEvent.js +0 -36
  151. package/lib/SyntheticInputEvent.js +0 -37
  152. package/lib/SyntheticKeyboardEvent.js +0 -84
  153. package/lib/SyntheticMouseEvent.js +0 -72
  154. package/lib/SyntheticTouchEvent.js +0 -45
  155. package/lib/SyntheticTransitionEvent.js +0 -39
  156. package/lib/SyntheticUIEvent.js +0 -59
  157. package/lib/SyntheticWheelEvent.js +0 -54
  158. package/lib/TapEventPlugin.js +0 -110
  159. package/lib/TouchHistoryMath.js +0 -99
  160. package/lib/Transaction.js +0 -233
  161. package/lib/ViewportMetrics.js +0 -27
  162. package/lib/accumulate.js +0 -46
  163. package/lib/accumulateInto.js +0 -58
  164. package/lib/adler32.js +0 -44
  165. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  166. package/lib/createReactNativeComponentClass.js +0 -42
  167. package/lib/dangerousStyleValue.js +0 -79
  168. package/lib/escapeTextContentForBrowser.js +0 -123
  169. package/lib/findDOMNode.js +0 -60
  170. package/lib/findNodeHandle.js +0 -91
  171. package/lib/forEachAccumulated.js +0 -31
  172. package/lib/getEventCharCode.js +0 -50
  173. package/lib/getEventKey.js +0 -102
  174. package/lib/getEventModifierState.js +0 -43
  175. package/lib/getEventTarget.js +0 -35
  176. package/lib/getHostComponentFromComposite.js +0 -30
  177. package/lib/getNodeForCharacterOffset.js +0 -74
  178. package/lib/getTestDocument.js +0 -21
  179. package/lib/getTextContentAccessor.js +0 -33
  180. package/lib/getVendorPrefixedEventName.js +0 -101
  181. package/lib/instantiateReactComponent.js +0 -119
  182. package/lib/isEventSupported.js +0 -60
  183. package/lib/isTextInputElement.js +0 -51
  184. package/lib/quoteAttributeValueForBrowser.js +0 -26
  185. package/lib/reactComponentExpect.js +0 -217
  186. package/lib/setInnerHTML.js +0 -98
  187. package/lib/setTextContent.js +0 -48
  188. package/lib/shouldUpdateReactComponent.js +0 -42
  189. package/lib/validateDOMNesting.js +0 -369
@@ -1,43 +0,0 @@
1
- /**
2
- * Copyright 2013-present, 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 ReactDOMNullInputValuePropHook
10
- */
11
-
12
- 'use strict';
13
-
14
- var ReactComponentTreeHook = require('./ReactComponentTreeHook');
15
-
16
- var warning = require('fbjs/lib/warning');
17
-
18
- var didWarnValueNull = false;
19
-
20
- function handleElement(debugID, element) {
21
- if (element == null) {
22
- return;
23
- }
24
- if (element.type !== 'input' && element.type !== 'textarea' && element.type !== 'select') {
25
- return;
26
- }
27
- if (element.props != null && element.props.value === null && !didWarnValueNull) {
28
- process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
29
-
30
- didWarnValueNull = true;
31
- }
32
- }
33
-
34
- var ReactDOMNullInputValuePropHook = {
35
- onBeforeMountComponent: function (debugID, element) {
36
- handleElement(debugID, element);
37
- },
38
- onBeforeUpdateComponent: function (debugID, element) {
39
- handleElement(debugID, element);
40
- }
41
- };
42
-
43
- module.exports = ReactDOMNullInputValuePropHook;
@@ -1,123 +0,0 @@
1
- /**
2
- * Copyright 2013-present, 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 ReactDOMOption
10
- */
11
-
12
- 'use strict';
13
-
14
- var _assign = require('object-assign');
15
-
16
- var ReactChildren = require('./ReactChildren');
17
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
18
- var ReactDOMSelect = require('./ReactDOMSelect');
19
-
20
- var warning = require('fbjs/lib/warning');
21
- var didWarnInvalidOptionChildren = false;
22
-
23
- function flattenChildren(children) {
24
- var content = '';
25
-
26
- // Flatten children and warn if they aren't strings or numbers;
27
- // invalid types are ignored.
28
- ReactChildren.forEach(children, function (child) {
29
- if (child == null) {
30
- return;
31
- }
32
- if (typeof child === 'string' || typeof child === 'number') {
33
- content += child;
34
- } else if (!didWarnInvalidOptionChildren) {
35
- didWarnInvalidOptionChildren = true;
36
- process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : void 0;
37
- }
38
- });
39
-
40
- return content;
41
- }
42
-
43
- /**
44
- * Implements an <option> host component that warns when `selected` is set.
45
- */
46
- var ReactDOMOption = {
47
- mountWrapper: function (inst, props, hostParent) {
48
- // TODO (yungsters): Remove support for `selected` in <option>.
49
- if (process.env.NODE_ENV !== 'production') {
50
- process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : void 0;
51
- }
52
-
53
- // Look up whether this option is 'selected'
54
- var selectValue = null;
55
- if (hostParent != null) {
56
- var selectParent = hostParent;
57
-
58
- if (selectParent._tag === 'optgroup') {
59
- selectParent = selectParent._hostParent;
60
- }
61
-
62
- if (selectParent != null && selectParent._tag === 'select') {
63
- selectValue = ReactDOMSelect.getSelectValueContext(selectParent);
64
- }
65
- }
66
-
67
- // If the value is null (e.g., no specified value or after initial mount)
68
- // or missing (e.g., for <datalist>), we don't change props.selected
69
- var selected = null;
70
- if (selectValue != null) {
71
- var value;
72
- if (props.value != null) {
73
- value = props.value + '';
74
- } else {
75
- value = flattenChildren(props.children);
76
- }
77
- selected = false;
78
- if (Array.isArray(selectValue)) {
79
- // multiple
80
- for (var i = 0; i < selectValue.length; i++) {
81
- if ('' + selectValue[i] === value) {
82
- selected = true;
83
- break;
84
- }
85
- }
86
- } else {
87
- selected = '' + selectValue === value;
88
- }
89
- }
90
-
91
- inst._wrapperState = { selected: selected };
92
- },
93
-
94
- postMountWrapper: function (inst) {
95
- // value="" should make a value attribute (#6219)
96
- var props = inst._currentElement.props;
97
- if (props.value != null) {
98
- var node = ReactDOMComponentTree.getNodeFromInstance(inst);
99
- node.setAttribute('value', props.value);
100
- }
101
- },
102
-
103
- getHostProps: function (inst, props) {
104
- var hostProps = _assign({ selected: undefined, children: undefined }, props);
105
-
106
- // Read state only from initial mount because <select> updates value
107
- // manually; we need the initial state only for server rendering
108
- if (inst._wrapperState.selected != null) {
109
- hostProps.selected = inst._wrapperState.selected;
110
- }
111
-
112
- var content = flattenChildren(props.children);
113
-
114
- if (content) {
115
- hostProps.children = content;
116
- }
117
-
118
- return hostProps;
119
- }
120
-
121
- };
122
-
123
- module.exports = ReactDOMOption;
@@ -1,201 +0,0 @@
1
- /**
2
- * Copyright 2013-present, 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 ReactDOMSelect
10
- */
11
-
12
- 'use strict';
13
-
14
- var _assign = require('object-assign');
15
-
16
- var DisabledInputUtils = require('./DisabledInputUtils');
17
- var LinkedValueUtils = require('./LinkedValueUtils');
18
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
- var ReactUpdates = require('./ReactUpdates');
20
-
21
- var warning = require('fbjs/lib/warning');
22
-
23
- var didWarnValueLink = false;
24
- var didWarnValueDefaultValue = false;
25
-
26
- function updateOptionsIfPendingUpdateAndMounted() {
27
- if (this._rootNodeID && this._wrapperState.pendingUpdate) {
28
- this._wrapperState.pendingUpdate = false;
29
-
30
- var props = this._currentElement.props;
31
- var value = LinkedValueUtils.getValue(props);
32
-
33
- if (value != null) {
34
- updateOptions(this, Boolean(props.multiple), value);
35
- }
36
- }
37
- }
38
-
39
- function getDeclarationErrorAddendum(owner) {
40
- if (owner) {
41
- var name = owner.getName();
42
- if (name) {
43
- return ' Check the render method of `' + name + '`.';
44
- }
45
- }
46
- return '';
47
- }
48
-
49
- var valuePropNames = ['value', 'defaultValue'];
50
-
51
- /**
52
- * Validation function for `value` and `defaultValue`.
53
- * @private
54
- */
55
- function checkSelectPropTypes(inst, props) {
56
- var owner = inst._currentElement._owner;
57
- LinkedValueUtils.checkPropTypes('select', props, owner);
58
-
59
- if (props.valueLink !== undefined && !didWarnValueLink) {
60
- process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `select` is deprecated; set `value` and `onChange` instead.') : void 0;
61
- didWarnValueLink = true;
62
- }
63
-
64
- for (var i = 0; i < valuePropNames.length; i++) {
65
- var propName = valuePropNames[i];
66
- if (props[propName] == null) {
67
- continue;
68
- }
69
- var isArray = Array.isArray(props[propName]);
70
- if (props.multiple && !isArray) {
71
- process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
72
- } else if (!props.multiple && isArray) {
73
- process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
74
- }
75
- }
76
- }
77
-
78
- /**
79
- * @param {ReactDOMComponent} inst
80
- * @param {boolean} multiple
81
- * @param {*} propValue A stringable (with `multiple`, a list of stringables).
82
- * @private
83
- */
84
- function updateOptions(inst, multiple, propValue) {
85
- var selectedValue, i;
86
- var options = ReactDOMComponentTree.getNodeFromInstance(inst).options;
87
-
88
- if (multiple) {
89
- selectedValue = {};
90
- for (i = 0; i < propValue.length; i++) {
91
- selectedValue['' + propValue[i]] = true;
92
- }
93
- for (i = 0; i < options.length; i++) {
94
- var selected = selectedValue.hasOwnProperty(options[i].value);
95
- if (options[i].selected !== selected) {
96
- options[i].selected = selected;
97
- }
98
- }
99
- } else {
100
- // Do not set `select.value` as exact behavior isn't consistent across all
101
- // browsers for all cases.
102
- selectedValue = '' + propValue;
103
- for (i = 0; i < options.length; i++) {
104
- if (options[i].value === selectedValue) {
105
- options[i].selected = true;
106
- return;
107
- }
108
- }
109
- if (options.length) {
110
- options[0].selected = true;
111
- }
112
- }
113
- }
114
-
115
- /**
116
- * Implements a <select> host component that allows optionally setting the
117
- * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
118
- * stringable. If `multiple` is true, the prop must be an array of stringables.
119
- *
120
- * If `value` is not supplied (or null/undefined), user actions that change the
121
- * selected option will trigger updates to the rendered options.
122
- *
123
- * If it is supplied (and not null/undefined), the rendered options will not
124
- * update in response to user actions. Instead, the `value` prop must change in
125
- * order for the rendered options to update.
126
- *
127
- * If `defaultValue` is provided, any options with the supplied values will be
128
- * selected.
129
- */
130
- var ReactDOMSelect = {
131
- getHostProps: function (inst, props) {
132
- return _assign({}, DisabledInputUtils.getHostProps(inst, props), {
133
- onChange: inst._wrapperState.onChange,
134
- value: undefined
135
- });
136
- },
137
-
138
- mountWrapper: function (inst, props) {
139
- if (process.env.NODE_ENV !== 'production') {
140
- checkSelectPropTypes(inst, props);
141
- }
142
-
143
- var value = LinkedValueUtils.getValue(props);
144
- inst._wrapperState = {
145
- pendingUpdate: false,
146
- initialValue: value != null ? value : props.defaultValue,
147
- listeners: null,
148
- onChange: _handleChange.bind(inst),
149
- wasMultiple: Boolean(props.multiple)
150
- };
151
-
152
- if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
153
- process.env.NODE_ENV !== 'production' ? warning(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components') : void 0;
154
- didWarnValueDefaultValue = true;
155
- }
156
- },
157
-
158
- getSelectValueContext: function (inst) {
159
- // ReactDOMOption looks at this initial value so the initial generated
160
- // markup has correct `selected` attributes
161
- return inst._wrapperState.initialValue;
162
- },
163
-
164
- postUpdateWrapper: function (inst) {
165
- var props = inst._currentElement.props;
166
-
167
- // After the initial mount, we control selected-ness manually so don't pass
168
- // this value down
169
- inst._wrapperState.initialValue = undefined;
170
-
171
- var wasMultiple = inst._wrapperState.wasMultiple;
172
- inst._wrapperState.wasMultiple = Boolean(props.multiple);
173
-
174
- var value = LinkedValueUtils.getValue(props);
175
- if (value != null) {
176
- inst._wrapperState.pendingUpdate = false;
177
- updateOptions(inst, Boolean(props.multiple), value);
178
- } else if (wasMultiple !== Boolean(props.multiple)) {
179
- // For simplicity, reapply `defaultValue` if `multiple` is toggled.
180
- if (props.defaultValue != null) {
181
- updateOptions(inst, Boolean(props.multiple), props.defaultValue);
182
- } else {
183
- // Revert the select back to its default unselected state.
184
- updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
185
- }
186
- }
187
- }
188
- };
189
-
190
- function _handleChange(event) {
191
- var props = this._currentElement.props;
192
- var returnValue = LinkedValueUtils.executeOnChange(props, event);
193
-
194
- if (this._rootNodeID) {
195
- this._wrapperState.pendingUpdate = true;
196
- }
197
- ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
198
- return returnValue;
199
- }
200
-
201
- module.exports = ReactDOMSelect;
@@ -1,212 +0,0 @@
1
- /**
2
- * Copyright 2013-present, 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 ReactDOMSelection
10
- */
11
-
12
- 'use strict';
13
-
14
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
-
16
- var getNodeForCharacterOffset = require('./getNodeForCharacterOffset');
17
- var getTextContentAccessor = require('./getTextContentAccessor');
18
-
19
- /**
20
- * While `isCollapsed` is available on the Selection object and `collapsed`
21
- * is available on the Range object, IE11 sometimes gets them wrong.
22
- * If the anchor/focus nodes and offsets are the same, the range is collapsed.
23
- */
24
- function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
25
- return anchorNode === focusNode && anchorOffset === focusOffset;
26
- }
27
-
28
- /**
29
- * Get the appropriate anchor and focus node/offset pairs for IE.
30
- *
31
- * The catch here is that IE's selection API doesn't provide information
32
- * about whether the selection is forward or backward, so we have to
33
- * behave as though it's always forward.
34
- *
35
- * IE text differs from modern selection in that it behaves as though
36
- * block elements end with a new line. This means character offsets will
37
- * differ between the two APIs.
38
- *
39
- * @param {DOMElement} node
40
- * @return {object}
41
- */
42
- function getIEOffsets(node) {
43
- var selection = document.selection;
44
- var selectedRange = selection.createRange();
45
- var selectedLength = selectedRange.text.length;
46
-
47
- // Duplicate selection so we can move range without breaking user selection.
48
- var fromStart = selectedRange.duplicate();
49
- fromStart.moveToElementText(node);
50
- fromStart.setEndPoint('EndToStart', selectedRange);
51
-
52
- var startOffset = fromStart.text.length;
53
- var endOffset = startOffset + selectedLength;
54
-
55
- return {
56
- start: startOffset,
57
- end: endOffset
58
- };
59
- }
60
-
61
- /**
62
- * @param {DOMElement} node
63
- * @return {?object}
64
- */
65
- function getModernOffsets(node) {
66
- var selection = window.getSelection && window.getSelection();
67
-
68
- if (!selection || selection.rangeCount === 0) {
69
- return null;
70
- }
71
-
72
- var anchorNode = selection.anchorNode;
73
- var anchorOffset = selection.anchorOffset;
74
- var focusNode = selection.focusNode;
75
- var focusOffset = selection.focusOffset;
76
-
77
- var currentRange = selection.getRangeAt(0);
78
-
79
- // In Firefox, range.startContainer and range.endContainer can be "anonymous
80
- // divs", e.g. the up/down buttons on an <input type="number">. Anonymous
81
- // divs do not seem to expose properties, triggering a "Permission denied
82
- // error" if any of its properties are accessed. The only seemingly possible
83
- // way to avoid erroring is to access a property that typically works for
84
- // non-anonymous divs and catch any error that may otherwise arise. See
85
- // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
86
- try {
87
- /* eslint-disable no-unused-expressions */
88
- currentRange.startContainer.nodeType;
89
- currentRange.endContainer.nodeType;
90
- /* eslint-enable no-unused-expressions */
91
- } catch (e) {
92
- return null;
93
- }
94
-
95
- // If the node and offset values are the same, the selection is collapsed.
96
- // `Selection.isCollapsed` is available natively, but IE sometimes gets
97
- // this value wrong.
98
- var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
99
-
100
- var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
101
-
102
- var tempRange = currentRange.cloneRange();
103
- tempRange.selectNodeContents(node);
104
- tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
105
-
106
- var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset);
107
-
108
- var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
109
- var end = start + rangeLength;
110
-
111
- // Detect whether the selection is backward.
112
- var detectionRange = document.createRange();
113
- detectionRange.setStart(anchorNode, anchorOffset);
114
- detectionRange.setEnd(focusNode, focusOffset);
115
- var isBackward = detectionRange.collapsed;
116
-
117
- return {
118
- start: isBackward ? end : start,
119
- end: isBackward ? start : end
120
- };
121
- }
122
-
123
- /**
124
- * @param {DOMElement|DOMTextNode} node
125
- * @param {object} offsets
126
- */
127
- function setIEOffsets(node, offsets) {
128
- var range = document.selection.createRange().duplicate();
129
- var start, end;
130
-
131
- if (offsets.end === undefined) {
132
- start = offsets.start;
133
- end = start;
134
- } else if (offsets.start > offsets.end) {
135
- start = offsets.end;
136
- end = offsets.start;
137
- } else {
138
- start = offsets.start;
139
- end = offsets.end;
140
- }
141
-
142
- range.moveToElementText(node);
143
- range.moveStart('character', start);
144
- range.setEndPoint('EndToStart', range);
145
- range.moveEnd('character', end - start);
146
- range.select();
147
- }
148
-
149
- /**
150
- * In modern non-IE browsers, we can support both forward and backward
151
- * selections.
152
- *
153
- * Note: IE10+ supports the Selection object, but it does not support
154
- * the `extend` method, which means that even in modern IE, it's not possible
155
- * to programmatically create a backward selection. Thus, for all IE
156
- * versions, we use the old IE API to create our selections.
157
- *
158
- * @param {DOMElement|DOMTextNode} node
159
- * @param {object} offsets
160
- */
161
- function setModernOffsets(node, offsets) {
162
- if (!window.getSelection) {
163
- return;
164
- }
165
-
166
- var selection = window.getSelection();
167
- var length = node[getTextContentAccessor()].length;
168
- var start = Math.min(offsets.start, length);
169
- var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
170
-
171
- // IE 11 uses modern selection, but doesn't support the extend method.
172
- // Flip backward selections, so we can set with a single range.
173
- if (!selection.extend && start > end) {
174
- var temp = end;
175
- end = start;
176
- start = temp;
177
- }
178
-
179
- var startMarker = getNodeForCharacterOffset(node, start);
180
- var endMarker = getNodeForCharacterOffset(node, end);
181
-
182
- if (startMarker && endMarker) {
183
- var range = document.createRange();
184
- range.setStart(startMarker.node, startMarker.offset);
185
- selection.removeAllRanges();
186
-
187
- if (start > end) {
188
- selection.addRange(range);
189
- selection.extend(endMarker.node, endMarker.offset);
190
- } else {
191
- range.setEnd(endMarker.node, endMarker.offset);
192
- selection.addRange(range);
193
- }
194
- }
195
- }
196
-
197
- var useIEOffsets = ExecutionEnvironment.canUseDOM && 'selection' in document && !('getSelection' in window);
198
-
199
- var ReactDOMSelection = {
200
- /**
201
- * @param {DOMElement} node
202
- */
203
- getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
204
-
205
- /**
206
- * @param {DOMElement|DOMTextNode} node
207
- * @param {object} offsets
208
- */
209
- setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
210
- };
211
-
212
- module.exports = ReactDOMSelection;