react 0.13.3 → 0.14.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/addons.js +7 -0
- package/dist/JSXTransformer.js +4101 -2432
- package/dist/react-with-addons.js +4389 -6277
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +4028 -5697
- package/dist/react.min.js +5 -6
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +26 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +86 -147
- package/lib/DOMPropertyOperations.js +91 -67
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +33 -44
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +15 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +71 -89
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +20 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +26 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +24 -31
- package/lib/ReactClass.js +96 -267
- package/lib/ReactComponent.js +28 -57
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +6 -7
- package/lib/ReactCompositeComponent.js +115 -381
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +16 -28
- package/lib/ReactDOMClient.js +90 -0
- package/lib/ReactDOMComponent.js +468 -156
- package/lib/ReactDOMIDOperations.js +25 -22
- package/lib/ReactDOMInput.js +79 -108
- package/lib/ReactDOMOption.js +58 -20
- package/lib/ReactDOMSelect.js +95 -83
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +44 -69
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +20 -76
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +26 -120
- package/lib/ReactElementValidator.js +56 -192
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +3 -3
- package/lib/ReactEventEmitterMixin.js +3 -13
- package/lib/ReactEventListener.js +58 -40
- package/lib/ReactFragment.js +33 -59
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +14 -23
- package/lib/ReactInstanceHandles.js +29 -58
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +142 -285
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -15
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +11 -36
- package/lib/ReactReconciler.js +14 -26
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +20 -15
- package/lib/ReactServerRenderingTransaction.js +9 -34
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +137 -190
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +69 -107
- package/lib/ReactUpdates.js +26 -81
- package/lib/ReactWithAddons.js +5 -6
- package/lib/SVGDOMPropertyConfig.js +39 -4
- package/lib/SelectEventPlugin.js +31 -33
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +138 -130
- package/lib/SyntheticClipboardEvent.js +5 -9
- package/lib/SyntheticCompositionEvent.js +4 -10
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +14 -15
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +4 -10
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +10 -16
- package/lib/SyntheticTouchEvent.js +3 -3
- package/lib/SyntheticUIEvent.js +5 -5
- package/lib/SyntheticWheelEvent.js +13 -17
- package/lib/Transaction.js +22 -28
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +6 -12
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +7 -27
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +3 -3
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +18 -40
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +23 -43
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +3 -3
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +23 -90
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +15 -17
- package/package.json +3 -3
- package/react.js +53 -1
- package/lib/LocalEventTrapMixin.js +0 -53
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactContext.js +0 -74
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/createFullPageComponent.js +0 -58
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
|
@@ -17,15 +17,32 @@ var DOMProperty = require("./DOMProperty");
|
|
|
17
17
|
var quoteAttributeValueForBrowser = require("./quoteAttributeValueForBrowser");
|
|
18
18
|
var warning = require("./warning");
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
// Simplified subset
|
|
21
|
+
var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][a-zA-Z_\.\-\d]*$/;
|
|
22
|
+
var illegalAttributeNameCache = {};
|
|
23
|
+
var validatedAttributeNameCache = {};
|
|
24
|
+
|
|
25
|
+
function isAttributeNameSafe(attributeName) {
|
|
26
|
+
if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
|
33
|
+
validatedAttributeNameCache[attributeName] = true;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
illegalAttributeNameCache[attributeName] = true;
|
|
37
|
+
'production' !== process.env.NODE_ENV ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
|
|
38
|
+
return false;
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
function shouldIgnoreValue(propertyInfo, value) {
|
|
42
|
+
return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
29
46
|
var reactProps = {
|
|
30
47
|
children: true,
|
|
31
48
|
dangerouslySetInnerHTML: true,
|
|
@@ -34,9 +51,8 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
34
51
|
};
|
|
35
52
|
var warnedProperties = {};
|
|
36
53
|
|
|
37
|
-
var warnUnknownProperty = function(name) {
|
|
38
|
-
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
|
|
39
|
-
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
54
|
+
var warnUnknownProperty = function (name) {
|
|
55
|
+
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
40
56
|
return;
|
|
41
57
|
}
|
|
42
58
|
|
|
@@ -44,23 +60,11 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
44
60
|
var lowerCasedName = name.toLowerCase();
|
|
45
61
|
|
|
46
62
|
// data-* attributes should be lowercase; suggest the lowercase version
|
|
47
|
-
var standardName = (
|
|
48
|
-
DOMProperty.isCustomAttribute(lowerCasedName) ?
|
|
49
|
-
lowerCasedName :
|
|
50
|
-
DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ?
|
|
51
|
-
DOMProperty.getPossibleStandardName[lowerCasedName] :
|
|
52
|
-
null
|
|
53
|
-
);
|
|
63
|
+
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
|
54
64
|
|
|
55
65
|
// For now, only warn when we have a suggested correction. This prevents
|
|
56
66
|
// logging too much when using transferPropsTo.
|
|
57
|
-
|
|
58
|
-
standardName == null,
|
|
59
|
-
'Unknown DOM property %s. Did you mean %s?',
|
|
60
|
-
name,
|
|
61
|
-
standardName
|
|
62
|
-
) : null);
|
|
63
|
-
|
|
67
|
+
'production' !== process.env.NODE_ENV ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -75,9 +79,8 @@ var DOMPropertyOperations = {
|
|
|
75
79
|
* @param {string} id Unescaped ID.
|
|
76
80
|
* @return {string} Markup string.
|
|
77
81
|
*/
|
|
78
|
-
createMarkupForID: function(id) {
|
|
79
|
-
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
|
|
80
|
-
quoteAttributeValueForBrowser(id);
|
|
82
|
+
createMarkupForID: function (id) {
|
|
83
|
+
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
|
|
81
84
|
},
|
|
82
85
|
|
|
83
86
|
/**
|
|
@@ -87,16 +90,15 @@ var DOMPropertyOperations = {
|
|
|
87
90
|
* @param {*} value
|
|
88
91
|
* @return {?string} Markup string, or null if the property was invalid.
|
|
89
92
|
*/
|
|
90
|
-
createMarkupForProperty: function(name, value) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (shouldIgnoreValue(
|
|
93
|
+
createMarkupForProperty: function (name, value) {
|
|
94
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
95
|
+
if (propertyInfo) {
|
|
96
|
+
if (shouldIgnoreValue(propertyInfo, value)) {
|
|
94
97
|
return '';
|
|
95
98
|
}
|
|
96
|
-
var attributeName =
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
return attributeName;
|
|
99
|
+
var attributeName = propertyInfo.attributeName;
|
|
100
|
+
if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
|
|
101
|
+
return attributeName + '=""';
|
|
100
102
|
}
|
|
101
103
|
return attributeName + '=' + quoteAttributeValueForBrowser(value);
|
|
102
104
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
@@ -104,12 +106,26 @@ var DOMPropertyOperations = {
|
|
|
104
106
|
return '';
|
|
105
107
|
}
|
|
106
108
|
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
107
|
-
} else if (
|
|
109
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
108
110
|
warnUnknownProperty(name);
|
|
109
111
|
}
|
|
110
112
|
return null;
|
|
111
113
|
},
|
|
112
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Creates markup for a custom property.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} name
|
|
119
|
+
* @param {*} value
|
|
120
|
+
* @return {string} Markup string, or empty string if the property was invalid.
|
|
121
|
+
*/
|
|
122
|
+
createMarkupForCustomAttribute: function (name, value) {
|
|
123
|
+
if (!isAttributeNameSafe(name) || value == null) {
|
|
124
|
+
return '';
|
|
125
|
+
}
|
|
126
|
+
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
127
|
+
},
|
|
128
|
+
|
|
113
129
|
/**
|
|
114
130
|
* Sets the value for a property on a node.
|
|
115
131
|
*
|
|
@@ -117,72 +133,80 @@ var DOMPropertyOperations = {
|
|
|
117
133
|
* @param {string} name
|
|
118
134
|
* @param {*} value
|
|
119
135
|
*/
|
|
120
|
-
setValueForProperty: function(node, name, value) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var mutationMethod =
|
|
136
|
+
setValueForProperty: function (node, name, value) {
|
|
137
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
138
|
+
if (propertyInfo) {
|
|
139
|
+
var mutationMethod = propertyInfo.mutationMethod;
|
|
124
140
|
if (mutationMethod) {
|
|
125
141
|
mutationMethod(node, value);
|
|
126
|
-
} else if (shouldIgnoreValue(
|
|
142
|
+
} else if (shouldIgnoreValue(propertyInfo, value)) {
|
|
127
143
|
this.deleteValueForProperty(node, name);
|
|
128
|
-
} else if (
|
|
144
|
+
} else if (propertyInfo.mustUseAttribute) {
|
|
145
|
+
var attributeName = propertyInfo.attributeName;
|
|
146
|
+
var namespace = propertyInfo.attributeNamespace;
|
|
129
147
|
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
|
130
148
|
// ('' + value) makes it output the correct toString()-value.
|
|
131
|
-
|
|
149
|
+
if (namespace) {
|
|
150
|
+
node.setAttributeNS(namespace, attributeName, '' + value);
|
|
151
|
+
} else {
|
|
152
|
+
node.setAttribute(attributeName, '' + value);
|
|
153
|
+
}
|
|
132
154
|
} else {
|
|
133
|
-
var propName =
|
|
155
|
+
var propName = propertyInfo.propertyName;
|
|
134
156
|
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
|
135
157
|
// property type before comparing; only `value` does and is string.
|
|
136
|
-
if (!
|
|
137
|
-
('' + node[propName]) !== ('' + value)) {
|
|
158
|
+
if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
|
|
138
159
|
// Contrary to `setAttribute`, object properties are properly
|
|
139
160
|
// `toString`ed by IE8/9.
|
|
140
161
|
node[propName] = value;
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
164
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
node.setAttribute(name, '' + value);
|
|
148
|
-
}
|
|
149
|
-
} else if ("production" !== process.env.NODE_ENV) {
|
|
165
|
+
DOMPropertyOperations.setValueForAttribute(node, name, value);
|
|
166
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
150
167
|
warnUnknownProperty(name);
|
|
151
168
|
}
|
|
152
169
|
},
|
|
153
170
|
|
|
171
|
+
setValueForAttribute: function (node, name, value) {
|
|
172
|
+
if (!isAttributeNameSafe(name)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (value == null) {
|
|
176
|
+
node.removeAttribute(name);
|
|
177
|
+
} else {
|
|
178
|
+
node.setAttribute(name, '' + value);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
154
182
|
/**
|
|
155
183
|
* Deletes the value for a property on a node.
|
|
156
184
|
*
|
|
157
185
|
* @param {DOMElement} node
|
|
158
186
|
* @param {string} name
|
|
159
187
|
*/
|
|
160
|
-
deleteValueForProperty: function(node, name) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var mutationMethod =
|
|
188
|
+
deleteValueForProperty: function (node, name) {
|
|
189
|
+
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
|
|
190
|
+
if (propertyInfo) {
|
|
191
|
+
var mutationMethod = propertyInfo.mutationMethod;
|
|
164
192
|
if (mutationMethod) {
|
|
165
193
|
mutationMethod(node, undefined);
|
|
166
|
-
} else if (
|
|
167
|
-
node.removeAttribute(
|
|
194
|
+
} else if (propertyInfo.mustUseAttribute) {
|
|
195
|
+
node.removeAttribute(propertyInfo.attributeName);
|
|
168
196
|
} else {
|
|
169
|
-
var propName =
|
|
170
|
-
var defaultValue = DOMProperty.getDefaultValueForProperty(
|
|
171
|
-
|
|
172
|
-
propName
|
|
173
|
-
);
|
|
174
|
-
if (!DOMProperty.hasSideEffects[name] ||
|
|
175
|
-
('' + node[propName]) !== defaultValue) {
|
|
197
|
+
var propName = propertyInfo.propertyName;
|
|
198
|
+
var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
|
|
199
|
+
if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) {
|
|
176
200
|
node[propName] = defaultValue;
|
|
177
201
|
}
|
|
178
202
|
}
|
|
179
203
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
180
204
|
node.removeAttribute(name);
|
|
181
|
-
} else if (
|
|
205
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
182
206
|
warnUnknownProperty(name);
|
|
183
207
|
}
|
|
184
208
|
}
|
|
185
209
|
|
|
186
210
|
};
|
|
187
211
|
|
|
188
|
-
module.exports = DOMPropertyOperations;
|
|
212
|
+
module.exports = DOMPropertyOperations;
|
package/lib/Danger.js
CHANGED
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
/*jslint evil: true, sub: true */
|
|
14
|
-
|
|
15
13
|
'use strict';
|
|
16
14
|
|
|
17
15
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
@@ -50,22 +48,13 @@ var Danger = {
|
|
|
50
48
|
* @return {array<DOMElement>} List of rendered nodes.
|
|
51
49
|
* @internal
|
|
52
50
|
*/
|
|
53
|
-
dangerouslyRenderMarkup: function(markupList) {
|
|
54
|
-
|
|
55
|
-
ExecutionEnvironment.canUseDOM,
|
|
56
|
-
'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
|
|
57
|
-
'thread. Make sure `window` and `document` are available globally ' +
|
|
58
|
-
'before requiring React when unit testing or use ' +
|
|
59
|
-
'React.renderToString for server rendering.'
|
|
60
|
-
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
51
|
+
dangerouslyRenderMarkup: function (markupList) {
|
|
52
|
+
!ExecutionEnvironment.canUseDOM ? 'production' !== process.env.NODE_ENV ? 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 ' + 'React.renderToString for server rendering.') : invariant(false) : undefined;
|
|
61
53
|
var nodeName;
|
|
62
54
|
var markupByNodeName = {};
|
|
63
55
|
// Group markup by `nodeName` if a wrap is necessary, else by '*'.
|
|
64
56
|
for (var i = 0; i < markupList.length; i++) {
|
|
65
|
-
|
|
66
|
-
markupList[i],
|
|
67
|
-
'dangerouslyRenderMarkup(...): Missing markup.'
|
|
68
|
-
) : invariant(markupList[i]));
|
|
57
|
+
!markupList[i] ? 'production' !== process.env.NODE_ENV ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
|
|
69
58
|
nodeName = getNodeName(markupList[i]);
|
|
70
59
|
nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
|
|
71
60
|
markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
|
|
@@ -90,61 +79,41 @@ var Danger = {
|
|
|
90
79
|
// Push the requested markup with an additional RESULT_INDEX_ATTR
|
|
91
80
|
// attribute. If the markup does not start with a < character, it
|
|
92
81
|
// will be discarded below (with an appropriate console.error).
|
|
93
|
-
markupListByNodeName[resultIndex] = markup.replace(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" '
|
|
97
|
-
);
|
|
82
|
+
markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP,
|
|
83
|
+
// This index will be parsed back out below.
|
|
84
|
+
'$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" ');
|
|
98
85
|
}
|
|
99
86
|
}
|
|
100
87
|
|
|
101
88
|
// Render each group of markup with similar wrapping `nodeName`.
|
|
102
|
-
var renderNodes = createNodesFromMarkup(
|
|
103
|
-
markupListByNodeName.join(''),
|
|
104
|
-
emptyFunction // Do nothing special with <script> tags.
|
|
89
|
+
var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags.
|
|
105
90
|
);
|
|
106
91
|
|
|
107
92
|
for (var j = 0; j < renderNodes.length; ++j) {
|
|
108
93
|
var renderNode = renderNodes[j];
|
|
109
|
-
if (renderNode.hasAttribute &&
|
|
110
|
-
renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
|
94
|
+
if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
|
|
111
95
|
|
|
112
96
|
resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
|
|
113
97
|
renderNode.removeAttribute(RESULT_INDEX_ATTR);
|
|
114
98
|
|
|
115
|
-
(
|
|
116
|
-
!resultList.hasOwnProperty(resultIndex),
|
|
117
|
-
'Danger: Assigning to an already-occupied result index.'
|
|
118
|
-
) : invariant(!resultList.hasOwnProperty(resultIndex)));
|
|
99
|
+
!!resultList.hasOwnProperty(resultIndex) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
|
|
119
100
|
|
|
120
101
|
resultList[resultIndex] = renderNode;
|
|
121
102
|
|
|
122
103
|
// This should match resultList.length and markupList.length when
|
|
123
104
|
// we're done.
|
|
124
105
|
resultListAssignmentCount += 1;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.error(
|
|
128
|
-
'Danger: Discarding unexpected node:',
|
|
129
|
-
renderNode
|
|
130
|
-
);
|
|
106
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
107
|
+
console.error('Danger: Discarding unexpected node:', renderNode);
|
|
131
108
|
}
|
|
132
109
|
}
|
|
133
110
|
}
|
|
134
111
|
|
|
135
112
|
// Although resultList was populated out of order, it should now be a dense
|
|
136
113
|
// array.
|
|
137
|
-
(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
) : invariant(resultListAssignmentCount === resultList.length));
|
|
141
|
-
|
|
142
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
143
|
-
resultList.length === markupList.length,
|
|
144
|
-
'Danger: Expected markup to render %s nodes, but rendered %s.',
|
|
145
|
-
markupList.length,
|
|
146
|
-
resultList.length
|
|
147
|
-
) : invariant(resultList.length === markupList.length));
|
|
114
|
+
!(resultListAssignmentCount === resultList.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
|
|
115
|
+
|
|
116
|
+
!(resultList.length === markupList.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
|
|
148
117
|
|
|
149
118
|
return resultList;
|
|
150
119
|
},
|
|
@@ -157,22 +126,10 @@ var Danger = {
|
|
|
157
126
|
* @param {string} markup Markup to render in place of the child node.
|
|
158
127
|
* @internal
|
|
159
128
|
*/
|
|
160
|
-
dangerouslyReplaceNodeWithMarkup: function(oldChild, markup) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
'worker thread. Make sure `window` and `document` are available ' +
|
|
165
|
-
'globally before requiring React when unit testing or use ' +
|
|
166
|
-
'React.renderToString for server rendering.'
|
|
167
|
-
) : invariant(ExecutionEnvironment.canUseDOM));
|
|
168
|
-
("production" !== process.env.NODE_ENV ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
|
|
169
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
170
|
-
oldChild.tagName.toLowerCase() !== 'html',
|
|
171
|
-
'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' +
|
|
172
|
-
'<html> node. This is because browser quirks make this unreliable ' +
|
|
173
|
-
'and/or slow. If you want to render to the root you must use ' +
|
|
174
|
-
'server rendering. See React.renderToString().'
|
|
175
|
-
) : invariant(oldChild.tagName.toLowerCase() !== 'html'));
|
|
129
|
+
dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
|
|
130
|
+
!ExecutionEnvironment.canUseDOM ? 'production' !== process.env.NODE_ENV ? 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 ' + 'React.renderToString for server rendering.') : invariant(false) : undefined;
|
|
131
|
+
!markup ? 'production' !== process.env.NODE_ENV ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
|
|
132
|
+
!(oldChild.tagName.toLowerCase() !== 'html') ? 'production' !== process.env.NODE_ENV ? 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 React.renderToString().') : invariant(false) : undefined;
|
|
176
133
|
|
|
177
134
|
var newChild = createNodesFromMarkup(markup, emptyFunction)[0];
|
|
178
135
|
oldChild.parentNode.replaceChild(newChild, oldChild);
|
|
@@ -180,4 +137,4 @@ var Danger = {
|
|
|
180
137
|
|
|
181
138
|
};
|
|
182
139
|
|
|
183
|
-
module.exports = Danger;
|
|
140
|
+
module.exports = Danger;
|
|
@@ -22,16 +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 = [
|
|
26
|
-
keyOf({ResponderEventPlugin: null}),
|
|
27
|
-
keyOf({SimpleEventPlugin: null}),
|
|
28
|
-
keyOf({TapEventPlugin: null}),
|
|
29
|
-
keyOf({EnterLeaveEventPlugin: null}),
|
|
30
|
-
keyOf({ChangeEventPlugin: null}),
|
|
31
|
-
keyOf({SelectEventPlugin: null}),
|
|
32
|
-
keyOf({BeforeInputEventPlugin: null}),
|
|
33
|
-
keyOf({AnalyticsEventPlugin: null}),
|
|
34
|
-
keyOf({MobileSafariClickEventPlugin: null})
|
|
35
|
-
];
|
|
25
|
+
var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null }), keyOf({ AnalyticsEventPlugin: null })];
|
|
36
26
|
|
|
37
|
-
module.exports = DefaultEventPluginOrder;
|
|
27
|
+
module.exports = DefaultEventPluginOrder;
|
|
@@ -24,18 +24,12 @@ var getFirstReactDOM = ReactMount.getFirstReactDOM;
|
|
|
24
24
|
|
|
25
25
|
var eventTypes = {
|
|
26
26
|
mouseEnter: {
|
|
27
|
-
registrationName: keyOf({onMouseEnter: null}),
|
|
28
|
-
dependencies: [
|
|
29
|
-
topLevelTypes.topMouseOut,
|
|
30
|
-
topLevelTypes.topMouseOver
|
|
31
|
-
]
|
|
27
|
+
registrationName: keyOf({ onMouseEnter: null }),
|
|
28
|
+
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
|
|
32
29
|
},
|
|
33
30
|
mouseLeave: {
|
|
34
|
-
registrationName: keyOf({onMouseLeave: null}),
|
|
35
|
-
dependencies: [
|
|
36
|
-
topLevelTypes.topMouseOut,
|
|
37
|
-
topLevelTypes.topMouseOver
|
|
38
|
-
]
|
|
31
|
+
registrationName: keyOf({ onMouseLeave: null }),
|
|
32
|
+
dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
|
|
39
33
|
}
|
|
40
34
|
};
|
|
41
35
|
|
|
@@ -59,17 +53,11 @@ var EnterLeaveEventPlugin = {
|
|
|
59
53
|
* @return {*} An accumulation of synthetic events.
|
|
60
54
|
* @see {EventPluginHub.extractEvents}
|
|
61
55
|
*/
|
|
62
|
-
extractEvents: function(
|
|
63
|
-
|
|
64
|
-
topLevelTarget,
|
|
65
|
-
topLevelTargetID,
|
|
66
|
-
nativeEvent) {
|
|
67
|
-
if (topLevelType === topLevelTypes.topMouseOver &&
|
|
68
|
-
(nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
|
56
|
+
extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
57
|
+
if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
|
|
69
58
|
return null;
|
|
70
59
|
}
|
|
71
|
-
if (topLevelType !== topLevelTypes.topMouseOut &&
|
|
72
|
-
topLevelType !== topLevelTypes.topMouseOver) {
|
|
60
|
+
if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
|
|
73
61
|
// Must not be a mouse in or mouse out - ignoring.
|
|
74
62
|
return null;
|
|
75
63
|
}
|
|
@@ -91,9 +79,7 @@ var EnterLeaveEventPlugin = {
|
|
|
91
79
|
var from, to;
|
|
92
80
|
if (topLevelType === topLevelTypes.topMouseOut) {
|
|
93
81
|
from = topLevelTarget;
|
|
94
|
-
to =
|
|
95
|
-
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
|
|
96
|
-
win;
|
|
82
|
+
to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) || win;
|
|
97
83
|
} else {
|
|
98
84
|
from = win;
|
|
99
85
|
to = topLevelTarget;
|
|
@@ -107,20 +93,12 @@ var EnterLeaveEventPlugin = {
|
|
|
107
93
|
var fromID = from ? ReactMount.getID(from) : '';
|
|
108
94
|
var toID = to ? ReactMount.getID(to) : '';
|
|
109
95
|
|
|
110
|
-
var leave = SyntheticMouseEvent.getPooled(
|
|
111
|
-
eventTypes.mouseLeave,
|
|
112
|
-
fromID,
|
|
113
|
-
nativeEvent
|
|
114
|
-
);
|
|
96
|
+
var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
|
|
115
97
|
leave.type = 'mouseleave';
|
|
116
98
|
leave.target = from;
|
|
117
99
|
leave.relatedTarget = to;
|
|
118
100
|
|
|
119
|
-
var enter = SyntheticMouseEvent.getPooled(
|
|
120
|
-
eventTypes.mouseEnter,
|
|
121
|
-
toID,
|
|
122
|
-
nativeEvent
|
|
123
|
-
);
|
|
101
|
+
var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
|
|
124
102
|
enter.type = 'mouseenter';
|
|
125
103
|
enter.target = to;
|
|
126
104
|
enter.relatedTarget = from;
|
|
@@ -135,4 +113,4 @@ var EnterLeaveEventPlugin = {
|
|
|
135
113
|
|
|
136
114
|
};
|
|
137
115
|
|
|
138
|
-
module.exports = EnterLeaveEventPlugin;
|
|
116
|
+
module.exports = EnterLeaveEventPlugin;
|