react 0.13.2 → 0.14.0-alpha3
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 +1 -1
- package/addons.js +7 -0
- package/addons/CSSTransitionGroup.js +1 -0
- package/addons/LinkedStateMixin.js +1 -0
- package/addons/Perf.js +1 -0
- package/addons/PureRenderMixin.js +1 -0
- package/addons/TestUtils.js +1 -0
- package/addons/TransitionGroup.js +1 -0
- package/addons/batchedUpdates.js +1 -0
- package/addons/cloneWithProps.js +1 -0
- package/addons/createFragment.js +1 -0
- package/addons/renderSubtreeIntoContainer.js +1 -0
- package/addons/shallowCompare.js +1 -0
- package/addons/update.js +1 -0
- package/dist/JSXTransformer.js +3355 -1685
- package/dist/react-with-addons.js +3320 -5133
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +2962 -4548
- package/dist/react.min.js +5 -5
- package/lib/AutoFocusMixin.js +4 -3
- 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 +24 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +41 -67
- package/lib/DOMPropertyOperations.js +30 -51
- 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 +27 -38
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +7 -19
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +34 -64
- package/lib/LocalEventTrapMixin.js +9 -16
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +8 -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 +18 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +21 -28
- package/lib/ReactClass.js +81 -234
- package/lib/ReactComponent.js +17 -33
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +4 -5
- package/lib/ReactCompositeComponent.js +87 -311
- package/lib/ReactContext.js +2 -44
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +3 -4
- package/lib/ReactDOMClient.js +85 -0
- package/lib/ReactDOMComponent.js +182 -146
- package/lib/ReactDOMForm.js +3 -3
- package/lib/ReactDOMIDOperations.js +11 -22
- package/lib/ReactDOMIframe.js +3 -3
- package/lib/ReactDOMImg.js +3 -3
- package/lib/ReactDOMInput.js +22 -35
- package/lib/ReactDOMOption.js +67 -10
- package/lib/ReactDOMSelect.js +50 -28
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +15 -27
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +31 -40
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +24 -57
- package/lib/ReactElementValidator.js +38 -105
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +2 -2
- package/lib/ReactEventEmitterMixin.js +3 -12
- package/lib/ReactEventListener.js +16 -38
- package/lib/ReactFragment.js +23 -54
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +11 -21
- package/lib/ReactInstanceHandles.js +27 -57
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +137 -260
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -11
- 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 +9 -34
- package/lib/ReactReconciler.js +9 -19
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +7 -15
- package/lib/ReactServerRenderingTransaction.js +7 -32
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +93 -165
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +27 -90
- package/lib/ReactUpdates.js +27 -79
- package/lib/ReactWithAddons.js +7 -6
- package/lib/SVGDOMPropertyConfig.js +41 -4
- package/lib/SelectEventPlugin.js +28 -29
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +136 -128
- package/lib/SyntheticClipboardEvent.js +3 -7
- package/lib/SyntheticCompositionEvent.js +3 -9
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +8 -10
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +3 -9
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +8 -14
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +3 -3
- package/lib/SyntheticWheelEvent.js +11 -15
- package/lib/Transaction.js +12 -24
- 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 +5 -11
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createFullPageComponent.js +4 -11
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +5 -24
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +7 -5
- 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 +14 -38
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +2 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +2 -2
- 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 +22 -89
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +17 -15
- package/package.json +3 -3
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
|
@@ -18,14 +18,10 @@ var quoteAttributeValueForBrowser = require("./quoteAttributeValueForBrowser");
|
|
|
18
18
|
var warning = require("./warning");
|
|
19
19
|
|
|
20
20
|
function shouldIgnoreValue(name, value) {
|
|
21
|
-
return value == null ||
|
|
22
|
-
(DOMProperty.hasBooleanValue[name] && !value) ||
|
|
23
|
-
(DOMProperty.hasNumericValue[name] && isNaN(value)) ||
|
|
24
|
-
(DOMProperty.hasPositiveNumericValue[name] && (value < 1)) ||
|
|
25
|
-
(DOMProperty.hasOverloadedBooleanValue[name] && value === false);
|
|
21
|
+
return value == null || DOMProperty.hasBooleanValue[name] && !value || DOMProperty.hasNumericValue[name] && isNaN(value) || DOMProperty.hasPositiveNumericValue[name] && value < 1 || DOMProperty.hasOverloadedBooleanValue[name] && value === false;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
if (
|
|
24
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
29
25
|
var reactProps = {
|
|
30
26
|
children: true,
|
|
31
27
|
dangerouslySetInnerHTML: true,
|
|
@@ -34,9 +30,8 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
34
30
|
};
|
|
35
31
|
var warnedProperties = {};
|
|
36
32
|
|
|
37
|
-
var warnUnknownProperty = function(name) {
|
|
38
|
-
if (reactProps.hasOwnProperty(name) && reactProps[name] ||
|
|
39
|
-
warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
33
|
+
var warnUnknownProperty = function (name) {
|
|
34
|
+
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
40
35
|
return;
|
|
41
36
|
}
|
|
42
37
|
|
|
@@ -44,23 +39,11 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
44
39
|
var lowerCasedName = name.toLowerCase();
|
|
45
40
|
|
|
46
41
|
// 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
|
-
);
|
|
42
|
+
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
|
54
43
|
|
|
55
44
|
// For now, only warn when we have a suggested correction. This prevents
|
|
56
45
|
// 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
|
-
|
|
46
|
+
'production' !== process.env.NODE_ENV ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
|
|
64
47
|
};
|
|
65
48
|
}
|
|
66
49
|
|
|
@@ -75,9 +58,8 @@ var DOMPropertyOperations = {
|
|
|
75
58
|
* @param {string} id Unescaped ID.
|
|
76
59
|
* @return {string} Markup string.
|
|
77
60
|
*/
|
|
78
|
-
createMarkupForID: function(id) {
|
|
79
|
-
return DOMProperty.ID_ATTRIBUTE_NAME + '=' +
|
|
80
|
-
quoteAttributeValueForBrowser(id);
|
|
61
|
+
createMarkupForID: function (id) {
|
|
62
|
+
return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
|
|
81
63
|
},
|
|
82
64
|
|
|
83
65
|
/**
|
|
@@ -87,16 +69,14 @@ var DOMPropertyOperations = {
|
|
|
87
69
|
* @param {*} value
|
|
88
70
|
* @return {?string} Markup string, or null if the property was invalid.
|
|
89
71
|
*/
|
|
90
|
-
createMarkupForProperty: function(name, value) {
|
|
91
|
-
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
92
|
-
DOMProperty.isStandardName[name]) {
|
|
72
|
+
createMarkupForProperty: function (name, value) {
|
|
73
|
+
if (DOMProperty.isStandardName.hasOwnProperty(name) && DOMProperty.isStandardName[name]) {
|
|
93
74
|
if (shouldIgnoreValue(name, value)) {
|
|
94
75
|
return '';
|
|
95
76
|
}
|
|
96
77
|
var attributeName = DOMProperty.getAttributeName[name];
|
|
97
|
-
if (DOMProperty.hasBooleanValue[name] ||
|
|
98
|
-
|
|
99
|
-
return attributeName;
|
|
78
|
+
if (DOMProperty.hasBooleanValue[name] || DOMProperty.hasOverloadedBooleanValue[name] && value === true) {
|
|
79
|
+
return attributeName + '=""';
|
|
100
80
|
}
|
|
101
81
|
return attributeName + '=' + quoteAttributeValueForBrowser(value);
|
|
102
82
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
@@ -104,7 +84,7 @@ var DOMPropertyOperations = {
|
|
|
104
84
|
return '';
|
|
105
85
|
}
|
|
106
86
|
return name + '=' + quoteAttributeValueForBrowser(value);
|
|
107
|
-
} else if (
|
|
87
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
108
88
|
warnUnknownProperty(name);
|
|
109
89
|
}
|
|
110
90
|
return null;
|
|
@@ -117,24 +97,28 @@ var DOMPropertyOperations = {
|
|
|
117
97
|
* @param {string} name
|
|
118
98
|
* @param {*} value
|
|
119
99
|
*/
|
|
120
|
-
setValueForProperty: function(node, name, value) {
|
|
121
|
-
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
122
|
-
DOMProperty.isStandardName[name]) {
|
|
100
|
+
setValueForProperty: function (node, name, value) {
|
|
101
|
+
if (DOMProperty.isStandardName.hasOwnProperty(name) && DOMProperty.isStandardName[name]) {
|
|
123
102
|
var mutationMethod = DOMProperty.getMutationMethod[name];
|
|
124
103
|
if (mutationMethod) {
|
|
125
104
|
mutationMethod(node, value);
|
|
126
105
|
} else if (shouldIgnoreValue(name, value)) {
|
|
127
106
|
this.deleteValueForProperty(node, name);
|
|
128
107
|
} else if (DOMProperty.mustUseAttribute[name]) {
|
|
108
|
+
var attributeName = DOMProperty.getAttributeName[name];
|
|
109
|
+
var namespace = DOMProperty.getAttributeNamespace[name];
|
|
129
110
|
// `setAttribute` with objects becomes only `[object]` in IE8/9,
|
|
130
111
|
// ('' + value) makes it output the correct toString()-value.
|
|
131
|
-
|
|
112
|
+
if (namespace) {
|
|
113
|
+
node.setAttributeNS(namespace, attributeName, '' + value);
|
|
114
|
+
} else {
|
|
115
|
+
node.setAttribute(attributeName, '' + value);
|
|
116
|
+
}
|
|
132
117
|
} else {
|
|
133
118
|
var propName = DOMProperty.getPropertyName[name];
|
|
134
119
|
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
|
|
135
120
|
// property type before comparing; only `value` does and is string.
|
|
136
|
-
if (!DOMProperty.hasSideEffects[name] ||
|
|
137
|
-
('' + node[propName]) !== ('' + value)) {
|
|
121
|
+
if (!DOMProperty.hasSideEffects[name] || '' + node[propName] !== '' + value) {
|
|
138
122
|
// Contrary to `setAttribute`, object properties are properly
|
|
139
123
|
// `toString`ed by IE8/9.
|
|
140
124
|
node[propName] = value;
|
|
@@ -146,7 +130,7 @@ var DOMPropertyOperations = {
|
|
|
146
130
|
} else {
|
|
147
131
|
node.setAttribute(name, '' + value);
|
|
148
132
|
}
|
|
149
|
-
} else if (
|
|
133
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
150
134
|
warnUnknownProperty(name);
|
|
151
135
|
}
|
|
152
136
|
},
|
|
@@ -157,9 +141,8 @@ var DOMPropertyOperations = {
|
|
|
157
141
|
* @param {DOMElement} node
|
|
158
142
|
* @param {string} name
|
|
159
143
|
*/
|
|
160
|
-
deleteValueForProperty: function(node, name) {
|
|
161
|
-
if (DOMProperty.isStandardName.hasOwnProperty(name) &&
|
|
162
|
-
DOMProperty.isStandardName[name]) {
|
|
144
|
+
deleteValueForProperty: function (node, name) {
|
|
145
|
+
if (DOMProperty.isStandardName.hasOwnProperty(name) && DOMProperty.isStandardName[name]) {
|
|
163
146
|
var mutationMethod = DOMProperty.getMutationMethod[name];
|
|
164
147
|
if (mutationMethod) {
|
|
165
148
|
mutationMethod(node, undefined);
|
|
@@ -167,22 +150,18 @@ var DOMPropertyOperations = {
|
|
|
167
150
|
node.removeAttribute(DOMProperty.getAttributeName[name]);
|
|
168
151
|
} else {
|
|
169
152
|
var propName = DOMProperty.getPropertyName[name];
|
|
170
|
-
var defaultValue = DOMProperty.getDefaultValueForProperty(
|
|
171
|
-
|
|
172
|
-
propName
|
|
173
|
-
);
|
|
174
|
-
if (!DOMProperty.hasSideEffects[name] ||
|
|
175
|
-
('' + node[propName]) !== defaultValue) {
|
|
153
|
+
var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
|
|
154
|
+
if (!DOMProperty.hasSideEffects[name] || '' + node[propName] !== defaultValue) {
|
|
176
155
|
node[propName] = defaultValue;
|
|
177
156
|
}
|
|
178
157
|
}
|
|
179
158
|
} else if (DOMProperty.isCustomAttribute(name)) {
|
|
180
159
|
node.removeAttribute(name);
|
|
181
|
-
} else if (
|
|
160
|
+
} else if ('production' !== process.env.NODE_ENV) {
|
|
182
161
|
warnUnknownProperty(name);
|
|
183
162
|
}
|
|
184
163
|
}
|
|
185
164
|
|
|
186
165
|
};
|
|
187
166
|
|
|
188
|
-
module.exports = DOMPropertyOperations;
|
|
167
|
+
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) {
|
|
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);
|
|
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);
|
|
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;
|
package/lib/EventConstants.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var keyMirror = require("./keyMirror");
|
|
15
15
|
|
|
16
|
-
var PropagationPhases = keyMirror({bubbled: null, captured: null});
|
|
16
|
+
var PropagationPhases = keyMirror({ bubbled: null, captured: null });
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Types of raw signals from the browser caught at the top level.
|
|
@@ -67,4 +67,4 @@ var EventConstants = {
|
|
|
67
67
|
PropagationPhases: PropagationPhases
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
module.exports = EventConstants;
|
|
70
|
+
module.exports = EventConstants;
|
package/lib/EventListener.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* @typechecks
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
20
22
|
var emptyFunction = require("./emptyFunction");
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -32,18 +34,18 @@ var EventListener = {
|
|
|
32
34
|
* @param {function} callback Callback function.
|
|
33
35
|
* @return {object} Object with a `remove` method.
|
|
34
36
|
*/
|
|
35
|
-
listen: function(target, eventType, callback) {
|
|
37
|
+
listen: function (target, eventType, callback) {
|
|
36
38
|
if (target.addEventListener) {
|
|
37
39
|
target.addEventListener(eventType, callback, false);
|
|
38
40
|
return {
|
|
39
|
-
remove: function() {
|
|
41
|
+
remove: function () {
|
|
40
42
|
target.removeEventListener(eventType, callback, false);
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
} else if (target.attachEvent) {
|
|
44
46
|
target.attachEvent('on' + eventType, callback);
|
|
45
47
|
return {
|
|
46
|
-
remove: function() {
|
|
48
|
+
remove: function () {
|
|
47
49
|
target.detachEvent('on' + eventType, callback);
|
|
48
50
|
}
|
|
49
51
|
};
|
|
@@ -58,14 +60,10 @@ var EventListener = {
|
|
|
58
60
|
* @param {function} callback Callback function.
|
|
59
61
|
* @return {object} Object with a `remove` method.
|
|
60
62
|
*/
|
|
61
|
-
capture: function(target, eventType, callback) {
|
|
63
|
+
capture: function (target, eventType, callback) {
|
|
62
64
|
if (!target.addEventListener) {
|
|
63
|
-
if (
|
|
64
|
-
console.error(
|
|
65
|
-
'Attempted to listen to events during the capture phase on a ' +
|
|
66
|
-
'browser that does not support the capture phase. Your application ' +
|
|
67
|
-
'will not receive some events.'
|
|
68
|
-
);
|
|
65
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
66
|
+
console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.');
|
|
69
67
|
}
|
|
70
68
|
return {
|
|
71
69
|
remove: emptyFunction
|
|
@@ -73,14 +71,14 @@ var EventListener = {
|
|
|
73
71
|
} else {
|
|
74
72
|
target.addEventListener(eventType, callback, true);
|
|
75
73
|
return {
|
|
76
|
-
remove: function() {
|
|
74
|
+
remove: function () {
|
|
77
75
|
target.removeEventListener(eventType, callback, true);
|
|
78
76
|
}
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
},
|
|
82
80
|
|
|
83
|
-
registerDefault: function() {}
|
|
81
|
+
registerDefault: function () {}
|
|
84
82
|
};
|
|
85
83
|
|
|
86
|
-
module.exports = EventListener;
|
|
84
|
+
module.exports = EventListener;
|