react 0.14.0-beta1 → 0.14.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/addons.js +8 -3
- package/dist/react-with-addons.js +5048 -4095
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4555 -3729
- package/dist/react.min.js +6 -5
- package/lib/AutoFocusUtils.js +3 -3
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +27 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +15 -14
- package/lib/DOMChildrenOperations.js +22 -7
- package/lib/DOMProperty.js +8 -8
- package/lib/DOMPropertyOperations.js +23 -10
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +18 -10
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +29 -21
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +34 -38
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +24 -4
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +8 -8
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +3 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +36 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +48 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +72 -32
- package/lib/ReactClass.js +46 -46
- package/lib/ReactComponent.js +18 -16
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +95 -44
- package/lib/ReactDOM.js +74 -159
- package/lib/ReactDOMComponent.js +235 -93
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -81
- package/lib/ReactDOMInput.js +18 -9
- package/lib/ReactDOMOption.js +7 -7
- package/lib/ReactDOMSelect.js +9 -9
- package/lib/ReactDOMSelection.js +19 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +14 -12
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -25
- package/lib/ReactDefaultPerf.js +17 -11
- package/lib/ReactDefaultPerfAnalysis.js +13 -12
- package/lib/ReactElement.js +85 -39
- package/lib/ReactElementValidator.js +47 -90
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +53 -9
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +33 -21
- package/lib/ReactFragment.js +27 -118
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -11
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +186 -85
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNoopUpdateQueue.js +3 -3
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +38 -9
- package/lib/ReactReconcileTransaction.js +10 -8
- package/lib/ReactReconciler.js +5 -6
- package/lib/ReactRef.js +14 -2
- package/lib/ReactServerBatchingStrategy.js +5 -5
- package/lib/ReactServerRendering.js +12 -12
- package/lib/ReactServerRenderingTransaction.js +6 -5
- package/lib/ReactTestUtils.js +47 -39
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +19 -19
- package/lib/ReactUpdates.js +15 -15
- package/lib/{performance.js → ReactVersion.js} +3 -12
- package/lib/ReactWithAddons.js +24 -15
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +19 -9
- package/lib/SimpleEventPlugin.js +198 -43
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +18 -4
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +3 -3
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +7 -7
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +11 -6
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +7 -6
- package/lib/findDOMNode.js +9 -9
- package/lib/flattenChildren.js +4 -4
- package/lib/getEventKey.js +1 -1
- package/lib/{isTextNode.js → getTestDocument.js} +7 -11
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +15 -17
- package/lib/isEventSupported.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +25 -18
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17588
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/ReactDOMClient.js +0 -90
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -93
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/joinClasses.js +0 -39
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/memoizeStringOnly.js +0 -31
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -57
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var DOMProperty = require(
|
|
15
|
+
var DOMProperty = require('./DOMProperty');
|
|
16
|
+
var ReactPerf = require('./ReactPerf');
|
|
16
17
|
|
|
17
|
-
var quoteAttributeValueForBrowser = require(
|
|
18
|
-
var warning = require(
|
|
18
|
+
var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
19
20
|
|
|
20
21
|
// Simplified subset
|
|
21
|
-
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][
|
|
22
|
+
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
|
|
22
23
|
var illegalAttributeNameCache = {};
|
|
23
24
|
var validatedAttributeNameCache = {};
|
|
24
25
|
|
|
@@ -34,7 +35,7 @@ function isAttributeNameSafe(attributeName) {
|
|
|
34
35
|
return true;
|
|
35
36
|
}
|
|
36
37
|
illegalAttributeNameCache[attributeName] = true;
|
|
37
|
-
|
|
38
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
|
|
38
39
|
return false;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -42,7 +43,7 @@ function shouldIgnoreValue(propertyInfo, value) {
|
|
|
42
43
|
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
if (
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
46
47
|
var reactProps = {
|
|
47
48
|
children: true,
|
|
48
49
|
dangerouslySetInnerHTML: true,
|
|
@@ -64,7 +65,7 @@ if ('production' !== process.env.NODE_ENV) {
|
|
|
64
65
|
|
|
65
66
|
// For now, only warn when we have a suggested correction. This prevents
|
|
66
67
|
// logging too much when using transferPropsTo.
|
|
67
|
-
|
|
68
|
+
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -83,6 +84,10 @@ var DOMPropertyOperations = {
|
|
|
83
84
|
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
|
|
84
85
|
},
|
|
85
86
|
|
|
87
|
+
setAttributeForID: function (node, id) {
|
|
88
|
+
node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
|
|
89
|
+
},
|
|
90
|
+
|
|
86
91
|
/**
|
|
87
92
|
* Creates markup for a property.
|
|
88
93
|
*
|
|
@@ -106,7 +111,7 @@ var DOMPropertyOperations = {
|
|
|
106
111
|
return '';
|
|
107
112
|
}
|
|
108
113
|
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
109
|
-
} else if (
|
|
114
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
110
115
|
warnUnknownProperty(name);
|
|
111
116
|
}
|
|
112
117
|
return null;
|
|
@@ -148,6 +153,8 @@ var DOMPropertyOperations = {
|
|
|
148
153
|
// ('' + value) makes it output the correct toString()-value.
|
|
149
154
|
if (namespace) {
|
|
150
155
|
node.setAttributeNS(namespace, attributeName, '' + value);
|
|
156
|
+
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
|
157
|
+
node.setAttribute(attributeName, '');
|
|
151
158
|
} else {
|
|
152
159
|
node.setAttribute(attributeName, '' + value);
|
|
153
160
|
}
|
|
@@ -163,7 +170,7 @@ var DOMPropertyOperations = {
|
|
|
163
170
|
}
|
|
164
171
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
165
172
|
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
|
166
|
-
} else if (
|
|
173
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
167
174
|
warnUnknownProperty(name);
|
|
168
175
|
}
|
|
169
176
|
},
|
|
@@ -202,11 +209,17 @@ var DOMPropertyOperations = {
|
|
|
202
209
|
}
|
|
203
210
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
204
211
|
node.removeAttribute(name);
|
|
205
|
-
} else if (
|
|
212
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
206
213
|
warnUnknownProperty(name);
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
};
|
|
211
218
|
|
|
219
|
+
ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
|
|
220
|
+
setValueForProperty: 'setValueForProperty',
|
|
221
|
+
setValueForAttribute: 'setValueForAttribute',
|
|
222
|
+
deleteValueForProperty: 'deleteValueForProperty'
|
|
223
|
+
});
|
|
224
|
+
|
|
212
225
|
module.exports = DOMPropertyOperations;
|
package/lib/Danger.js
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ExecutionEnvironment = require(
|
|
15
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
16
16
|
|
|
17
|
-
var createNodesFromMarkup = require(
|
|
18
|
-
var emptyFunction = require(
|
|
19
|
-
var getMarkupWrap = require(
|
|
20
|
-
var invariant = require(
|
|
17
|
+
var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
|
18
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
19
|
+
var getMarkupWrap = require('fbjs/lib/getMarkupWrap');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
21
21
|
|
|
22
22
|
var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
|
|
23
23
|
var RESULT_INDEX_ATTR = 'data-danger-index';
|
|
@@ -49,12 +49,12 @@ var Danger = {
|
|
|
49
49
|
* @internal
|
|
50
50
|
*/
|
|
51
51
|
dangerouslyRenderMarkup: function (markupList) {
|
|
52
|
-
!ExecutionEnvironment.canUseDOM ?
|
|
52
|
+
!ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined;
|
|
53
53
|
var nodeName;
|
|
54
54
|
var markupByNodeName = {};
|
|
55
55
|
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
|
|
56
56
|
for (var i = 0; i < markupList.length; i++) {
|
|
57
|
-
!markupList[i] ?
|
|
57
|
+
!markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
|
|
58
58
|
nodeName = getNodeName(markupList[i]);
|
|
59
59
|
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
|
60
60
|
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
|
@@ -96,14 +96,14 @@ var Danger = {
|
|
|
96
96
|
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
|
97
97
|
renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
|
98
98
|
|
|
99
|
-
!!resultList.hasOwnProperty(resultIndex) ?
|
|
99
|
+
!!resultList.hasOwnProperty(resultIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
|
|
100
100
|
|
|
101
101
|
resultList[resultIndex] = renderNode;
|
|
102
102
|
|
|
103
103
|
// This should match resultList.length and markupList.length when
|
|
104
104
|
// we're done.
|
|
105
105
|
resultListAssignmentCount += 1;
|
|
106
|
-
} else if (
|
|
106
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
107
107
|
console.error('Danger: Discarding unexpected node:', renderNode);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -111,9 +111,9 @@ var Danger = {
|
|
|
111
111
|
|
|
112
112
|
// Although resultList was populated out of order, it should now be a dense
|
|
113
113
|
// array.
|
|
114
|
-
!(resultListAssignmentCount === resultList.length) ?
|
|
114
|
+
!(resultListAssignmentCount === resultList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
|
|
115
115
|
|
|
116
|
-
!(resultList.length === markupList.length) ?
|
|
116
|
+
!(resultList.length === markupList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
|
|
117
117
|
|
|
118
118
|
return resultList;
|
|
119
119
|
},
|
|
@@ -127,11 +127,16 @@ var Danger = {
|
|
|
127
127
|
* @internal
|
|
128
128
|
*/
|
|
129
129
|
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
|
130
|
-
!ExecutionEnvironment.canUseDOM ?
|
|
131
|
-
!markup ?
|
|
132
|
-
!(oldChild.tagName.toLowerCase() !== 'html') ?
|
|
133
|
-
|
|
134
|
-
var newChild
|
|
130
|
+
!ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
|
|
131
|
+
!markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
|
|
132
|
+
!(oldChild.tagName.toLowerCase() !== 'html') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined;
|
|
133
|
+
|
|
134
|
+
var newChild;
|
|
135
|
+
if (typeof markup === 'string') {
|
|
136
|
+
newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
137
|
+
} else {
|
|
138
|
+
newChild = markup;
|
|
139
|
+
}
|
|
135
140
|
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
136
141
|
}
|
|
137
142
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var keyOf = require(
|
|
14
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Module that is injectable into `EventPluginHub`, that specifies a
|
|
@@ -22,6 +22,6 @@ var keyOf = require("./keyOf");
|
|
|
22
22
|
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
|
|
23
23
|
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
|
|
24
24
|
*/
|
|
25
|
-
var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })
|
|
25
|
+
var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })];
|
|
26
26
|
|
|
27
27
|
module.exports = DefaultEventPluginOrder;
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var EventConstants = require(
|
|
16
|
-
var EventPropagators = require(
|
|
17
|
-
var SyntheticMouseEvent = require(
|
|
15
|
+
var EventConstants = require('./EventConstants');
|
|
16
|
+
var EventPropagators = require('./EventPropagators');
|
|
17
|
+
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
|
|
18
18
|
|
|
19
|
-
var ReactMount = require(
|
|
20
|
-
var keyOf = require(
|
|
19
|
+
var ReactMount = require('./ReactMount');
|
|
20
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
21
21
|
|
|
22
22
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
23
23
|
var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
|
@@ -76,13 +76,24 @@ var EnterLeaveEventPlugin = {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
var from
|
|
79
|
+
var from;
|
|
80
|
+
var to;
|
|
81
|
+
var fromID = '';
|
|
82
|
+
var toID = '';
|
|
80
83
|
if (topLevelType === topLevelTypes.topMouseOut) {
|
|
81
84
|
from = topLevelTarget;
|
|
82
|
-
|
|
85
|
+
fromID = topLevelTargetID;
|
|
86
|
+
to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement);
|
|
87
|
+
if (to) {
|
|
88
|
+
toID = ReactMount.getID(to);
|
|
89
|
+
} else {
|
|
90
|
+
to = win;
|
|
91
|
+
}
|
|
92
|
+
to = to || win;
|
|
83
93
|
} else {
|
|
84
94
|
from = win;
|
|
85
95
|
to = topLevelTarget;
|
|
96
|
+
toID = topLevelTargetID;
|
|
86
97
|
}
|
|
87
98
|
|
|
88
99
|
if (from === to) {
|
|
@@ -90,9 +101,6 @@ var EnterLeaveEventPlugin = {
|
|
|
90
101
|
return null;
|
|
91
102
|
}
|
|
92
103
|
|
|
93
|
-
var fromID = from ? ReactMount.getID(from) : '';
|
|
94
|
-
var toID = to ? ReactMount.getID(to) : '';
|
|
95
|
-
|
|
96
104
|
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
|
|
97
105
|
leave.type = 'mouseleave';
|
|
98
106
|
leave.target = from;
|
package/lib/EventConstants.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var keyMirror = require(
|
|
14
|
+
var keyMirror = require('fbjs/lib/keyMirror');
|
|
15
15
|
|
|
16
16
|
var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
|
17
17
|
|
|
@@ -19,7 +19,10 @@ var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
|
|
19
19
|
* Types of raw signals from the browser caught at the top level.
|
|
20
20
|
*/
|
|
21
21
|
var topLevelTypes = keyMirror({
|
|
22
|
+
topAbort: null,
|
|
22
23
|
topBlur: null,
|
|
24
|
+
topCanPlay: null,
|
|
25
|
+
topCanPlayThrough: null,
|
|
23
26
|
topChange: null,
|
|
24
27
|
topClick: null,
|
|
25
28
|
topCompositionEnd: null,
|
|
@@ -37,6 +40,10 @@ var topLevelTypes = keyMirror({
|
|
|
37
40
|
topDragOver: null,
|
|
38
41
|
topDragStart: null,
|
|
39
42
|
topDrop: null,
|
|
43
|
+
topDurationChange: null,
|
|
44
|
+
topEmptied: null,
|
|
45
|
+
topEncrypted: null,
|
|
46
|
+
topEnded: null,
|
|
40
47
|
topError: null,
|
|
41
48
|
topFocus: null,
|
|
42
49
|
topInput: null,
|
|
@@ -44,21 +51,36 @@ var topLevelTypes = keyMirror({
|
|
|
44
51
|
topKeyPress: null,
|
|
45
52
|
topKeyUp: null,
|
|
46
53
|
topLoad: null,
|
|
54
|
+
topLoadedData: null,
|
|
55
|
+
topLoadedMetadata: null,
|
|
56
|
+
topLoadStart: null,
|
|
47
57
|
topMouseDown: null,
|
|
48
58
|
topMouseMove: null,
|
|
49
59
|
topMouseOut: null,
|
|
50
60
|
topMouseOver: null,
|
|
51
61
|
topMouseUp: null,
|
|
52
62
|
topPaste: null,
|
|
63
|
+
topPause: null,
|
|
64
|
+
topPlay: null,
|
|
65
|
+
topPlaying: null,
|
|
66
|
+
topProgress: null,
|
|
67
|
+
topRateChange: null,
|
|
53
68
|
topReset: null,
|
|
54
69
|
topScroll: null,
|
|
70
|
+
topSeeked: null,
|
|
71
|
+
topSeeking: null,
|
|
55
72
|
topSelectionChange: null,
|
|
73
|
+
topStalled: null,
|
|
56
74
|
topSubmit: null,
|
|
75
|
+
topSuspend: null,
|
|
57
76
|
topTextInput: null,
|
|
77
|
+
topTimeUpdate: null,
|
|
58
78
|
topTouchCancel: null,
|
|
59
79
|
topTouchEnd: null,
|
|
60
80
|
topTouchMove: null,
|
|
61
81
|
topTouchStart: null,
|
|
82
|
+
topVolumeChange: null,
|
|
83
|
+
topWaiting: null,
|
|
62
84
|
topWheel: null
|
|
63
85
|
});
|
|
64
86
|
|
package/lib/EventPluginHub.js
CHANGED
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var EventPluginRegistry = require(
|
|
15
|
-
var EventPluginUtils = require(
|
|
14
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
15
|
+
var EventPluginUtils = require('./EventPluginUtils');
|
|
16
|
+
var ReactErrorUtils = require('./ReactErrorUtils');
|
|
16
17
|
|
|
17
|
-
var accumulateInto = require(
|
|
18
|
-
var forEachAccumulated = require(
|
|
19
|
-
var invariant = require(
|
|
20
|
-
var warning = require(
|
|
18
|
+
var accumulateInto = require('./accumulateInto');
|
|
19
|
+
var forEachAccumulated = require('./forEachAccumulated');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal store for event listeners
|
|
@@ -34,23 +35,24 @@ var eventQueue = null;
|
|
|
34
35
|
* Dispatches an event and releases it back into the pool, unless persistent.
|
|
35
36
|
*
|
|
36
37
|
* @param {?object} event Synthetic event to be dispatched.
|
|
38
|
+
* @param {boolean} simulated If the event is simulated (changes exn behavior)
|
|
37
39
|
* @private
|
|
38
40
|
*/
|
|
39
|
-
var executeDispatchesAndRelease = function (event) {
|
|
41
|
+
var executeDispatchesAndRelease = function (event, simulated) {
|
|
40
42
|
if (event) {
|
|
41
|
-
|
|
42
|
-
// Plugins can provide custom behavior when dispatching events.
|
|
43
|
-
var PluginModule = EventPluginRegistry.getPluginModuleForEvent(event);
|
|
44
|
-
if (PluginModule && PluginModule.executeDispatch) {
|
|
45
|
-
executeDispatch = PluginModule.executeDispatch;
|
|
46
|
-
}
|
|
47
|
-
EventPluginUtils.executeDispatchesInOrder(event, executeDispatch);
|
|
43
|
+
EventPluginUtils.executeDispatchesInOrder(event, simulated);
|
|
48
44
|
|
|
49
45
|
if (!event.isPersistent()) {
|
|
50
46
|
event.constructor.release(event);
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
};
|
|
50
|
+
var executeDispatchesAndReleaseSimulated = function (e) {
|
|
51
|
+
return executeDispatchesAndRelease(e, true);
|
|
52
|
+
};
|
|
53
|
+
var executeDispatchesAndReleaseTopLevel = function (e) {
|
|
54
|
+
return executeDispatchesAndRelease(e, false);
|
|
55
|
+
};
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
@@ -60,7 +62,7 @@ var InstanceHandle = null;
|
|
|
60
62
|
|
|
61
63
|
function validateInstanceHandle() {
|
|
62
64
|
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
|
|
63
|
-
|
|
65
|
+
process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
/**
|
|
@@ -104,13 +106,13 @@ var EventPluginHub = {
|
|
|
104
106
|
*/
|
|
105
107
|
injectInstanceHandle: function (InjectedInstanceHandle) {
|
|
106
108
|
InstanceHandle = InjectedInstanceHandle;
|
|
107
|
-
if (
|
|
109
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
108
110
|
validateInstanceHandle();
|
|
109
111
|
}
|
|
110
112
|
},
|
|
111
113
|
|
|
112
114
|
getInstanceHandle: function () {
|
|
113
|
-
if (
|
|
115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
114
116
|
validateInstanceHandle();
|
|
115
117
|
}
|
|
116
118
|
return InstanceHandle;
|
|
@@ -141,7 +143,7 @@ var EventPluginHub = {
|
|
|
141
143
|
* @param {?function} listener The callback to store.
|
|
142
144
|
*/
|
|
143
145
|
putListener: function (id, registrationName, listener) {
|
|
144
|
-
!(typeof listener === 'function') ?
|
|
146
|
+
!(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
|
|
145
147
|
|
|
146
148
|
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
|
147
149
|
bankForRegistrationName[id] = listener;
|
|
@@ -246,13 +248,19 @@ var EventPluginHub = {
|
|
|
246
248
|
*
|
|
247
249
|
* @internal
|
|
248
250
|
*/
|
|
249
|
-
processEventQueue: function () {
|
|
251
|
+
processEventQueue: function (simulated) {
|
|
250
252
|
// Set `eventQueue` to null before processing it so that we can tell if more
|
|
251
253
|
// events get enqueued while processing.
|
|
252
254
|
var processingEventQueue = eventQueue;
|
|
253
255
|
eventQueue = null;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
if (simulated) {
|
|
257
|
+
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
|
|
258
|
+
} else {
|
|
259
|
+
forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
|
|
260
|
+
}
|
|
261
|
+
!!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined;
|
|
262
|
+
// This would be a good time to rethrow if any of the event handlers threw.
|
|
263
|
+
ReactErrorUtils.rethrowCaughtError();
|
|
256
264
|
},
|
|
257
265
|
|
|
258
266
|
/**
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var invariant = require(
|
|
15
|
+
var invariant = require('fbjs/lib/invariant');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Injectable ordering of event plugins.
|
|
@@ -37,15 +37,15 @@ function recomputePluginOrdering() {
|
|
|
37
37
|
for (var pluginName in namesToPlugins) {
|
|
38
38
|
var PluginModule = namesToPlugins[pluginName];
|
|
39
39
|
var pluginIndex = EventPluginOrder.indexOf(pluginName);
|
|
40
|
-
!(pluginIndex > -1) ?
|
|
40
|
+
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
|
|
41
41
|
if (EventPluginRegistry.plugins[pluginIndex]) {
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
|
-
!PluginModule.extractEvents ?
|
|
44
|
+
!PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
|
|
45
45
|
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
|
|
46
46
|
var publishedEvents = PluginModule.eventTypes;
|
|
47
47
|
for (var eventName in publishedEvents) {
|
|
48
|
-
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ?
|
|
48
|
+
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -59,7 +59,7 @@ function recomputePluginOrdering() {
|
|
|
59
59
|
* @private
|
|
60
60
|
*/
|
|
61
61
|
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
62
|
-
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ?
|
|
62
|
+
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
|
|
63
63
|
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
|
64
64
|
|
|
65
65
|
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
|
@@ -87,7 +87,7 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
|
|
|
87
87
|
* @private
|
|
88
88
|
*/
|
|
89
89
|
function publishRegistrationName(registrationName, PluginModule, eventName) {
|
|
90
|
-
!!EventPluginRegistry.registrationNameModules[registrationName] ?
|
|
90
|
+
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
|
|
91
91
|
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
|
|
92
92
|
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
|
|
93
93
|
}
|
|
@@ -129,7 +129,7 @@ var EventPluginRegistry = {
|
|
|
129
129
|
* @see {EventPluginHub.injection.injectEventPluginOrder}
|
|
130
130
|
*/
|
|
131
131
|
injectEventPluginOrder: function (InjectedEventPluginOrder) {
|
|
132
|
-
!!EventPluginOrder ?
|
|
132
|
+
!!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
|
|
133
133
|
// Clone the ordering so it cannot be dynamically mutated.
|
|
134
134
|
EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
|
|
135
135
|
recomputePluginOrdering();
|
|
@@ -153,7 +153,7 @@ var EventPluginRegistry = {
|
|
|
153
153
|
}
|
|
154
154
|
var PluginModule = injectedNamesToPlugins[pluginName];
|
|
155
155
|
if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
|
|
156
|
-
!!namesToPlugins[pluginName] ?
|
|
156
|
+
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
|
|
157
157
|
namesToPlugins[pluginName] = PluginModule;
|
|
158
158
|
isOrderingDirty = true;
|
|
159
159
|
}
|