react 0.14.0-alpha1 → 0.14.0-beta2
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 +5 -2
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5376 -4800
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +5175 -4626
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -119
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +14 -5
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +9 -111
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +24 -22
- package/lib/ReactClass.js +68 -86
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -4
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +384 -62
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -25
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +38 -42
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +13 -13
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +34 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +35 -92
- package/lib/ReactElementValidator.js +53 -130
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +90 -89
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +72 -33
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -3
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -9
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +24 -27
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +199 -100
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- 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/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
|
@@ -18,16 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
var ReactElement = require(
|
|
22
|
-
var ReactFragment = require(
|
|
23
|
-
var ReactPropTypeLocations = require(
|
|
24
|
-
var ReactPropTypeLocationNames = require(
|
|
25
|
-
var ReactCurrentOwner = require(
|
|
26
|
-
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
21
|
+
var ReactElement = require('./ReactElement');
|
|
22
|
+
var ReactFragment = require('./ReactFragment');
|
|
23
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
24
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
25
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
27
26
|
|
|
28
|
-
var getIteratorFn = require(
|
|
29
|
-
var invariant = require(
|
|
30
|
-
var warning = require(
|
|
27
|
+
var getIteratorFn = require('./getIteratorFn');
|
|
28
|
+
var invariant = require('fbjs/lib/invariant');
|
|
29
|
+
var warning = require('fbjs/lib/warning');
|
|
31
30
|
|
|
32
31
|
function getDeclarationErrorAddendum() {
|
|
33
32
|
if (ReactCurrentOwner.current) {
|
|
@@ -90,10 +89,17 @@ function getCurrentOwnerDisplayName() {
|
|
|
90
89
|
* @param {*} parentType element's parent's type.
|
|
91
90
|
*/
|
|
92
91
|
function validateExplicitKey(element, parentType) {
|
|
93
|
-
if (element.key != null) {
|
|
92
|
+
if (element._store.validated || element.key != null) {
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
96
|
-
|
|
95
|
+
element._store.validated = true;
|
|
96
|
+
|
|
97
|
+
var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
|
|
98
|
+
if (addenda === null) {
|
|
99
|
+
// we already showed the warning
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
/**
|
|
@@ -109,42 +115,50 @@ function validatePropertyKey(name, element, parentType) {
|
|
|
109
115
|
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
110
116
|
return;
|
|
111
117
|
}
|
|
112
|
-
|
|
118
|
+
var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
|
|
119
|
+
if (addenda === null) {
|
|
120
|
+
// we already showed the warning
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
/**
|
|
116
127
|
* Shared warning and monitoring code for the key warnings.
|
|
117
128
|
*
|
|
118
129
|
* @internal
|
|
119
|
-
* @param {string}
|
|
130
|
+
* @param {string} messageType A key used for de-duping warnings.
|
|
120
131
|
* @param {ReactElement} element Component that requires a key.
|
|
121
132
|
* @param {*} parentType element's parent's type.
|
|
133
|
+
* @returns {?object} A set of addenda to use in the warning message, or null
|
|
134
|
+
* if the warning has already been shown before (and shouldn't be shown again).
|
|
122
135
|
*/
|
|
123
|
-
function
|
|
136
|
+
function getAddendaForKeyUse(messageType, element, parentType) {
|
|
124
137
|
var ownerName = getCurrentOwnerDisplayName();
|
|
125
138
|
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
126
139
|
|
|
127
140
|
var useName = ownerName || parentName;
|
|
128
|
-
var memoizer = ownerHasKeyUseWarning[
|
|
129
|
-
if (memoizer
|
|
130
|
-
return;
|
|
141
|
+
var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
|
|
142
|
+
if (memoizer[useName]) {
|
|
143
|
+
return null;
|
|
131
144
|
}
|
|
132
145
|
memoizer[useName] = true;
|
|
133
146
|
|
|
134
|
-
var
|
|
147
|
+
var addenda = {
|
|
148
|
+
parentOrOwner: ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : null,
|
|
149
|
+
url: ' See https://fb.me/react-warning-keys for more information.',
|
|
150
|
+
childOwner: null
|
|
151
|
+
};
|
|
135
152
|
|
|
136
153
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
137
154
|
// property, it may be the creator of the child that's responsible for
|
|
138
155
|
// assigning it a key.
|
|
139
|
-
var childOwnerAddendum = '';
|
|
140
156
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
|
|
157
|
+
// Give the component that originally created this child.
|
|
158
|
+
addenda.childOwner = ' It was passed a child from ' + getName(element._owner) + '.';
|
|
145
159
|
}
|
|
146
160
|
|
|
147
|
-
|
|
161
|
+
return addenda;
|
|
148
162
|
}
|
|
149
163
|
|
|
150
164
|
/**
|
|
@@ -158,22 +172,15 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
|
|
|
158
172
|
*/
|
|
159
173
|
function validateChildKeys(node, parentType) {
|
|
160
174
|
if (Array.isArray(node)) {
|
|
161
|
-
if (node._reactChildKeysValidated) {
|
|
162
|
-
// All child elements were passed in a valid location.
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
175
|
for (var i = 0; i < node.length; i++) {
|
|
166
176
|
var child = node[i];
|
|
167
177
|
if (ReactElement.isValidElement(child)) {
|
|
168
178
|
validateExplicitKey(child, parentType);
|
|
169
|
-
} else {
|
|
170
|
-
// TODO: Warn on unkeyed arrays and suggest using createFragment
|
|
171
|
-
validateChildKeys(child, parentType);
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
|
-
} else if (
|
|
181
|
+
} else if (ReactElement.isValidElement(node)) {
|
|
175
182
|
// This element was passed in a valid location.
|
|
176
|
-
|
|
183
|
+
node._store.validated = true;
|
|
177
184
|
} else if (node) {
|
|
178
185
|
var iteratorFn = getIteratorFn(node);
|
|
179
186
|
// Entry iterators provide implicit keys.
|
|
@@ -184,8 +191,6 @@ function validateChildKeys(node, parentType) {
|
|
|
184
191
|
while (!(step = iterator.next()).done) {
|
|
185
192
|
if (ReactElement.isValidElement(step.value)) {
|
|
186
193
|
validateExplicitKey(step.value, parentType);
|
|
187
|
-
} else {
|
|
188
|
-
validateChildKeys(step.value, parentType);
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
196
|
}
|
|
@@ -194,7 +199,6 @@ function validateChildKeys(node, parentType) {
|
|
|
194
199
|
for (var key in fragment) {
|
|
195
200
|
if (fragment.hasOwnProperty(key)) {
|
|
196
201
|
validatePropertyKey(key, fragment[key], parentType);
|
|
197
|
-
validateChildKeys(fragment[key], parentType);
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
@@ -220,93 +224,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
|
|
|
220
224
|
try {
|
|
221
225
|
// This is intentionally an invariant that gets caught. It's the same
|
|
222
226
|
// behavior as without this statement except with a better message.
|
|
223
|
-
'
|
|
227
|
+
!(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
|
|
224
228
|
error = propTypes[propName](props, propName, componentName, location);
|
|
225
229
|
} catch (ex) {
|
|
226
230
|
error = ex;
|
|
227
231
|
}
|
|
228
|
-
|
|
232
|
+
process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
|
|
229
233
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
230
234
|
// Only monitor this failure once because there tends to be a lot of the
|
|
231
235
|
// same error.
|
|
232
236
|
loggedTypeFailures[error.message] = true;
|
|
233
237
|
|
|
234
238
|
var addendum = getDeclarationErrorAddendum();
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
var warnedPropsMutations = {};
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Warn about mutating props when setting `propName` on `element`.
|
|
245
|
-
*
|
|
246
|
-
* @param {string} propName The string key within props that was set
|
|
247
|
-
* @param {ReactElement} element
|
|
248
|
-
*/
|
|
249
|
-
function warnForPropsMutation(propName, element) {
|
|
250
|
-
var type = element.type;
|
|
251
|
-
var elementName = typeof type === 'string' ? type : type.displayName;
|
|
252
|
-
var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
|
|
253
|
-
|
|
254
|
-
var warningKey = propName + '|' + elementName + '|' + ownerName;
|
|
255
|
-
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
warnedPropsMutations[warningKey] = true;
|
|
259
|
-
|
|
260
|
-
var elementInfo = '';
|
|
261
|
-
if (elementName) {
|
|
262
|
-
elementInfo = ' <' + elementName + ' />';
|
|
263
|
-
}
|
|
264
|
-
var ownerInfo = '';
|
|
265
|
-
if (ownerName) {
|
|
266
|
-
ownerInfo = ' The element was created by ' + ownerName + '.';
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set .props.%s of the React component%s. Instead, specify the ' + 'correct value when initially creating the element or use ' + 'React.cloneElement to make a new element with updated props.%s', propName, elementInfo, ownerInfo) : null;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Inline Object.is polyfill
|
|
273
|
-
function is(a, b) {
|
|
274
|
-
if (a !== a) {
|
|
275
|
-
// NaN
|
|
276
|
-
return b !== b;
|
|
277
|
-
}
|
|
278
|
-
if (a === 0 && b === 0) {
|
|
279
|
-
// +-0
|
|
280
|
-
return 1 / a === 1 / b;
|
|
281
|
-
}
|
|
282
|
-
return a === b;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Given an element, check if its props have been mutated since element
|
|
287
|
-
* creation (or the last call to this function). In particular, check if any
|
|
288
|
-
* new props have been added, which we can't directly catch by defining warning
|
|
289
|
-
* properties on the props object.
|
|
290
|
-
*
|
|
291
|
-
* @param {ReactElement} element
|
|
292
|
-
*/
|
|
293
|
-
function checkAndWarnForMutatedProps(element) {
|
|
294
|
-
if (!element._store) {
|
|
295
|
-
// Element was created using `new ReactElement` directly or with
|
|
296
|
-
// `ReactElement.createElement`; skip mutation checking
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
var originalProps = element._store.originalProps;
|
|
301
|
-
var props = element.props;
|
|
302
|
-
|
|
303
|
-
for (var propName in props) {
|
|
304
|
-
if (props.hasOwnProperty(propName)) {
|
|
305
|
-
if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
|
|
306
|
-
warnForPropsMutation(propName, element);
|
|
307
|
-
|
|
308
|
-
// Copy over the new value so that the two props objects match again
|
|
309
|
-
originalProps[propName] = props[propName];
|
|
239
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
|
|
310
240
|
}
|
|
311
241
|
}
|
|
312
242
|
}
|
|
@@ -319,32 +249,25 @@ function checkAndWarnForMutatedProps(element) {
|
|
|
319
249
|
* @param {ReactElement} element
|
|
320
250
|
*/
|
|
321
251
|
function validatePropTypes(element) {
|
|
322
|
-
|
|
323
|
-
|
|
252
|
+
var componentClass = element.type;
|
|
253
|
+
if (typeof componentClass !== 'function') {
|
|
324
254
|
return;
|
|
325
255
|
}
|
|
326
|
-
// Extract the component class from the element. Converts string types
|
|
327
|
-
// to a composite class which may have propTypes.
|
|
328
|
-
// TODO: Validating a string's propTypes is not decoupled from the
|
|
329
|
-
// rendering target which is problematic.
|
|
330
|
-
var componentClass = ReactNativeComponent.getComponentClassForElement(element);
|
|
331
256
|
var name = componentClass.displayName || componentClass.name;
|
|
332
257
|
if (componentClass.propTypes) {
|
|
333
258
|
checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
|
|
334
259
|
}
|
|
335
260
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
336
|
-
|
|
261
|
+
process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
|
|
337
262
|
}
|
|
338
263
|
}
|
|
339
264
|
|
|
340
265
|
var ReactElementValidator = {
|
|
341
266
|
|
|
342
|
-
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
|
|
343
|
-
|
|
344
267
|
createElement: function (type, props, children) {
|
|
345
268
|
// We warn in this case but don't throw. We expect the element creation to
|
|
346
269
|
// succeed and there will likely be errors in render.
|
|
347
|
-
|
|
270
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
|
|
348
271
|
|
|
349
272
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
350
273
|
|
|
@@ -368,19 +291,21 @@ var ReactElementValidator = {
|
|
|
368
291
|
// Legacy hook TODO: Warn if this is accessed
|
|
369
292
|
validatedFactory.type = type;
|
|
370
293
|
|
|
371
|
-
if (
|
|
294
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
372
295
|
try {
|
|
373
296
|
Object.defineProperty(validatedFactory, 'type', {
|
|
374
297
|
enumerable: false,
|
|
375
298
|
get: function () {
|
|
376
|
-
|
|
299
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
|
|
377
300
|
Object.defineProperty(this, 'type', {
|
|
378
301
|
value: type
|
|
379
302
|
});
|
|
380
303
|
return type;
|
|
381
304
|
}
|
|
382
305
|
});
|
|
383
|
-
} catch (x) {
|
|
306
|
+
} catch (x) {
|
|
307
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
308
|
+
}
|
|
384
309
|
}
|
|
385
310
|
|
|
386
311
|
return validatedFactory;
|
|
@@ -397,6 +322,4 @@ var ReactElementValidator = {
|
|
|
397
322
|
|
|
398
323
|
};
|
|
399
324
|
|
|
400
|
-
module.exports = ReactElementValidator;
|
|
401
|
-
|
|
402
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
325
|
+
module.exports = ReactElementValidator;
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactElement = require(
|
|
15
|
-
var ReactInstanceMap = require(
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
16
16
|
|
|
17
|
-
var invariant = require(
|
|
17
|
+
var invariant = require('fbjs/lib/invariant');
|
|
18
18
|
|
|
19
19
|
var component;
|
|
20
20
|
// This registry keeps track of the React IDs of the components that rendered to
|
|
@@ -48,7 +48,7 @@ ReactEmptyComponentType.prototype.componentWillUnmount = function () {
|
|
|
48
48
|
deregisterNullComponentID(internalInstance._rootNodeID);
|
|
49
49
|
};
|
|
50
50
|
ReactEmptyComponentType.prototype.render = function () {
|
|
51
|
-
|
|
51
|
+
!component ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(false) : undefined;
|
|
52
52
|
return component();
|
|
53
53
|
};
|
|
54
54
|
|
package/lib/ReactErrorUtils.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var EventPluginHub = require(
|
|
14
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
15
15
|
|
|
16
16
|
function runEventQueueInBatch(events) {
|
|
17
17
|
EventPluginHub.enqueueEvents(events);
|
|
@@ -29,9 +29,8 @@ var ReactEventEmitterMixin = {
|
|
|
29
29
|
* @param {string} topLevelTargetID ID of `topLevelTarget`.
|
|
30
30
|
* @param {object} nativeEvent Native environment event.
|
|
31
31
|
*/
|
|
32
|
-
handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent) {
|
|
33
|
-
var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent);
|
|
34
|
-
|
|
32
|
+
handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
|
|
33
|
+
var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
|
|
35
34
|
runEventQueueInBatch(events);
|
|
36
35
|
}
|
|
37
36
|
};
|
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var EventListener = require(
|
|
16
|
-
var ExecutionEnvironment = require(
|
|
17
|
-
var PooledClass = require(
|
|
18
|
-
var ReactInstanceHandles = require(
|
|
19
|
-
var ReactMount = require(
|
|
20
|
-
var ReactUpdates = require(
|
|
15
|
+
var EventListener = require('fbjs/lib/EventListener');
|
|
16
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
|
+
var PooledClass = require('./PooledClass');
|
|
18
|
+
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
19
|
+
var ReactMount = require('./ReactMount');
|
|
20
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
21
21
|
|
|
22
|
-
var assign = require(
|
|
23
|
-
var getEventTarget = require(
|
|
24
|
-
var getUnboundedScrollPosition = require(
|
|
22
|
+
var assign = require('./Object.assign');
|
|
23
|
+
var getEventTarget = require('./getEventTarget');
|
|
24
|
+
var getUnboundedScrollPosition = require('fbjs/lib/getUnboundedScrollPosition');
|
|
25
|
+
|
|
26
|
+
var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Finds the parent React component of `node`.
|
|
@@ -57,6 +59,17 @@ assign(TopLevelCallbackBookKeeping.prototype, {
|
|
|
57
59
|
PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
|
|
58
60
|
|
|
59
61
|
function handleTopLevelImpl(bookKeeping) {
|
|
62
|
+
if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
|
|
63
|
+
// New browsers have a path attribute on native events
|
|
64
|
+
handleTopLevelWithPath(bookKeeping);
|
|
65
|
+
} else {
|
|
66
|
+
// Legacy browsers don't have a path attribute on native events
|
|
67
|
+
handleTopLevelWithoutPath(bookKeeping);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Legacy browsers don't have a path attribute on native events
|
|
72
|
+
function handleTopLevelWithoutPath(bookKeeping) {
|
|
60
73
|
var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
|
|
61
74
|
|
|
62
75
|
// Loop through the hierarchy, in case there's any nested components.
|
|
@@ -72,7 +85,39 @@ function handleTopLevelImpl(bookKeeping) {
|
|
|
72
85
|
for (var i = 0; i < bookKeeping.ancestors.length; i++) {
|
|
73
86
|
topLevelTarget = bookKeeping.ancestors[i];
|
|
74
87
|
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
|
|
75
|
-
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent);
|
|
88
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// New browsers have a path attribute on native events
|
|
93
|
+
function handleTopLevelWithPath(bookKeeping) {
|
|
94
|
+
var path = bookKeeping.nativeEvent.path;
|
|
95
|
+
var currentNativeTarget = path[0];
|
|
96
|
+
var eventsFired = 0;
|
|
97
|
+
for (var i = 0; i < path.length; i++) {
|
|
98
|
+
var currentPathElement = path[i];
|
|
99
|
+
var currentPathElementID = ReactMount.getID(currentPathElement);
|
|
100
|
+
if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
|
|
101
|
+
currentNativeTarget = path[i + 1];
|
|
102
|
+
}
|
|
103
|
+
if (ReactMount.isRenderedByReact(currentPathElement)) {
|
|
104
|
+
var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
|
|
105
|
+
bookKeeping.ancestors.push(currentPathElement);
|
|
106
|
+
|
|
107
|
+
var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
|
|
108
|
+
eventsFired++;
|
|
109
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
|
|
110
|
+
|
|
111
|
+
// Jump to the root of this React render tree
|
|
112
|
+
while (currentPathElementID !== newRootID) {
|
|
113
|
+
i++;
|
|
114
|
+
currentPathElement = path[i];
|
|
115
|
+
currentPathElementID = ReactMount.getID(currentPathElement);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (eventsFired === 0) {
|
|
120
|
+
ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
|
|
76
121
|
}
|
|
77
122
|
}
|
|
78
123
|
|
|
@@ -105,7 +150,7 @@ var ReactEventListener = {
|
|
|
105
150
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
106
151
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
107
152
|
* @param {object} handle Element on which to attach listener.
|
|
108
|
-
* @return {object} An object with a remove function which will forcefully
|
|
153
|
+
* @return {?object} An object with a remove function which will forcefully
|
|
109
154
|
* remove the listener.
|
|
110
155
|
* @internal
|
|
111
156
|
*/
|
|
@@ -123,7 +168,7 @@ var ReactEventListener = {
|
|
|
123
168
|
* @param {string} topLevelType Record from `EventConstants`.
|
|
124
169
|
* @param {string} handlerBaseName Event name (e.g. "click").
|
|
125
170
|
* @param {object} handle Element on which to attach listener.
|
|
126
|
-
* @return {object} An object with a remove function which will forcefully
|
|
171
|
+
* @return {?object} An object with a remove function which will forcefully
|
|
127
172
|
* remove the listener.
|
|
128
173
|
* @internal
|
|
129
174
|
*/
|