react-test-renderer 15.5.0 → 15.5.4

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 (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,284 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _prodInvariant = require('./reactProdInvariant'),
14
+ _assign = require('object-assign');
15
+
16
+ var DOMPropertyOperations = require('./DOMPropertyOperations');
17
+ var LinkedValueUtils = require('./LinkedValueUtils');
18
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
+ var ReactUpdates = require('./ReactUpdates');
20
+
21
+ var invariant = require('fbjs/lib/invariant');
22
+ var warning = require('fbjs/lib/warning');
23
+
24
+ var didWarnValueLink = false;
25
+ var didWarnCheckedLink = false;
26
+ var didWarnValueDefaultValue = false;
27
+ var didWarnCheckedDefaultChecked = false;
28
+ var didWarnControlledToUncontrolled = false;
29
+ var didWarnUncontrolledToControlled = false;
30
+
31
+ function forceUpdateIfMounted() {
32
+ if (this._rootNodeID) {
33
+ // DOM component is still mounted; update
34
+ ReactDOMInput.updateWrapper(this);
35
+ }
36
+ }
37
+
38
+ function isControlled(props) {
39
+ var usesChecked = props.type === 'checkbox' || props.type === 'radio';
40
+ return usesChecked ? props.checked != null : props.value != null;
41
+ }
42
+
43
+ /**
44
+ * Implements an <input> host component that allows setting these optional
45
+ * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
46
+ *
47
+ * If `checked` or `value` are not supplied (or null/undefined), user actions
48
+ * that affect the checked state or value will trigger updates to the element.
49
+ *
50
+ * If they are supplied (and not null/undefined), the rendered element will not
51
+ * trigger updates to the element. Instead, the props must change in order for
52
+ * the rendered element to be updated.
53
+ *
54
+ * The rendered element will be initialized as unchecked (or `defaultChecked`)
55
+ * with an empty value (or `defaultValue`).
56
+ *
57
+ * @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
58
+ */
59
+ var ReactDOMInput = {
60
+ getHostProps: function (inst, props) {
61
+ var value = LinkedValueUtils.getValue(props);
62
+ var checked = LinkedValueUtils.getChecked(props);
63
+
64
+ var hostProps = _assign({
65
+ // Make sure we set .type before any other properties (setting .value
66
+ // before .type means .value is lost in IE11 and below)
67
+ type: undefined,
68
+ // Make sure we set .step before .value (setting .value before .step
69
+ // means .value is rounded on mount, based upon step precision)
70
+ step: undefined,
71
+ // Make sure we set .min & .max before .value (to ensure proper order
72
+ // in corner cases such as min or max deriving from value, e.g. Issue #7170)
73
+ min: undefined,
74
+ max: undefined
75
+ }, props, {
76
+ defaultChecked: undefined,
77
+ defaultValue: undefined,
78
+ value: value != null ? value : inst._wrapperState.initialValue,
79
+ checked: checked != null ? checked : inst._wrapperState.initialChecked,
80
+ onChange: inst._wrapperState.onChange
81
+ });
82
+
83
+ return hostProps;
84
+ },
85
+
86
+ mountWrapper: function (inst, props) {
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner);
89
+
90
+ var owner = inst._currentElement._owner;
91
+
92
+ if (props.valueLink !== undefined && !didWarnValueLink) {
93
+ process.env.NODE_ENV !== 'production' ? warning(false, '`valueLink` prop on `input` is deprecated; set `value` and `onChange` instead.') : void 0;
94
+ didWarnValueLink = true;
95
+ }
96
+ if (props.checkedLink !== undefined && !didWarnCheckedLink) {
97
+ process.env.NODE_ENV !== 'production' ? warning(false, '`checkedLink` prop on `input` is deprecated; set `value` and `onChange` instead.') : void 0;
98
+ didWarnCheckedLink = true;
99
+ }
100
+ if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
101
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
102
+ didWarnCheckedDefaultChecked = true;
103
+ }
104
+ if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
105
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input 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 input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
106
+ didWarnValueDefaultValue = true;
107
+ }
108
+ }
109
+
110
+ var defaultValue = props.defaultValue;
111
+ inst._wrapperState = {
112
+ initialChecked: props.checked != null ? props.checked : props.defaultChecked,
113
+ initialValue: props.value != null ? props.value : defaultValue,
114
+ listeners: null,
115
+ onChange: _handleChange.bind(inst),
116
+ controlled: isControlled(props)
117
+ };
118
+ },
119
+
120
+ updateWrapper: function (inst) {
121
+ var props = inst._currentElement.props;
122
+
123
+ if (process.env.NODE_ENV !== 'production') {
124
+ var controlled = isControlled(props);
125
+ var owner = inst._currentElement._owner;
126
+
127
+ if (!inst._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
128
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
129
+ didWarnUncontrolledToControlled = true;
130
+ }
131
+ if (inst._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
132
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', owner && owner.getName() || 'A component', props.type) : void 0;
133
+ didWarnControlledToUncontrolled = true;
134
+ }
135
+ }
136
+
137
+ // TODO: Shouldn't this be getChecked(props)?
138
+ var checked = props.checked;
139
+ if (checked != null) {
140
+ DOMPropertyOperations.setValueForProperty(ReactDOMComponentTree.getNodeFromInstance(inst), 'checked', checked || false);
141
+ }
142
+
143
+ var node = ReactDOMComponentTree.getNodeFromInstance(inst);
144
+ var value = LinkedValueUtils.getValue(props);
145
+ if (value != null) {
146
+ if (value === 0 && node.value === '') {
147
+ node.value = '0';
148
+ // Note: IE9 reports a number inputs as 'text', so check props instead.
149
+ } else if (props.type === 'number') {
150
+ // Simulate `input.valueAsNumber`. IE9 does not support it
151
+ var valueAsNumber = parseFloat(node.value, 10) || 0;
152
+
153
+ // eslint-disable-next-line
154
+ if (value != valueAsNumber) {
155
+ // Cast `value` to a string to ensure the value is set correctly. While
156
+ // browsers typically do this as necessary, jsdom doesn't.
157
+ node.value = '' + value;
158
+ }
159
+ // eslint-disable-next-line
160
+ } else if (value != node.value) {
161
+ // Cast `value` to a string to ensure the value is set correctly. While
162
+ // browsers typically do this as necessary, jsdom doesn't.
163
+ node.value = '' + value;
164
+ }
165
+ } else {
166
+ if (props.value == null && props.defaultValue != null) {
167
+ // In Chrome, assigning defaultValue to certain input types triggers input validation.
168
+ // For number inputs, the display value loses trailing decimal points. For email inputs,
169
+ // Chrome raises "The specified value <x> is not a valid email address".
170
+ //
171
+ // Here we check to see if the defaultValue has actually changed, avoiding these problems
172
+ // when the user is inputting text
173
+ //
174
+ // https://github.com/facebook/react/issues/7253
175
+ if (node.defaultValue !== '' + props.defaultValue) {
176
+ node.defaultValue = '' + props.defaultValue;
177
+ }
178
+ }
179
+ if (props.checked == null && props.defaultChecked != null) {
180
+ node.defaultChecked = !!props.defaultChecked;
181
+ }
182
+ }
183
+ },
184
+
185
+ postMountWrapper: function (inst) {
186
+ var props = inst._currentElement.props;
187
+
188
+ // This is in postMount because we need access to the DOM node, which is not
189
+ // available until after the component has mounted.
190
+ var node = ReactDOMComponentTree.getNodeFromInstance(inst);
191
+
192
+ // Detach value from defaultValue. We won't do anything if we're working on
193
+ // submit or reset inputs as those values & defaultValues are linked. They
194
+ // are not resetable nodes so this operation doesn't matter and actually
195
+ // removes browser-default values (eg "Submit Query") when no value is
196
+ // provided.
197
+
198
+ switch (props.type) {
199
+ case 'submit':
200
+ case 'reset':
201
+ break;
202
+ case 'color':
203
+ case 'date':
204
+ case 'datetime':
205
+ case 'datetime-local':
206
+ case 'month':
207
+ case 'time':
208
+ case 'week':
209
+ // This fixes the no-show issue on iOS Safari and Android Chrome:
210
+ // https://github.com/facebook/react/issues/7233
211
+ node.value = '';
212
+ node.value = node.defaultValue;
213
+ break;
214
+ default:
215
+ node.value = node.value;
216
+ break;
217
+ }
218
+
219
+ // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
220
+ // this is needed to work around a chrome bug where setting defaultChecked
221
+ // will sometimes influence the value of checked (even after detachment).
222
+ // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
223
+ // We need to temporarily unset name to avoid disrupting radio button groups.
224
+ var name = node.name;
225
+ if (name !== '') {
226
+ node.name = '';
227
+ }
228
+ node.defaultChecked = !node.defaultChecked;
229
+ node.defaultChecked = !node.defaultChecked;
230
+ if (name !== '') {
231
+ node.name = name;
232
+ }
233
+ }
234
+ };
235
+
236
+ function _handleChange(event) {
237
+ var props = this._currentElement.props;
238
+
239
+ var returnValue = LinkedValueUtils.executeOnChange(props, event);
240
+
241
+ // Here we use asap to wait until all updates have propagated, which
242
+ // is important when using controlled components within layers:
243
+ // https://github.com/facebook/react/issues/1698
244
+ ReactUpdates.asap(forceUpdateIfMounted, this);
245
+
246
+ var name = props.name;
247
+ if (props.type === 'radio' && name != null) {
248
+ var rootNode = ReactDOMComponentTree.getNodeFromInstance(this);
249
+ var queryRoot = rootNode;
250
+
251
+ while (queryRoot.parentNode) {
252
+ queryRoot = queryRoot.parentNode;
253
+ }
254
+
255
+ // If `rootNode.form` was non-null, then we could try `form.elements`,
256
+ // but that sometimes behaves strangely in IE8. We could also try using
257
+ // `form.getElementsByName`, but that will only return direct children
258
+ // and won't include inputs that use the HTML5 `form=` attribute. Since
259
+ // the input might not even be in a form, let's just use the global
260
+ // `querySelectorAll` to ensure we don't miss anything.
261
+ var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
262
+
263
+ for (var i = 0; i < group.length; i++) {
264
+ var otherNode = group[i];
265
+ if (otherNode === rootNode || otherNode.form !== rootNode.form) {
266
+ continue;
267
+ }
268
+ // This will throw if radio buttons rendered by different copies of React
269
+ // and the same name are rendered into the same form (same as #1939).
270
+ // That's probably okay; we don't support it just as we don't support
271
+ // mixing React radio buttons with non-React ones.
272
+ var otherInstance = ReactDOMComponentTree.getInstanceFromNode(otherNode);
273
+ !otherInstance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : _prodInvariant('90') : void 0;
274
+ // If this is a controlled radio button group, forcing the input that
275
+ // was previously checked to update will cause it to be come re-checked
276
+ // as appropriate.
277
+ ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
278
+ }
279
+ }
280
+
281
+ return returnValue;
282
+ }
283
+
284
+ module.exports = ReactDOMInput;
@@ -0,0 +1,92 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var DOMProperty = require('./DOMProperty');
14
+ var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
15
+
16
+ var warning = require('fbjs/lib/warning');
17
+
18
+ var warnedProperties = {};
19
+ var rARIA = new RegExp('^(aria)-[' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
20
+
21
+ function validateProperty(tagName, name, debugID) {
22
+ if (warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
23
+ return true;
24
+ }
25
+
26
+ if (rARIA.test(name)) {
27
+ var lowerCasedName = name.toLowerCase();
28
+ var standardName = DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
29
+
30
+ // If this is an aria-* attribute, but is not listed in the known DOM
31
+ // DOM properties, then it is an invalid aria-* attribute.
32
+ if (standardName == null) {
33
+ warnedProperties[name] = true;
34
+ return false;
35
+ }
36
+ // aria-* attributes should be lowercase; suggest the lowercase version.
37
+ if (name !== standardName) {
38
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown ARIA attribute %s. Did you mean %s?%s', name, standardName, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
39
+ warnedProperties[name] = true;
40
+ return true;
41
+ }
42
+ }
43
+
44
+ return true;
45
+ }
46
+
47
+ function warnInvalidARIAProps(debugID, element) {
48
+ var invalidProps = [];
49
+
50
+ for (var key in element.props) {
51
+ var isValid = validateProperty(element.type, key, debugID);
52
+ if (!isValid) {
53
+ invalidProps.push(key);
54
+ }
55
+ }
56
+
57
+ var unknownPropString = invalidProps.map(function (prop) {
58
+ return '`' + prop + '`';
59
+ }).join(', ');
60
+
61
+ if (invalidProps.length === 1) {
62
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
63
+ } else if (invalidProps.length > 1) {
64
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
65
+ }
66
+ }
67
+
68
+ function handleElement(debugID, element) {
69
+ if (element == null || typeof element.type !== 'string') {
70
+ return;
71
+ }
72
+ if (element.type.indexOf('-') >= 0 || element.props.is) {
73
+ return;
74
+ }
75
+
76
+ warnInvalidARIAProps(debugID, element);
77
+ }
78
+
79
+ var ReactDOMInvalidARIAHook = {
80
+ onBeforeMountComponent: function (debugID, element) {
81
+ if (process.env.NODE_ENV !== 'production') {
82
+ handleElement(debugID, element);
83
+ }
84
+ },
85
+ onBeforeUpdateComponent: function (debugID, element) {
86
+ if (process.env.NODE_ENV !== 'production') {
87
+ handleElement(debugID, element);
88
+ }
89
+ }
90
+ };
91
+
92
+ module.exports = ReactDOMInvalidARIAHook;
@@ -0,0 +1,42 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
14
+
15
+ var warning = require('fbjs/lib/warning');
16
+
17
+ var didWarnValueNull = false;
18
+
19
+ function handleElement(debugID, element) {
20
+ if (element == null) {
21
+ return;
22
+ }
23
+ if (element.type !== 'input' && element.type !== 'textarea' && element.type !== 'select') {
24
+ return;
25
+ }
26
+ if (element.props != null && element.props.value === null && !didWarnValueNull) {
27
+ 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;
28
+
29
+ didWarnValueNull = true;
30
+ }
31
+ }
32
+
33
+ var ReactDOMNullInputValuePropHook = {
34
+ onBeforeMountComponent: function (debugID, element) {
35
+ handleElement(debugID, element);
36
+ },
37
+ onBeforeUpdateComponent: function (debugID, element) {
38
+ handleElement(debugID, element);
39
+ }
40
+ };
41
+
42
+ module.exports = ReactDOMNullInputValuePropHook;
@@ -0,0 +1,122 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var React = require('react/lib/React');
16
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
17
+ var ReactDOMSelect = require('./ReactDOMSelect');
18
+
19
+ var warning = require('fbjs/lib/warning');
20
+ var didWarnInvalidOptionChildren = false;
21
+
22
+ function flattenChildren(children) {
23
+ var content = '';
24
+
25
+ // Flatten children and warn if they aren't strings or numbers;
26
+ // invalid types are ignored.
27
+ React.Children.forEach(children, function (child) {
28
+ if (child == null) {
29
+ return;
30
+ }
31
+ if (typeof child === 'string' || typeof child === 'number') {
32
+ content += child;
33
+ } else if (!didWarnInvalidOptionChildren) {
34
+ didWarnInvalidOptionChildren = true;
35
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : void 0;
36
+ }
37
+ });
38
+
39
+ return content;
40
+ }
41
+
42
+ /**
43
+ * Implements an <option> host component that warns when `selected` is set.
44
+ */
45
+ var ReactDOMOption = {
46
+ mountWrapper: function (inst, props, hostParent) {
47
+ // TODO (yungsters): Remove support for `selected` in <option>.
48
+ if (process.env.NODE_ENV !== 'production') {
49
+ 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;
50
+ }
51
+
52
+ // Look up whether this option is 'selected'
53
+ var selectValue = null;
54
+ if (hostParent != null) {
55
+ var selectParent = hostParent;
56
+
57
+ if (selectParent._tag === 'optgroup') {
58
+ selectParent = selectParent._hostParent;
59
+ }
60
+
61
+ if (selectParent != null && selectParent._tag === 'select') {
62
+ selectValue = ReactDOMSelect.getSelectValueContext(selectParent);
63
+ }
64
+ }
65
+
66
+ // If the value is null (e.g., no specified value or after initial mount)
67
+ // or missing (e.g., for <datalist>), we don't change props.selected
68
+ var selected = null;
69
+ if (selectValue != null) {
70
+ var value;
71
+ if (props.value != null) {
72
+ value = props.value + '';
73
+ } else {
74
+ value = flattenChildren(props.children);
75
+ }
76
+ selected = false;
77
+ if (Array.isArray(selectValue)) {
78
+ // multiple
79
+ for (var i = 0; i < selectValue.length; i++) {
80
+ if ('' + selectValue[i] === value) {
81
+ selected = true;
82
+ break;
83
+ }
84
+ }
85
+ } else {
86
+ selected = '' + selectValue === value;
87
+ }
88
+ }
89
+
90
+ inst._wrapperState = { selected: selected };
91
+ },
92
+
93
+ postMountWrapper: function (inst) {
94
+ // value="" should make a value attribute (#6219)
95
+ var props = inst._currentElement.props;
96
+ if (props.value != null) {
97
+ var node = ReactDOMComponentTree.getNodeFromInstance(inst);
98
+ node.setAttribute('value', props.value);
99
+ }
100
+ },
101
+
102
+ getHostProps: function (inst, props) {
103
+ var hostProps = _assign({ selected: undefined, children: undefined }, props);
104
+
105
+ // Read state only from initial mount because <select> updates value
106
+ // manually; we need the initial state only for server rendering
107
+ if (inst._wrapperState.selected != null) {
108
+ hostProps.selected = inst._wrapperState.selected;
109
+ }
110
+
111
+ var content = flattenChildren(props.children);
112
+
113
+ if (content) {
114
+ hostProps.children = content;
115
+ }
116
+
117
+ return hostProps;
118
+ }
119
+
120
+ };
121
+
122
+ module.exports = ReactDOMOption;