react 0.9.0-rc1 → 0.11.0-rc1
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 +3 -0
- package/dist/JSXTransformer.js +13445 -0
- package/dist/react-with-addons.js +20226 -0
- package/dist/react-with-addons.min.js +22 -0
- package/dist/react.js +18434 -0
- package/dist/react.min.js +21 -0
- package/lib/AutoFocusMixin.js +4 -2
- package/lib/BeforeInputEventPlugin.js +222 -0
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +1 -1
- package/lib/CSSPropertyOperations.js +4 -4
- package/lib/{ReactMountReady.js → CallbackQueue.js} +33 -25
- package/lib/ChangeEventPlugin.js +2 -2
- package/lib/ClientReactRootIndex.js +1 -1
- package/lib/CompositionEventPlugin.js +6 -2
- package/lib/DOMChildrenOperations.js +34 -21
- package/lib/DOMProperty.js +52 -22
- package/lib/DOMPropertyOperations.js +29 -17
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +2 -1
- package/lib/EnterLeaveEventPlugin.js +1 -1
- package/lib/EventConstants.js +2 -1
- package/lib/EventListener.js +5 -2
- package/lib/EventPluginHub.js +5 -6
- package/lib/EventPluginRegistry.js +27 -4
- package/lib/EventPluginUtils.js +12 -2
- package/lib/EventPropagators.js +1 -1
- package/lib/ExecutionEnvironment.js +9 -3
- package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +47 -58
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +27 -29
- package/lib/LocalEventTrapMixin.js +52 -0
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +39 -4
- package/lib/ReactBrowserComponentMixin.js +46 -0
- package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +118 -95
- package/lib/ReactCSSTransitionGroup.js +13 -11
- package/lib/ReactCSSTransitionGroupChild.js +3 -6
- package/lib/ReactChildren.js +35 -14
- package/lib/ReactComponent.js +120 -224
- package/lib/ReactComponentBrowserEnvironment.js +4 -37
- package/lib/ReactComponentWithPureRenderMixin.js +54 -0
- package/lib/ReactCompositeComponent.js +250 -288
- package/lib/ReactContext.js +1 -1
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +26 -24
- package/lib/ReactDOMButton.js +3 -2
- package/lib/ReactDOMComponent.js +43 -24
- package/lib/ReactDOMForm.js +8 -13
- package/lib/ReactDOMIDOperations.js +3 -32
- package/lib/ReactDOMImg.js +8 -14
- package/lib/ReactDOMInput.js +3 -2
- package/lib/ReactDOMOption.js +12 -8
- package/lib/ReactDOMSelect.js +19 -17
- package/lib/ReactDOMSelection.js +36 -11
- package/lib/ReactDOMTextarea.js +10 -8
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +28 -15
- package/lib/ReactDefaultPerf.js +29 -12
- package/lib/ReactDefaultPerfAnalysis.js +5 -1
- package/lib/ReactDescriptor.js +243 -0
- package/lib/ReactDescriptorValidator.js +283 -0
- package/lib/ReactEmptyComponent.js +78 -0
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -4
- package/lib/ReactEventListener.js +189 -0
- package/lib/ReactInjection.js +9 -3
- package/lib/ReactInputSelection.js +3 -2
- package/lib/ReactInstanceHandles.js +1 -1
- package/lib/ReactLink.js +25 -1
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +62 -22
- package/lib/ReactMultiChild.js +19 -14
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactOwner.js +7 -2
- package/lib/ReactPerf.js +1 -1
- package/lib/ReactPropTransferer.js +45 -30
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +222 -238
- package/lib/ReactPutListenerQueue.js +3 -3
- package/lib/ReactReconcileTransaction.js +22 -21
- package/lib/ReactRootIndex.js +1 -1
- package/lib/ReactServerRendering.js +42 -12
- package/lib/ReactServerRenderingTransaction.js +115 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +412 -0
- package/lib/ReactTextComponent.js +22 -14
- package/lib/ReactTransitionChildMapping.js +3 -3
- package/lib/ReactTransitionEvents.js +20 -1
- package/lib/ReactTransitionGroup.js +10 -7
- package/lib/ReactUpdates.js +140 -23
- package/lib/ReactWithAddons.js +13 -3
- package/lib/SVGDOMPropertyConfig.js +97 -0
- package/lib/SelectEventPlugin.js +1 -1
- package/lib/ServerReactRootIndex.js +1 -1
- package/lib/SimpleEventPlugin.js +8 -2
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +1 -1
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +52 -0
- package/lib/SyntheticKeyboardEvent.js +34 -5
- package/lib/SyntheticMouseEvent.js +4 -1
- package/lib/SyntheticTouchEvent.js +5 -2
- package/lib/SyntheticUIEvent.js +25 -3
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/Transaction.js +1 -33
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +11 -9
- package/lib/containsNode.js +1 -1
- package/lib/copyProperties.js +1 -1
- package/lib/createArrayFrom.js +1 -1
- package/lib/createFullPageComponent.js +2 -2
- package/lib/createNodesFromMarkup.js +1 -1
- package/lib/cx.js +1 -1
- package/lib/dangerousStyleValue.js +12 -6
- package/lib/emptyFunction.js +1 -1
- package/lib/{ReactComponentEnvironment.js → emptyObject.js} +7 -6
- package/lib/escapeTextForBrowser.js +3 -4
- package/lib/flattenChildren.js +10 -8
- package/lib/focusNode.js +33 -0
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventKey.js +36 -6
- package/lib/getEventModifierState.js +52 -0
- package/lib/getEventTarget.js +1 -1
- package/lib/getMarkupWrap.js +3 -1
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +2 -2
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +4 -1
- package/lib/hyphenateStyleName.js +46 -0
- package/lib/instantiateReactComponent.js +62 -0
- package/lib/invariant.js +21 -23
- package/lib/isEventSupported.js +1 -1
- package/lib/isNode.js +2 -2
- package/lib/isTextInputElement.js +1 -1
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/keyOf.js +1 -1
- package/lib/{objMap.js → mapObject.js} +9 -4
- package/lib/memoizeStringOnly.js +1 -1
- package/lib/merge.js +1 -1
- package/lib/mergeHelpers.js +12 -1
- package/lib/mergeInto.js +4 -3
- package/lib/mixInto.js +1 -1
- package/lib/monitorCodeUse.js +37 -0
- package/lib/onlyChild.js +4 -4
- package/lib/performance.js +33 -0
- package/lib/performanceNow.js +6 -15
- package/lib/setInnerHTML.js +77 -0
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +15 -29
- package/lib/toArray.js +1 -1
- package/lib/traverseAllChildren.js +10 -6
- package/lib/update.js +171 -0
- package/lib/warning.js +19 -11
- package/package.json +5 -3
- package/lib/ReactEventTopLevelCallback.js +0 -109
- package/lib/createObjectFrom.js +0 -61
- package/lib/objMapKeyVal.js +0 -47
package/lib/PooledClass.js
CHANGED
package/lib/React.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -25,6 +25,7 @@ var ReactComponent = require("./ReactComponent");
|
|
|
25
25
|
var ReactCompositeComponent = require("./ReactCompositeComponent");
|
|
26
26
|
var ReactContext = require("./ReactContext");
|
|
27
27
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
28
|
+
var ReactDescriptor = require("./ReactDescriptor");
|
|
28
29
|
var ReactDOM = require("./ReactDOM");
|
|
29
30
|
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
30
31
|
var ReactDefaultInjection = require("./ReactDefaultInjection");
|
|
@@ -52,6 +53,10 @@ var React = {
|
|
|
52
53
|
EventPluginUtils.useTouchEvents = shouldUseTouch;
|
|
53
54
|
},
|
|
54
55
|
createClass: ReactCompositeComponent.createClass,
|
|
56
|
+
createDescriptor: function(type, props, children) {
|
|
57
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
58
|
+
return type.apply(null, args);
|
|
59
|
+
},
|
|
55
60
|
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
|
|
56
61
|
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
|
|
57
62
|
renderComponent: ReactPerf.measure(
|
|
@@ -60,9 +65,11 @@ var React = {
|
|
|
60
65
|
ReactMount.renderComponent
|
|
61
66
|
),
|
|
62
67
|
renderComponentToString: ReactServerRendering.renderComponentToString,
|
|
68
|
+
renderComponentToStaticMarkup:
|
|
69
|
+
ReactServerRendering.renderComponentToStaticMarkup,
|
|
63
70
|
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
|
|
64
|
-
isValidClass:
|
|
65
|
-
isValidComponent:
|
|
71
|
+
isValidClass: ReactDescriptor.isValidFactory,
|
|
72
|
+
isValidComponent: ReactDescriptor.isValidDescriptor,
|
|
66
73
|
withContext: ReactContext.withContext,
|
|
67
74
|
__internals: {
|
|
68
75
|
Component: ReactComponent,
|
|
@@ -85,11 +92,39 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
85
92
|
'Download the React DevTools for a better development experience: ' +
|
|
86
93
|
'http://fb.me/react-devtools'
|
|
87
94
|
);
|
|
95
|
+
|
|
96
|
+
var expectedFeatures = [
|
|
97
|
+
// shims
|
|
98
|
+
Array.isArray,
|
|
99
|
+
Array.prototype.every,
|
|
100
|
+
Array.prototype.forEach,
|
|
101
|
+
Array.prototype.indexOf,
|
|
102
|
+
Array.prototype.map,
|
|
103
|
+
Date.now,
|
|
104
|
+
Function.prototype.bind,
|
|
105
|
+
Object.keys,
|
|
106
|
+
String.prototype.split,
|
|
107
|
+
String.prototype.trim,
|
|
108
|
+
|
|
109
|
+
// shams
|
|
110
|
+
Object.create,
|
|
111
|
+
Object.freeze
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
for (var i in expectedFeatures) {
|
|
115
|
+
if (!expectedFeatures[i]) {
|
|
116
|
+
console.error(
|
|
117
|
+
'One or more ES5 shim/shams expected by React are not available: ' +
|
|
118
|
+
'http://fb.me/react-warning-polyfills'
|
|
119
|
+
);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
88
123
|
}
|
|
89
124
|
}
|
|
90
125
|
|
|
91
126
|
// Version exists only in the open-source version of React, not in Facebook's
|
|
92
127
|
// internal version.
|
|
93
|
-
React.version = '0.
|
|
128
|
+
React.version = '0.11.0-rc1';
|
|
94
129
|
|
|
95
130
|
module.exports = React;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 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 ReactBrowserComponentMixin
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
22
|
+
var ReactMount = require("./ReactMount");
|
|
23
|
+
|
|
24
|
+
var invariant = require("./invariant");
|
|
25
|
+
|
|
26
|
+
var ReactBrowserComponentMixin = {
|
|
27
|
+
/**
|
|
28
|
+
* Returns the DOM node rendered by this component.
|
|
29
|
+
*
|
|
30
|
+
* @return {DOMElement} The root node of this component.
|
|
31
|
+
* @final
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
34
|
+
getDOMNode: function() {
|
|
35
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
36
|
+
this.isMounted(),
|
|
37
|
+
'getDOMNode(): A component must be mounted to have a DOM node.'
|
|
38
|
+
) : invariant(this.isMounted()));
|
|
39
|
+
if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return ReactMount.getNode(this._rootNodeID);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
module.exports = ReactBrowserComponentMixin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,29 +13,31 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
|
-
* @providesModule
|
|
16
|
+
* @providesModule ReactBrowserEventEmitter
|
|
17
17
|
* @typechecks static-only
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
22
|
var EventConstants = require("./EventConstants");
|
|
23
|
-
var EventListener = require("./EventListener");
|
|
24
23
|
var EventPluginHub = require("./EventPluginHub");
|
|
25
24
|
var EventPluginRegistry = require("./EventPluginRegistry");
|
|
26
|
-
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
27
25
|
var ReactEventEmitterMixin = require("./ReactEventEmitterMixin");
|
|
28
26
|
var ViewportMetrics = require("./ViewportMetrics");
|
|
29
27
|
|
|
30
|
-
var invariant = require("./invariant");
|
|
31
28
|
var isEventSupported = require("./isEventSupported");
|
|
32
29
|
var merge = require("./merge");
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
|
-
* Summary of `
|
|
32
|
+
* Summary of `ReactBrowserEventEmitter` event handling:
|
|
36
33
|
*
|
|
37
|
-
* - Top-level delegation is used to trap native browser events.
|
|
38
|
-
*
|
|
34
|
+
* - Top-level delegation is used to trap most native browser events. This
|
|
35
|
+
* may only occur in the main thread and is the responsibility of
|
|
36
|
+
* ReactEventListener, which is injected and can therefore support pluggable
|
|
37
|
+
* event sources. This is the only work that occurs in the main thread.
|
|
38
|
+
*
|
|
39
|
+
* - We normalize and de-duplicate events to account for browser quirks. This
|
|
40
|
+
* may be done in the worker thread.
|
|
39
41
|
*
|
|
40
42
|
* - Forward these native events (with the associated top-level type used to
|
|
41
43
|
* trap it) to `EventPluginHub`, which in turn will ask plugins if they want
|
|
@@ -48,11 +50,16 @@ var merge = require("./merge");
|
|
|
48
50
|
*
|
|
49
51
|
* Overview of React and the event system:
|
|
50
52
|
*
|
|
51
|
-
* .
|
|
52
53
|
* +------------+ .
|
|
53
54
|
* | DOM | .
|
|
55
|
+
* +------------+ .
|
|
56
|
+
* | .
|
|
57
|
+
* v .
|
|
58
|
+
* +------------+ .
|
|
59
|
+
* | ReactEvent | .
|
|
60
|
+
* | Listener | .
|
|
54
61
|
* +------------+ . +-----------+
|
|
55
|
-
*
|
|
62
|
+
* | . +--------+|SimpleEvent|
|
|
56
63
|
* | . | |Plugin |
|
|
57
64
|
* +-----|------+ . v +-----------+
|
|
58
65
|
* | | | . +--------------+ +------------+
|
|
@@ -115,6 +122,7 @@ var topEventMapping = {
|
|
|
115
122
|
topPaste: 'paste',
|
|
116
123
|
topScroll: 'scroll',
|
|
117
124
|
topSelectionChange: 'selectionchange',
|
|
125
|
+
topTextInput: 'textInput',
|
|
118
126
|
topTouchCancel: 'touchcancel',
|
|
119
127
|
topTouchEnd: 'touchend',
|
|
120
128
|
topTouchMove: 'touchmove',
|
|
@@ -128,7 +136,9 @@ var topEventMapping = {
|
|
|
128
136
|
var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2);
|
|
129
137
|
|
|
130
138
|
function getListeningForDocument(mountAt) {
|
|
131
|
-
|
|
139
|
+
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
|
|
140
|
+
// directly.
|
|
141
|
+
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
|
|
132
142
|
mountAt[topListenersIDKey] = reactTopListenersCounter++;
|
|
133
143
|
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
|
|
134
144
|
}
|
|
@@ -136,64 +146,31 @@ function getListeningForDocument(mountAt) {
|
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
142
|
-
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
143
|
-
* @param {DOMEventTarget} element Element on which to attach listener.
|
|
144
|
-
* @internal
|
|
145
|
-
*/
|
|
146
|
-
function trapBubbledEvent(topLevelType, handlerBaseName, element) {
|
|
147
|
-
EventListener.listen(
|
|
148
|
-
element,
|
|
149
|
-
handlerBaseName,
|
|
150
|
-
ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
|
|
151
|
-
topLevelType
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Traps a top-level event by using event capturing.
|
|
158
|
-
*
|
|
159
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
160
|
-
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
161
|
-
* @param {DOMEventTarget} element Element on which to attach listener.
|
|
162
|
-
* @internal
|
|
163
|
-
*/
|
|
164
|
-
function trapCapturedEvent(topLevelType, handlerBaseName, element) {
|
|
165
|
-
EventListener.capture(
|
|
166
|
-
element,
|
|
167
|
-
handlerBaseName,
|
|
168
|
-
ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
|
|
169
|
-
topLevelType
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* `ReactEventEmitter` is used to attach top-level event listeners. For example:
|
|
149
|
+
* `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
|
|
150
|
+
* example:
|
|
176
151
|
*
|
|
177
|
-
*
|
|
152
|
+
* ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
|
|
178
153
|
*
|
|
179
154
|
* This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
|
|
180
155
|
*
|
|
181
156
|
* @internal
|
|
182
157
|
*/
|
|
183
|
-
var
|
|
158
|
+
var ReactBrowserEventEmitter = merge(ReactEventEmitterMixin, {
|
|
184
159
|
|
|
185
160
|
/**
|
|
186
|
-
*
|
|
187
|
-
* to allow dependency injection.
|
|
161
|
+
* Injectable event backend
|
|
188
162
|
*/
|
|
189
|
-
|
|
163
|
+
ReactEventListener: null,
|
|
190
164
|
|
|
191
165
|
injection: {
|
|
192
166
|
/**
|
|
193
|
-
* @param {
|
|
167
|
+
* @param {object} ReactEventListener
|
|
194
168
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
169
|
+
injectReactEventListener: function(ReactEventListener) {
|
|
170
|
+
ReactEventListener.setHandleTopLevel(
|
|
171
|
+
ReactBrowserEventEmitter.handleTopLevel
|
|
172
|
+
);
|
|
173
|
+
ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
|
|
197
174
|
}
|
|
198
175
|
},
|
|
199
176
|
|
|
@@ -203,13 +180,8 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
203
180
|
* @param {boolean} enabled True if callbacks should be enabled.
|
|
204
181
|
*/
|
|
205
182
|
setEnabled: function(enabled) {
|
|
206
|
-
(
|
|
207
|
-
|
|
208
|
-
'setEnabled(...): Cannot toggle event listening in a Worker thread. ' +
|
|
209
|
-
'This is likely a bug in the framework. Please report immediately.'
|
|
210
|
-
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
211
|
-
if (ReactEventEmitter.TopLevelCallbackCreator) {
|
|
212
|
-
ReactEventEmitter.TopLevelCallbackCreator.setEnabled(enabled);
|
|
183
|
+
if (ReactBrowserEventEmitter.ReactEventListener) {
|
|
184
|
+
ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
|
|
213
185
|
}
|
|
214
186
|
},
|
|
215
187
|
|
|
@@ -218,8 +190,8 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
218
190
|
*/
|
|
219
191
|
isEnabled: function() {
|
|
220
192
|
return !!(
|
|
221
|
-
|
|
222
|
-
|
|
193
|
+
ReactBrowserEventEmitter.ReactEventListener &&
|
|
194
|
+
ReactBrowserEventEmitter.ReactEventListener.isEnabled()
|
|
223
195
|
);
|
|
224
196
|
},
|
|
225
197
|
|
|
@@ -242,10 +214,10 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
242
214
|
* they bubble to document.
|
|
243
215
|
*
|
|
244
216
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
245
|
-
* @param {
|
|
217
|
+
* @param {object} contentDocumentHandle Document which owns the container
|
|
246
218
|
*/
|
|
247
|
-
listenTo: function(registrationName,
|
|
248
|
-
var mountAt =
|
|
219
|
+
listenTo: function(registrationName, contentDocumentHandle) {
|
|
220
|
+
var mountAt = contentDocumentHandle;
|
|
249
221
|
var isListening = getListeningForDocument(mountAt);
|
|
250
222
|
var dependencies = EventPluginRegistry.
|
|
251
223
|
registrationNameDependencies[registrationName];
|
|
@@ -253,47 +225,85 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
253
225
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
254
226
|
for (var i = 0, l = dependencies.length; i < l; i++) {
|
|
255
227
|
var dependency = dependencies[i];
|
|
256
|
-
if (!
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
228
|
+
if (!(
|
|
229
|
+
isListening.hasOwnProperty(dependency) &&
|
|
230
|
+
isListening[dependency]
|
|
231
|
+
)) {
|
|
232
|
+
if (dependency === topLevelTypes.topWheel) {
|
|
260
233
|
if (isEventSupported('wheel')) {
|
|
261
|
-
trapBubbledEvent(
|
|
234
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
235
|
+
topLevelTypes.topWheel,
|
|
236
|
+
'wheel',
|
|
237
|
+
mountAt
|
|
238
|
+
);
|
|
262
239
|
} else if (isEventSupported('mousewheel')) {
|
|
263
|
-
trapBubbledEvent(
|
|
240
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
241
|
+
topLevelTypes.topWheel,
|
|
242
|
+
'mousewheel',
|
|
243
|
+
mountAt
|
|
244
|
+
);
|
|
264
245
|
} else {
|
|
265
246
|
// Firefox needs to capture a different mouse scroll event.
|
|
266
247
|
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
|
|
267
|
-
trapBubbledEvent(
|
|
248
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
268
249
|
topLevelTypes.topWheel,
|
|
269
250
|
'DOMMouseScroll',
|
|
270
|
-
mountAt
|
|
251
|
+
mountAt
|
|
252
|
+
);
|
|
271
253
|
}
|
|
272
|
-
} else if (
|
|
254
|
+
} else if (dependency === topLevelTypes.topScroll) {
|
|
273
255
|
|
|
274
256
|
if (isEventSupported('scroll', true)) {
|
|
275
|
-
trapCapturedEvent(
|
|
257
|
+
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
258
|
+
topLevelTypes.topScroll,
|
|
259
|
+
'scroll',
|
|
260
|
+
mountAt
|
|
261
|
+
);
|
|
276
262
|
} else {
|
|
277
|
-
trapBubbledEvent(
|
|
263
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
264
|
+
topLevelTypes.topScroll,
|
|
265
|
+
'scroll',
|
|
266
|
+
ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE
|
|
267
|
+
);
|
|
278
268
|
}
|
|
279
|
-
} else if (
|
|
280
|
-
|
|
269
|
+
} else if (dependency === topLevelTypes.topFocus ||
|
|
270
|
+
dependency === topLevelTypes.topBlur) {
|
|
281
271
|
|
|
282
272
|
if (isEventSupported('focus', true)) {
|
|
283
|
-
trapCapturedEvent(
|
|
284
|
-
|
|
273
|
+
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
274
|
+
topLevelTypes.topFocus,
|
|
275
|
+
'focus',
|
|
276
|
+
mountAt
|
|
277
|
+
);
|
|
278
|
+
ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
279
|
+
topLevelTypes.topBlur,
|
|
280
|
+
'blur',
|
|
281
|
+
mountAt
|
|
282
|
+
);
|
|
285
283
|
} else if (isEventSupported('focusin')) {
|
|
286
284
|
// IE has `focusin` and `focusout` events which bubble.
|
|
287
285
|
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
|
|
288
|
-
trapBubbledEvent(
|
|
289
|
-
|
|
286
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
287
|
+
topLevelTypes.topFocus,
|
|
288
|
+
'focusin',
|
|
289
|
+
mountAt
|
|
290
|
+
);
|
|
291
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
292
|
+
topLevelTypes.topBlur,
|
|
293
|
+
'focusout',
|
|
294
|
+
mountAt
|
|
295
|
+
);
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
// to make sure blur and focus event listeners are only attached once
|
|
293
299
|
isListening[topLevelTypes.topBlur] = true;
|
|
294
300
|
isListening[topLevelTypes.topFocus] = true;
|
|
295
|
-
} else if (topEventMapping
|
|
296
|
-
trapBubbledEvent(
|
|
301
|
+
} else if (topEventMapping.hasOwnProperty(dependency)) {
|
|
302
|
+
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
303
|
+
dependency,
|
|
304
|
+
topEventMapping[dependency],
|
|
305
|
+
mountAt
|
|
306
|
+
);
|
|
297
307
|
}
|
|
298
308
|
|
|
299
309
|
isListening[dependency] = true;
|
|
@@ -301,6 +311,22 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
301
311
|
}
|
|
302
312
|
},
|
|
303
313
|
|
|
314
|
+
trapBubbledEvent: function(topLevelType, handlerBaseName, handle) {
|
|
315
|
+
return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(
|
|
316
|
+
topLevelType,
|
|
317
|
+
handlerBaseName,
|
|
318
|
+
handle
|
|
319
|
+
);
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
trapCapturedEvent: function(topLevelType, handlerBaseName, handle) {
|
|
323
|
+
return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(
|
|
324
|
+
topLevelType,
|
|
325
|
+
handlerBaseName,
|
|
326
|
+
handle
|
|
327
|
+
);
|
|
328
|
+
},
|
|
329
|
+
|
|
304
330
|
/**
|
|
305
331
|
* Listens to window scroll and resize events. We cache scroll values so that
|
|
306
332
|
* application code can access them without triggering reflows.
|
|
@@ -312,12 +338,13 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
312
338
|
ensureScrollValueMonitoring: function(){
|
|
313
339
|
if (!isMonitoringScrollValue) {
|
|
314
340
|
var refresh = ViewportMetrics.refreshScrollValues;
|
|
315
|
-
|
|
316
|
-
EventListener.listen(window, 'resize', refresh);
|
|
341
|
+
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
|
|
317
342
|
isMonitoringScrollValue = true;
|
|
318
343
|
}
|
|
319
344
|
},
|
|
320
345
|
|
|
346
|
+
eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
|
|
347
|
+
|
|
321
348
|
registrationNameModules: EventPluginHub.registrationNameModules,
|
|
322
349
|
|
|
323
350
|
putListener: EventPluginHub.putListener,
|
|
@@ -326,12 +353,8 @@ var ReactEventEmitter = merge(ReactEventEmitterMixin, {
|
|
|
326
353
|
|
|
327
354
|
deleteListener: EventPluginHub.deleteListener,
|
|
328
355
|
|
|
329
|
-
deleteAllListeners: EventPluginHub.deleteAllListeners
|
|
330
|
-
|
|
331
|
-
trapBubbledEvent: trapBubbledEvent,
|
|
332
|
-
|
|
333
|
-
trapCapturedEvent: trapCapturedEvent
|
|
356
|
+
deleteAllListeners: EventPluginHub.deleteAllListeners
|
|
334
357
|
|
|
335
358
|
});
|
|
336
359
|
|
|
337
|
-
module.exports =
|
|
360
|
+
module.exports = ReactBrowserEventEmitter;
|