react-test-renderer 15.5.0 → 15.5.4
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/lib/ReactShallowRenderer.js +6 -0
- package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
- package/lib/shallow/AutoFocusUtils.js +23 -0
- package/lib/shallow/BeforeInputEventPlugin.js +384 -0
- package/lib/shallow/CSSProperty.js +147 -0
- package/lib/shallow/CSSPropertyOperations.js +208 -0
- package/lib/shallow/CallbackQueue.js +118 -0
- package/lib/shallow/ChangeEventPlugin.js +345 -0
- package/lib/shallow/DOMChildrenOperations.js +224 -0
- package/lib/shallow/DOMLazyTree.js +117 -0
- package/lib/shallow/DOMNamespaces.js +19 -0
- package/lib/shallow/DOMProperty.js +209 -0
- package/lib/shallow/DOMPropertyOperations.js +236 -0
- package/lib/shallow/Danger.js +47 -0
- package/lib/shallow/DefaultEventPluginOrder.js +25 -0
- package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
- package/lib/shallow/EventConstants.js +91 -0
- package/lib/shallow/EventPluginHub.js +277 -0
- package/lib/shallow/EventPluginRegistry.js +254 -0
- package/lib/shallow/EventPluginUtils.js +225 -0
- package/lib/shallow/EventPropagators.js +133 -0
- package/lib/shallow/FallbackCompositionState.js +94 -0
- package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
- package/lib/shallow/KeyEscapeUtils.js +58 -0
- package/lib/shallow/LinkedValueUtils.js +137 -0
- package/lib/shallow/PluginModuleType.js +12 -0
- package/lib/shallow/PooledClass.js +111 -0
- package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
- package/lib/shallow/ReactChildFiber.js +243 -0
- package/lib/shallow/ReactChildReconciler.js +153 -0
- package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
- package/lib/shallow/ReactComponentEnvironment.js +45 -0
- package/lib/shallow/ReactCompositeComponent.js +901 -0
- package/lib/shallow/ReactCoroutine.js +80 -0
- package/lib/shallow/ReactDOM.js +110 -0
- package/lib/shallow/ReactDOMComponent.js +1000 -0
- package/lib/shallow/ReactDOMComponentFlags.js +17 -0
- package/lib/shallow/ReactDOMComponentTree.js +194 -0
- package/lib/shallow/ReactDOMContainerInfo.js +32 -0
- package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
- package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
- package/lib/shallow/ReactDOMFiber.js +97 -0
- package/lib/shallow/ReactDOMIDOperations.js +33 -0
- package/lib/shallow/ReactDOMInput.js +284 -0
- package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
- package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
- package/lib/shallow/ReactDOMOption.js +122 -0
- package/lib/shallow/ReactDOMSelect.js +199 -0
- package/lib/shallow/ReactDOMSelection.js +211 -0
- package/lib/shallow/ReactDOMServer.js +25 -0
- package/lib/shallow/ReactDOMTextComponent.js +163 -0
- package/lib/shallow/ReactDOMTextarea.js +159 -0
- package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
- package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
- package/lib/shallow/ReactDebugTool.js +358 -0
- package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
- package/lib/shallow/ReactDefaultInjection.js +85 -0
- package/lib/shallow/ReactElementSymbol.js +19 -0
- package/lib/shallow/ReactEmptyComponent.js +29 -0
- package/lib/shallow/ReactErrorUtils.js +75 -0
- package/lib/shallow/ReactEventEmitterMixin.js +32 -0
- package/lib/shallow/ReactEventListener.js +154 -0
- package/lib/shallow/ReactFeatureFlags.js +21 -0
- package/lib/shallow/ReactFiber.js +190 -0
- package/lib/shallow/ReactFiberBeginWork.js +380 -0
- package/lib/shallow/ReactFiberCommitWork.js +78 -0
- package/lib/shallow/ReactFiberCompleteWork.js +208 -0
- package/lib/shallow/ReactFiberReconciler.js +64 -0
- package/lib/shallow/ReactFiberRoot.js +29 -0
- package/lib/shallow/ReactFiberScheduler.js +331 -0
- package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
- package/lib/shallow/ReactHostComponent.js +67 -0
- package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
- package/lib/shallow/ReactInjection.js +33 -0
- package/lib/shallow/ReactInputSelection.js +123 -0
- package/lib/shallow/ReactInstanceMap.js +47 -0
- package/lib/shallow/ReactInstanceType.js +12 -0
- package/lib/shallow/ReactInstrumentation.js +23 -0
- package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
- package/lib/shallow/ReactMarkupChecksum.js +49 -0
- package/lib/shallow/ReactMount.js +537 -0
- package/lib/shallow/ReactMultiChild.js +449 -0
- package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
- package/lib/shallow/ReactNodeTypes.js +39 -0
- package/lib/shallow/ReactOwner.js +93 -0
- package/lib/shallow/ReactPerf.js +500 -0
- package/lib/shallow/ReactPriorityLevel.js +20 -0
- package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
- package/lib/shallow/ReactPropTypeLocations.js +12 -0
- package/lib/shallow/ReactPropTypesSecret.js +16 -0
- package/lib/shallow/ReactReconcileTransaction.js +177 -0
- package/lib/shallow/ReactReconciler.js +167 -0
- package/lib/shallow/ReactRef.js +88 -0
- package/lib/shallow/ReactReifiedYield.js +30 -0
- package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
- package/lib/shallow/ReactServerRendering.js +89 -0
- package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
- package/lib/shallow/ReactServerUpdateQueue.js +138 -0
- package/lib/shallow/ReactShallowRenderer.js +150 -0
- package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
- package/lib/shallow/ReactSyntheticEventType.js +14 -0
- package/lib/shallow/ReactTestEmptyComponent.js +36 -0
- package/lib/shallow/ReactTestMount.js +131 -0
- package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
- package/lib/shallow/ReactTestRenderer.js +139 -0
- package/lib/shallow/ReactTestTextComponent.js +40 -0
- package/lib/shallow/ReactTypeOfWork.js +23 -0
- package/lib/shallow/ReactTypes.js +12 -0
- package/lib/shallow/ReactUpdateQueue.js +235 -0
- package/lib/shallow/ReactUpdates.js +250 -0
- package/lib/shallow/ReactVersion.js +13 -0
- package/lib/shallow/ResponderEventPlugin.js +507 -0
- package/lib/shallow/ResponderSyntheticEvent.js +38 -0
- package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
- package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
- package/lib/shallow/SelectEventPlugin.js +190 -0
- package/lib/shallow/SimpleEventPlugin.js +227 -0
- package/lib/shallow/SyntheticAnimationEvent.js +38 -0
- package/lib/shallow/SyntheticClipboardEvent.js +37 -0
- package/lib/shallow/SyntheticCompositionEvent.js +35 -0
- package/lib/shallow/SyntheticDragEvent.js +35 -0
- package/lib/shallow/SyntheticEvent.js +267 -0
- package/lib/shallow/SyntheticFocusEvent.js +35 -0
- package/lib/shallow/SyntheticInputEvent.js +36 -0
- package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
- package/lib/shallow/SyntheticMouseEvent.js +71 -0
- package/lib/shallow/SyntheticTouchEvent.js +44 -0
- package/lib/shallow/SyntheticTransitionEvent.js +38 -0
- package/lib/shallow/SyntheticUIEvent.js +58 -0
- package/lib/shallow/SyntheticWheelEvent.js +53 -0
- package/lib/shallow/TapEventPlugin.js +115 -0
- package/lib/shallow/TouchHistoryMath.js +98 -0
- package/lib/shallow/Transaction.js +224 -0
- package/lib/shallow/ViewportMetrics.js +26 -0
- package/lib/shallow/accumulate.js +45 -0
- package/lib/shallow/accumulateInto.js +57 -0
- package/lib/shallow/adler32.js +43 -0
- package/lib/shallow/canDefineProperty.js +25 -0
- package/lib/shallow/checkReactTypeSpec.js +86 -0
- package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
- package/lib/shallow/dangerousStyleValue.js +78 -0
- package/lib/shallow/deprecated.js +56 -0
- package/lib/shallow/escapeTextContentForBrowser.js +122 -0
- package/lib/shallow/findDOMNode.js +59 -0
- package/lib/shallow/flattenChildren.js +75 -0
- package/lib/shallow/forEachAccumulated.js +30 -0
- package/lib/shallow/getEventCharCode.js +49 -0
- package/lib/shallow/getEventKey.js +101 -0
- package/lib/shallow/getEventModifierState.js +42 -0
- package/lib/shallow/getEventTarget.js +34 -0
- package/lib/shallow/getHostComponentFromComposite.js +29 -0
- package/lib/shallow/getIteratorFn.js +40 -0
- package/lib/shallow/getNodeForCharacterOffset.js +73 -0
- package/lib/shallow/getTextContentAccessor.js +32 -0
- package/lib/shallow/getVendorPrefixedEventName.js +100 -0
- package/lib/shallow/instantiateReactComponent.js +128 -0
- package/lib/shallow/isEventSupported.js +59 -0
- package/lib/shallow/isTextInputElement.js +50 -0
- package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
- package/lib/shallow/reactProdInvariant.js +38 -0
- package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
- package/lib/shallow/setInnerHTML.js +97 -0
- package/lib/shallow/setTextContent.js +51 -0
- package/lib/shallow/shouldUpdateReactComponent.js +41 -0
- package/lib/shallow/traverseAllChildren.js +175 -0
- package/lib/shallow/validateDOMNesting.js +376 -0
- package/package.json +1 -1
- package/shallow.js +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var DOMProperty = require('./DOMProperty');
|
|
14
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
15
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
16
|
+
|
|
17
|
+
var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
19
|
+
|
|
20
|
+
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + DOMProperty.ATTRIBUTE_NAME_START_CHAR + '][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
|
|
21
|
+
var illegalAttributeNameCache = {};
|
|
22
|
+
var validatedAttributeNameCache = {};
|
|
23
|
+
|
|
24
|
+
function isAttributeNameSafe(attributeName) {
|
|
25
|
+
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
|
32
|
+
validatedAttributeNameCache[attributeName] = true;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
illegalAttributeNameCache[attributeName] = true;
|
|
36
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : void 0;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function shouldIgnoreValue(propertyInfo, value) {
|
|
41
|
+
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Operations for dealing with DOM properties.
|
|
46
|
+
*/
|
|
47
|
+
var DOMPropertyOperations = {
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates markup for the ID property.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} id Unescaped ID.
|
|
53
|
+
* @return {string} Markup string.
|
|
54
|
+
*/
|
|
55
|
+
createMarkupForID: function (id) {
|
|
56
|
+
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
setAttributeForID: function (node, id) {
|
|
60
|
+
node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
createMarkupForRoot: function () {
|
|
64
|
+
return DOMProperty.ROOT_ATTRIBUTE_NAME + '=""';
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
setAttributeForRoot: function (node) {
|
|
68
|
+
node.setAttribute(DOMProperty.ROOT_ATTRIBUTE_NAME, '');
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Creates markup for a property.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} name
|
|
75
|
+
* @param {*} value
|
|
76
|
+
* @return {?string} Markup string, or null if the property was invalid.
|
|
77
|
+
*/
|
|
78
|
+
createMarkupForProperty: function (name, value) {
|
|
79
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
80
|
+
if (propertyInfo) {
|
|
81
|
+
if (shouldIgnoreValue(propertyInfo, value)) {
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
var attributeName = propertyInfo.attributeName;
|
|
85
|
+
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
|
86
|
+
return attributeName + '=""';
|
|
87
|
+
}
|
|
88
|
+
return attributeName + '=' + quoteAttributeValueForBrowser(value);
|
|
89
|
+
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
90
|
+
if (value == null) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates markup for a custom property.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} name
|
|
102
|
+
* @param {*} value
|
|
103
|
+
* @return {string} Markup string, or empty string if the property was invalid.
|
|
104
|
+
*/
|
|
105
|
+
createMarkupForCustomAttribute: function (name, value) {
|
|
106
|
+
if (!isAttributeNameSafe(name) || value == null) {
|
|
107
|
+
return '';
|
|
108
|
+
}
|
|
109
|
+
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sets the value for a property on a node.
|
|
114
|
+
*
|
|
115
|
+
* @param {DOMElement} node
|
|
116
|
+
* @param {string} name
|
|
117
|
+
* @param {*} value
|
|
118
|
+
*/
|
|
119
|
+
setValueForProperty: function (node, name, value) {
|
|
120
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
121
|
+
if (propertyInfo) {
|
|
122
|
+
var mutationMethod = propertyInfo.mutationMethod;
|
|
123
|
+
if (mutationMethod) {
|
|
124
|
+
mutationMethod(node, value);
|
|
125
|
+
} else if (shouldIgnoreValue(propertyInfo, value)) {
|
|
126
|
+
this.deleteValueForProperty(node, name);
|
|
127
|
+
return;
|
|
128
|
+
} else if (propertyInfo.mustUseProperty) {
|
|
129
|
+
// Contrary to `setAttribute`, object properties are properly
|
|
130
|
+
// `toString`ed by IE8/9.
|
|
131
|
+
node[propertyInfo.propertyName] = value;
|
|
132
|
+
} else {
|
|
133
|
+
var attributeName = propertyInfo.attributeName;
|
|
134
|
+
var namespace = propertyInfo.attributeNamespace;
|
|
135
|
+
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
|
136
|
+
// ('' + value) makes it output the correct toString()-value.
|
|
137
|
+
if (namespace) {
|
|
138
|
+
node.setAttributeNS(namespace, attributeName, '' + value);
|
|
139
|
+
} else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
|
140
|
+
node.setAttribute(attributeName, '');
|
|
141
|
+
} else {
|
|
142
|
+
node.setAttribute(attributeName, '' + value);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
146
|
+
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
151
|
+
var payload = {};
|
|
152
|
+
payload[name] = value;
|
|
153
|
+
ReactInstrumentation.debugTool.onHostOperation({
|
|
154
|
+
instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
|
|
155
|
+
type: 'update attribute',
|
|
156
|
+
payload: payload
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
setValueForAttribute: function (node, name, value) {
|
|
162
|
+
if (!isAttributeNameSafe(name)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (value == null) {
|
|
166
|
+
node.removeAttribute(name);
|
|
167
|
+
} else {
|
|
168
|
+
node.setAttribute(name, '' + value);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
172
|
+
var payload = {};
|
|
173
|
+
payload[name] = value;
|
|
174
|
+
ReactInstrumentation.debugTool.onHostOperation({
|
|
175
|
+
instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
|
|
176
|
+
type: 'update attribute',
|
|
177
|
+
payload: payload
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Deletes an attributes from a node.
|
|
184
|
+
*
|
|
185
|
+
* @param {DOMElement} node
|
|
186
|
+
* @param {string} name
|
|
187
|
+
*/
|
|
188
|
+
deleteValueForAttribute: function (node, name) {
|
|
189
|
+
node.removeAttribute(name);
|
|
190
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
191
|
+
ReactInstrumentation.debugTool.onHostOperation({
|
|
192
|
+
instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
|
|
193
|
+
type: 'remove attribute',
|
|
194
|
+
payload: name
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Deletes the value for a property on a node.
|
|
201
|
+
*
|
|
202
|
+
* @param {DOMElement} node
|
|
203
|
+
* @param {string} name
|
|
204
|
+
*/
|
|
205
|
+
deleteValueForProperty: function (node, name) {
|
|
206
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
207
|
+
if (propertyInfo) {
|
|
208
|
+
var mutationMethod = propertyInfo.mutationMethod;
|
|
209
|
+
if (mutationMethod) {
|
|
210
|
+
mutationMethod(node, undefined);
|
|
211
|
+
} else if (propertyInfo.mustUseProperty) {
|
|
212
|
+
var propName = propertyInfo.propertyName;
|
|
213
|
+
if (propertyInfo.hasBooleanValue) {
|
|
214
|
+
node[propName] = false;
|
|
215
|
+
} else {
|
|
216
|
+
node[propName] = '';
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
node.removeAttribute(propertyInfo.attributeName);
|
|
220
|
+
}
|
|
221
|
+
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
222
|
+
node.removeAttribute(name);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
226
|
+
ReactInstrumentation.debugTool.onHostOperation({
|
|
227
|
+
instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
|
|
228
|
+
type: 'remove attribute',
|
|
229
|
+
payload: name
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
module.exports = DOMPropertyOperations;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
14
|
+
|
|
15
|
+
var DOMLazyTree = require('./DOMLazyTree');
|
|
16
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
|
+
|
|
18
|
+
var createNodesFromMarkup = require('fbjs/lib/createNodesFromMarkup');
|
|
19
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
21
|
+
|
|
22
|
+
var Danger = {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Replaces a node with a string of markup at its current position within its
|
|
26
|
+
* parent. The markup must render into a single root node.
|
|
27
|
+
*
|
|
28
|
+
* @param {DOMElement} oldChild Child node to replace.
|
|
29
|
+
* @param {string} markup Markup to render in place of the child node.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
|
33
|
+
!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.') : _prodInvariant('56') : void 0;
|
|
34
|
+
!markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : _prodInvariant('57') : void 0;
|
|
35
|
+
!(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().') : _prodInvariant('58') : void 0;
|
|
36
|
+
|
|
37
|
+
if (typeof markup === 'string') {
|
|
38
|
+
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
39
|
+
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
40
|
+
} else {
|
|
41
|
+
DOMLazyTree.replaceChildWithTree(oldChild, markup);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = Danger;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Module that is injectable into `EventPluginHub`, that specifies a
|
|
15
|
+
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
|
|
16
|
+
* plugins, without having to package every one of them. This is better than
|
|
17
|
+
* having plugins be ordered in the same order that they are injected because
|
|
18
|
+
* that ordering would be influenced by the packaging order.
|
|
19
|
+
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
|
|
20
|
+
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
var DefaultEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
|
|
24
|
+
|
|
25
|
+
module.exports = DefaultEventPluginOrder;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
var EventPropagators = require('./EventPropagators');
|
|
14
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
15
|
+
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
|
|
16
|
+
|
|
17
|
+
var eventTypes = {
|
|
18
|
+
mouseEnter: {
|
|
19
|
+
registrationName: 'onMouseEnter',
|
|
20
|
+
dependencies: ['topMouseOut', 'topMouseOver']
|
|
21
|
+
},
|
|
22
|
+
mouseLeave: {
|
|
23
|
+
registrationName: 'onMouseLeave',
|
|
24
|
+
dependencies: ['topMouseOut', 'topMouseOver']
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var EnterLeaveEventPlugin = {
|
|
29
|
+
|
|
30
|
+
eventTypes: eventTypes,
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* For almost every interaction we care about, there will be both a top-level
|
|
34
|
+
* `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
|
|
35
|
+
* we do not extract duplicate events. However, moving the mouse into the
|
|
36
|
+
* browser from outside will not fire a `mouseout` event. In this case, we use
|
|
37
|
+
* the `mouseover` top-level event.
|
|
38
|
+
*/
|
|
39
|
+
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
|
40
|
+
if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') {
|
|
44
|
+
// Must not be a mouse in or mouse out - ignoring.
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var win;
|
|
49
|
+
if (nativeEventTarget.window === nativeEventTarget) {
|
|
50
|
+
// `nativeEventTarget` is probably a window object.
|
|
51
|
+
win = nativeEventTarget;
|
|
52
|
+
} else {
|
|
53
|
+
// TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
|
|
54
|
+
var doc = nativeEventTarget.ownerDocument;
|
|
55
|
+
if (doc) {
|
|
56
|
+
win = doc.defaultView || doc.parentWindow;
|
|
57
|
+
} else {
|
|
58
|
+
win = window;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var from;
|
|
63
|
+
var to;
|
|
64
|
+
if (topLevelType === 'topMouseOut') {
|
|
65
|
+
from = targetInst;
|
|
66
|
+
var related = nativeEvent.relatedTarget || nativeEvent.toElement;
|
|
67
|
+
to = related ? ReactDOMComponentTree.getClosestInstanceFromNode(related) : null;
|
|
68
|
+
} else {
|
|
69
|
+
// Moving to a node from outside the window.
|
|
70
|
+
from = null;
|
|
71
|
+
to = targetInst;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (from === to) {
|
|
75
|
+
// Nothing pertains to our managed components.
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var fromNode = from == null ? win : ReactDOMComponentTree.getNodeFromInstance(from);
|
|
80
|
+
var toNode = to == null ? win : ReactDOMComponentTree.getNodeFromInstance(to);
|
|
81
|
+
|
|
82
|
+
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, from, nativeEvent, nativeEventTarget);
|
|
83
|
+
leave.type = 'mouseleave';
|
|
84
|
+
leave.target = fromNode;
|
|
85
|
+
leave.relatedTarget = toNode;
|
|
86
|
+
|
|
87
|
+
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, to, nativeEvent, nativeEventTarget);
|
|
88
|
+
enter.type = 'mouseenter';
|
|
89
|
+
enter.target = toNode;
|
|
90
|
+
enter.relatedTarget = fromNode;
|
|
91
|
+
|
|
92
|
+
EventPropagators.accumulateEnterLeaveDispatches(leave, enter, from, to);
|
|
93
|
+
|
|
94
|
+
return [leave, enter];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
module.exports = EnterLeaveEventPlugin;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Types of raw signals from the browser caught at the top level.
|
|
15
|
+
*/
|
|
16
|
+
var topLevelTypes = {
|
|
17
|
+
topAbort: null,
|
|
18
|
+
topAnimationEnd: null,
|
|
19
|
+
topAnimationIteration: null,
|
|
20
|
+
topAnimationStart: null,
|
|
21
|
+
topBlur: null,
|
|
22
|
+
topCanPlay: null,
|
|
23
|
+
topCanPlayThrough: null,
|
|
24
|
+
topChange: null,
|
|
25
|
+
topClick: null,
|
|
26
|
+
topCompositionEnd: null,
|
|
27
|
+
topCompositionStart: null,
|
|
28
|
+
topCompositionUpdate: null,
|
|
29
|
+
topContextMenu: null,
|
|
30
|
+
topCopy: null,
|
|
31
|
+
topCut: null,
|
|
32
|
+
topDoubleClick: null,
|
|
33
|
+
topDrag: null,
|
|
34
|
+
topDragEnd: null,
|
|
35
|
+
topDragEnter: null,
|
|
36
|
+
topDragExit: null,
|
|
37
|
+
topDragLeave: null,
|
|
38
|
+
topDragOver: null,
|
|
39
|
+
topDragStart: null,
|
|
40
|
+
topDrop: null,
|
|
41
|
+
topDurationChange: null,
|
|
42
|
+
topEmptied: null,
|
|
43
|
+
topEncrypted: null,
|
|
44
|
+
topEnded: null,
|
|
45
|
+
topError: null,
|
|
46
|
+
topFocus: null,
|
|
47
|
+
topInput: null,
|
|
48
|
+
topInvalid: null,
|
|
49
|
+
topKeyDown: null,
|
|
50
|
+
topKeyPress: null,
|
|
51
|
+
topKeyUp: null,
|
|
52
|
+
topLoad: null,
|
|
53
|
+
topLoadedData: null,
|
|
54
|
+
topLoadedMetadata: null,
|
|
55
|
+
topLoadStart: null,
|
|
56
|
+
topMouseDown: null,
|
|
57
|
+
topMouseMove: null,
|
|
58
|
+
topMouseOut: null,
|
|
59
|
+
topMouseOver: null,
|
|
60
|
+
topMouseUp: null,
|
|
61
|
+
topPaste: null,
|
|
62
|
+
topPause: null,
|
|
63
|
+
topPlay: null,
|
|
64
|
+
topPlaying: null,
|
|
65
|
+
topProgress: null,
|
|
66
|
+
topRateChange: null,
|
|
67
|
+
topReset: null,
|
|
68
|
+
topScroll: null,
|
|
69
|
+
topSeeked: null,
|
|
70
|
+
topSeeking: null,
|
|
71
|
+
topSelectionChange: null,
|
|
72
|
+
topStalled: null,
|
|
73
|
+
topSubmit: null,
|
|
74
|
+
topSuspend: null,
|
|
75
|
+
topTextInput: null,
|
|
76
|
+
topTimeUpdate: null,
|
|
77
|
+
topTouchCancel: null,
|
|
78
|
+
topTouchEnd: null,
|
|
79
|
+
topTouchMove: null,
|
|
80
|
+
topTouchStart: null,
|
|
81
|
+
topTransitionEnd: null,
|
|
82
|
+
topVolumeChange: null,
|
|
83
|
+
topWaiting: null,
|
|
84
|
+
topWheel: null
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
var EventConstants = {
|
|
88
|
+
topLevelTypes: topLevelTypes
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
module.exports = EventConstants;
|