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,341 @@
|
|
|
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 ReactEventEmitter
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var EventConstants = require("./EventConstants");
|
|
23
|
+
var EventListener = require("./EventListener");
|
|
24
|
+
var EventPluginHub = require("./EventPluginHub");
|
|
25
|
+
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
26
|
+
var ReactEventEmitterMixin = require("./ReactEventEmitterMixin");
|
|
27
|
+
var ViewportMetrics = require("./ViewportMetrics");
|
|
28
|
+
|
|
29
|
+
var invariant = require("./invariant");
|
|
30
|
+
var isEventSupported = require("./isEventSupported");
|
|
31
|
+
var merge = require("./merge");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Summary of `ReactEventEmitter` event handling:
|
|
35
|
+
*
|
|
36
|
+
* - Top-level delegation is used to trap native browser events. We normalize
|
|
37
|
+
* and de-duplicate events to account for browser quirks.
|
|
38
|
+
*
|
|
39
|
+
* - Forward these native events (with the associated top-level type used to
|
|
40
|
+
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
|
|
41
|
+
* to extract any synthetic events.
|
|
42
|
+
*
|
|
43
|
+
* - The `EventPluginHub` will then process each event by annotating them with
|
|
44
|
+
* "dispatches", a sequence of listeners and IDs that care about that event.
|
|
45
|
+
*
|
|
46
|
+
* - The `EventPluginHub` then dispatches the events.
|
|
47
|
+
*
|
|
48
|
+
* Overview of React and the event system:
|
|
49
|
+
*
|
|
50
|
+
* .
|
|
51
|
+
* +------------+ .
|
|
52
|
+
* | DOM | .
|
|
53
|
+
* +------------+ . +-----------+
|
|
54
|
+
* + . +--------+|SimpleEvent|
|
|
55
|
+
* | . | |Plugin |
|
|
56
|
+
* +-----|------+ . v +-----------+
|
|
57
|
+
* | | | . +--------------+ +------------+
|
|
58
|
+
* | +-----------.--->|EventPluginHub| | Event |
|
|
59
|
+
* | | . | | +-----------+ | Propagators|
|
|
60
|
+
* | ReactEvent | . | | |TapEvent | |------------|
|
|
61
|
+
* | Emitter | . | |<---+|Plugin | |other plugin|
|
|
62
|
+
* | | . | | +-----------+ | utilities |
|
|
63
|
+
* | +-----------.---------+ | +------------+
|
|
64
|
+
* | | | . +----|---------+
|
|
65
|
+
* +-----|------+ . | ^ +-----------+
|
|
66
|
+
* | . | | |Enter/Leave|
|
|
67
|
+
* + . | +-------+|Plugin |
|
|
68
|
+
* +-------------+ . v +-----------+
|
|
69
|
+
* | application | . +----------+
|
|
70
|
+
* |-------------| . | callback |
|
|
71
|
+
* | | . | registry |
|
|
72
|
+
* | | . +----------+
|
|
73
|
+
* +-------------+ .
|
|
74
|
+
* .
|
|
75
|
+
* React Core . General Purpose Event Plugin System
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Traps top-level events by using event bubbling.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
82
|
+
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
83
|
+
* @param {DOMEventTarget} element Element on which to attach listener.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
function trapBubbledEvent(topLevelType, handlerBaseName, element) {
|
|
87
|
+
EventListener.listen(
|
|
88
|
+
element,
|
|
89
|
+
handlerBaseName,
|
|
90
|
+
ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
|
|
91
|
+
topLevelType
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Traps a top-level event by using event capturing.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
100
|
+
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
101
|
+
* @param {DOMEventTarget} element Element on which to attach listener.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function trapCapturedEvent(topLevelType, handlerBaseName, element) {
|
|
105
|
+
EventListener.capture(
|
|
106
|
+
element,
|
|
107
|
+
handlerBaseName,
|
|
108
|
+
ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
|
|
109
|
+
topLevelType
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Listens to window scroll and resize events. We cache scroll values so that
|
|
116
|
+
* application code can access them without triggering reflows.
|
|
117
|
+
*
|
|
118
|
+
* NOTE: Scroll events do not bubble.
|
|
119
|
+
*
|
|
120
|
+
* @private
|
|
121
|
+
* @see http://www.quirksmode.org/dom/events/scroll.html
|
|
122
|
+
*/
|
|
123
|
+
function registerScrollValueMonitoring() {
|
|
124
|
+
var refresh = ViewportMetrics.refreshScrollValues;
|
|
125
|
+
EventListener.listen(window, 'scroll', refresh);
|
|
126
|
+
EventListener.listen(window, 'resize', refresh);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* `ReactEventEmitter` is used to attach top-level event listeners. For example:
|
|
131
|
+
*
|
|
132
|
+
* ReactEventEmitter.putListener('myID', 'onClick', myFunction);
|
|
133
|
+
*
|
|
134
|
+
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* React references `ReactEventTopLevelCallback` using this property in order
|
|
142
|
+
* to allow dependency injection.
|
|
143
|
+
*/
|
|
144
|
+
TopLevelCallbackCreator: null,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Ensures that top-level event delegation listeners are installed.
|
|
148
|
+
*
|
|
149
|
+
* There are issues with listening to both touch events and mouse events on
|
|
150
|
+
* the top-level, so we make the caller choose which one to listen to. (If
|
|
151
|
+
* there's a touch top-level listeners, anchors don't receive clicks for some
|
|
152
|
+
* reason, and only in some cases).
|
|
153
|
+
*
|
|
154
|
+
* @param {boolean} touchNotMouse Listen to touch events instead of mouse.
|
|
155
|
+
* @param {DOMDocument} contentDocument DOM document to listen on
|
|
156
|
+
*/
|
|
157
|
+
ensureListening: function(touchNotMouse, contentDocument) {
|
|
158
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
159
|
+
ExecutionEnvironment.canUseDOM,
|
|
160
|
+
'ensureListening(...): Cannot toggle event listening in a Worker ' +
|
|
161
|
+
'thread. This is likely a bug in the framework. Please report ' +
|
|
162
|
+
'immediately.'
|
|
163
|
+
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
164
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
165
|
+
ReactEventEmitter.TopLevelCallbackCreator,
|
|
166
|
+
'ensureListening(...): Cannot be called without a top level callback ' +
|
|
167
|
+
'creator being injected.'
|
|
168
|
+
) : invariant(ReactEventEmitter.TopLevelCallbackCreator));
|
|
169
|
+
// Call out to base implementation.
|
|
170
|
+
ReactEventEmitterMixin.ensureListening.call(
|
|
171
|
+
ReactEventEmitter,
|
|
172
|
+
{
|
|
173
|
+
touchNotMouse: touchNotMouse,
|
|
174
|
+
contentDocument: contentDocument
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Sets whether or not any created callbacks should be enabled.
|
|
181
|
+
*
|
|
182
|
+
* @param {boolean} enabled True if callbacks should be enabled.
|
|
183
|
+
*/
|
|
184
|
+
setEnabled: function(enabled) {
|
|
185
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
186
|
+
ExecutionEnvironment.canUseDOM,
|
|
187
|
+
'setEnabled(...): Cannot toggle event listening in a Worker thread. ' +
|
|
188
|
+
'This is likely a bug in the framework. Please report immediately.'
|
|
189
|
+
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
190
|
+
if (ReactEventEmitter.TopLevelCallbackCreator) {
|
|
191
|
+
ReactEventEmitter.TopLevelCallbackCreator.setEnabled(enabled);
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @return {boolean} True if callbacks are enabled.
|
|
197
|
+
*/
|
|
198
|
+
isEnabled: function() {
|
|
199
|
+
return !!(
|
|
200
|
+
ReactEventEmitter.TopLevelCallbackCreator &&
|
|
201
|
+
ReactEventEmitter.TopLevelCallbackCreator.isEnabled()
|
|
202
|
+
);
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* We listen for bubbled touch events on the document object.
|
|
207
|
+
*
|
|
208
|
+
* Firefox v8.01 (and possibly others) exhibited strange behavior when
|
|
209
|
+
* mounting `onmousemove` events at some node that was not the document
|
|
210
|
+
* element. The symptoms were that if your mouse is not moving over something
|
|
211
|
+
* contained within that mount point (for example on the background) the
|
|
212
|
+
* top-level listeners for `onmousemove` won't be called. However, if you
|
|
213
|
+
* register the `mousemove` on the document object, then it will of course
|
|
214
|
+
* catch all `mousemove`s. This along with iOS quirks, justifies restricting
|
|
215
|
+
* top-level listeners to the document object only, at least for these
|
|
216
|
+
* movement types of events and possibly all events.
|
|
217
|
+
*
|
|
218
|
+
* @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
|
|
219
|
+
*
|
|
220
|
+
* Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
|
|
221
|
+
* they bubble to document.
|
|
222
|
+
*
|
|
223
|
+
* @param {boolean} touchNotMouse Listen to touch events instead of mouse.
|
|
224
|
+
* @param {DOMDocument} contentDocument Document which owns the container
|
|
225
|
+
* @private
|
|
226
|
+
* @see http://www.quirksmode.org/dom/events/keys.html.
|
|
227
|
+
*/
|
|
228
|
+
listenAtTopLevel: function(touchNotMouse, contentDocument) {
|
|
229
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
230
|
+
!contentDocument._isListening,
|
|
231
|
+
'listenAtTopLevel(...): Cannot setup top-level listener more than once.'
|
|
232
|
+
) : invariant(!contentDocument._isListening));
|
|
233
|
+
var topLevelTypes = EventConstants.topLevelTypes;
|
|
234
|
+
var mountAt = contentDocument;
|
|
235
|
+
|
|
236
|
+
registerScrollValueMonitoring();
|
|
237
|
+
trapBubbledEvent(topLevelTypes.topMouseOver, 'mouseover', mountAt);
|
|
238
|
+
trapBubbledEvent(topLevelTypes.topMouseDown, 'mousedown', mountAt);
|
|
239
|
+
trapBubbledEvent(topLevelTypes.topMouseUp, 'mouseup', mountAt);
|
|
240
|
+
trapBubbledEvent(topLevelTypes.topMouseMove, 'mousemove', mountAt);
|
|
241
|
+
trapBubbledEvent(topLevelTypes.topMouseOut, 'mouseout', mountAt);
|
|
242
|
+
trapBubbledEvent(topLevelTypes.topClick, 'click', mountAt);
|
|
243
|
+
trapBubbledEvent(topLevelTypes.topDoubleClick, 'dblclick', mountAt);
|
|
244
|
+
trapBubbledEvent(topLevelTypes.topContextMenu, 'contextmenu', mountAt);
|
|
245
|
+
if (touchNotMouse) {
|
|
246
|
+
trapBubbledEvent(topLevelTypes.topTouchStart, 'touchstart', mountAt);
|
|
247
|
+
trapBubbledEvent(topLevelTypes.topTouchEnd, 'touchend', mountAt);
|
|
248
|
+
trapBubbledEvent(topLevelTypes.topTouchMove, 'touchmove', mountAt);
|
|
249
|
+
trapBubbledEvent(topLevelTypes.topTouchCancel, 'touchcancel', mountAt);
|
|
250
|
+
}
|
|
251
|
+
trapBubbledEvent(topLevelTypes.topKeyUp, 'keyup', mountAt);
|
|
252
|
+
trapBubbledEvent(topLevelTypes.topKeyPress, 'keypress', mountAt);
|
|
253
|
+
trapBubbledEvent(topLevelTypes.topKeyDown, 'keydown', mountAt);
|
|
254
|
+
trapBubbledEvent(topLevelTypes.topInput, 'input', mountAt);
|
|
255
|
+
trapBubbledEvent(topLevelTypes.topChange, 'change', mountAt);
|
|
256
|
+
trapBubbledEvent(
|
|
257
|
+
topLevelTypes.topSelectionChange,
|
|
258
|
+
'selectionchange',
|
|
259
|
+
mountAt
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
trapBubbledEvent(
|
|
263
|
+
topLevelTypes.topCompositionEnd,
|
|
264
|
+
'compositionend',
|
|
265
|
+
mountAt
|
|
266
|
+
);
|
|
267
|
+
trapBubbledEvent(
|
|
268
|
+
topLevelTypes.topCompositionStart,
|
|
269
|
+
'compositionstart',
|
|
270
|
+
mountAt
|
|
271
|
+
);
|
|
272
|
+
trapBubbledEvent(
|
|
273
|
+
topLevelTypes.topCompositionUpdate,
|
|
274
|
+
'compositionupdate',
|
|
275
|
+
mountAt
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
if (isEventSupported('drag')) {
|
|
279
|
+
trapBubbledEvent(topLevelTypes.topDrag, 'drag', mountAt);
|
|
280
|
+
trapBubbledEvent(topLevelTypes.topDragEnd, 'dragend', mountAt);
|
|
281
|
+
trapBubbledEvent(topLevelTypes.topDragEnter, 'dragenter', mountAt);
|
|
282
|
+
trapBubbledEvent(topLevelTypes.topDragExit, 'dragexit', mountAt);
|
|
283
|
+
trapBubbledEvent(topLevelTypes.topDragLeave, 'dragleave', mountAt);
|
|
284
|
+
trapBubbledEvent(topLevelTypes.topDragOver, 'dragover', mountAt);
|
|
285
|
+
trapBubbledEvent(topLevelTypes.topDragStart, 'dragstart', mountAt);
|
|
286
|
+
trapBubbledEvent(topLevelTypes.topDrop, 'drop', mountAt);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (isEventSupported('wheel')) {
|
|
290
|
+
trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt);
|
|
291
|
+
} else if (isEventSupported('mousewheel')) {
|
|
292
|
+
trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt);
|
|
293
|
+
} else {
|
|
294
|
+
// Firefox needs to capture a different mouse scroll event.
|
|
295
|
+
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
|
|
296
|
+
trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// IE<9 does not support capturing so just trap the bubbled event there.
|
|
300
|
+
if (isEventSupported('scroll', true)) {
|
|
301
|
+
trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt);
|
|
302
|
+
} else {
|
|
303
|
+
trapBubbledEvent(topLevelTypes.topScroll, 'scroll', window);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (isEventSupported('focus', true)) {
|
|
307
|
+
trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt);
|
|
308
|
+
trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt);
|
|
309
|
+
} else if (isEventSupported('focusin')) {
|
|
310
|
+
// IE has `focusin` and `focusout` events which bubble.
|
|
311
|
+
// @see
|
|
312
|
+
// http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
|
|
313
|
+
trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt);
|
|
314
|
+
trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (isEventSupported('copy')) {
|
|
318
|
+
trapBubbledEvent(topLevelTypes.topCopy, 'copy', mountAt);
|
|
319
|
+
trapBubbledEvent(topLevelTypes.topCut, 'cut', mountAt);
|
|
320
|
+
trapBubbledEvent(topLevelTypes.topPaste, 'paste', mountAt);
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
registrationNames: EventPluginHub.registrationNames,
|
|
325
|
+
|
|
326
|
+
putListener: EventPluginHub.putListener,
|
|
327
|
+
|
|
328
|
+
getListener: EventPluginHub.getListener,
|
|
329
|
+
|
|
330
|
+
deleteListener: EventPluginHub.deleteListener,
|
|
331
|
+
|
|
332
|
+
deleteAllListeners: EventPluginHub.deleteAllListeners,
|
|
333
|
+
|
|
334
|
+
trapBubbledEvent: trapBubbledEvent,
|
|
335
|
+
|
|
336
|
+
trapCapturedEvent: trapCapturedEvent
|
|
337
|
+
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
module.exports = ReactEventEmitter;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 ReactEventEmitterMixin
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var EventPluginHub = require("./EventPluginHub");
|
|
22
|
+
var ReactUpdates = require("./ReactUpdates");
|
|
23
|
+
|
|
24
|
+
function runEventQueueInBatch(events) {
|
|
25
|
+
EventPluginHub.enqueueEvents(events);
|
|
26
|
+
EventPluginHub.processEventQueue();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var ReactEventEmitterMixin = {
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not `ensureListening` has been invoked.
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
_isListening: false,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Function, must be implemented. Listens to events on the top level of the
|
|
39
|
+
* application.
|
|
40
|
+
*
|
|
41
|
+
* @abstract
|
|
42
|
+
*
|
|
43
|
+
* listenAtTopLevel: null,
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Ensures that top-level event delegation listeners are installed.
|
|
48
|
+
*
|
|
49
|
+
* There are issues with listening to both touch events and mouse events on
|
|
50
|
+
* the top-level, so we make the caller choose which one to listen to. (If
|
|
51
|
+
* there's a touch top-level listeners, anchors don't receive clicks for some
|
|
52
|
+
* reason, and only in some cases).
|
|
53
|
+
*
|
|
54
|
+
* @param {*} config Configuration passed through to `listenAtTopLevel`.
|
|
55
|
+
*/
|
|
56
|
+
ensureListening: function(config) {
|
|
57
|
+
if (!config.contentDocument._reactIsListening) {
|
|
58
|
+
this.listenAtTopLevel(config.touchNotMouse, config.contentDocument);
|
|
59
|
+
config.contentDocument._reactIsListening = true;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Streams a fired top-level event to `EventPluginHub` where plugins have the
|
|
65
|
+
* opportunity to create `ReactEvent`s to be dispatched.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
68
|
+
* @param {object} topLevelTarget The listening component root node.
|
|
69
|
+
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
70
|
+
* @param {object} nativeEvent Native environment event.
|
|
71
|
+
*/
|
|
72
|
+
handleTopLevel: function(
|
|
73
|
+
topLevelType,
|
|
74
|
+
topLevelTarget,
|
|
75
|
+
topLevelTargetID,
|
|
76
|
+
nativeEvent) {
|
|
77
|
+
var events = EventPluginHub.extractEvents(
|
|
78
|
+
topLevelType,
|
|
79
|
+
topLevelTarget,
|
|
80
|
+
topLevelTargetID,
|
|
81
|
+
nativeEvent
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// Event queue being processed in the same cycle allows `preventDefault`.
|
|
85
|
+
ReactUpdates.batchedUpdates(runEventQueueInBatch, events);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports = ReactEventEmitterMixin;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 ReactEventTopLevelCallback
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var ReactEventEmitter = require("./ReactEventEmitter");
|
|
23
|
+
var ReactMount = require("./ReactMount");
|
|
24
|
+
|
|
25
|
+
var getEventTarget = require("./getEventTarget");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @type {boolean}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
var _topLevelListenersEnabled = true;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Top-level callback creator used to implement event handling using delegation.
|
|
35
|
+
* This is used via dependency injection.
|
|
36
|
+
*/
|
|
37
|
+
var ReactEventTopLevelCallback = {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sets whether or not any created callbacks should be enabled.
|
|
41
|
+
*
|
|
42
|
+
* @param {boolean} enabled True if callbacks should be enabled.
|
|
43
|
+
*/
|
|
44
|
+
setEnabled: function(enabled) {
|
|
45
|
+
_topLevelListenersEnabled = !!enabled;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @return {boolean} True if callbacks are enabled.
|
|
50
|
+
*/
|
|
51
|
+
isEnabled: function() {
|
|
52
|
+
return _topLevelListenersEnabled;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Creates a callback for the supplied `topLevelType` that could be added as
|
|
57
|
+
* a listener to the document. The callback computes a `topLevelTarget` which
|
|
58
|
+
* should be the root node of a mounted React component where the listener
|
|
59
|
+
* is attached.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} topLevelType Record from `EventConstants`.
|
|
62
|
+
* @return {function} Callback for handling top-level events.
|
|
63
|
+
*/
|
|
64
|
+
createTopLevelCallback: function(topLevelType) {
|
|
65
|
+
return function(nativeEvent) {
|
|
66
|
+
if (!_topLevelListenersEnabled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// TODO: Remove when synthetic events are ready, this is for IE<9.
|
|
70
|
+
if (nativeEvent.srcElement &&
|
|
71
|
+
nativeEvent.srcElement !== nativeEvent.target) {
|
|
72
|
+
nativeEvent.target = nativeEvent.srcElement;
|
|
73
|
+
}
|
|
74
|
+
var topLevelTarget = ReactMount.getFirstReactDOM(
|
|
75
|
+
getEventTarget(nativeEvent)
|
|
76
|
+
) || window;
|
|
77
|
+
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
|
|
78
|
+
ReactEventEmitter.handleTopLevel(
|
|
79
|
+
topLevelType,
|
|
80
|
+
topLevelTarget,
|
|
81
|
+
topLevelTargetID,
|
|
82
|
+
nativeEvent
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports = ReactEventTopLevelCallback;
|