react 0.14.10 → 15.0.0
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.
- package/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
package/lib/SelectEventPlugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
var EventConstants = require('./EventConstants');
|
|
15
15
|
var EventPropagators = require('./EventPropagators');
|
|
16
16
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
17
18
|
var ReactInputSelection = require('./ReactInputSelection');
|
|
18
19
|
var SyntheticEvent = require('./SyntheticEvent');
|
|
19
20
|
|
|
@@ -37,12 +38,12 @@ var eventTypes = {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
var activeElement = null;
|
|
40
|
-
var
|
|
41
|
+
var activeElementInst = null;
|
|
41
42
|
var lastSelection = null;
|
|
42
43
|
var mouseDown = false;
|
|
43
44
|
|
|
44
45
|
// Track whether a listener exists for this plugin. If none exist, we do
|
|
45
|
-
// not extract events.
|
|
46
|
+
// not extract events. See #3639.
|
|
46
47
|
var hasListener = false;
|
|
47
48
|
var ON_SELECT_KEY = keyOf({ onSelect: null });
|
|
48
49
|
|
|
@@ -100,7 +101,7 @@ function constructSelectEvent(nativeEvent, nativeEventTarget) {
|
|
|
100
101
|
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
|
101
102
|
lastSelection = currentSelection;
|
|
102
103
|
|
|
103
|
-
var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select,
|
|
104
|
+
var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementInst, nativeEvent, nativeEventTarget);
|
|
104
105
|
|
|
105
106
|
syntheticEvent.type = 'select';
|
|
106
107
|
syntheticEvent.target = activeElement;
|
|
@@ -131,31 +132,25 @@ var SelectEventPlugin = {
|
|
|
131
132
|
|
|
132
133
|
eventTypes: eventTypes,
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
136
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
137
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
138
|
-
* @param {object} nativeEvent Native browser event.
|
|
139
|
-
* @return {*} An accumulation of synthetic events.
|
|
140
|
-
* @see {EventPluginHub.extractEvents}
|
|
141
|
-
*/
|
|
142
|
-
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
135
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
143
136
|
if (!hasListener) {
|
|
144
137
|
return null;
|
|
145
138
|
}
|
|
146
139
|
|
|
140
|
+
var targetNode = targetInst ? ReactDOMComponentTree.getNodeFromInstance(targetInst) : window;
|
|
141
|
+
|
|
147
142
|
switch (topLevelType) {
|
|
148
143
|
// Track the input node that has focus.
|
|
149
144
|
case topLevelTypes.topFocus:
|
|
150
|
-
if (isTextInputElement(
|
|
151
|
-
activeElement =
|
|
152
|
-
|
|
145
|
+
if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
|
|
146
|
+
activeElement = targetNode;
|
|
147
|
+
activeElementInst = targetInst;
|
|
153
148
|
lastSelection = null;
|
|
154
149
|
}
|
|
155
150
|
break;
|
|
156
151
|
case topLevelTypes.topBlur:
|
|
157
152
|
activeElement = null;
|
|
158
|
-
|
|
153
|
+
activeElementInst = null;
|
|
159
154
|
lastSelection = null;
|
|
160
155
|
break;
|
|
161
156
|
|
|
@@ -191,7 +186,7 @@ var SelectEventPlugin = {
|
|
|
191
186
|
return null;
|
|
192
187
|
},
|
|
193
188
|
|
|
194
|
-
didPutListener: function (
|
|
189
|
+
didPutListener: function (inst, registrationName, listener) {
|
|
195
190
|
if (registrationName === ON_SELECT_KEY) {
|
|
196
191
|
hasListener = true;
|
|
197
192
|
}
|
package/lib/SimpleEventPlugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
var EventConstants = require('./EventConstants');
|
|
15
15
|
var EventListener = require('fbjs/lib/EventListener');
|
|
16
16
|
var EventPropagators = require('./EventPropagators');
|
|
17
|
-
var
|
|
17
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
18
|
+
var SyntheticAnimationEvent = require('./SyntheticAnimationEvent');
|
|
18
19
|
var SyntheticClipboardEvent = require('./SyntheticClipboardEvent');
|
|
19
20
|
var SyntheticEvent = require('./SyntheticEvent');
|
|
20
21
|
var SyntheticFocusEvent = require('./SyntheticFocusEvent');
|
|
@@ -22,6 +23,7 @@ var SyntheticKeyboardEvent = require('./SyntheticKeyboardEvent');
|
|
|
22
23
|
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
|
|
23
24
|
var SyntheticDragEvent = require('./SyntheticDragEvent');
|
|
24
25
|
var SyntheticTouchEvent = require('./SyntheticTouchEvent');
|
|
26
|
+
var SyntheticTransitionEvent = require('./SyntheticTransitionEvent');
|
|
25
27
|
var SyntheticUIEvent = require('./SyntheticUIEvent');
|
|
26
28
|
var SyntheticWheelEvent = require('./SyntheticWheelEvent');
|
|
27
29
|
|
|
@@ -39,6 +41,24 @@ var eventTypes = {
|
|
|
39
41
|
captured: keyOf({ onAbortCapture: true })
|
|
40
42
|
}
|
|
41
43
|
},
|
|
44
|
+
animationEnd: {
|
|
45
|
+
phasedRegistrationNames: {
|
|
46
|
+
bubbled: keyOf({ onAnimationEnd: true }),
|
|
47
|
+
captured: keyOf({ onAnimationEndCapture: true })
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
animationIteration: {
|
|
51
|
+
phasedRegistrationNames: {
|
|
52
|
+
bubbled: keyOf({ onAnimationIteration: true }),
|
|
53
|
+
captured: keyOf({ onAnimationIterationCapture: true })
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
animationStart: {
|
|
57
|
+
phasedRegistrationNames: {
|
|
58
|
+
bubbled: keyOf({ onAnimationStart: true }),
|
|
59
|
+
captured: keyOf({ onAnimationStartCapture: true })
|
|
60
|
+
}
|
|
61
|
+
},
|
|
42
62
|
blur: {
|
|
43
63
|
phasedRegistrationNames: {
|
|
44
64
|
bubbled: keyOf({ onBlur: true }),
|
|
@@ -177,6 +197,12 @@ var eventTypes = {
|
|
|
177
197
|
captured: keyOf({ onInputCapture: true })
|
|
178
198
|
}
|
|
179
199
|
},
|
|
200
|
+
invalid: {
|
|
201
|
+
phasedRegistrationNames: {
|
|
202
|
+
bubbled: keyOf({ onInvalid: true }),
|
|
203
|
+
captured: keyOf({ onInvalidCapture: true })
|
|
204
|
+
}
|
|
205
|
+
},
|
|
180
206
|
keyDown: {
|
|
181
207
|
phasedRegistrationNames: {
|
|
182
208
|
bubbled: keyOf({ onKeyDown: true }),
|
|
@@ -359,6 +385,12 @@ var eventTypes = {
|
|
|
359
385
|
captured: keyOf({ onTouchStartCapture: true })
|
|
360
386
|
}
|
|
361
387
|
},
|
|
388
|
+
transitionEnd: {
|
|
389
|
+
phasedRegistrationNames: {
|
|
390
|
+
bubbled: keyOf({ onTransitionEnd: true }),
|
|
391
|
+
captured: keyOf({ onTransitionEndCapture: true })
|
|
392
|
+
}
|
|
393
|
+
},
|
|
362
394
|
volumeChange: {
|
|
363
395
|
phasedRegistrationNames: {
|
|
364
396
|
bubbled: keyOf({ onVolumeChange: true }),
|
|
@@ -381,6 +413,9 @@ var eventTypes = {
|
|
|
381
413
|
|
|
382
414
|
var topLevelEventsToDispatchConfig = {
|
|
383
415
|
topAbort: eventTypes.abort,
|
|
416
|
+
topAnimationEnd: eventTypes.animationEnd,
|
|
417
|
+
topAnimationIteration: eventTypes.animationIteration,
|
|
418
|
+
topAnimationStart: eventTypes.animationStart,
|
|
384
419
|
topBlur: eventTypes.blur,
|
|
385
420
|
topCanPlay: eventTypes.canPlay,
|
|
386
421
|
topCanPlayThrough: eventTypes.canPlayThrough,
|
|
@@ -404,6 +439,7 @@ var topLevelEventsToDispatchConfig = {
|
|
|
404
439
|
topError: eventTypes.error,
|
|
405
440
|
topFocus: eventTypes.focus,
|
|
406
441
|
topInput: eventTypes.input,
|
|
442
|
+
topInvalid: eventTypes.invalid,
|
|
407
443
|
topKeyDown: eventTypes.keyDown,
|
|
408
444
|
topKeyPress: eventTypes.keyPress,
|
|
409
445
|
topKeyUp: eventTypes.keyUp,
|
|
@@ -434,6 +470,7 @@ var topLevelEventsToDispatchConfig = {
|
|
|
434
470
|
topTouchEnd: eventTypes.touchEnd,
|
|
435
471
|
topTouchMove: eventTypes.touchMove,
|
|
436
472
|
topTouchStart: eventTypes.touchStart,
|
|
473
|
+
topTransitionEnd: eventTypes.transitionEnd,
|
|
437
474
|
topVolumeChange: eventTypes.volumeChange,
|
|
438
475
|
topWaiting: eventTypes.waiting,
|
|
439
476
|
topWheel: eventTypes.wheel
|
|
@@ -450,15 +487,7 @@ var SimpleEventPlugin = {
|
|
|
450
487
|
|
|
451
488
|
eventTypes: eventTypes,
|
|
452
489
|
|
|
453
|
-
|
|
454
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
455
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
456
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
457
|
-
* @param {object} nativeEvent Native browser event.
|
|
458
|
-
* @return {*} An accumulation of synthetic events.
|
|
459
|
-
* @see {EventPluginHub.extractEvents}
|
|
460
|
-
*/
|
|
461
|
-
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
490
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
462
491
|
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
|
|
463
492
|
if (!dispatchConfig) {
|
|
464
493
|
return null;
|
|
@@ -474,6 +503,7 @@ var SimpleEventPlugin = {
|
|
|
474
503
|
case topLevelTypes.topEnded:
|
|
475
504
|
case topLevelTypes.topError:
|
|
476
505
|
case topLevelTypes.topInput:
|
|
506
|
+
case topLevelTypes.topInvalid:
|
|
477
507
|
case topLevelTypes.topLoad:
|
|
478
508
|
case topLevelTypes.topLoadedData:
|
|
479
509
|
case topLevelTypes.topLoadedMetadata:
|
|
@@ -497,7 +527,7 @@ var SimpleEventPlugin = {
|
|
|
497
527
|
EventConstructor = SyntheticEvent;
|
|
498
528
|
break;
|
|
499
529
|
case topLevelTypes.topKeyPress:
|
|
500
|
-
//
|
|
530
|
+
// Firefox creates a keypress event for function keys too. This removes
|
|
501
531
|
// the unwanted keypress events. Enter is however both printable and
|
|
502
532
|
// non-printable. One would expect Tab to be as well (but it isn't).
|
|
503
533
|
if (getEventCharCode(nativeEvent) === 0) {
|
|
@@ -544,6 +574,14 @@ var SimpleEventPlugin = {
|
|
|
544
574
|
case topLevelTypes.topTouchStart:
|
|
545
575
|
EventConstructor = SyntheticTouchEvent;
|
|
546
576
|
break;
|
|
577
|
+
case topLevelTypes.topAnimationEnd:
|
|
578
|
+
case topLevelTypes.topAnimationIteration:
|
|
579
|
+
case topLevelTypes.topAnimationStart:
|
|
580
|
+
EventConstructor = SyntheticAnimationEvent;
|
|
581
|
+
break;
|
|
582
|
+
case topLevelTypes.topTransitionEnd:
|
|
583
|
+
EventConstructor = SyntheticTransitionEvent;
|
|
584
|
+
break;
|
|
547
585
|
case topLevelTypes.topScroll:
|
|
548
586
|
EventConstructor = SyntheticUIEvent;
|
|
549
587
|
break;
|
|
@@ -556,27 +594,29 @@ var SimpleEventPlugin = {
|
|
|
556
594
|
EventConstructor = SyntheticClipboardEvent;
|
|
557
595
|
break;
|
|
558
596
|
}
|
|
559
|
-
!EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) :
|
|
560
|
-
var event = EventConstructor.getPooled(dispatchConfig,
|
|
597
|
+
!EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) : void 0;
|
|
598
|
+
var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
|
|
561
599
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
562
600
|
return event;
|
|
563
601
|
},
|
|
564
602
|
|
|
565
|
-
didPutListener: function (
|
|
603
|
+
didPutListener: function (inst, registrationName, listener) {
|
|
566
604
|
// Mobile Safari does not fire properly bubble click events on
|
|
567
605
|
// non-interactive elements, which means delegated click listeners do not
|
|
568
606
|
// fire. The workaround for this bug involves attaching an empty click
|
|
569
607
|
// listener on the target node.
|
|
570
608
|
if (registrationName === ON_CLICK_KEY) {
|
|
571
|
-
var
|
|
609
|
+
var id = inst._rootNodeID;
|
|
610
|
+
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
|
|
572
611
|
if (!onClickListeners[id]) {
|
|
573
612
|
onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
|
|
574
613
|
}
|
|
575
614
|
}
|
|
576
615
|
},
|
|
577
616
|
|
|
578
|
-
willDeleteListener: function (
|
|
617
|
+
willDeleteListener: function (inst, registrationName) {
|
|
579
618
|
if (registrationName === ON_CLICK_KEY) {
|
|
619
|
+
var id = inst._rootNodeID;
|
|
580
620
|
onClickListeners[id].remove();
|
|
581
621
|
delete onClickListeners[id];
|
|
582
622
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 SyntheticAnimationEvent
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var SyntheticEvent = require('./SyntheticEvent');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @interface Event
|
|
18
|
+
* @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
|
|
19
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
|
|
20
|
+
*/
|
|
21
|
+
var AnimationEventInterface = {
|
|
22
|
+
animationName: null,
|
|
23
|
+
elapsedTime: null,
|
|
24
|
+
pseudoElement: null
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
29
|
+
* @param {string} dispatchMarker Marker identifying the event target.
|
|
30
|
+
* @param {object} nativeEvent Native browser event.
|
|
31
|
+
* @extends {SyntheticEvent}
|
|
32
|
+
*/
|
|
33
|
+
function SyntheticAnimationEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
|
|
34
|
+
return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
SyntheticEvent.augmentClass(SyntheticAnimationEvent, AnimationEventInterface);
|
|
38
|
+
|
|
39
|
+
module.exports = SyntheticAnimationEvent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule SyntheticClipboardEvent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -31,7 +30,7 @@ var ClipboardEventInterface = {
|
|
|
31
30
|
* @extends {SyntheticUIEvent}
|
|
32
31
|
*/
|
|
33
32
|
function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
|
|
34
|
-
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
33
|
+
return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule SyntheticCompositionEvent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -29,7 +28,7 @@ var CompositionEventInterface = {
|
|
|
29
28
|
* @extends {SyntheticUIEvent}
|
|
30
29
|
*/
|
|
31
30
|
function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
|
|
32
|
-
SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
31
|
+
return SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule SyntheticDragEvent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -29,7 +28,7 @@ var DragEventInterface = {
|
|
|
29
28
|
* @extends {SyntheticUIEvent}
|
|
30
29
|
*/
|
|
31
30
|
function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
|
|
32
|
-
SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
31
|
+
return SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
|
package/lib/SyntheticEvent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,17 +7,22 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule SyntheticEvent
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var PooledClass = require('./PooledClass');
|
|
16
17
|
|
|
17
|
-
var assign = require('./Object.assign');
|
|
18
18
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
19
19
|
var warning = require('fbjs/lib/warning');
|
|
20
20
|
|
|
21
|
+
var didWarnForAddedNewProperty = false;
|
|
22
|
+
var isProxySupported = typeof Proxy === 'function';
|
|
23
|
+
|
|
24
|
+
var shouldBeReleasedProperties = ['dispatchConfig', '_targetInst', 'nativeEvent', 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', '_dispatchInstances'];
|
|
25
|
+
|
|
21
26
|
/**
|
|
22
27
|
* @interface Event
|
|
23
28
|
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
|
@@ -51,12 +56,20 @@ var EventInterface = {
|
|
|
51
56
|
* DOM interface; custom application-specific events can also subclass this.
|
|
52
57
|
*
|
|
53
58
|
* @param {object} dispatchConfig Configuration used to dispatch this event.
|
|
54
|
-
* @param {
|
|
59
|
+
* @param {*} targetInst Marker identifying the event target.
|
|
55
60
|
* @param {object} nativeEvent Native browser event.
|
|
61
|
+
* @param {DOMEventTarget} nativeEventTarget Target node.
|
|
56
62
|
*/
|
|
57
|
-
function SyntheticEvent(dispatchConfig,
|
|
63
|
+
function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
|
|
64
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
65
|
+
// these have a getter/setter for warnings
|
|
66
|
+
delete this.nativeEvent;
|
|
67
|
+
delete this.preventDefault;
|
|
68
|
+
delete this.stopPropagation;
|
|
69
|
+
}
|
|
70
|
+
|
|
58
71
|
this.dispatchConfig = dispatchConfig;
|
|
59
|
-
this.
|
|
72
|
+
this._targetInst = targetInst;
|
|
60
73
|
this.nativeEvent = nativeEvent;
|
|
61
74
|
|
|
62
75
|
var Interface = this.constructor.Interface;
|
|
@@ -64,6 +77,9 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent
|
|
|
64
77
|
if (!Interface.hasOwnProperty(propName)) {
|
|
65
78
|
continue;
|
|
66
79
|
}
|
|
80
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
81
|
+
delete this[propName]; // this has a getter/setter for warnings
|
|
82
|
+
}
|
|
67
83
|
var normalize = Interface[propName];
|
|
68
84
|
if (normalize) {
|
|
69
85
|
this[propName] = normalize(nativeEvent);
|
|
@@ -83,16 +99,14 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent
|
|
|
83
99
|
this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
|
|
84
100
|
}
|
|
85
101
|
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
|
|
102
|
+
return this;
|
|
86
103
|
}
|
|
87
104
|
|
|
88
|
-
|
|
105
|
+
_assign(SyntheticEvent.prototype, {
|
|
89
106
|
|
|
90
107
|
preventDefault: function () {
|
|
91
108
|
this.defaultPrevented = true;
|
|
92
109
|
var event = this.nativeEvent;
|
|
93
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
94
|
-
process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
|
|
95
|
-
}
|
|
96
110
|
if (!event) {
|
|
97
111
|
return;
|
|
98
112
|
}
|
|
@@ -107,9 +121,6 @@ assign(SyntheticEvent.prototype, {
|
|
|
107
121
|
|
|
108
122
|
stopPropagation: function () {
|
|
109
123
|
var event = this.nativeEvent;
|
|
110
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
111
|
-
process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
|
|
112
|
-
}
|
|
113
124
|
if (!event) {
|
|
114
125
|
return;
|
|
115
126
|
}
|
|
@@ -144,17 +155,50 @@ assign(SyntheticEvent.prototype, {
|
|
|
144
155
|
destructor: function () {
|
|
145
156
|
var Interface = this.constructor.Interface;
|
|
146
157
|
for (var propName in Interface) {
|
|
147
|
-
|
|
158
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
159
|
+
Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
|
|
160
|
+
} else {
|
|
161
|
+
this[propName] = null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (var i = 0; i < shouldBeReleasedProperties.length; i++) {
|
|
165
|
+
this[shouldBeReleasedProperties[i]] = null;
|
|
166
|
+
}
|
|
167
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
168
|
+
var noop = require('fbjs/lib/emptyFunction');
|
|
169
|
+
Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
|
|
170
|
+
Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', noop));
|
|
171
|
+
Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', noop));
|
|
148
172
|
}
|
|
149
|
-
this.dispatchConfig = null;
|
|
150
|
-
this.dispatchMarker = null;
|
|
151
|
-
this.nativeEvent = null;
|
|
152
173
|
}
|
|
153
174
|
|
|
154
175
|
});
|
|
155
176
|
|
|
156
177
|
SyntheticEvent.Interface = EventInterface;
|
|
157
178
|
|
|
179
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
180
|
+
if (isProxySupported) {
|
|
181
|
+
/*eslint-disable no-func-assign */
|
|
182
|
+
SyntheticEvent = new Proxy(SyntheticEvent, {
|
|
183
|
+
construct: function (target, args) {
|
|
184
|
+
return this.apply(target, Object.create(target.prototype), args);
|
|
185
|
+
},
|
|
186
|
+
apply: function (constructor, that, args) {
|
|
187
|
+
return new Proxy(constructor.apply(that, args), {
|
|
188
|
+
set: function (target, prop, value) {
|
|
189
|
+
if (prop !== 'isPersistent' && !target.constructor.Interface.hasOwnProperty(prop) && shouldBeReleasedProperties.indexOf(prop) === -1) {
|
|
190
|
+
process.env.NODE_ENV !== 'production' ? warning(didWarnForAddedNewProperty || target.isPersistent(), 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re adding a new property in the synthetic event object. ' + 'The property is never released. See ' + 'https://fb.me/react-event-pooling for more information.') : void 0;
|
|
191
|
+
didWarnForAddedNewProperty = true;
|
|
192
|
+
}
|
|
193
|
+
target[prop] = value;
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
/*eslint-enable no-func-assign */
|
|
200
|
+
}
|
|
201
|
+
}
|
|
158
202
|
/**
|
|
159
203
|
* Helper to reduce boilerplate when creating subclasses.
|
|
160
204
|
*
|
|
@@ -164,12 +208,15 @@ SyntheticEvent.Interface = EventInterface;
|
|
|
164
208
|
SyntheticEvent.augmentClass = function (Class, Interface) {
|
|
165
209
|
var Super = this;
|
|
166
210
|
|
|
167
|
-
var
|
|
168
|
-
|
|
211
|
+
var E = function () {};
|
|
212
|
+
E.prototype = Super.prototype;
|
|
213
|
+
var prototype = new E();
|
|
214
|
+
|
|
215
|
+
_assign(prototype, Class.prototype);
|
|
169
216
|
Class.prototype = prototype;
|
|
170
217
|
Class.prototype.constructor = Class;
|
|
171
218
|
|
|
172
|
-
Class.Interface =
|
|
219
|
+
Class.Interface = _assign({}, Super.Interface, Interface);
|
|
173
220
|
Class.augmentClass = Super.augmentClass;
|
|
174
221
|
|
|
175
222
|
PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
|
|
@@ -177,4 +224,38 @@ SyntheticEvent.augmentClass = function (Class, Interface) {
|
|
|
177
224
|
|
|
178
225
|
PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
|
|
179
226
|
|
|
180
|
-
module.exports = SyntheticEvent;
|
|
227
|
+
module.exports = SyntheticEvent;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Helper to nullify syntheticEvent instance properties when destructing
|
|
231
|
+
*
|
|
232
|
+
* @param {object} SyntheticEvent
|
|
233
|
+
* @param {String} propName
|
|
234
|
+
* @return {object} defineProperty object
|
|
235
|
+
*/
|
|
236
|
+
function getPooledWarningPropertyDefinition(propName, getVal) {
|
|
237
|
+
var isFunction = typeof getVal === 'function';
|
|
238
|
+
return {
|
|
239
|
+
configurable: true,
|
|
240
|
+
set: set,
|
|
241
|
+
get: get
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function set(val) {
|
|
245
|
+
var action = isFunction ? 'setting the method' : 'setting the property';
|
|
246
|
+
warn(action, 'This is effectively a no-op');
|
|
247
|
+
return val;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function get() {
|
|
251
|
+
var action = isFunction ? 'accessing the method' : 'accessing the property';
|
|
252
|
+
var result = isFunction ? 'This is a no-op function' : 'This is set to null';
|
|
253
|
+
warn(action, result);
|
|
254
|
+
return getVal;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function warn(action, result) {
|
|
258
|
+
var warningCondition = false;
|
|
259
|
+
process.env.NODE_ENV !== 'production' ? warning(warningCondition, 'This synthetic event is reused for performance reasons. If you\'re seeing this, ' + 'you\'re %s `%s` on a released/nullified synthetic event. %s. ' + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
|
|
260
|
+
}
|
|
261
|
+
}
|