react 0.14.10 → 15.0.0
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/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactChildReconciler
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -23,10 +22,10 @@ function instantiateChild(childInstances, child, name) {
|
|
|
23
22
|
// We found a component instance.
|
|
24
23
|
var keyUnique = childInstances[name] === undefined;
|
|
25
24
|
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
-
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) :
|
|
25
|
+
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : void 0;
|
|
27
26
|
}
|
|
28
27
|
if (child != null && keyUnique) {
|
|
29
|
-
childInstances[name] = instantiateReactComponent(child
|
|
28
|
+
childInstances[name] = instantiateReactComponent(child);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -63,21 +62,22 @@ var ReactChildReconciler = {
|
|
|
63
62
|
* @return {?object} A new set of child instances.
|
|
64
63
|
* @internal
|
|
65
64
|
*/
|
|
66
|
-
updateChildren: function (prevChildren, nextChildren, transaction, context) {
|
|
65
|
+
updateChildren: function (prevChildren, nextChildren, removedNodes, transaction, context) {
|
|
67
66
|
// We currently don't have a way to track moves here but if we use iterators
|
|
68
67
|
// instead of for..in we can zip the iterators and check if an item has
|
|
69
68
|
// moved.
|
|
70
69
|
// TODO: If nothing has changed, return the prevChildren object so that we
|
|
71
70
|
// can quickly bailout if nothing has changed.
|
|
72
71
|
if (!nextChildren && !prevChildren) {
|
|
73
|
-
return
|
|
72
|
+
return;
|
|
74
73
|
}
|
|
75
74
|
var name;
|
|
75
|
+
var prevChild;
|
|
76
76
|
for (name in nextChildren) {
|
|
77
77
|
if (!nextChildren.hasOwnProperty(name)) {
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
prevChild = prevChildren && prevChildren[name];
|
|
81
81
|
var prevElement = prevChild && prevChild._currentElement;
|
|
82
82
|
var nextElement = nextChildren[name];
|
|
83
83
|
if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
@@ -85,20 +85,22 @@ var ReactChildReconciler = {
|
|
|
85
85
|
nextChildren[name] = prevChild;
|
|
86
86
|
} else {
|
|
87
87
|
if (prevChild) {
|
|
88
|
-
ReactReconciler.
|
|
88
|
+
removedNodes[name] = ReactReconciler.getNativeNode(prevChild);
|
|
89
|
+
ReactReconciler.unmountComponent(prevChild, false);
|
|
89
90
|
}
|
|
90
91
|
// The child must be instantiated before it's mounted.
|
|
91
|
-
var nextChildInstance = instantiateReactComponent(nextElement
|
|
92
|
+
var nextChildInstance = instantiateReactComponent(nextElement);
|
|
92
93
|
nextChildren[name] = nextChildInstance;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
// Unmount children that are no longer present.
|
|
96
97
|
for (name in prevChildren) {
|
|
97
98
|
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
98
|
-
|
|
99
|
+
prevChild = prevChildren[name];
|
|
100
|
+
removedNodes[name] = ReactReconciler.getNativeNode(prevChild);
|
|
101
|
+
ReactReconciler.unmountComponent(prevChild, false);
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
return nextChildren;
|
|
102
104
|
},
|
|
103
105
|
|
|
104
106
|
/**
|
|
@@ -108,11 +110,11 @@ var ReactChildReconciler = {
|
|
|
108
110
|
* @param {?object} renderedChildren Previously initialized set of children.
|
|
109
111
|
* @internal
|
|
110
112
|
*/
|
|
111
|
-
unmountChildren: function (renderedChildren) {
|
|
113
|
+
unmountChildren: function (renderedChildren, safely) {
|
|
112
114
|
for (var name in renderedChildren) {
|
|
113
115
|
if (renderedChildren.hasOwnProperty(name)) {
|
|
114
116
|
var renderedChild = renderedChildren[name];
|
|
115
|
-
ReactReconciler.unmountComponent(renderedChild);
|
|
117
|
+
ReactReconciler.unmountComponent(renderedChild, safely);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
}
|
package/lib/ReactChildren.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -20,9 +20,9 @@ var traverseAllChildren = require('./traverseAllChildren');
|
|
|
20
20
|
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
|
21
21
|
var fourArgumentPooler = PooledClass.fourArgumentPooler;
|
|
22
22
|
|
|
23
|
-
var userProvidedKeyEscapeRegex =
|
|
23
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
24
24
|
function escapeUserProvidedKey(text) {
|
|
25
|
-
return ('' + text).replace(userProvidedKeyEscapeRegex, '
|
|
25
|
+
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -102,6 +102,7 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
102
102
|
var func = bookKeeping.func;
|
|
103
103
|
var context = bookKeeping.context;
|
|
104
104
|
|
|
105
|
+
|
|
105
106
|
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
106
107
|
if (Array.isArray(mappedChild)) {
|
|
107
108
|
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
|
|
@@ -110,7 +111,7 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
110
111
|
mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
|
|
111
112
|
// Keep both the (mapped) and old keys if they differ, just as
|
|
112
113
|
// traverseAllChildren used to do for objects as children
|
|
113
|
-
keyPrefix + (mappedChild
|
|
114
|
+
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
|
114
115
|
}
|
|
115
116
|
result.push(mappedChild);
|
|
116
117
|
}
|
package/lib/ReactClass.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var ReactComponent = require('./ReactComponent');
|
|
15
17
|
var ReactElement = require('./ReactElement');
|
|
16
18
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
17
19
|
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
18
20
|
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
19
21
|
|
|
20
|
-
var assign = require('./Object.assign');
|
|
21
22
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
22
23
|
var invariant = require('fbjs/lib/invariant');
|
|
23
24
|
var keyMirror = require('fbjs/lib/keyMirror');
|
|
@@ -53,14 +54,6 @@ var SpecPolicy = keyMirror({
|
|
|
53
54
|
|
|
54
55
|
var injectedMixins = [];
|
|
55
56
|
|
|
56
|
-
var warnedSetProps = false;
|
|
57
|
-
function warnSetProps() {
|
|
58
|
-
if (!warnedSetProps) {
|
|
59
|
-
warnedSetProps = true;
|
|
60
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
57
|
/**
|
|
65
58
|
* Composite components are higher-level components that compose other composite
|
|
66
59
|
* or native components.
|
|
@@ -330,13 +323,13 @@ var RESERVED_SPEC_KEYS = {
|
|
|
330
323
|
if (process.env.NODE_ENV !== 'production') {
|
|
331
324
|
validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
|
|
332
325
|
}
|
|
333
|
-
Constructor.childContextTypes =
|
|
326
|
+
Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
|
|
334
327
|
},
|
|
335
328
|
contextTypes: function (Constructor, contextTypes) {
|
|
336
329
|
if (process.env.NODE_ENV !== 'production') {
|
|
337
330
|
validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
|
|
338
331
|
}
|
|
339
|
-
Constructor.contextTypes =
|
|
332
|
+
Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
|
|
340
333
|
},
|
|
341
334
|
/**
|
|
342
335
|
* Special case getDefaultProps which should move into statics but requires
|
|
@@ -353,7 +346,7 @@ var RESERVED_SPEC_KEYS = {
|
|
|
353
346
|
if (process.env.NODE_ENV !== 'production') {
|
|
354
347
|
validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
|
|
355
348
|
}
|
|
356
|
-
Constructor.propTypes =
|
|
349
|
+
Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
|
|
357
350
|
},
|
|
358
351
|
statics: function (Constructor, statics) {
|
|
359
352
|
mixStaticSpecIntoComponent(Constructor, statics);
|
|
@@ -365,39 +358,40 @@ function validateTypeDef(Constructor, typeDef, location) {
|
|
|
365
358
|
for (var propName in typeDef) {
|
|
366
359
|
if (typeDef.hasOwnProperty(propName)) {
|
|
367
360
|
// use a warning instead of an invariant so components
|
|
368
|
-
// don't show up in prod but
|
|
369
|
-
process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) :
|
|
361
|
+
// don't show up in prod but only in __DEV__
|
|
362
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;
|
|
370
363
|
}
|
|
371
364
|
}
|
|
372
365
|
}
|
|
373
366
|
|
|
374
|
-
function validateMethodOverride(
|
|
367
|
+
function validateMethodOverride(isAlreadyDefined, name) {
|
|
375
368
|
var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
|
|
376
369
|
|
|
377
370
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
378
371
|
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
379
|
-
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) :
|
|
372
|
+
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) : void 0;
|
|
380
373
|
}
|
|
381
374
|
|
|
382
375
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
383
|
-
if (
|
|
384
|
-
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) :
|
|
376
|
+
if (isAlreadyDefined) {
|
|
377
|
+
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : void 0;
|
|
385
378
|
}
|
|
386
379
|
}
|
|
387
380
|
|
|
388
381
|
/**
|
|
389
382
|
* Mixin helper which handles policy validation and reserved
|
|
390
|
-
* specification keys when building React
|
|
383
|
+
* specification keys when building React classes.
|
|
391
384
|
*/
|
|
392
385
|
function mixSpecIntoComponent(Constructor, spec) {
|
|
393
386
|
if (!spec) {
|
|
394
387
|
return;
|
|
395
388
|
}
|
|
396
389
|
|
|
397
|
-
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) :
|
|
398
|
-
!!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) :
|
|
390
|
+
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class or function as a mixin. Instead, just use a ' + 'regular object.') : invariant(false) : void 0;
|
|
391
|
+
!!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : void 0;
|
|
399
392
|
|
|
400
393
|
var proto = Constructor.prototype;
|
|
394
|
+
var autoBindPairs = proto.__reactAutoBindPairs;
|
|
401
395
|
|
|
402
396
|
// By handling mixins before any other properties, we ensure the same
|
|
403
397
|
// chaining order is applied to methods with DEFINE_MANY policy, whether
|
|
@@ -417,7 +411,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
417
411
|
}
|
|
418
412
|
|
|
419
413
|
var property = spec[name];
|
|
420
|
-
|
|
414
|
+
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
415
|
+
validateMethodOverride(isAlreadyDefined, name);
|
|
421
416
|
|
|
422
417
|
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
|
|
423
418
|
RESERVED_SPEC_KEYS[name](Constructor, property);
|
|
@@ -427,22 +422,18 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
427
422
|
// 1. Expected ReactClass methods (in the "interface").
|
|
428
423
|
// 2. Overridden methods (that were mixed in).
|
|
429
424
|
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
|
|
430
|
-
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
431
425
|
var isFunction = typeof property === 'function';
|
|
432
426
|
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
|
|
433
427
|
|
|
434
428
|
if (shouldAutoBind) {
|
|
435
|
-
|
|
436
|
-
proto.__reactAutoBindMap = {};
|
|
437
|
-
}
|
|
438
|
-
proto.__reactAutoBindMap[name] = property;
|
|
429
|
+
autoBindPairs.push(name, property);
|
|
439
430
|
proto[name] = property;
|
|
440
431
|
} else {
|
|
441
432
|
if (isAlreadyDefined) {
|
|
442
433
|
var specPolicy = ReactClassInterface[name];
|
|
443
434
|
|
|
444
435
|
// These cases should already be caught by validateMethodOverride.
|
|
445
|
-
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) :
|
|
436
|
+
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : void 0;
|
|
446
437
|
|
|
447
438
|
// For methods which are defined more than once, call the existing
|
|
448
439
|
// methods before calling the new property, merging if appropriate.
|
|
@@ -476,11 +467,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
476
467
|
continue;
|
|
477
468
|
}
|
|
478
469
|
|
|
479
|
-
var isReserved =
|
|
480
|
-
!!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name) : invariant(false) :
|
|
470
|
+
var isReserved = name in RESERVED_SPEC_KEYS;
|
|
471
|
+
!!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name) : invariant(false) : void 0;
|
|
481
472
|
|
|
482
|
-
var isInherited =
|
|
483
|
-
!!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) :
|
|
473
|
+
var isInherited = name in Constructor;
|
|
474
|
+
!!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : void 0;
|
|
484
475
|
Constructor[name] = property;
|
|
485
476
|
}
|
|
486
477
|
}
|
|
@@ -493,11 +484,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
493
484
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
494
485
|
*/
|
|
495
486
|
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
496
|
-
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) :
|
|
487
|
+
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : void 0;
|
|
497
488
|
|
|
498
489
|
for (var key in two) {
|
|
499
490
|
if (two.hasOwnProperty(key)) {
|
|
500
|
-
!(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key) : invariant(false) :
|
|
491
|
+
!(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key) : invariant(false) : void 0;
|
|
501
492
|
one[key] = two[key];
|
|
502
493
|
}
|
|
503
494
|
}
|
|
@@ -558,7 +549,6 @@ function bindAutoBindMethod(component, method) {
|
|
|
558
549
|
boundMethod.__reactBoundArguments = null;
|
|
559
550
|
var componentName = component.constructor.displayName;
|
|
560
551
|
var _bind = boundMethod.bind;
|
|
561
|
-
/* eslint-disable block-scoped-var, no-undef */
|
|
562
552
|
boundMethod.bind = function (newThis) {
|
|
563
553
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
564
554
|
args[_key - 1] = arguments[_key];
|
|
@@ -568,9 +558,9 @@ function bindAutoBindMethod(component, method) {
|
|
|
568
558
|
// ignore the value of "this" that the user is trying to use, so
|
|
569
559
|
// let's warn.
|
|
570
560
|
if (newThis !== component && newThis !== null) {
|
|
571
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) :
|
|
561
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0;
|
|
572
562
|
} else if (!args.length) {
|
|
573
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) :
|
|
563
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0;
|
|
574
564
|
return boundMethod;
|
|
575
565
|
}
|
|
576
566
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
@@ -578,7 +568,6 @@ function bindAutoBindMethod(component, method) {
|
|
|
578
568
|
reboundMethod.__reactBoundMethod = method;
|
|
579
569
|
reboundMethod.__reactBoundArguments = args;
|
|
580
570
|
return reboundMethod;
|
|
581
|
-
/* eslint-enable */
|
|
582
571
|
};
|
|
583
572
|
}
|
|
584
573
|
return boundMethod;
|
|
@@ -590,11 +579,11 @@ function bindAutoBindMethod(component, method) {
|
|
|
590
579
|
* @param {object} component Component whose method is going to be bound.
|
|
591
580
|
*/
|
|
592
581
|
function bindAutoBindMethods(component) {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
582
|
+
var pairs = component.__reactAutoBindPairs;
|
|
583
|
+
for (var i = 0; i < pairs.length; i += 2) {
|
|
584
|
+
var autoBindKey = pairs[i];
|
|
585
|
+
var method = pairs[i + 1];
|
|
586
|
+
component[autoBindKey] = bindAutoBindMethod(component, method);
|
|
598
587
|
}
|
|
599
588
|
}
|
|
600
589
|
|
|
@@ -611,7 +600,7 @@ var ReactClassMixin = {
|
|
|
611
600
|
replaceState: function (newState, callback) {
|
|
612
601
|
this.updater.enqueueReplaceState(this, newState);
|
|
613
602
|
if (callback) {
|
|
614
|
-
this.updater.enqueueCallback(this, callback);
|
|
603
|
+
this.updater.enqueueCallback(this, callback, 'replaceState');
|
|
615
604
|
}
|
|
616
605
|
},
|
|
617
606
|
|
|
@@ -623,49 +612,11 @@ var ReactClassMixin = {
|
|
|
623
612
|
*/
|
|
624
613
|
isMounted: function () {
|
|
625
614
|
return this.updater.isMounted(this);
|
|
626
|
-
},
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
* Sets a subset of the props.
|
|
630
|
-
*
|
|
631
|
-
* @param {object} partialProps Subset of the next props.
|
|
632
|
-
* @param {?function} callback Called after props are updated.
|
|
633
|
-
* @final
|
|
634
|
-
* @public
|
|
635
|
-
* @deprecated
|
|
636
|
-
*/
|
|
637
|
-
setProps: function (partialProps, callback) {
|
|
638
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
639
|
-
warnSetProps();
|
|
640
|
-
}
|
|
641
|
-
this.updater.enqueueSetProps(this, partialProps);
|
|
642
|
-
if (callback) {
|
|
643
|
-
this.updater.enqueueCallback(this, callback);
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Replace all the props.
|
|
649
|
-
*
|
|
650
|
-
* @param {object} newProps Subset of the next props.
|
|
651
|
-
* @param {?function} callback Called after props are updated.
|
|
652
|
-
* @final
|
|
653
|
-
* @public
|
|
654
|
-
* @deprecated
|
|
655
|
-
*/
|
|
656
|
-
replaceProps: function (newProps, callback) {
|
|
657
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
658
|
-
warnSetProps();
|
|
659
|
-
}
|
|
660
|
-
this.updater.enqueueReplaceProps(this, newProps);
|
|
661
|
-
if (callback) {
|
|
662
|
-
this.updater.enqueueCallback(this, callback);
|
|
663
|
-
}
|
|
664
615
|
}
|
|
665
616
|
};
|
|
666
617
|
|
|
667
618
|
var ReactClassComponent = function () {};
|
|
668
|
-
|
|
619
|
+
_assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
|
|
669
620
|
|
|
670
621
|
/**
|
|
671
622
|
* Module for creating composite components.
|
|
@@ -683,15 +634,15 @@ var ReactClass = {
|
|
|
683
634
|
*/
|
|
684
635
|
createClass: function (spec) {
|
|
685
636
|
var Constructor = function (props, context, updater) {
|
|
686
|
-
// This constructor
|
|
637
|
+
// This constructor gets overridden by mocks. The argument is used
|
|
687
638
|
// by mocks to assert on what gets mounted.
|
|
688
639
|
|
|
689
640
|
if (process.env.NODE_ENV !== 'production') {
|
|
690
|
-
process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') :
|
|
641
|
+
process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;
|
|
691
642
|
}
|
|
692
643
|
|
|
693
644
|
// Wire up auto-binding
|
|
694
|
-
if (this.
|
|
645
|
+
if (this.__reactAutoBindPairs.length) {
|
|
695
646
|
bindAutoBindMethods(this);
|
|
696
647
|
}
|
|
697
648
|
|
|
@@ -708,18 +659,19 @@ var ReactClass = {
|
|
|
708
659
|
var initialState = this.getInitialState ? this.getInitialState() : null;
|
|
709
660
|
if (process.env.NODE_ENV !== 'production') {
|
|
710
661
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
711
|
-
if (
|
|
662
|
+
if (initialState === undefined && this.getInitialState._isMockFunction) {
|
|
712
663
|
// This is probably bad practice. Consider warning here and
|
|
713
664
|
// deprecating this convenience.
|
|
714
665
|
initialState = null;
|
|
715
666
|
}
|
|
716
667
|
}
|
|
717
|
-
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) :
|
|
668
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : void 0;
|
|
718
669
|
|
|
719
670
|
this.state = initialState;
|
|
720
671
|
};
|
|
721
672
|
Constructor.prototype = new ReactClassComponent();
|
|
722
673
|
Constructor.prototype.constructor = Constructor;
|
|
674
|
+
Constructor.prototype.__reactAutoBindPairs = [];
|
|
723
675
|
|
|
724
676
|
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
|
|
725
677
|
|
|
@@ -743,11 +695,11 @@ var ReactClass = {
|
|
|
743
695
|
}
|
|
744
696
|
}
|
|
745
697
|
|
|
746
|
-
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) :
|
|
698
|
+
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : void 0;
|
|
747
699
|
|
|
748
700
|
if (process.env.NODE_ENV !== 'production') {
|
|
749
|
-
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') :
|
|
750
|
-
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') :
|
|
701
|
+
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
|
|
702
|
+
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0;
|
|
751
703
|
}
|
|
752
704
|
|
|
753
705
|
// Reduce time spent doing lookups by setting these on the prototype.
|