react 0.14.9 → 15.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/addons.js +2 -0
- package/dist/react-with-addons.js +4299 -4138
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4059 -3644
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +21 -7
- package/lib/CallbackQueue.js +12 -1
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +15 -36
- package/lib/DOMPropertyOperations.js +40 -52
- package/lib/Danger.js +6 -7
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +20 -64
- package/lib/EventPluginRegistry.js +23 -2
- package/lib/EventPluginUtils.js +60 -35
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +2 -3
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +14 -12
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +21 -70
- package/lib/ReactComponent.js +4 -5
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +3 -3
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +146 -55
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +26 -14
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +162 -231
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +9 -8
- package/lib/ReactDOMSelect.js +38 -15
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +32 -5
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +2 -2
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +2 -2
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +4 -6
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +74 -447
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +2 -2
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +1 -24
- package/lib/ReactOwner.js +5 -4
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +16 -34
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +30 -21
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +4 -63
- package/lib/ReactUpdates.js +19 -2
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +53 -65
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +56 -16
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +97 -17
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +1 -1
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +3 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +1 -1
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +7 -9
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +6 -6
- package/lib/update.js +2 -2
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,19 +7,18 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule DOMPropertyOperations
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
14
|
var DOMProperty = require('./DOMProperty');
|
|
15
|
+
var ReactDOMInstrumentation = require('./ReactDOMInstrumentation');
|
|
16
16
|
var ReactPerf = require('./ReactPerf');
|
|
17
17
|
|
|
18
18
|
var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
|
|
19
19
|
var warning = require('fbjs/lib/warning');
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
|
|
21
|
+
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
|
|
23
22
|
var illegalAttributeNameCache = {};
|
|
24
23
|
var validatedAttributeNameCache = {};
|
|
25
24
|
|
|
@@ -43,32 +42,6 @@ function shouldIgnoreValue(propertyInfo, value) {
|
|
|
43
42
|
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
-
var reactProps = {
|
|
48
|
-
children: true,
|
|
49
|
-
dangerouslySetInnerHTML: true,
|
|
50
|
-
key: true,
|
|
51
|
-
ref: true
|
|
52
|
-
};
|
|
53
|
-
var warnedProperties = {};
|
|
54
|
-
|
|
55
|
-
var warnUnknownProperty = function (name) {
|
|
56
|
-
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
warnedProperties[name] = true;
|
|
61
|
-
var lowerCasedName = name.toLowerCase();
|
|
62
|
-
|
|
63
|
-
// data-* attributes should be lowercase; suggest the lowercase version
|
|
64
|
-
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
|
65
|
-
|
|
66
|
-
// For now, only warn when we have a suggested correction. This prevents
|
|
67
|
-
// logging too much when using transferPropsTo.
|
|
68
|
-
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
45
|
/**
|
|
73
46
|
* Operations for dealing with DOM properties.
|
|
74
47
|
*/
|
|
@@ -88,6 +61,14 @@ var DOMPropertyOperations = {
|
|
|
88
61
|
node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
|
|
89
62
|
},
|
|
90
63
|
|
|
64
|
+
createMarkupForRoot: function () {
|
|
65
|
+
return DOMProperty.ROOT_ATTRIBUTE_NAME + '=""';
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
setAttributeForRoot: function (node) {
|
|
69
|
+
node.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME, '');
|
|
70
|
+
},
|
|
71
|
+
|
|
91
72
|
/**
|
|
92
73
|
* Creates markup for a property.
|
|
93
74
|
*
|
|
@@ -96,6 +77,9 @@ var DOMPropertyOperations = {
|
|
|
96
77
|
* @return {?string} Markup string, or null if the property was invalid.
|
|
97
78
|
*/
|
|
98
79
|
createMarkupForProperty: function (name, value) {
|
|
80
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
81
|
+
ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(name, value);
|
|
82
|
+
}
|
|
99
83
|
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
100
84
|
if (propertyInfo) {
|
|
101
85
|
if (shouldIgnoreValue(propertyInfo, value)) {
|
|
@@ -111,8 +95,6 @@ var DOMPropertyOperations = {
|
|
|
111
95
|
return '';
|
|
112
96
|
}
|
|
113
97
|
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
114
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
115
|
-
warnUnknownProperty(name);
|
|
116
98
|
}
|
|
117
99
|
return null;
|
|
118
100
|
},
|
|
@@ -139,6 +121,9 @@ var DOMPropertyOperations = {
|
|
|
139
121
|
* @param {*} value
|
|
140
122
|
*/
|
|
141
123
|
setValueForProperty: function (node, name, value) {
|
|
124
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
125
|
+
ReactDOMInstrumentation.debugTool.onSetValueForProperty(node, name, value);
|
|
126
|
+
}
|
|
142
127
|
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
143
128
|
if (propertyInfo) {
|
|
144
129
|
var mutationMethod = propertyInfo.mutationMethod;
|
|
@@ -146,7 +131,16 @@ var DOMPropertyOperations = {
|
|
|
146
131
|
mutationMethod(node, value);
|
|
147
132
|
} else if (shouldIgnoreValue(propertyInfo, value)) {
|
|
148
133
|
this.deleteValueForProperty(node, name);
|
|
149
|
-
} else if (propertyInfo.
|
|
134
|
+
} else if (propertyInfo.mustUseProperty) {
|
|
135
|
+
var propName = propertyInfo.propertyName;
|
|
136
|
+
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
|
137
|
+
// property type before comparing; only `value` does and is string.
|
|
138
|
+
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
|
|
139
|
+
// Contrary to `setAttribute`, object properties are properly
|
|
140
|
+
// `toString`ed by IE8/9.
|
|
141
|
+
node[propName] = value;
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
150
144
|
var attributeName = propertyInfo.attributeName;
|
|
151
145
|
var namespace = propertyInfo.attributeNamespace;
|
|
152
146
|
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
|
@@ -158,20 +152,9 @@ var DOMPropertyOperations = {
|
|
|
158
152
|
} else {
|
|
159
153
|
node.setAttribute(attributeName, '' + value);
|
|
160
154
|
}
|
|
161
|
-
} else {
|
|
162
|
-
var propName = propertyInfo.propertyName;
|
|
163
|
-
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
|
164
|
-
// property type before comparing; only `value` does and is string.
|
|
165
|
-
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
|
|
166
|
-
// Contrary to `setAttribute`, object properties are properly
|
|
167
|
-
// `toString`ed by IE8/9.
|
|
168
|
-
node[propName] = value;
|
|
169
|
-
}
|
|
170
155
|
}
|
|
171
156
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
172
157
|
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
|
173
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
174
|
-
warnUnknownProperty(name);
|
|
175
158
|
}
|
|
176
159
|
},
|
|
177
160
|
|
|
@@ -193,24 +176,29 @@ var DOMPropertyOperations = {
|
|
|
193
176
|
* @param {string} name
|
|
194
177
|
*/
|
|
195
178
|
deleteValueForProperty: function (node, name) {
|
|
179
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
180
|
+
ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name);
|
|
181
|
+
}
|
|
196
182
|
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
197
183
|
if (propertyInfo) {
|
|
198
184
|
var mutationMethod = propertyInfo.mutationMethod;
|
|
199
185
|
if (mutationMethod) {
|
|
200
186
|
mutationMethod(node, undefined);
|
|
201
|
-
} else if (propertyInfo.
|
|
202
|
-
node.removeAttribute(propertyInfo.attributeName);
|
|
203
|
-
} else {
|
|
187
|
+
} else if (propertyInfo.mustUseProperty) {
|
|
204
188
|
var propName = propertyInfo.propertyName;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
node[propName] =
|
|
189
|
+
if (propertyInfo.hasBooleanValue) {
|
|
190
|
+
// No HAS_SIDE_EFFECTS logic here, only `value` has it and is string.
|
|
191
|
+
node[propName] = false;
|
|
192
|
+
} else {
|
|
193
|
+
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '') {
|
|
194
|
+
node[propName] = '';
|
|
195
|
+
}
|
|
208
196
|
}
|
|
197
|
+
} else {
|
|
198
|
+
node.removeAttribute(propertyInfo.attributeName);
|
|
209
199
|
}
|
|
210
200
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
211
201
|
node.removeAttribute(name);
|
|
212
|
-
} else if (process.env.NODE_ENV !== 'production') {
|
|
213
|
-
warnUnknownProperty(name);
|
|
214
202
|
}
|
|
215
203
|
}
|
|
216
204
|
|
package/lib/Danger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule Danger
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
15
15
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
16
16
|
|
|
17
17
|
var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
|
@@ -129,15 +129,14 @@ var Danger = {
|
|
|
129
129
|
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
|
130
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
131
|
!markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
|
|
132
|
-
!(oldChild.
|
|
132
|
+
!(oldChild.nodeName !== '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
133
|
|
|
134
|
-
var newChild;
|
|
135
134
|
if (typeof markup === 'string') {
|
|
136
|
-
newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
135
|
+
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
136
|
+
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
137
137
|
} else {
|
|
138
|
-
|
|
138
|
+
DOMLazyTree.replaceChildWithTree(oldChild, markup);
|
|
139
139
|
}
|
|
140
|
-
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,20 +7,18 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule EnterLeaveEventPlugin
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
15
14
|
var EventConstants = require('./EventConstants');
|
|
16
15
|
var EventPropagators = require('./EventPropagators');
|
|
16
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
17
17
|
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
|
|
18
18
|
|
|
19
|
-
var ReactMount = require('./ReactMount');
|
|
20
19
|
var keyOf = require('fbjs/lib/keyOf');
|
|
21
20
|
|
|
22
21
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
23
|
-
var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
|
24
22
|
|
|
25
23
|
var eventTypes = {
|
|
26
24
|
mouseEnter: {
|
|
@@ -33,8 +31,6 @@ var eventTypes = {
|
|
|
33
31
|
}
|
|
34
32
|
};
|
|
35
33
|
|
|
36
|
-
var extractedEvents = [null, null];
|
|
37
|
-
|
|
38
34
|
var EnterLeaveEventPlugin = {
|
|
39
35
|
|
|
40
36
|
eventTypes: eventTypes,
|
|
@@ -45,15 +41,8 @@ var EnterLeaveEventPlugin = {
|
|
|
45
41
|
* we do not extract duplicate events. However, moving the mouse into the
|
|
46
42
|
* browser from outside will not fire a `mouseout` event. In this case, we use
|
|
47
43
|
* the `mouseover` top-level event.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
50
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
51
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
52
|
-
* @param {object} nativeEvent Native browser event.
|
|
53
|
-
* @return {*} An accumulation of synthetic events.
|
|
54
|
-
* @see {EventPluginHub.extractEvents}
|
|
55
44
|
*/
|
|
56
|
-
extractEvents: function (topLevelType,
|
|
45
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
57
46
|
if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
|
58
47
|
return null;
|
|
59
48
|
}
|
|
@@ -63,12 +52,12 @@ var EnterLeaveEventPlugin = {
|
|
|
63
52
|
}
|
|
64
53
|
|
|
65
54
|
var win;
|
|
66
|
-
if (
|
|
67
|
-
// `
|
|
68
|
-
win =
|
|
55
|
+
if (nativeEventTarget.window === nativeEventTarget) {
|
|
56
|
+
// `nativeEventTarget` is probably a window object.
|
|
57
|
+
win = nativeEventTarget;
|
|
69
58
|
} else {
|
|
70
59
|
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
|
71
|
-
var doc =
|
|
60
|
+
var doc = nativeEventTarget.ownerDocument;
|
|
72
61
|
if (doc) {
|
|
73
62
|
win = doc.defaultView || doc.parentWindow;
|
|
74
63
|
} else {
|
|
@@ -78,22 +67,14 @@ var EnterLeaveEventPlugin = {
|
|
|
78
67
|
|
|
79
68
|
var from;
|
|
80
69
|
var to;
|
|
81
|
-
var fromID = '';
|
|
82
|
-
var toID = '';
|
|
83
70
|
if (topLevelType === topLevelTypes.topMouseOut) {
|
|
84
|
-
from =
|
|
85
|
-
|
|
86
|
-
to =
|
|
87
|
-
if (to) {
|
|
88
|
-
toID = ReactMount.getID(to);
|
|
89
|
-
} else {
|
|
90
|
-
to = win;
|
|
91
|
-
}
|
|
92
|
-
to = to || win;
|
|
71
|
+
from = targetInst;
|
|
72
|
+
var related = nativeEvent.relatedTarget || nativeEvent.toElement;
|
|
73
|
+
to = related ? ReactDOMComponentTree.getClosestInstanceFromNode(related) : null;
|
|
93
74
|
} else {
|
|
94
|
-
from
|
|
95
|
-
|
|
96
|
-
|
|
75
|
+
// Moving to a node from outside the window.
|
|
76
|
+
from = null;
|
|
77
|
+
to = targetInst;
|
|
97
78
|
}
|
|
98
79
|
|
|
99
80
|
if (from === to) {
|
|
@@ -101,22 +82,22 @@ var EnterLeaveEventPlugin = {
|
|
|
101
82
|
return null;
|
|
102
83
|
}
|
|
103
84
|
|
|
104
|
-
var
|
|
85
|
+
var fromNode = from == null ? win : ReactDOMComponentTree.getNodeFromInstance(from);
|
|
86
|
+
var toNode = to == null ? win : ReactDOMComponentTree.getNodeFromInstance(to);
|
|
87
|
+
|
|
88
|
+
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, from, nativeEvent, nativeEventTarget);
|
|
105
89
|
leave.type = 'mouseleave';
|
|
106
|
-
leave.target =
|
|
107
|
-
leave.relatedTarget =
|
|
90
|
+
leave.target = fromNode;
|
|
91
|
+
leave.relatedTarget = toNode;
|
|
108
92
|
|
|
109
|
-
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter,
|
|
93
|
+
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, to, nativeEvent, nativeEventTarget);
|
|
110
94
|
enter.type = 'mouseenter';
|
|
111
|
-
enter.target =
|
|
112
|
-
enter.relatedTarget =
|
|
113
|
-
|
|
114
|
-
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
|
|
95
|
+
enter.target = toNode;
|
|
96
|
+
enter.relatedTarget = fromNode;
|
|
115
97
|
|
|
116
|
-
|
|
117
|
-
extractedEvents[1] = enter;
|
|
98
|
+
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, from, to);
|
|
118
99
|
|
|
119
|
-
return
|
|
100
|
+
return [leave, enter];
|
|
120
101
|
}
|
|
121
102
|
|
|
122
103
|
};
|
package/lib/EventConstants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -20,6 +20,9 @@ var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
|
|
20
20
|
*/
|
|
21
21
|
var topLevelTypes = keyMirror({
|
|
22
22
|
topAbort: null,
|
|
23
|
+
topAnimationEnd: null,
|
|
24
|
+
topAnimationIteration: null,
|
|
25
|
+
topAnimationStart: null,
|
|
23
26
|
topBlur: null,
|
|
24
27
|
topCanPlay: null,
|
|
25
28
|
topCanPlayThrough: null,
|
|
@@ -47,6 +50,7 @@ var topLevelTypes = keyMirror({
|
|
|
47
50
|
topError: null,
|
|
48
51
|
topFocus: null,
|
|
49
52
|
topInput: null,
|
|
53
|
+
topInvalid: null,
|
|
50
54
|
topKeyDown: null,
|
|
51
55
|
topKeyPress: null,
|
|
52
56
|
topKeyUp: null,
|
|
@@ -79,6 +83,7 @@ var topLevelTypes = keyMirror({
|
|
|
79
83
|
topTouchEnd: null,
|
|
80
84
|
topTouchMove: null,
|
|
81
85
|
topTouchStart: null,
|
|
86
|
+
topTransitionEnd: null,
|
|
82
87
|
topVolumeChange: null,
|
|
83
88
|
topWaiting: null,
|
|
84
89
|
topWheel: null
|
package/lib/EventPluginHub.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -18,7 +18,6 @@ var ReactErrorUtils = require('./ReactErrorUtils');
|
|
|
18
18
|
var accumulateInto = require('./accumulateInto');
|
|
19
19
|
var forEachAccumulated = require('./forEachAccumulated');
|
|
20
20
|
var invariant = require('fbjs/lib/invariant');
|
|
21
|
-
var warning = require('fbjs/lib/warning');
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Internal store for event listeners
|
|
@@ -54,17 +53,6 @@ var executeDispatchesAndReleaseTopLevel = function (e) {
|
|
|
54
53
|
return executeDispatchesAndRelease(e, false);
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
/**
|
|
58
|
-
* - `InstanceHandle`: [required] Module that performs logical traversals of DOM
|
|
59
|
-
* hierarchy given ids of the logical DOM elements involved.
|
|
60
|
-
*/
|
|
61
|
-
var InstanceHandle = null;
|
|
62
|
-
|
|
63
|
-
function validateInstanceHandle() {
|
|
64
|
-
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
|
|
65
|
-
process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
56
|
/**
|
|
69
57
|
* This is a unified interface for event plugins to be installed and configured.
|
|
70
58
|
*
|
|
@@ -94,30 +82,6 @@ var EventPluginHub = {
|
|
|
94
82
|
*/
|
|
95
83
|
injection: {
|
|
96
84
|
|
|
97
|
-
/**
|
|
98
|
-
* @param {object} InjectedMount
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
injectMount: EventPluginUtils.injection.injectMount,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @param {object} InjectedInstanceHandle
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
injectInstanceHandle: function (InjectedInstanceHandle) {
|
|
108
|
-
InstanceHandle = InjectedInstanceHandle;
|
|
109
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
110
|
-
validateInstanceHandle();
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
getInstanceHandle: function () {
|
|
115
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
-
validateInstanceHandle();
|
|
117
|
-
}
|
|
118
|
-
return InstanceHandle;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
85
|
/**
|
|
122
86
|
* @param {array} InjectedEventPluginOrder
|
|
123
87
|
* @public
|
|
@@ -131,75 +95,71 @@ var EventPluginHub = {
|
|
|
131
95
|
|
|
132
96
|
},
|
|
133
97
|
|
|
134
|
-
eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
|
|
135
|
-
|
|
136
|
-
registrationNameModules: EventPluginRegistry.registrationNameModules,
|
|
137
|
-
|
|
138
98
|
/**
|
|
139
99
|
* Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
|
|
140
100
|
*
|
|
141
|
-
* @param {
|
|
101
|
+
* @param {object} inst The instance, which is the source of events.
|
|
142
102
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
143
|
-
* @param {
|
|
103
|
+
* @param {function} listener The callback to store.
|
|
144
104
|
*/
|
|
145
|
-
putListener: function (
|
|
105
|
+
putListener: function (inst, registrationName, listener) {
|
|
146
106
|
!(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;
|
|
147
107
|
|
|
148
108
|
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
|
149
|
-
bankForRegistrationName[
|
|
109
|
+
bankForRegistrationName[inst._rootNodeID] = listener;
|
|
150
110
|
|
|
151
111
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
152
112
|
if (PluginModule && PluginModule.didPutListener) {
|
|
153
|
-
PluginModule.didPutListener(
|
|
113
|
+
PluginModule.didPutListener(inst, registrationName, listener);
|
|
154
114
|
}
|
|
155
115
|
},
|
|
156
116
|
|
|
157
117
|
/**
|
|
158
|
-
* @param {
|
|
118
|
+
* @param {object} inst The instance, which is the source of events.
|
|
159
119
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
160
120
|
* @return {?function} The stored callback.
|
|
161
121
|
*/
|
|
162
|
-
getListener: function (
|
|
122
|
+
getListener: function (inst, registrationName) {
|
|
163
123
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
164
|
-
return bankForRegistrationName && bankForRegistrationName[
|
|
124
|
+
return bankForRegistrationName && bankForRegistrationName[inst._rootNodeID];
|
|
165
125
|
},
|
|
166
126
|
|
|
167
127
|
/**
|
|
168
128
|
* Deletes a listener from the registration bank.
|
|
169
129
|
*
|
|
170
|
-
* @param {
|
|
130
|
+
* @param {object} inst The instance, which is the source of events.
|
|
171
131
|
* @param {string} registrationName Name of listener (e.g. `onClick`).
|
|
172
132
|
*/
|
|
173
|
-
deleteListener: function (
|
|
133
|
+
deleteListener: function (inst, registrationName) {
|
|
174
134
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
175
135
|
if (PluginModule && PluginModule.willDeleteListener) {
|
|
176
|
-
PluginModule.willDeleteListener(
|
|
136
|
+
PluginModule.willDeleteListener(inst, registrationName);
|
|
177
137
|
}
|
|
178
138
|
|
|
179
139
|
var bankForRegistrationName = listenerBank[registrationName];
|
|
180
140
|
// TODO: This should never be null -- when is it?
|
|
181
141
|
if (bankForRegistrationName) {
|
|
182
|
-
delete bankForRegistrationName[
|
|
142
|
+
delete bankForRegistrationName[inst._rootNodeID];
|
|
183
143
|
}
|
|
184
144
|
},
|
|
185
145
|
|
|
186
146
|
/**
|
|
187
147
|
* Deletes all listeners for the DOM element with the supplied ID.
|
|
188
148
|
*
|
|
189
|
-
* @param {
|
|
149
|
+
* @param {object} inst The instance, which is the source of events.
|
|
190
150
|
*/
|
|
191
|
-
deleteAllListeners: function (
|
|
151
|
+
deleteAllListeners: function (inst) {
|
|
192
152
|
for (var registrationName in listenerBank) {
|
|
193
|
-
if (!listenerBank[registrationName][
|
|
153
|
+
if (!listenerBank[registrationName][inst._rootNodeID]) {
|
|
194
154
|
continue;
|
|
195
155
|
}
|
|
196
156
|
|
|
197
157
|
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
|
|
198
158
|
if (PluginModule && PluginModule.willDeleteListener) {
|
|
199
|
-
PluginModule.willDeleteListener(
|
|
159
|
+
PluginModule.willDeleteListener(inst, registrationName);
|
|
200
160
|
}
|
|
201
161
|
|
|
202
|
-
delete listenerBank[registrationName][
|
|
162
|
+
delete listenerBank[registrationName][inst._rootNodeID];
|
|
203
163
|
}
|
|
204
164
|
},
|
|
205
165
|
|
|
@@ -207,21 +167,17 @@ var EventPluginHub = {
|
|
|
207
167
|
* Allows registered plugins an opportunity to extract events from top-level
|
|
208
168
|
* native browser events.
|
|
209
169
|
*
|
|
210
|
-
* @param {string} topLevelType Record from `EventConstants`.
|
|
211
|
-
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
|
212
|
-
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
213
|
-
* @param {object} nativeEvent Native browser event.
|
|
214
170
|
* @return {*} An accumulation of synthetic events.
|
|
215
171
|
* @internal
|
|
216
172
|
*/
|
|
217
|
-
extractEvents: function (topLevelType,
|
|
173
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
218
174
|
var events;
|
|
219
175
|
var plugins = EventPluginRegistry.plugins;
|
|
220
176
|
for (var i = 0; i < plugins.length; i++) {
|
|
221
177
|
// Not every plugin in the ordering may be loaded at runtime.
|
|
222
178
|
var possiblePlugin = plugins[i];
|
|
223
179
|
if (possiblePlugin) {
|
|
224
|
-
var extractedEvents = possiblePlugin.extractEvents(topLevelType,
|
|
180
|
+
var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
|
|
225
181
|
if (extractedEvents) {
|
|
226
182
|
events = accumulateInto(events, extractedEvents);
|
|
227
183
|
}
|