react 0.14.0-alpha3 → 0.14.0-rc1
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 +8 -3
- package/dist/react-dom.js +42 -0
- package/dist/react-dom.min.js +12 -0
- package/dist/react-with-addons.js +6076 -5337
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +5445 -4839
- 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 +18 -3
- package/lib/CSSPropertyOperations.js +22 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +18 -15
- package/lib/DOMChildrenOperations.js +17 -7
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +84 -33
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +21 -13
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +17 -20
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +33 -42
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +19 -3
- 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 +15 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +56 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +75 -35
- package/lib/ReactClass.js +70 -87
- package/lib/ReactComponent.js +27 -20
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +117 -106
- package/lib/ReactDOM.js +74 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +441 -72
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -66
- package/lib/ReactDOMInput.js +87 -99
- package/lib/ReactDOMOption.js +25 -44
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -72
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -11
- package/lib/ReactElement.js +92 -107
- package/lib/ReactElementValidator.js +53 -173
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +45 -9
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +64 -12
- package/lib/ReactFragment.js +29 -115
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +196 -122
- package/lib/ReactMultiChild.js +119 -25
- 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 +41 -12
- package/lib/ReactReconcileTransaction.js +12 -10
- package/lib/ReactReconciler.js +8 -11
- package/lib/ReactRef.js +15 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +8 -7
- package/lib/ReactTestUtils.js +89 -64
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +60 -35
- package/lib/ReactUpdates.js +15 -18
- package/lib/{isTextNode.js → ReactVersion.js} +2 -13
- package/lib/ReactWithAddons.js +24 -17
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +25 -16
- package/lib/SimpleEventPlugin.js +200 -45
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +24 -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 +17 -11
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +48 -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 +27 -25
- 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 +216 -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/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +21 -19
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +2 -0
- 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/dist/JSXTransformer.js +0 -17589
- 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/ReactDOMClient.js +0 -85
- 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/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/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,14 @@
|
|
|
18
18
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
|
-
var ReactElement = require(
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
26
|
-
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
21
|
+
var ReactElement = require('./ReactElement');
|
|
22
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
23
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
24
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
27
25
|
|
|
28
|
-
var getIteratorFn = require(
|
|
29
|
-
var invariant = require(
|
|
30
|
-
var warning = require(
|
|
26
|
+
var getIteratorFn = require('./getIteratorFn');
|
|
27
|
+
var invariant = require('fbjs/lib/invariant');
|
|
28
|
+
var warning = require('fbjs/lib/warning');
|
|
31
29
|
|
|
32
30
|
function getDeclarationErrorAddendum() {
|
|
33
31
|
if (ReactCurrentOwner.current) {
|
|
@@ -48,37 +46,6 @@ var ownerHasKeyUseWarning = {};
|
|
|
48
46
|
|
|
49
47
|
var loggedTypeFailures = {};
|
|
50
48
|
|
|
51
|
-
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Gets the instance's name for use in warnings.
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
* @return {?string} Display name or undefined
|
|
58
|
-
*/
|
|
59
|
-
function getName(instance) {
|
|
60
|
-
var publicInstance = instance && instance.getPublicInstance();
|
|
61
|
-
if (!publicInstance) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
var constructor = publicInstance.constructor;
|
|
65
|
-
if (!constructor) {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
return constructor.displayName || constructor.name || undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Gets the current owner's displayName for use in warnings.
|
|
73
|
-
*
|
|
74
|
-
* @internal
|
|
75
|
-
* @return {?string} Display name or undefined
|
|
76
|
-
*/
|
|
77
|
-
function getCurrentOwnerDisplayName() {
|
|
78
|
-
var current = ReactCurrentOwner.current;
|
|
79
|
-
return current && getName(current) || undefined;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
49
|
/**
|
|
83
50
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
84
51
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -95,58 +62,54 @@ function validateExplicitKey(element, parentType) {
|
|
|
95
62
|
}
|
|
96
63
|
element._store.validated = true;
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Warn if the key is being defined as an object property but has an incorrect
|
|
103
|
-
* value.
|
|
104
|
-
*
|
|
105
|
-
* @internal
|
|
106
|
-
* @param {string} name Property name of the key.
|
|
107
|
-
* @param {ReactElement} element Component that requires a key.
|
|
108
|
-
* @param {*} parentType element's parent's type.
|
|
109
|
-
*/
|
|
110
|
-
function validatePropertyKey(name, element, parentType) {
|
|
111
|
-
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
65
|
+
var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
|
|
66
|
+
if (addenda === null) {
|
|
67
|
+
// we already showed the warning
|
|
112
68
|
return;
|
|
113
69
|
}
|
|
114
|
-
|
|
70
|
+
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;
|
|
115
71
|
}
|
|
116
72
|
|
|
117
73
|
/**
|
|
118
74
|
* Shared warning and monitoring code for the key warnings.
|
|
119
75
|
*
|
|
120
76
|
* @internal
|
|
121
|
-
* @param {string}
|
|
77
|
+
* @param {string} messageType A key used for de-duping warnings.
|
|
122
78
|
* @param {ReactElement} element Component that requires a key.
|
|
123
79
|
* @param {*} parentType element's parent's type.
|
|
80
|
+
* @returns {?object} A set of addenda to use in the warning message, or null
|
|
81
|
+
* if the warning has already been shown before (and shouldn't be shown again).
|
|
124
82
|
*/
|
|
125
|
-
function
|
|
126
|
-
var
|
|
127
|
-
|
|
83
|
+
function getAddendaForKeyUse(messageType, element, parentType) {
|
|
84
|
+
var addendum = getDeclarationErrorAddendum();
|
|
85
|
+
if (!addendum) {
|
|
86
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
87
|
+
if (parentName) {
|
|
88
|
+
addendum = ' Check the top-level render call using <' + parentName + '>.';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
128
91
|
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return;
|
|
92
|
+
var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
|
|
93
|
+
if (memoizer[addendum]) {
|
|
94
|
+
return null;
|
|
133
95
|
}
|
|
134
|
-
memoizer[
|
|
96
|
+
memoizer[addendum] = true;
|
|
135
97
|
|
|
136
|
-
var
|
|
98
|
+
var addenda = {
|
|
99
|
+
parentOrOwner: addendum,
|
|
100
|
+
url: ' See https://fb.me/react-warning-keys for more information.',
|
|
101
|
+
childOwner: null
|
|
102
|
+
};
|
|
137
103
|
|
|
138
104
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
139
105
|
// property, it may be the creator of the child that's responsible for
|
|
140
106
|
// assigning it a key.
|
|
141
|
-
var childOwnerAddendum = '';
|
|
142
107
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
|
|
108
|
+
// Give the component that originally created this child.
|
|
109
|
+
addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
|
|
147
110
|
}
|
|
148
111
|
|
|
149
|
-
|
|
112
|
+
return addenda;
|
|
150
113
|
}
|
|
151
114
|
|
|
152
115
|
/**
|
|
@@ -159,6 +122,9 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
|
|
|
159
122
|
* @param {*} parentType node's parent's type.
|
|
160
123
|
*/
|
|
161
124
|
function validateChildKeys(node, parentType) {
|
|
125
|
+
if (typeof node !== 'object') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
162
128
|
if (Array.isArray(node)) {
|
|
163
129
|
for (var i = 0; i < node.length; i++) {
|
|
164
130
|
var child = node[i];
|
|
@@ -168,7 +134,9 @@ function validateChildKeys(node, parentType) {
|
|
|
168
134
|
}
|
|
169
135
|
} else if (ReactElement.isValidElement(node)) {
|
|
170
136
|
// This element was passed in a valid location.
|
|
171
|
-
node._store
|
|
137
|
+
if (node._store) {
|
|
138
|
+
node._store.validated = true;
|
|
139
|
+
}
|
|
172
140
|
} else if (node) {
|
|
173
141
|
var iteratorFn = getIteratorFn(node);
|
|
174
142
|
// Entry iterators provide implicit keys.
|
|
@@ -182,13 +150,6 @@ function validateChildKeys(node, parentType) {
|
|
|
182
150
|
}
|
|
183
151
|
}
|
|
184
152
|
}
|
|
185
|
-
} else if (typeof node === 'object') {
|
|
186
|
-
var fragment = ReactFragment.extractIfFragment(node);
|
|
187
|
-
for (var key in fragment) {
|
|
188
|
-
if (fragment.hasOwnProperty(key)) {
|
|
189
|
-
validatePropertyKey(key, fragment[key], parentType);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
153
|
}
|
|
193
154
|
}
|
|
194
155
|
}
|
|
@@ -212,93 +173,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
|
|
|
212
173
|
try {
|
|
213
174
|
// This is intentionally an invariant that gets caught. It's the same
|
|
214
175
|
// behavior as without this statement except with a better message.
|
|
215
|
-
!(typeof propTypes[propName] === 'function') ?
|
|
176
|
+
!(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;
|
|
216
177
|
error = propTypes[propName](props, propName, componentName, location);
|
|
217
178
|
} catch (ex) {
|
|
218
179
|
error = ex;
|
|
219
180
|
}
|
|
220
|
-
|
|
181
|
+
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;
|
|
221
182
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
222
183
|
// Only monitor this failure once because there tends to be a lot of the
|
|
223
184
|
// same error.
|
|
224
185
|
loggedTypeFailures[error.message] = true;
|
|
225
186
|
|
|
226
187
|
var addendum = getDeclarationErrorAddendum();
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
var warnedPropsMutations = {};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Warn about mutating props when setting `propName` on `element`.
|
|
237
|
-
*
|
|
238
|
-
* @param {string} propName The string key within props that was set
|
|
239
|
-
* @param {ReactElement} element
|
|
240
|
-
*/
|
|
241
|
-
function warnForPropsMutation(propName, element) {
|
|
242
|
-
var type = element.type;
|
|
243
|
-
var elementName = typeof type === 'string' ? type : type.displayName;
|
|
244
|
-
var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
|
|
245
|
-
|
|
246
|
-
var warningKey = propName + '|' + elementName + '|' + ownerName;
|
|
247
|
-
if (warnedPropsMutations.hasOwnProperty(warningKey)) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
warnedPropsMutations[warningKey] = true;
|
|
251
|
-
|
|
252
|
-
var elementInfo = '';
|
|
253
|
-
if (elementName) {
|
|
254
|
-
elementInfo = ' <' + elementName + ' />';
|
|
255
|
-
}
|
|
256
|
-
var ownerInfo = '';
|
|
257
|
-
if (ownerName) {
|
|
258
|
-
ownerInfo = ' The element was created by ' + ownerName + '.';
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
'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) : undefined;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Inline Object.is polyfill
|
|
265
|
-
function is(a, b) {
|
|
266
|
-
if (a !== a) {
|
|
267
|
-
// NaN
|
|
268
|
-
return b !== b;
|
|
269
|
-
}
|
|
270
|
-
if (a === 0 && b === 0) {
|
|
271
|
-
// +-0
|
|
272
|
-
return 1 / a === 1 / b;
|
|
273
|
-
}
|
|
274
|
-
return a === b;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Given an element, check if its props have been mutated since element
|
|
279
|
-
* creation (or the last call to this function). In particular, check if any
|
|
280
|
-
* new props have been added, which we can't directly catch by defining warning
|
|
281
|
-
* properties on the props object.
|
|
282
|
-
*
|
|
283
|
-
* @param {ReactElement} element
|
|
284
|
-
*/
|
|
285
|
-
function checkAndWarnForMutatedProps(element) {
|
|
286
|
-
if (!element._store) {
|
|
287
|
-
// Element was created using `new ReactElement` directly or with
|
|
288
|
-
// `ReactElement.createElement`; skip mutation checking
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
var originalProps = element._store.originalProps;
|
|
293
|
-
var props = element.props;
|
|
294
|
-
|
|
295
|
-
for (var propName in props) {
|
|
296
|
-
if (props.hasOwnProperty(propName)) {
|
|
297
|
-
if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
|
|
298
|
-
warnForPropsMutation(propName, element);
|
|
299
|
-
|
|
300
|
-
// Copy over the new value so that the two props objects match again
|
|
301
|
-
originalProps[propName] = props[propName];
|
|
188
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
|
|
302
189
|
}
|
|
303
190
|
}
|
|
304
191
|
}
|
|
@@ -311,32 +198,25 @@ function checkAndWarnForMutatedProps(element) {
|
|
|
311
198
|
* @param {ReactElement} element
|
|
312
199
|
*/
|
|
313
200
|
function validatePropTypes(element) {
|
|
314
|
-
|
|
315
|
-
|
|
201
|
+
var componentClass = element.type;
|
|
202
|
+
if (typeof componentClass !== 'function') {
|
|
316
203
|
return;
|
|
317
204
|
}
|
|
318
|
-
// Extract the component class from the element. Converts string types
|
|
319
|
-
// to a composite class which may have propTypes.
|
|
320
|
-
// TODO: Validating a string's propTypes is not decoupled from the
|
|
321
|
-
// rendering target which is problematic.
|
|
322
|
-
var componentClass = ReactNativeComponent.getComponentClassForElement(element);
|
|
323
205
|
var name = componentClass.displayName || componentClass.name;
|
|
324
206
|
if (componentClass.propTypes) {
|
|
325
207
|
checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
|
|
326
208
|
}
|
|
327
209
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
328
|
-
|
|
210
|
+
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;
|
|
329
211
|
}
|
|
330
212
|
}
|
|
331
213
|
|
|
332
214
|
var ReactElementValidator = {
|
|
333
215
|
|
|
334
|
-
checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
|
|
335
|
-
|
|
336
216
|
createElement: function (type, props, children) {
|
|
337
217
|
// We warn in this case but don't throw. We expect the element creation to
|
|
338
218
|
// succeed and there will likely be errors in render.
|
|
339
|
-
|
|
219
|
+
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;
|
|
340
220
|
|
|
341
221
|
var element = ReactElement.createElement.apply(this, arguments);
|
|
342
222
|
|
|
@@ -360,19 +240,21 @@ var ReactElementValidator = {
|
|
|
360
240
|
// Legacy hook TODO: Warn if this is accessed
|
|
361
241
|
validatedFactory.type = type;
|
|
362
242
|
|
|
363
|
-
if (
|
|
243
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
364
244
|
try {
|
|
365
245
|
Object.defineProperty(validatedFactory, 'type', {
|
|
366
246
|
enumerable: false,
|
|
367
247
|
get: function () {
|
|
368
|
-
|
|
248
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
|
|
369
249
|
Object.defineProperty(this, 'type', {
|
|
370
250
|
value: type
|
|
371
251
|
});
|
|
372
252
|
return type;
|
|
373
253
|
}
|
|
374
254
|
});
|
|
375
|
-
} catch (x) {
|
|
255
|
+
} catch (x) {
|
|
256
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
257
|
+
}
|
|
376
258
|
}
|
|
377
259
|
|
|
378
260
|
return validatedFactory;
|
|
@@ -389,6 +271,4 @@ var ReactElementValidator = {
|
|
|
389
271
|
|
|
390
272
|
};
|
|
391
273
|
|
|
392
|
-
module.exports = ReactElementValidator;
|
|
393
|
-
|
|
394
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
274
|
+
module.exports = ReactElementValidator;
|
|
@@ -11,77 +11,41 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactElement = require(
|
|
15
|
-
var
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
var ReactEmptyComponentRegistry = require('./ReactEmptyComponentRegistry');
|
|
16
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
var assign = require('./Object.assign');
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
-
// This registry keeps track of the React IDs of the components that rendered to
|
|
21
|
-
// `null` (in reality a placeholder such as `noscript`)
|
|
22
|
-
var nullComponentIDsRegistry = {};
|
|
20
|
+
var placeholderElement;
|
|
23
21
|
|
|
24
22
|
var ReactEmptyComponentInjection = {
|
|
25
|
-
injectEmptyComponent: function (
|
|
26
|
-
|
|
23
|
+
injectEmptyComponent: function (component) {
|
|
24
|
+
placeholderElement = ReactElement.createElement(component);
|
|
27
25
|
}
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// need this check. We're going to assume if we're here it means we ran
|
|
35
|
-
// componentWillUnmount already so there is no internal instance (it gets
|
|
36
|
-
// removed as part of the unmounting process).
|
|
37
|
-
if (!internalInstance) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
registerNullComponentID(internalInstance._rootNodeID);
|
|
28
|
+
var ReactEmptyComponent = function (instantiate) {
|
|
29
|
+
this._currentElement = null;
|
|
30
|
+
this._rootNodeID = null;
|
|
31
|
+
this._renderedComponent = instantiate(placeholderElement);
|
|
41
32
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
assign(ReactEmptyComponent.prototype, {
|
|
34
|
+
construct: function (element) {},
|
|
35
|
+
mountComponent: function (rootID, transaction, context) {
|
|
36
|
+
ReactEmptyComponentRegistry.registerNullComponentID(rootID);
|
|
37
|
+
this._rootNodeID = rootID;
|
|
38
|
+
return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
|
|
39
|
+
},
|
|
40
|
+
receiveComponent: function () {},
|
|
41
|
+
unmountComponent: function (rootID, transaction, context) {
|
|
42
|
+
ReactReconciler.unmountComponent(this._renderedComponent);
|
|
43
|
+
ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
|
|
44
|
+
this._rootNodeID = null;
|
|
45
|
+
this._renderedComponent = null;
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
ReactEmptyComponentType.prototype.render = function () {
|
|
51
|
-
!component ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Trying to return null from a render, but no null placeholder component ' + 'was injected.') : invariant(false) : undefined;
|
|
52
|
-
return component();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Mark the component as having rendered to null.
|
|
59
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
60
|
-
*/
|
|
61
|
-
function registerNullComponentID(id) {
|
|
62
|
-
nullComponentIDsRegistry[id] = true;
|
|
63
|
-
}
|
|
47
|
+
});
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
* Unmark the component as having rendered to null: it renders to something now.
|
|
67
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
68
|
-
*/
|
|
69
|
-
function deregisterNullComponentID(id) {
|
|
70
|
-
delete nullComponentIDsRegistry[id];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @param {string} id Component's `_rootNodeID`.
|
|
75
|
-
* @return {boolean} True if the component is rendered to null.
|
|
76
|
-
*/
|
|
77
|
-
function isNullComponentID(id) {
|
|
78
|
-
return !!nullComponentIDsRegistry[id];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var ReactEmptyComponent = {
|
|
82
|
-
emptyElement: emptyElement,
|
|
83
|
-
injection: ReactEmptyComponentInjection,
|
|
84
|
-
isNullComponentID: isNullComponentID
|
|
85
|
-
};
|
|
49
|
+
ReactEmptyComponent.injection = ReactEmptyComponentInjection;
|
|
86
50
|
|
|
87
51
|
module.exports = ReactEmptyComponent;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactEmptyComponentRegistry
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
// This registry keeps track of the React IDs of the components that rendered to
|
|
15
|
+
// `null` (in reality a placeholder such as `noscript`)
|
|
16
|
+
var nullComponentIDsRegistry = {};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
20
|
+
* @return {boolean} True if the component is rendered to null.
|
|
21
|
+
*/
|
|
22
|
+
function isNullComponentID(id) {
|
|
23
|
+
return !!nullComponentIDsRegistry[id];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Mark the component as having rendered to null.
|
|
28
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
29
|
+
*/
|
|
30
|
+
function registerNullComponentID(id) {
|
|
31
|
+
nullComponentIDsRegistry[id] = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Unmark the component as having rendered to null: it renders to something now.
|
|
36
|
+
* @param {string} id Component's `_rootNodeID`.
|
|
37
|
+
*/
|
|
38
|
+
function deregisterNullComponentID(id) {
|
|
39
|
+
delete nullComponentIDsRegistry[id];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var ReactEmptyComponentRegistry = {
|
|
43
|
+
isNullComponentID: isNullComponentID,
|
|
44
|
+
registerNullComponentID: registerNullComponentID,
|
|
45
|
+
deregisterNullComponentID: deregisterNullComponentID
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = ReactEmptyComponentRegistry;
|