react 0.7.1 → 0.8.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/README.md +15 -228
- package/ReactJSErrors.js +40 -0
- package/addons.js +4 -0
- package/lib/$.js +46 -0
- package/lib/CSSCore.js +114 -0
- package/lib/CSSProperty.js +90 -0
- package/lib/CSSPropertyOperations.js +97 -0
- package/lib/CallbackRegistry.js +91 -0
- package/lib/ChangeEventPlugin.js +365 -0
- package/lib/CompositionEventPlugin.js +212 -0
- package/lib/DOMChildrenOperations.js +135 -0
- package/lib/DOMProperty.js +266 -0
- package/lib/DOMPropertyOperations.js +168 -0
- package/lib/Danger.js +186 -0
- package/lib/DefaultDOMPropertyConfig.js +187 -0
- package/lib/DefaultEventPluginOrder.js +44 -0
- package/lib/EnterLeaveEventPlugin.js +112 -0
- package/lib/EventConstants.js +73 -0
- package/lib/EventListener.js +61 -0
- package/lib/EventPluginHub.js +190 -0
- package/lib/EventPluginRegistry.js +237 -0
- package/lib/EventPluginUtils.js +185 -0
- package/lib/EventPropagators.js +179 -0
- package/lib/ExecutionEnvironment.js +41 -0
- package/lib/LinkedStateMixin.js +46 -0
- package/lib/LinkedValueMixin.js +68 -0
- package/lib/MobileSafariClickEventPlugin.js +63 -0
- package/lib/PooledClass.js +113 -0
- package/lib/React.js +71 -0
- package/lib/ReactChildren.js +132 -0
- package/lib/ReactComponent.js +515 -0
- package/lib/ReactComponentBrowserEnvironment.js +140 -0
- package/lib/ReactComponentEnvironment.js +24 -0
- package/lib/ReactCompositeComponent.js +1020 -0
- package/lib/ReactCurrentOwner.js +39 -0
- package/lib/ReactDOM.js +194 -0
- package/lib/ReactDOMButton.js +64 -0
- package/lib/ReactDOMComponent.js +374 -0
- package/lib/ReactDOMForm.js +52 -0
- package/lib/ReactDOMIDOperations.js +173 -0
- package/lib/ReactDOMInput.js +169 -0
- package/lib/ReactDOMOption.js +50 -0
- package/lib/ReactDOMSelect.js +160 -0
- package/lib/ReactDOMSelection.js +189 -0
- package/lib/ReactDOMTextarea.js +136 -0
- package/lib/ReactDefaultBatchingStrategy.js +75 -0
- package/lib/ReactDefaultInjection.js +91 -0
- package/lib/ReactDefaultPerf.js +407 -0
- package/lib/ReactErrorUtils.js +46 -0
- package/lib/ReactEventEmitter.js +341 -0
- package/lib/ReactEventEmitterMixin.js +89 -0
- package/lib/ReactEventTopLevelCallback.js +89 -0
- package/lib/ReactInputSelection.js +140 -0
- package/lib/ReactInstanceHandles.js +322 -0
- package/lib/ReactLink.js +54 -0
- package/lib/ReactMarkupChecksum.js +53 -0
- package/lib/ReactMount.js +617 -0
- package/lib/ReactMountReady.js +95 -0
- package/lib/ReactMultiChild.js +441 -0
- package/lib/ReactMultiChildUpdateTypes.js +36 -0
- package/lib/ReactOwner.js +146 -0
- package/lib/ReactPerf.js +88 -0
- package/lib/ReactPropTransferer.js +128 -0
- package/lib/ReactPropTypes.js +158 -0
- package/lib/ReactReconcileTransaction.js +161 -0
- package/lib/ReactServerRendering.js +62 -0
- package/lib/ReactStateSetters.js +111 -0
- package/lib/ReactTextComponent.js +94 -0
- package/lib/ReactTransitionEvents.js +97 -0
- package/lib/ReactTransitionGroup.js +112 -0
- package/lib/ReactTransitionKeySet.js +111 -0
- package/lib/ReactTransitionableChild.js +152 -0
- package/lib/ReactUpdates.js +145 -0
- package/lib/ReactWithAddons.js +41 -0
- package/lib/SelectEventPlugin.js +217 -0
- package/lib/SimpleEventPlugin.js +365 -0
- package/lib/SyntheticClipboardEvent.js +45 -0
- package/lib/SyntheticCompositionEvent.js +51 -0
- package/lib/SyntheticEvent.js +163 -0
- package/lib/SyntheticFocusEvent.js +44 -0
- package/lib/SyntheticKeyboardEvent.js +56 -0
- package/lib/SyntheticMouseEvent.js +85 -0
- package/lib/SyntheticTouchEvent.js +50 -0
- package/lib/SyntheticUIEvent.js +45 -0
- package/lib/SyntheticWheelEvent.js +63 -0
- package/lib/Transaction.js +251 -0
- package/lib/ViewportMetrics.js +37 -0
- package/lib/accumulate.js +54 -0
- package/lib/adler32.js +39 -0
- package/lib/containsNode.js +49 -0
- package/lib/copyProperties.js +54 -0
- package/lib/createArrayFrom.js +94 -0
- package/lib/createNodesFromMarkup.js +93 -0
- package/lib/createObjectFrom.js +61 -0
- package/lib/cx.js +44 -0
- package/lib/dangerousStyleValue.js +57 -0
- package/lib/emptyFunction.js +43 -0
- package/lib/escapeTextForBrowser.js +47 -0
- package/lib/ex.js +49 -0
- package/lib/filterAttributes.js +45 -0
- package/lib/flattenChildren.js +54 -0
- package/lib/forEachAccumulated.js +36 -0
- package/lib/ge.js +76 -0
- package/lib/getActiveElement.js +33 -0
- package/lib/getEventTarget.js +36 -0
- package/lib/getMarkupWrap.js +108 -0
- package/lib/getNodeForCharacterOffset.js +80 -0
- package/lib/getReactRootElementInContainer.js +40 -0
- package/lib/getTextContentAccessor.js +40 -0
- package/lib/getUnboundedScrollPosition.js +45 -0
- package/lib/hyphenate.js +35 -0
- package/lib/invariant.js +54 -0
- package/lib/isEventSupported.js +74 -0
- package/lib/isNode.js +33 -0
- package/lib/isTextInputElement.js +49 -0
- package/lib/isTextNode.js +30 -0
- package/lib/joinClasses.js +44 -0
- package/lib/keyMirror.js +58 -0
- package/lib/keyOf.js +41 -0
- package/lib/memoizeStringOnly.js +39 -0
- package/lib/merge.js +37 -0
- package/lib/mergeHelpers.js +137 -0
- package/lib/mergeInto.js +45 -0
- package/lib/mixInto.js +34 -0
- package/lib/mutateHTMLNodeWithMarkup.js +100 -0
- package/lib/objMap.js +47 -0
- package/lib/objMapKeyVal.js +47 -0
- package/lib/performanceNow.js +42 -0
- package/lib/shallowEqual.js +49 -0
- package/lib/traverseAllChildren.js +127 -0
- package/package.json +33 -31
- package/react.js +4 -0
- package/.npmignore +0 -7
- package/.travis.yml +0 -7
- package/Jakefile.js +0 -39
- package/LICENSE +0 -19
- package/browser-test/dist.html +0 -90
- package/browser-test/index.html +0 -86
- package/browser-test/min.html +0 -90
- package/dist/react.js +0 -3141
- package/dist/react.min.js +0 -22
- package/doc/advanced.md +0 -175
- package/doc/color-def.graffle +0 -938
- package/doc/color-def.png +0 -0
- package/doc/simple.dot +0 -25
- package/doc/simple.png +0 -0
- package/examples/longer-example.js +0 -41
- package/examples/simple.js +0 -45
- package/examples/using-ast-directly.js +0 -30
- package/examples/using-events1.js +0 -79
- package/examples/using-log-events.js +0 -43
- package/lib/base-task.js +0 -120
- package/lib/cb-task.js +0 -84
- package/lib/core.js +0 -138
- package/lib/dsl.js +0 -138
- package/lib/error.js +0 -55
- package/lib/event-collector.js +0 -81
- package/lib/event-manager.js +0 -89
- package/lib/eventemitter.js +0 -20
- package/lib/finalcb-first-task.js +0 -68
- package/lib/finalcb-task.js +0 -65
- package/lib/id.js +0 -22
- package/lib/input-parser.js +0 -56
- package/lib/log-events.js +0 -101
- package/lib/parse.js +0 -41
- package/lib/promise-resolve.js +0 -50
- package/lib/promise-task.js +0 -93
- package/lib/react.js +0 -59
- package/lib/ret-task.js +0 -71
- package/lib/sprintf.js +0 -18
- package/lib/status.js +0 -14
- package/lib/task.js +0 -251
- package/lib/track-tasks.js +0 -74
- package/lib/validate.js +0 -159
- package/lib/vcon.js +0 -113
- package/lib/when-task.js +0 -84
- package/src/dist.build.requirejs +0 -20
- package/test/ast.mocha.js +0 -136
- package/test/cb-task.mocha.js +0 -220
- package/test/core-deferred.mocha.js +0 -143
- package/test/core-when.mocha.js +0 -96
- package/test/core.mocha.js +0 -589
- package/test/dsl.mocha.js +0 -352
- package/test/event-manager.mocha.js +0 -119
- package/test/exec-options.mocha.js +0 -48
- package/test/finalcb-task.mocha.js +0 -58
- package/test/input-parser.mocha.js +0 -86
- package/test/log-events.mocha.js +0 -88
- package/test/mocha.opts +0 -2
- package/test/module-use.mocha.js +0 -164
- package/test/promise-auto-resolve.mocha.js +0 -68
- package/test/ret-task.mocha.js +0 -220
- package/test/task.mocha.js +0 -42
- package/test/validate-cb-task.mocha.js +0 -100
- package/test/validate-ret-task.mocha.js +0 -110
- package/test/validate.mocha.js +0 -324
- package/test/vcon.mocha.js +0 -193
- package/vendor/chai/chai.js +0 -4251
- package/vendor/jquery/jquery-1.7.1.js +0 -9266
- package/vendor/jquery/jquery-1.7.1.min.js +0 -4
- package/vendor/node/util.js +0 -531
- package/vendor/requirejs/require.js +0 -2045
- package/vendor/requirejs/require.min.js +0 -36
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule ReactWithAddons
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This module exists purely in the open source project, and is meant as a way
|
|
21
|
+
* to create a separate standalone build of React. This build has "addons", or
|
|
22
|
+
* functionality we've built and think might be useful but doesn't have a good
|
|
23
|
+
* place to live inside React core.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
"use strict";
|
|
27
|
+
|
|
28
|
+
var LinkedStateMixin = require("./LinkedStateMixin");
|
|
29
|
+
var React = require("./React");
|
|
30
|
+
var ReactTransitionGroup = require("./ReactTransitionGroup");
|
|
31
|
+
|
|
32
|
+
var cx = require("./cx");
|
|
33
|
+
|
|
34
|
+
React.addons = {
|
|
35
|
+
classSet: cx,
|
|
36
|
+
LinkedStateMixin: LinkedStateMixin,
|
|
37
|
+
TransitionGroup: ReactTransitionGroup
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = React;
|
|
41
|
+
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule SelectEventPlugin
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var EventConstants = require("./EventConstants");
|
|
22
|
+
var EventPluginHub = require("./EventPluginHub");
|
|
23
|
+
var EventPropagators = require("./EventPropagators");
|
|
24
|
+
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
25
|
+
var ReactInputSelection = require("./ReactInputSelection");
|
|
26
|
+
var SyntheticEvent = require("./SyntheticEvent");
|
|
27
|
+
|
|
28
|
+
var getActiveElement = require("./getActiveElement");
|
|
29
|
+
var isTextInputElement = require("./isTextInputElement");
|
|
30
|
+
var keyOf = require("./keyOf");
|
|
31
|
+
var shallowEqual = require("./shallowEqual");
|
|
32
|
+
|
|
33
|
+
var topLevelTypes = EventConstants.topLevelTypes;
|
|
34
|
+
|
|
35
|
+
var eventTypes = {
|
|
36
|
+
select: {
|
|
37
|
+
phasedRegistrationNames: {
|
|
38
|
+
bubbled: keyOf({onSelect: null}),
|
|
39
|
+
captured: keyOf({onSelectCapture: null})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var useSelectionChange = false;
|
|
45
|
+
|
|
46
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
47
|
+
useSelectionChange = 'onselectionchange' in document;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var activeElement = null;
|
|
51
|
+
var activeElementID = null;
|
|
52
|
+
var activeNativeEvent = null;
|
|
53
|
+
var lastSelection = null;
|
|
54
|
+
var mouseDown = false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get an object which is a unique representation of the current selection.
|
|
58
|
+
*
|
|
59
|
+
* The return value will not be consistent across nodes or browsers, but
|
|
60
|
+
* two identical selections on the same node will return identical objects.
|
|
61
|
+
*
|
|
62
|
+
* @param {DOMElement} node
|
|
63
|
+
* @param {object}
|
|
64
|
+
*/
|
|
65
|
+
function getSelection(node) {
|
|
66
|
+
if ('selectionStart' in node &&
|
|
67
|
+
ReactInputSelection.hasSelectionCapabilities(node)) {
|
|
68
|
+
return {
|
|
69
|
+
start: node.selectionStart,
|
|
70
|
+
end: node.selectionEnd
|
|
71
|
+
};
|
|
72
|
+
} else if (document.selection) {
|
|
73
|
+
var range = document.selection.createRange();
|
|
74
|
+
return {
|
|
75
|
+
parentElement: range.parentElement(),
|
|
76
|
+
text: range.text,
|
|
77
|
+
top: range.boundingTop,
|
|
78
|
+
left: range.boundingLeft
|
|
79
|
+
};
|
|
80
|
+
} else {
|
|
81
|
+
var selection = window.getSelection();
|
|
82
|
+
return {
|
|
83
|
+
anchorNode: selection.anchorNode,
|
|
84
|
+
anchorOffset: selection.anchorOffset,
|
|
85
|
+
focusNode: selection.focusNode,
|
|
86
|
+
focusOffset: selection.focusOffset
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Poll selection to see whether it's changed.
|
|
93
|
+
*
|
|
94
|
+
* @param {object} nativeEvent
|
|
95
|
+
* @return {?SyntheticEvent}
|
|
96
|
+
*/
|
|
97
|
+
function constructSelectEvent(nativeEvent) {
|
|
98
|
+
// Ensure we have the right element, and that the user is not dragging a
|
|
99
|
+
// selection (this matches native `select` event behavior).
|
|
100
|
+
if (mouseDown || activeElement != getActiveElement()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Only fire when selection has actually changed.
|
|
105
|
+
var currentSelection = getSelection(activeElement);
|
|
106
|
+
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
|
107
|
+
lastSelection = currentSelection;
|
|
108
|
+
|
|
109
|
+
var syntheticEvent = SyntheticEvent.getPooled(
|
|
110
|
+
eventTypes.select,
|
|
111
|
+
activeElementID,
|
|
112
|
+
nativeEvent
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
syntheticEvent.type = 'select';
|
|
116
|
+
syntheticEvent.target = activeElement;
|
|
117
|
+
|
|
118
|
+
EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
|
|
119
|
+
|
|
120
|
+
return syntheticEvent;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handle deferred event. And manually dispatch synthetic events.
|
|
126
|
+
*/
|
|
127
|
+
function dispatchDeferredSelectEvent() {
|
|
128
|
+
if (!activeNativeEvent) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var syntheticEvent = constructSelectEvent(activeNativeEvent);
|
|
133
|
+
activeNativeEvent = null;
|
|
134
|
+
|
|
135
|
+
// Enqueue and process the abstract event manually.
|
|
136
|
+
if (syntheticEvent) {
|
|
137
|
+
EventPluginHub.enqueueEvents(syntheticEvent);
|
|
138
|
+
EventPluginHub.processEventQueue();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* This plugin creates an `onSelect` event that normalizes select events
|
|
144
|
+
* across form elements.
|
|
145
|
+
*
|
|
146
|
+
* Supported elements are:
|
|
147
|
+
* - input (see `isTextInputElement`)
|
|
148
|
+
* - textarea
|
|
149
|
+
* - contentEditable
|
|
150
|
+
*
|
|
151
|
+
* This differs from native browser implementations in the following ways:
|
|
152
|
+
* - Fires on contentEditable fields as well as inputs.
|
|
153
|
+
* - Fires for collapsed selection.
|
|
154
|
+
* - Fires after user input.
|
|
155
|
+
*/
|
|
156
|
+
var SelectEventPlugin = {
|
|
157
|
+
|
|
158
|
+
eventTypes: eventTypes,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
162
|
+
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
163
|
+
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
164
|
+
* @param {object} nativeEvent Native browser event.
|
|
165
|
+
* @return {*} An accumulation of synthetic events.
|
|
166
|
+
* @see {EventPluginHub.extractEvents}
|
|
167
|
+
*/
|
|
168
|
+
extractEvents: function(
|
|
169
|
+
topLevelType,
|
|
170
|
+
topLevelTarget,
|
|
171
|
+
topLevelTargetID,
|
|
172
|
+
nativeEvent) {
|
|
173
|
+
|
|
174
|
+
switch (topLevelType) {
|
|
175
|
+
// Track the input node that has focus.
|
|
176
|
+
case topLevelTypes.topFocus:
|
|
177
|
+
if (isTextInputElement(topLevelTarget) ||
|
|
178
|
+
topLevelTarget.contentEditable === 'true') {
|
|
179
|
+
activeElement = topLevelTarget;
|
|
180
|
+
activeElementID = topLevelTargetID;
|
|
181
|
+
lastSelection = null;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case topLevelTypes.topBlur:
|
|
185
|
+
activeElement = null;
|
|
186
|
+
activeElementID = null;
|
|
187
|
+
lastSelection = null;
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
// Don't fire the event while the user is dragging. This matches the
|
|
191
|
+
// semantics of the native select event.
|
|
192
|
+
case topLevelTypes.topMouseDown:
|
|
193
|
+
mouseDown = true;
|
|
194
|
+
break;
|
|
195
|
+
case topLevelTypes.topContextMenu:
|
|
196
|
+
case topLevelTypes.topMouseUp:
|
|
197
|
+
mouseDown = false;
|
|
198
|
+
return constructSelectEvent(nativeEvent);
|
|
199
|
+
|
|
200
|
+
// Chrome and IE fire non-standard event when selection is changed (and
|
|
201
|
+
// sometimes when it hasn't).
|
|
202
|
+
case topLevelTypes.topSelectionChange:
|
|
203
|
+
return constructSelectEvent(nativeEvent);
|
|
204
|
+
|
|
205
|
+
// Firefox doesn't support selectionchange, so check selection status
|
|
206
|
+
// after each key entry.
|
|
207
|
+
case topLevelTypes.topKeyDown:
|
|
208
|
+
if (!useSelectionChange) {
|
|
209
|
+
activeNativeEvent = nativeEvent;
|
|
210
|
+
setTimeout(dispatchDeferredSelectEvent, 0);
|
|
211
|
+
}
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
module.exports = SelectEventPlugin;
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule SimpleEventPlugin
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var EventConstants = require("./EventConstants");
|
|
22
|
+
var EventPropagators = require("./EventPropagators");
|
|
23
|
+
var SyntheticClipboardEvent = require("./SyntheticClipboardEvent");
|
|
24
|
+
var SyntheticEvent = require("./SyntheticEvent");
|
|
25
|
+
var SyntheticFocusEvent = require("./SyntheticFocusEvent");
|
|
26
|
+
var SyntheticKeyboardEvent = require("./SyntheticKeyboardEvent");
|
|
27
|
+
var SyntheticMouseEvent = require("./SyntheticMouseEvent");
|
|
28
|
+
var SyntheticTouchEvent = require("./SyntheticTouchEvent");
|
|
29
|
+
var SyntheticUIEvent = require("./SyntheticUIEvent");
|
|
30
|
+
var SyntheticWheelEvent = require("./SyntheticWheelEvent");
|
|
31
|
+
|
|
32
|
+
var invariant = require("./invariant");
|
|
33
|
+
var keyOf = require("./keyOf");
|
|
34
|
+
|
|
35
|
+
var topLevelTypes = EventConstants.topLevelTypes;
|
|
36
|
+
|
|
37
|
+
var eventTypes = {
|
|
38
|
+
blur: {
|
|
39
|
+
phasedRegistrationNames: {
|
|
40
|
+
bubbled: keyOf({onBlur: true}),
|
|
41
|
+
captured: keyOf({onBlurCapture: true})
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
click: {
|
|
45
|
+
phasedRegistrationNames: {
|
|
46
|
+
bubbled: keyOf({onClick: true}),
|
|
47
|
+
captured: keyOf({onClickCapture: true})
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
contextMenu: {
|
|
51
|
+
phasedRegistrationNames: {
|
|
52
|
+
bubbled: keyOf({onContextMenu: true}),
|
|
53
|
+
captured: keyOf({onContextMenuCapture: true})
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
copy: {
|
|
57
|
+
phasedRegistrationNames: {
|
|
58
|
+
bubbled: keyOf({onCopy: true}),
|
|
59
|
+
captured: keyOf({onCopyCapture: true})
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
cut: {
|
|
63
|
+
phasedRegistrationNames: {
|
|
64
|
+
bubbled: keyOf({onCut: true}),
|
|
65
|
+
captured: keyOf({onCutCapture: true})
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
doubleClick: {
|
|
69
|
+
phasedRegistrationNames: {
|
|
70
|
+
bubbled: keyOf({onDoubleClick: true}),
|
|
71
|
+
captured: keyOf({onDoubleClickCapture: true})
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
drag: {
|
|
75
|
+
phasedRegistrationNames: {
|
|
76
|
+
bubbled: keyOf({onDrag: true}),
|
|
77
|
+
captured: keyOf({onDragCapture: true})
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
dragEnd: {
|
|
81
|
+
phasedRegistrationNames: {
|
|
82
|
+
bubbled: keyOf({onDragEnd: true}),
|
|
83
|
+
captured: keyOf({onDragEndCapture: true})
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
dragEnter: {
|
|
87
|
+
phasedRegistrationNames: {
|
|
88
|
+
bubbled: keyOf({onDragEnter: true}),
|
|
89
|
+
captured: keyOf({onDragEnterCapture: true})
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
dragExit: {
|
|
93
|
+
phasedRegistrationNames: {
|
|
94
|
+
bubbled: keyOf({onDragExit: true}),
|
|
95
|
+
captured: keyOf({onDragExitCapture: true})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
dragLeave: {
|
|
99
|
+
phasedRegistrationNames: {
|
|
100
|
+
bubbled: keyOf({onDragLeave: true}),
|
|
101
|
+
captured: keyOf({onDragLeaveCapture: true})
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
dragOver: {
|
|
105
|
+
phasedRegistrationNames: {
|
|
106
|
+
bubbled: keyOf({onDragOver: true}),
|
|
107
|
+
captured: keyOf({onDragOverCapture: true})
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
dragStart: {
|
|
111
|
+
phasedRegistrationNames: {
|
|
112
|
+
bubbled: keyOf({onDragStart: true}),
|
|
113
|
+
captured: keyOf({onDragStartCapture: true})
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
drop: {
|
|
117
|
+
phasedRegistrationNames: {
|
|
118
|
+
bubbled: keyOf({onDrop: true}),
|
|
119
|
+
captured: keyOf({onDropCapture: true})
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
focus: {
|
|
123
|
+
phasedRegistrationNames: {
|
|
124
|
+
bubbled: keyOf({onFocus: true}),
|
|
125
|
+
captured: keyOf({onFocusCapture: true})
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
input: {
|
|
129
|
+
phasedRegistrationNames: {
|
|
130
|
+
bubbled: keyOf({onInput: true}),
|
|
131
|
+
captured: keyOf({onInputCapture: true})
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
keyDown: {
|
|
135
|
+
phasedRegistrationNames: {
|
|
136
|
+
bubbled: keyOf({onKeyDown: true}),
|
|
137
|
+
captured: keyOf({onKeyDownCapture: true})
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
keyPress: {
|
|
141
|
+
phasedRegistrationNames: {
|
|
142
|
+
bubbled: keyOf({onKeyPress: true}),
|
|
143
|
+
captured: keyOf({onKeyPressCapture: true})
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
keyUp: {
|
|
147
|
+
phasedRegistrationNames: {
|
|
148
|
+
bubbled: keyOf({onKeyUp: true}),
|
|
149
|
+
captured: keyOf({onKeyUpCapture: true})
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
// Note: We do not allow listening to mouseOver events. Instead, use the
|
|
153
|
+
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
|
|
154
|
+
mouseDown: {
|
|
155
|
+
phasedRegistrationNames: {
|
|
156
|
+
bubbled: keyOf({onMouseDown: true}),
|
|
157
|
+
captured: keyOf({onMouseDownCapture: true})
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
mouseMove: {
|
|
161
|
+
phasedRegistrationNames: {
|
|
162
|
+
bubbled: keyOf({onMouseMove: true}),
|
|
163
|
+
captured: keyOf({onMouseMoveCapture: true})
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
mouseUp: {
|
|
167
|
+
phasedRegistrationNames: {
|
|
168
|
+
bubbled: keyOf({onMouseUp: true}),
|
|
169
|
+
captured: keyOf({onMouseUpCapture: true})
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
paste: {
|
|
173
|
+
phasedRegistrationNames: {
|
|
174
|
+
bubbled: keyOf({onPaste: true}),
|
|
175
|
+
captured: keyOf({onPasteCapture: true})
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
scroll: {
|
|
179
|
+
phasedRegistrationNames: {
|
|
180
|
+
bubbled: keyOf({onScroll: true}),
|
|
181
|
+
captured: keyOf({onScrollCapture: true})
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
submit: {
|
|
185
|
+
phasedRegistrationNames: {
|
|
186
|
+
bubbled: keyOf({onSubmit: true}),
|
|
187
|
+
captured: keyOf({onSubmitCapture: true})
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
touchCancel: {
|
|
191
|
+
phasedRegistrationNames: {
|
|
192
|
+
bubbled: keyOf({onTouchCancel: true}),
|
|
193
|
+
captured: keyOf({onTouchCancelCapture: true})
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
touchEnd: {
|
|
197
|
+
phasedRegistrationNames: {
|
|
198
|
+
bubbled: keyOf({onTouchEnd: true}),
|
|
199
|
+
captured: keyOf({onTouchEndCapture: true})
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
touchMove: {
|
|
203
|
+
phasedRegistrationNames: {
|
|
204
|
+
bubbled: keyOf({onTouchMove: true}),
|
|
205
|
+
captured: keyOf({onTouchMoveCapture: true})
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
touchStart: {
|
|
209
|
+
phasedRegistrationNames: {
|
|
210
|
+
bubbled: keyOf({onTouchStart: true}),
|
|
211
|
+
captured: keyOf({onTouchStartCapture: true})
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
wheel: {
|
|
215
|
+
phasedRegistrationNames: {
|
|
216
|
+
bubbled: keyOf({onWheel: true}),
|
|
217
|
+
captured: keyOf({onWheelCapture: true})
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
var topLevelEventsToDispatchConfig = {
|
|
223
|
+
topBlur: eventTypes.blur,
|
|
224
|
+
topClick: eventTypes.click,
|
|
225
|
+
topContextMenu: eventTypes.contextMenu,
|
|
226
|
+
topCopy: eventTypes.copy,
|
|
227
|
+
topCut: eventTypes.cut,
|
|
228
|
+
topDoubleClick: eventTypes.doubleClick,
|
|
229
|
+
topDrag: eventTypes.drag,
|
|
230
|
+
topDragEnd: eventTypes.dragEnd,
|
|
231
|
+
topDragEnter: eventTypes.dragEnter,
|
|
232
|
+
topDragExit: eventTypes.dragExit,
|
|
233
|
+
topDragLeave: eventTypes.dragLeave,
|
|
234
|
+
topDragOver: eventTypes.dragOver,
|
|
235
|
+
topDragStart: eventTypes.dragStart,
|
|
236
|
+
topDrop: eventTypes.drop,
|
|
237
|
+
topFocus: eventTypes.focus,
|
|
238
|
+
topInput: eventTypes.input,
|
|
239
|
+
topKeyDown: eventTypes.keyDown,
|
|
240
|
+
topKeyPress: eventTypes.keyPress,
|
|
241
|
+
topKeyUp: eventTypes.keyUp,
|
|
242
|
+
topMouseDown: eventTypes.mouseDown,
|
|
243
|
+
topMouseMove: eventTypes.mouseMove,
|
|
244
|
+
topMouseUp: eventTypes.mouseUp,
|
|
245
|
+
topPaste: eventTypes.paste,
|
|
246
|
+
topScroll: eventTypes.scroll,
|
|
247
|
+
topSubmit: eventTypes.submit,
|
|
248
|
+
topTouchCancel: eventTypes.touchCancel,
|
|
249
|
+
topTouchEnd: eventTypes.touchEnd,
|
|
250
|
+
topTouchMove: eventTypes.touchMove,
|
|
251
|
+
topTouchStart: eventTypes.touchStart,
|
|
252
|
+
topWheel: eventTypes.wheel
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
var SimpleEventPlugin = {
|
|
256
|
+
|
|
257
|
+
eventTypes: eventTypes,
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Same as the default implementation, except cancels the event when return
|
|
261
|
+
* value is false.
|
|
262
|
+
*
|
|
263
|
+
* @param {object} Event to be dispatched.
|
|
264
|
+
* @param {function} Application-level callback.
|
|
265
|
+
* @param {string} domID DOM ID to pass to the callback.
|
|
266
|
+
*/
|
|
267
|
+
executeDispatch: function(event, listener, domID) {
|
|
268
|
+
var returnValue = listener(event, domID);
|
|
269
|
+
if (returnValue === false) {
|
|
270
|
+
event.stopPropagation();
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
277
|
+
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
278
|
+
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
279
|
+
* @param {object} nativeEvent Native browser event.
|
|
280
|
+
* @return {*} An accumulation of synthetic events.
|
|
281
|
+
* @see {EventPluginHub.extractEvents}
|
|
282
|
+
*/
|
|
283
|
+
extractEvents: function(
|
|
284
|
+
topLevelType,
|
|
285
|
+
topLevelTarget,
|
|
286
|
+
topLevelTargetID,
|
|
287
|
+
nativeEvent) {
|
|
288
|
+
var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
|
|
289
|
+
if (!dispatchConfig) {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
var EventConstructor;
|
|
293
|
+
switch(topLevelType) {
|
|
294
|
+
case topLevelTypes.topInput:
|
|
295
|
+
case topLevelTypes.topSubmit:
|
|
296
|
+
// HTML Events
|
|
297
|
+
// @see http://www.w3.org/TR/html5/index.html#events-0
|
|
298
|
+
EventConstructor = SyntheticEvent;
|
|
299
|
+
break;
|
|
300
|
+
case topLevelTypes.topKeyDown:
|
|
301
|
+
case topLevelTypes.topKeyPress:
|
|
302
|
+
case topLevelTypes.topKeyUp:
|
|
303
|
+
EventConstructor = SyntheticKeyboardEvent;
|
|
304
|
+
break;
|
|
305
|
+
case topLevelTypes.topBlur:
|
|
306
|
+
case topLevelTypes.topFocus:
|
|
307
|
+
EventConstructor = SyntheticFocusEvent;
|
|
308
|
+
break;
|
|
309
|
+
case topLevelTypes.topClick:
|
|
310
|
+
// Firefox creates a click event on right mouse clicks. This removes the
|
|
311
|
+
// unwanted click events.
|
|
312
|
+
if (nativeEvent.button === 2) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
/* falls through */
|
|
316
|
+
case topLevelTypes.topContextMenu:
|
|
317
|
+
case topLevelTypes.topDoubleClick:
|
|
318
|
+
case topLevelTypes.topDrag:
|
|
319
|
+
case topLevelTypes.topDragEnd:
|
|
320
|
+
case topLevelTypes.topDragEnter:
|
|
321
|
+
case topLevelTypes.topDragExit:
|
|
322
|
+
case topLevelTypes.topDragLeave:
|
|
323
|
+
case topLevelTypes.topDragOver:
|
|
324
|
+
case topLevelTypes.topDragStart:
|
|
325
|
+
case topLevelTypes.topDrop:
|
|
326
|
+
case topLevelTypes.topMouseDown:
|
|
327
|
+
case topLevelTypes.topMouseMove:
|
|
328
|
+
case topLevelTypes.topMouseUp:
|
|
329
|
+
EventConstructor = SyntheticMouseEvent;
|
|
330
|
+
break;
|
|
331
|
+
case topLevelTypes.topTouchCancel:
|
|
332
|
+
case topLevelTypes.topTouchEnd:
|
|
333
|
+
case topLevelTypes.topTouchMove:
|
|
334
|
+
case topLevelTypes.topTouchStart:
|
|
335
|
+
EventConstructor = SyntheticTouchEvent;
|
|
336
|
+
break;
|
|
337
|
+
case topLevelTypes.topScroll:
|
|
338
|
+
EventConstructor = SyntheticUIEvent;
|
|
339
|
+
break;
|
|
340
|
+
case topLevelTypes.topWheel:
|
|
341
|
+
EventConstructor = SyntheticWheelEvent;
|
|
342
|
+
break;
|
|
343
|
+
case topLevelTypes.topCopy:
|
|
344
|
+
case topLevelTypes.topCut:
|
|
345
|
+
case topLevelTypes.topPaste:
|
|
346
|
+
EventConstructor = SyntheticClipboardEvent;
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
350
|
+
EventConstructor,
|
|
351
|
+
'SimpleEventPlugin: Unhandled event type, `%s`.',
|
|
352
|
+
topLevelType
|
|
353
|
+
) : invariant(EventConstructor));
|
|
354
|
+
var event = EventConstructor.getPooled(
|
|
355
|
+
dispatchConfig,
|
|
356
|
+
topLevelTargetID,
|
|
357
|
+
nativeEvent
|
|
358
|
+
);
|
|
359
|
+
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
360
|
+
return event;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
module.exports = SimpleEventPlugin;
|