react 15.3.2 → 15.4.0-rc.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 (210) hide show
  1. package/dist/react-with-addons.js +3864 -21390
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2639 -19486
  4. package/dist/react.min.js +2 -6
  5. package/lib/KeyEscapeUtils.js +0 -1
  6. package/lib/LinkedStateMixin.js +1 -3
  7. package/lib/PooledClass.js +3 -1
  8. package/lib/React.js +0 -1
  9. package/lib/ReactAddonsDOMDependencies.js +35 -0
  10. package/lib/ReactAddonsDOMDependenciesUMDShim.js +31 -0
  11. package/lib/ReactCSSTransitionGroup.js +60 -43
  12. package/lib/ReactCSSTransitionGroupChild.js +2 -3
  13. package/lib/ReactChildren.js +0 -1
  14. package/lib/ReactClass.js +38 -54
  15. package/lib/ReactComponent.js +0 -1
  16. package/lib/ReactComponentTreeDevtool.js +0 -1
  17. package/lib/ReactComponentTreeHook.js +84 -101
  18. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +4 -7
  19. package/lib/ReactComponentWithPureRenderMixin.js +0 -1
  20. package/lib/ReactCurrentOwner.js +1 -2
  21. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +5 -4
  22. package/lib/ReactDOMFactories.js +0 -1
  23. package/lib/ReactElement.js +6 -14
  24. package/lib/ReactElementSymbol.js +19 -0
  25. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +3 -9
  26. package/lib/ReactElementValidator.js +1 -3
  27. package/lib/ReactFragment.js +0 -1
  28. package/lib/ReactLink.js +0 -1
  29. package/lib/ReactNoopUpdateQueue.js +0 -1
  30. package/lib/ReactPropTypeLocationNames.js +1 -1
  31. package/lib/ReactPropTypeLocations.js +2 -12
  32. package/lib/ReactPropTypes.js +5 -3
  33. package/lib/ReactPropTypesSecret.js +1 -1
  34. package/lib/ReactPureComponent.js +0 -1
  35. package/lib/ReactStateSetters.js +0 -1
  36. package/lib/ReactTransitionChildMapping.js +0 -1
  37. package/lib/ReactTransitionEvents.js +1 -2
  38. package/lib/ReactTransitionGroup.js +145 -142
  39. package/lib/ReactUMDEntry.js +11 -6
  40. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +3 -6
  41. package/lib/ReactVersion.js +1 -2
  42. package/lib/ReactWithAddons.js +15 -3
  43. package/lib/ReactWithAddonsUMDEntry.js +11 -6
  44. package/lib/canDefineProperty.js +2 -1
  45. package/lib/checkReactTypeSpec.js +0 -1
  46. package/lib/deprecated.js +0 -1
  47. package/lib/flattenChildren.js +0 -1
  48. package/lib/getIteratorFn.js +0 -1
  49. package/lib/onlyChild.js +0 -1
  50. package/lib/reactProdInvariant.js +0 -1
  51. package/lib/shallowCompare.js +1 -2
  52. package/lib/sliceChildren.js +0 -1
  53. package/lib/traverseAllChildren.js +11 -3
  54. package/lib/update.js +6 -8
  55. package/package.json +1 -1
  56. package/lib/AutoFocusUtils.js +0 -24
  57. package/lib/BeforeInputEventPlugin.js +0 -390
  58. package/lib/CSSProperty.js +0 -148
  59. package/lib/CSSPropertyOperations.js +0 -205
  60. package/lib/CallbackQueue.js +0 -106
  61. package/lib/ChangeEventPlugin.js +0 -325
  62. package/lib/DOMChildrenOperations.js +0 -194
  63. package/lib/DOMLazyTree.js +0 -118
  64. package/lib/DOMProperty.js +0 -206
  65. package/lib/DOMPropertyOperations.js +0 -221
  66. package/lib/Danger.js +0 -48
  67. package/lib/DefaultEventPluginOrder.js +0 -27
  68. package/lib/DisabledInputUtils.js +0 -50
  69. package/lib/EnterLeaveEventPlugin.js +0 -105
  70. package/lib/EventConstants.js +0 -97
  71. package/lib/EventPluginHub.js +0 -251
  72. package/lib/EventPluginRegistry.js +0 -247
  73. package/lib/EventPluginUtils.js +0 -229
  74. package/lib/EventPropagators.js +0 -137
  75. package/lib/FallbackCompositionState.js +0 -95
  76. package/lib/HTMLDOMPropertyConfig.js +0 -212
  77. package/lib/LinkedValueUtils.js +0 -136
  78. package/lib/NativeMethodsMixin.js +0 -167
  79. package/lib/ReactBrowserEventEmitter.js +0 -330
  80. package/lib/ReactChildReconciler.js +0 -154
  81. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  82. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  83. package/lib/ReactComponentEnvironment.js +0 -45
  84. package/lib/ReactComponentTreeTestUtils.js +0 -87
  85. package/lib/ReactCompositeComponent.js +0 -904
  86. package/lib/ReactDOM.js +0 -110
  87. package/lib/ReactDOMButton.js +0 -24
  88. package/lib/ReactDOMComponent.js +0 -1006
  89. package/lib/ReactDOMComponentTree.js +0 -188
  90. package/lib/ReactDOMContainerInfo.js +0 -33
  91. package/lib/ReactDOMEmptyComponent.js +0 -60
  92. package/lib/ReactDOMFiber.js +0 -76
  93. package/lib/ReactDOMIDOperations.js +0 -34
  94. package/lib/ReactDOMInput.js +0 -269
  95. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  96. package/lib/ReactDOMOption.js +0 -123
  97. package/lib/ReactDOMSelect.js +0 -201
  98. package/lib/ReactDOMSelection.js +0 -212
  99. package/lib/ReactDOMServer.js +0 -26
  100. package/lib/ReactDOMTextComponent.js +0 -164
  101. package/lib/ReactDOMTextarea.js +0 -155
  102. package/lib/ReactDOMTreeTraversal.js +0 -136
  103. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  104. package/lib/ReactDebugTool.js +0 -301
  105. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  106. package/lib/ReactDefaultInjection.js +0 -84
  107. package/lib/ReactEmptyComponent.js +0 -30
  108. package/lib/ReactErrorUtils.js +0 -76
  109. package/lib/ReactEventEmitterMixin.js +0 -33
  110. package/lib/ReactEventListener.js +0 -157
  111. package/lib/ReactFeatureFlags.js +0 -22
  112. package/lib/ReactHostComponent.js +0 -76
  113. package/lib/ReactHostOperationHistoryHook.js +0 -37
  114. package/lib/ReactInjection.js +0 -36
  115. package/lib/ReactInputSelection.js +0 -124
  116. package/lib/ReactInstanceHandles.js +0 -302
  117. package/lib/ReactInstanceMap.js +0 -48
  118. package/lib/ReactInstrumentation.js +0 -21
  119. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  120. package/lib/ReactMarkupChecksum.js +0 -50
  121. package/lib/ReactMount.js +0 -534
  122. package/lib/ReactMultiChild.js +0 -451
  123. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  124. package/lib/ReactNative.js +0 -71
  125. package/lib/ReactNativeAttributePayload.js +0 -371
  126. package/lib/ReactNativeBaseComponent.js +0 -198
  127. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  128. package/lib/ReactNativeComponentEnvironment.js +0 -31
  129. package/lib/ReactNativeComponentTree.js +0 -68
  130. package/lib/ReactNativeContainerInfo.js +0 -21
  131. package/lib/ReactNativeDOMIDOperations.js +0 -79
  132. package/lib/ReactNativeDefaultInjection.js +0 -101
  133. package/lib/ReactNativeEventEmitter.js +0 -191
  134. package/lib/ReactNativeEventPluginOrder.js +0 -16
  135. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  136. package/lib/ReactNativeMount.js +0 -193
  137. package/lib/ReactNativePropRegistry.js +0 -52
  138. package/lib/ReactNativeReconcileTransaction.js +0 -129
  139. package/lib/ReactNativeTagHandles.js +0 -56
  140. package/lib/ReactNativeTextComponent.js +0 -71
  141. package/lib/ReactNativeTreeTraversal.js +0 -127
  142. package/lib/ReactNodeTypes.js +0 -40
  143. package/lib/ReactNoop.js +0 -173
  144. package/lib/ReactOwner.js +0 -94
  145. package/lib/ReactPerf.js +0 -494
  146. package/lib/ReactReconcileTransaction.js +0 -178
  147. package/lib/ReactReconciler.js +0 -168
  148. package/lib/ReactRef.js +0 -80
  149. package/lib/ReactServerBatchingStrategy.js +0 -22
  150. package/lib/ReactServerRendering.js +0 -90
  151. package/lib/ReactServerRenderingTransaction.js +0 -90
  152. package/lib/ReactServerUpdateQueue.js +0 -141
  153. package/lib/ReactSimpleEmptyComponent.js +0 -37
  154. package/lib/ReactTestMount.js +0 -126
  155. package/lib/ReactTestReconcileTransaction.js +0 -121
  156. package/lib/ReactTestRenderer.js +0 -144
  157. package/lib/ReactTestUtils.js +0 -518
  158. package/lib/ReactUpdateQueue.js +0 -226
  159. package/lib/ReactUpdates.js +0 -251
  160. package/lib/ResponderEventPlugin.js +0 -510
  161. package/lib/ResponderSyntheticEvent.js +0 -39
  162. package/lib/ResponderTouchHistoryStore.js +0 -184
  163. package/lib/SVGDOMPropertyConfig.js +0 -302
  164. package/lib/SelectEventPlugin.js +0 -196
  165. package/lib/SimpleEventPlugin.js +0 -635
  166. package/lib/SyntheticAnimationEvent.js +0 -39
  167. package/lib/SyntheticClipboardEvent.js +0 -38
  168. package/lib/SyntheticCompositionEvent.js +0 -36
  169. package/lib/SyntheticDragEvent.js +0 -36
  170. package/lib/SyntheticEvent.js +0 -268
  171. package/lib/SyntheticFocusEvent.js +0 -36
  172. package/lib/SyntheticInputEvent.js +0 -37
  173. package/lib/SyntheticKeyboardEvent.js +0 -84
  174. package/lib/SyntheticMouseEvent.js +0 -72
  175. package/lib/SyntheticTouchEvent.js +0 -45
  176. package/lib/SyntheticTransitionEvent.js +0 -39
  177. package/lib/SyntheticUIEvent.js +0 -59
  178. package/lib/SyntheticWheelEvent.js +0 -54
  179. package/lib/TapEventPlugin.js +0 -110
  180. package/lib/TouchHistoryMath.js +0 -99
  181. package/lib/Transaction.js +0 -233
  182. package/lib/ViewportMetrics.js +0 -27
  183. package/lib/accumulate.js +0 -46
  184. package/lib/accumulateInto.js +0 -58
  185. package/lib/adler32.js +0 -44
  186. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  187. package/lib/createReactNativeComponentClass.js +0 -42
  188. package/lib/dangerousStyleValue.js +0 -79
  189. package/lib/escapeTextContentForBrowser.js +0 -123
  190. package/lib/findDOMNode.js +0 -60
  191. package/lib/findNodeHandle.js +0 -91
  192. package/lib/forEachAccumulated.js +0 -31
  193. package/lib/getEventCharCode.js +0 -50
  194. package/lib/getEventKey.js +0 -102
  195. package/lib/getEventModifierState.js +0 -43
  196. package/lib/getEventTarget.js +0 -35
  197. package/lib/getHostComponentFromComposite.js +0 -30
  198. package/lib/getNodeForCharacterOffset.js +0 -74
  199. package/lib/getTestDocument.js +0 -21
  200. package/lib/getTextContentAccessor.js +0 -33
  201. package/lib/getVendorPrefixedEventName.js +0 -101
  202. package/lib/instantiateReactComponent.js +0 -119
  203. package/lib/isEventSupported.js +0 -60
  204. package/lib/isTextInputElement.js +0 -51
  205. package/lib/quoteAttributeValueForBrowser.js +0 -26
  206. package/lib/reactComponentExpect.js +0 -217
  207. package/lib/setInnerHTML.js +0 -98
  208. package/lib/setTextContent.js +0 -48
  209. package/lib/shouldUpdateReactComponent.js +0 -42
  210. package/lib/validateDOMNesting.js +0 -382
@@ -1,325 +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 ChangeEventPlugin
10
- */
11
-
12
- 'use strict';
13
-
14
- var EventConstants = require('./EventConstants');
15
- var EventPluginHub = require('./EventPluginHub');
16
- var EventPropagators = require('./EventPropagators');
17
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
18
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
19
- var ReactUpdates = require('./ReactUpdates');
20
- var SyntheticEvent = require('./SyntheticEvent');
21
-
22
- var getEventTarget = require('./getEventTarget');
23
- var isEventSupported = require('./isEventSupported');
24
- var isTextInputElement = require('./isTextInputElement');
25
- var keyOf = require('fbjs/lib/keyOf');
26
-
27
- var topLevelTypes = EventConstants.topLevelTypes;
28
-
29
- var eventTypes = {
30
- change: {
31
- phasedRegistrationNames: {
32
- bubbled: keyOf({ onChange: null }),
33
- captured: keyOf({ onChangeCapture: null })
34
- },
35
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
36
- }
37
- };
38
-
39
- /**
40
- * For IE shims
41
- */
42
- var activeElement = null;
43
- var activeElementInst = null;
44
- var activeElementValue = null;
45
- var activeElementValueProp = null;
46
-
47
- /**
48
- * SECTION: handle `change` event
49
- */
50
- function shouldUseChangeEvent(elem) {
51
- var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
52
- return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
53
- }
54
-
55
- var doesChangeEventBubble = false;
56
- if (ExecutionEnvironment.canUseDOM) {
57
- // See `handleChange` comment below
58
- doesChangeEventBubble = isEventSupported('change') && (!document.documentMode || document.documentMode > 8);
59
- }
60
-
61
- function manualDispatchChangeEvent(nativeEvent) {
62
- var event = SyntheticEvent.getPooled(eventTypes.change, activeElementInst, nativeEvent, getEventTarget(nativeEvent));
63
- EventPropagators.accumulateTwoPhaseDispatches(event);
64
-
65
- // If change and propertychange bubbled, we'd just bind to it like all the
66
- // other events and have it go through ReactBrowserEventEmitter. Since it
67
- // doesn't, we manually listen for the events and so we have to enqueue and
68
- // process the abstract event manually.
69
- //
70
- // Batching is necessary here in order to ensure that all event handlers run
71
- // before the next rerender (including event handlers attached to ancestor
72
- // elements instead of directly on the input). Without this, controlled
73
- // components don't work properly in conjunction with event bubbling because
74
- // the component is rerendered and the value reverted before all the event
75
- // handlers can run. See https://github.com/facebook/react/issues/708.
76
- ReactUpdates.batchedUpdates(runEventInBatch, event);
77
- }
78
-
79
- function runEventInBatch(event) {
80
- EventPluginHub.enqueueEvents(event);
81
- EventPluginHub.processEventQueue(false);
82
- }
83
-
84
- function startWatchingForChangeEventIE8(target, targetInst) {
85
- activeElement = target;
86
- activeElementInst = targetInst;
87
- activeElement.attachEvent('onchange', manualDispatchChangeEvent);
88
- }
89
-
90
- function stopWatchingForChangeEventIE8() {
91
- if (!activeElement) {
92
- return;
93
- }
94
- activeElement.detachEvent('onchange', manualDispatchChangeEvent);
95
- activeElement = null;
96
- activeElementInst = null;
97
- }
98
-
99
- function getTargetInstForChangeEvent(topLevelType, targetInst) {
100
- if (topLevelType === topLevelTypes.topChange) {
101
- return targetInst;
102
- }
103
- }
104
- function handleEventsForChangeEventIE8(topLevelType, target, targetInst) {
105
- if (topLevelType === topLevelTypes.topFocus) {
106
- // stopWatching() should be a noop here but we call it just in case we
107
- // missed a blur event somehow.
108
- stopWatchingForChangeEventIE8();
109
- startWatchingForChangeEventIE8(target, targetInst);
110
- } else if (topLevelType === topLevelTypes.topBlur) {
111
- stopWatchingForChangeEventIE8();
112
- }
113
- }
114
-
115
- /**
116
- * SECTION: handle `input` event
117
- */
118
- var isInputEventSupported = false;
119
- if (ExecutionEnvironment.canUseDOM) {
120
- // IE9 claims to support the input event but fails to trigger it when
121
- // deleting text, so we ignore its input events.
122
- // IE10+ fire input events to often, such when a placeholder
123
- // changes or when an input with a placeholder is focused.
124
- isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 11);
125
- }
126
-
127
- /**
128
- * (For IE <=11) Replacement getter/setter for the `value` property that gets
129
- * set on the active element.
130
- */
131
- var newValueProp = {
132
- get: function () {
133
- return activeElementValueProp.get.call(this);
134
- },
135
- set: function (val) {
136
- // Cast to a string so we can do equality checks.
137
- activeElementValue = '' + val;
138
- activeElementValueProp.set.call(this, val);
139
- }
140
- };
141
-
142
- /**
143
- * (For IE <=11) Starts tracking propertychange events on the passed-in element
144
- * and override the value property so that we can distinguish user events from
145
- * value changes in JS.
146
- */
147
- function startWatchingForValueChange(target, targetInst) {
148
- activeElement = target;
149
- activeElementInst = targetInst;
150
- activeElementValue = target.value;
151
- activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
152
-
153
- // Not guarded in a canDefineProperty check: IE8 supports defineProperty only
154
- // on DOM elements
155
- Object.defineProperty(activeElement, 'value', newValueProp);
156
- if (activeElement.attachEvent) {
157
- activeElement.attachEvent('onpropertychange', handlePropertyChange);
158
- } else {
159
- activeElement.addEventListener('propertychange', handlePropertyChange, false);
160
- }
161
- }
162
-
163
- /**
164
- * (For IE <=11) Removes the event listeners from the currently-tracked element,
165
- * if any exists.
166
- */
167
- function stopWatchingForValueChange() {
168
- if (!activeElement) {
169
- return;
170
- }
171
-
172
- // delete restores the original property definition
173
- delete activeElement.value;
174
-
175
- if (activeElement.detachEvent) {
176
- activeElement.detachEvent('onpropertychange', handlePropertyChange);
177
- } else {
178
- activeElement.removeEventListener('propertychange', handlePropertyChange, false);
179
- }
180
-
181
- activeElement = null;
182
- activeElementInst = null;
183
- activeElementValue = null;
184
- activeElementValueProp = null;
185
- }
186
-
187
- /**
188
- * (For IE <=11) Handles a propertychange event, sending a `change` event if
189
- * the value of the active element has changed.
190
- */
191
- function handlePropertyChange(nativeEvent) {
192
- if (nativeEvent.propertyName !== 'value') {
193
- return;
194
- }
195
- var value = nativeEvent.srcElement.value;
196
- if (value === activeElementValue) {
197
- return;
198
- }
199
- activeElementValue = value;
200
-
201
- manualDispatchChangeEvent(nativeEvent);
202
- }
203
-
204
- /**
205
- * If a `change` event should be fired, returns the target's ID.
206
- */
207
- function getTargetInstForInputEvent(topLevelType, targetInst) {
208
- if (topLevelType === topLevelTypes.topInput) {
209
- // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
210
- // what we want so fall through here and trigger an abstract event
211
- return targetInst;
212
- }
213
- }
214
-
215
- function handleEventsForInputEventIE(topLevelType, target, targetInst) {
216
- if (topLevelType === topLevelTypes.topFocus) {
217
- // In IE8, we can capture almost all .value changes by adding a
218
- // propertychange handler and looking for events with propertyName
219
- // equal to 'value'
220
- // In IE9-11, propertychange fires for most input events but is buggy and
221
- // doesn't fire when text is deleted, but conveniently, selectionchange
222
- // appears to fire in all of the remaining cases so we catch those and
223
- // forward the event if the value has changed
224
- // In either case, we don't want to call the event handler if the value
225
- // is changed from JS so we redefine a setter for `.value` that updates
226
- // our activeElementValue variable, allowing us to ignore those changes
227
- //
228
- // stopWatching() should be a noop here but we call it just in case we
229
- // missed a blur event somehow.
230
- stopWatchingForValueChange();
231
- startWatchingForValueChange(target, targetInst);
232
- } else if (topLevelType === topLevelTypes.topBlur) {
233
- stopWatchingForValueChange();
234
- }
235
- }
236
-
237
- // For IE8 and IE9.
238
- function getTargetInstForInputEventIE(topLevelType, targetInst) {
239
- if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
240
- // On the selectionchange event, the target is just document which isn't
241
- // helpful for us so just check activeElement instead.
242
- //
243
- // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
244
- // propertychange on the first input event after setting `value` from a
245
- // script and fires only keydown, keypress, keyup. Catching keyup usually
246
- // gets it and catching keydown lets us fire an event for the first
247
- // keystroke if user does a key repeat (it'll be a little delayed: right
248
- // before the second keystroke). Other input methods (e.g., paste) seem to
249
- // fire selectionchange normally.
250
- if (activeElement && activeElement.value !== activeElementValue) {
251
- activeElementValue = activeElement.value;
252
- return activeElementInst;
253
- }
254
- }
255
- }
256
-
257
- /**
258
- * SECTION: handle `click` event
259
- */
260
- function shouldUseClickEvent(elem) {
261
- // Use the `click` event to detect changes to checkbox and radio inputs.
262
- // This approach works across all browsers, whereas `change` does not fire
263
- // until `blur` in IE8.
264
- return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
265
- }
266
-
267
- function getTargetInstForClickEvent(topLevelType, targetInst) {
268
- if (topLevelType === topLevelTypes.topClick) {
269
- return targetInst;
270
- }
271
- }
272
-
273
- /**
274
- * This plugin creates an `onChange` event that normalizes change events
275
- * across form elements. This event fires at a time when it's possible to
276
- * change the element's value without seeing a flicker.
277
- *
278
- * Supported elements are:
279
- * - input (see `isTextInputElement`)
280
- * - textarea
281
- * - select
282
- */
283
- var ChangeEventPlugin = {
284
-
285
- eventTypes: eventTypes,
286
-
287
- extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
288
- var targetNode = targetInst ? ReactDOMComponentTree.getNodeFromInstance(targetInst) : window;
289
-
290
- var getTargetInstFunc, handleEventFunc;
291
- if (shouldUseChangeEvent(targetNode)) {
292
- if (doesChangeEventBubble) {
293
- getTargetInstFunc = getTargetInstForChangeEvent;
294
- } else {
295
- handleEventFunc = handleEventsForChangeEventIE8;
296
- }
297
- } else if (isTextInputElement(targetNode)) {
298
- if (isInputEventSupported) {
299
- getTargetInstFunc = getTargetInstForInputEvent;
300
- } else {
301
- getTargetInstFunc = getTargetInstForInputEventIE;
302
- handleEventFunc = handleEventsForInputEventIE;
303
- }
304
- } else if (shouldUseClickEvent(targetNode)) {
305
- getTargetInstFunc = getTargetInstForClickEvent;
306
- }
307
-
308
- if (getTargetInstFunc) {
309
- var inst = getTargetInstFunc(topLevelType, targetInst);
310
- if (inst) {
311
- var event = SyntheticEvent.getPooled(eventTypes.change, inst, nativeEvent, nativeEventTarget);
312
- event.type = 'change';
313
- EventPropagators.accumulateTwoPhaseDispatches(event);
314
- return event;
315
- }
316
- }
317
-
318
- if (handleEventFunc) {
319
- handleEventFunc(topLevelType, targetNode, targetInst);
320
- }
321
- }
322
-
323
- };
324
-
325
- module.exports = ChangeEventPlugin;
@@ -1,194 +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 DOMChildrenOperations
10
- */
11
-
12
- 'use strict';
13
-
14
- var DOMLazyTree = require('./DOMLazyTree');
15
- var Danger = require('./Danger');
16
- var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
17
- var ReactDOMComponentTree = require('./ReactDOMComponentTree');
18
- var ReactInstrumentation = require('./ReactInstrumentation');
19
-
20
- var createMicrosoftUnsafeLocalFunction = require('./createMicrosoftUnsafeLocalFunction');
21
- var setInnerHTML = require('./setInnerHTML');
22
- var setTextContent = require('./setTextContent');
23
-
24
- function getNodeAfter(parentNode, node) {
25
- // Special case for text components, which return [open, close] comments
26
- // from getHostNode.
27
- if (Array.isArray(node)) {
28
- node = node[1];
29
- }
30
- return node ? node.nextSibling : parentNode.firstChild;
31
- }
32
-
33
- /**
34
- * Inserts `childNode` as a child of `parentNode` at the `index`.
35
- *
36
- * @param {DOMElement} parentNode Parent node in which to insert.
37
- * @param {DOMElement} childNode Child node to insert.
38
- * @param {number} index Index at which to insert the child.
39
- * @internal
40
- */
41
- var insertChildAt = createMicrosoftUnsafeLocalFunction(function (parentNode, childNode, referenceNode) {
42
- // We rely exclusively on `insertBefore(node, null)` instead of also using
43
- // `appendChild(node)`. (Using `undefined` is not allowed by all browsers so
44
- // we are careful to use `null`.)
45
- parentNode.insertBefore(childNode, referenceNode);
46
- });
47
-
48
- function insertLazyTreeChildAt(parentNode, childTree, referenceNode) {
49
- DOMLazyTree.insertTreeBefore(parentNode, childTree, referenceNode);
50
- }
51
-
52
- function moveChild(parentNode, childNode, referenceNode) {
53
- if (Array.isArray(childNode)) {
54
- moveDelimitedText(parentNode, childNode[0], childNode[1], referenceNode);
55
- } else {
56
- insertChildAt(parentNode, childNode, referenceNode);
57
- }
58
- }
59
-
60
- function removeChild(parentNode, childNode) {
61
- if (Array.isArray(childNode)) {
62
- var closingComment = childNode[1];
63
- childNode = childNode[0];
64
- removeDelimitedText(parentNode, childNode, closingComment);
65
- parentNode.removeChild(closingComment);
66
- }
67
- parentNode.removeChild(childNode);
68
- }
69
-
70
- function moveDelimitedText(parentNode, openingComment, closingComment, referenceNode) {
71
- var node = openingComment;
72
- while (true) {
73
- var nextNode = node.nextSibling;
74
- insertChildAt(parentNode, node, referenceNode);
75
- if (node === closingComment) {
76
- break;
77
- }
78
- node = nextNode;
79
- }
80
- }
81
-
82
- function removeDelimitedText(parentNode, startNode, closingComment) {
83
- while (true) {
84
- var node = startNode.nextSibling;
85
- if (node === closingComment) {
86
- // The closing comment is removed by ReactMultiChild.
87
- break;
88
- } else {
89
- parentNode.removeChild(node);
90
- }
91
- }
92
- }
93
-
94
- function replaceDelimitedText(openingComment, closingComment, stringText) {
95
- var parentNode = openingComment.parentNode;
96
- var nodeAfterComment = openingComment.nextSibling;
97
- if (nodeAfterComment === closingComment) {
98
- // There are no text nodes between the opening and closing comments; insert
99
- // a new one if stringText isn't empty.
100
- if (stringText) {
101
- insertChildAt(parentNode, document.createTextNode(stringText), nodeAfterComment);
102
- }
103
- } else {
104
- if (stringText) {
105
- // Set the text content of the first node after the opening comment, and
106
- // remove all following nodes up until the closing comment.
107
- setTextContent(nodeAfterComment, stringText);
108
- removeDelimitedText(parentNode, nodeAfterComment, closingComment);
109
- } else {
110
- removeDelimitedText(parentNode, openingComment, closingComment);
111
- }
112
- }
113
-
114
- if (process.env.NODE_ENV !== 'production') {
115
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(openingComment)._debugID, 'replace text', stringText);
116
- }
117
- }
118
-
119
- var dangerouslyReplaceNodeWithMarkup = Danger.dangerouslyReplaceNodeWithMarkup;
120
- if (process.env.NODE_ENV !== 'production') {
121
- dangerouslyReplaceNodeWithMarkup = function (oldChild, markup, prevInstance) {
122
- Danger.dangerouslyReplaceNodeWithMarkup(oldChild, markup);
123
- if (prevInstance._debugID !== 0) {
124
- ReactInstrumentation.debugTool.onHostOperation(prevInstance._debugID, 'replace with', markup.toString());
125
- } else {
126
- var nextInstance = ReactDOMComponentTree.getInstanceFromNode(markup.node);
127
- if (nextInstance._debugID !== 0) {
128
- ReactInstrumentation.debugTool.onHostOperation(nextInstance._debugID, 'mount', markup.toString());
129
- }
130
- }
131
- };
132
- }
133
-
134
- /**
135
- * Operations for updating with DOM children.
136
- */
137
- var DOMChildrenOperations = {
138
-
139
- dangerouslyReplaceNodeWithMarkup: dangerouslyReplaceNodeWithMarkup,
140
-
141
- replaceDelimitedText: replaceDelimitedText,
142
-
143
- /**
144
- * Updates a component's children by processing a series of updates. The
145
- * update configurations are each expected to have a `parentNode` property.
146
- *
147
- * @param {array<object>} updates List of update configurations.
148
- * @internal
149
- */
150
- processUpdates: function (parentNode, updates) {
151
- if (process.env.NODE_ENV !== 'production') {
152
- var parentNodeDebugID = ReactDOMComponentTree.getInstanceFromNode(parentNode)._debugID;
153
- }
154
-
155
- for (var k = 0; k < updates.length; k++) {
156
- var update = updates[k];
157
- switch (update.type) {
158
- case ReactMultiChildUpdateTypes.INSERT_MARKUP:
159
- insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode));
160
- if (process.env.NODE_ENV !== 'production') {
161
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'insert child', { toIndex: update.toIndex, content: update.content.toString() });
162
- }
163
- break;
164
- case ReactMultiChildUpdateTypes.MOVE_EXISTING:
165
- moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode));
166
- if (process.env.NODE_ENV !== 'production') {
167
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'move child', { fromIndex: update.fromIndex, toIndex: update.toIndex });
168
- }
169
- break;
170
- case ReactMultiChildUpdateTypes.SET_MARKUP:
171
- setInnerHTML(parentNode, update.content);
172
- if (process.env.NODE_ENV !== 'production') {
173
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'replace children', update.content.toString());
174
- }
175
- break;
176
- case ReactMultiChildUpdateTypes.TEXT_CONTENT:
177
- setTextContent(parentNode, update.content);
178
- if (process.env.NODE_ENV !== 'production') {
179
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'replace text', update.content.toString());
180
- }
181
- break;
182
- case ReactMultiChildUpdateTypes.REMOVE_NODE:
183
- removeChild(parentNode, update.fromNode);
184
- if (process.env.NODE_ENV !== 'production') {
185
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'remove child', { fromIndex: update.fromIndex });
186
- }
187
- break;
188
- }
189
- }
190
- }
191
-
192
- };
193
-
194
- module.exports = DOMChildrenOperations;