react 16.0.0-alpha.8 → 16.0.0-alpha.12
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/cjs/react.development.js +445 -1549
- package/cjs/react.production.min.js +1 -1
- package/package.json +4 -2
- package/umd/react.development.js +1914 -1757
- package/umd/react.production.min.js +2 -2
package/cjs/react.development.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var objectAssign$1 = require('object-assign');
|
|
4
4
|
var warning = require('fbjs/lib/warning');
|
|
5
5
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
6
6
|
var invariant = require('fbjs/lib/invariant');
|
|
7
7
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
8
|
+
var checkPropTypes = require('prop-types/checkPropTypes');
|
|
9
|
+
var propTypes = require('prop-types');
|
|
10
|
+
var factory = require('create-react-class/factory');
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -107,18 +110,18 @@ var ReactNoopUpdateQueue_1 = ReactNoopUpdateQueue;
|
|
|
107
110
|
* @providesModule canDefineProperty
|
|
108
111
|
*/
|
|
109
112
|
|
|
110
|
-
var canDefineProperty = false;
|
|
113
|
+
var canDefineProperty$1 = false;
|
|
111
114
|
{
|
|
112
115
|
try {
|
|
113
116
|
// $FlowFixMe https://github.com/facebook/flow/issues/285
|
|
114
117
|
Object.defineProperty({}, 'x', { get: function () {} });
|
|
115
|
-
canDefineProperty = true;
|
|
118
|
+
canDefineProperty$1 = true;
|
|
116
119
|
} catch (x) {
|
|
117
120
|
// IE will fail on defineProperty
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
var canDefineProperty_1 = canDefineProperty;
|
|
124
|
+
var canDefineProperty_1 = canDefineProperty$1;
|
|
122
125
|
|
|
123
126
|
/**
|
|
124
127
|
* Base class helpers for the updating state of a component.
|
|
@@ -227,7 +230,7 @@ ComponentDummy.prototype = ReactComponent.prototype;
|
|
|
227
230
|
ReactPureComponent.prototype = new ComponentDummy();
|
|
228
231
|
ReactPureComponent.prototype.constructor = ReactPureComponent;
|
|
229
232
|
// Avoid an extra prototype jump for these methods.
|
|
230
|
-
|
|
233
|
+
objectAssign$1(ReactPureComponent.prototype, ReactComponent.prototype);
|
|
231
234
|
ReactPureComponent.prototype.isPureReactComponent = true;
|
|
232
235
|
|
|
233
236
|
var ReactBaseClasses = {
|
|
@@ -606,14 +609,14 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
606
609
|
* See https://facebook.github.io/react/docs/react-api.html#createfactory
|
|
607
610
|
*/
|
|
608
611
|
ReactElement.createFactory = function (type) {
|
|
609
|
-
var factory = ReactElement.createElement.bind(null, type);
|
|
612
|
+
var factory$$1 = ReactElement.createElement.bind(null, type);
|
|
610
613
|
// Expose the type on the factory and the prototype so that it can be
|
|
611
614
|
// easily accessed on elements. E.g. `<Foo />.type === Foo`.
|
|
612
615
|
// This should not be named `constructor` since this may not be the function
|
|
613
616
|
// that created the element, and it may not even be a constructor.
|
|
614
617
|
// Legacy hook TODO: Warn if this is accessed
|
|
615
|
-
factory.type = type;
|
|
616
|
-
return factory;
|
|
618
|
+
factory$$1.type = type;
|
|
619
|
+
return factory$$1;
|
|
617
620
|
};
|
|
618
621
|
|
|
619
622
|
ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
|
|
@@ -630,7 +633,7 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
630
633
|
var propName;
|
|
631
634
|
|
|
632
635
|
// Original props are copied
|
|
633
|
-
var props =
|
|
636
|
+
var props = objectAssign$1({}, element.props);
|
|
634
637
|
|
|
635
638
|
// Reserved names are extracted
|
|
636
639
|
var key = element.key;
|
|
@@ -799,998 +802,32 @@ var KeyEscapeUtils = {
|
|
|
799
802
|
|
|
800
803
|
var KeyEscapeUtils_1 = KeyEscapeUtils;
|
|
801
804
|
|
|
802
|
-
var SEPARATOR = '.';
|
|
803
|
-
var SUBSEPARATOR = ':';
|
|
804
|
-
|
|
805
|
-
/**
|
|
806
|
-
* This is inlined from ReactElement since this file is shared between
|
|
807
|
-
* isomorphic and renderers. We could extract this to a
|
|
808
|
-
*
|
|
809
|
-
*/
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* TODO: Test that a single child and an array with one item have the same key
|
|
813
|
-
* pattern.
|
|
814
|
-
*/
|
|
815
|
-
|
|
816
|
-
var didWarnAboutMaps = false;
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* Generate a key string that identifies a component within a set.
|
|
820
|
-
*
|
|
821
|
-
* @param {*} component A component that could contain a manual key.
|
|
822
|
-
* @param {number} index Index that is used if a manual key is not provided.
|
|
823
|
-
* @return {string}
|
|
824
|
-
*/
|
|
825
|
-
function getComponentKey(component, index) {
|
|
826
|
-
// Do some typechecking here since we call this blindly. We want to ensure
|
|
827
|
-
// that we don't block potential future ES APIs.
|
|
828
|
-
if (component && typeof component === 'object' && component.key != null) {
|
|
829
|
-
// Explicit key
|
|
830
|
-
return KeyEscapeUtils_1.escape(component.key);
|
|
831
|
-
}
|
|
832
|
-
// Implicit key determined by the index in the set
|
|
833
|
-
return index.toString(36);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
/**
|
|
837
|
-
* @param {?*} children Children tree container.
|
|
838
|
-
* @param {!string} nameSoFar Name of the key path so far.
|
|
839
|
-
* @param {!function} callback Callback to invoke with each child found.
|
|
840
|
-
* @param {?*} traverseContext Used to pass information throughout the traversal
|
|
841
|
-
* process.
|
|
842
|
-
* @return {!number} The number of children in this subtree.
|
|
843
|
-
*/
|
|
844
|
-
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
|
845
|
-
var type = typeof children;
|
|
846
|
-
|
|
847
|
-
if (type === 'undefined' || type === 'boolean') {
|
|
848
|
-
// All of the above are perceived as null.
|
|
849
|
-
children = null;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
if (children === null || type === 'string' || type === 'number' ||
|
|
853
|
-
// The following is inlined from ReactElement. This means we can optimize
|
|
854
|
-
// some checks. React Fiber also inlines this logic for similar purposes.
|
|
855
|
-
type === 'object' && children.$$typeof === ReactElementSymbol) {
|
|
856
|
-
callback(traverseContext, children,
|
|
857
|
-
// If it's the only child, treat the name as if it was wrapped in an array
|
|
858
|
-
// so that it's consistent if the number of children grows.
|
|
859
|
-
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
|
860
|
-
return 1;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
var child;
|
|
864
|
-
var nextName;
|
|
865
|
-
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
866
|
-
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
867
|
-
|
|
868
|
-
if (Array.isArray(children)) {
|
|
869
|
-
for (var i = 0; i < children.length; i++) {
|
|
870
|
-
child = children[i];
|
|
871
|
-
nextName = nextNamePrefix + getComponentKey(child, i);
|
|
872
|
-
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
873
|
-
}
|
|
874
|
-
} else {
|
|
875
|
-
var iteratorFn = getIteratorFn_1(children);
|
|
876
|
-
if (iteratorFn) {
|
|
877
|
-
{
|
|
878
|
-
// Warn about using Maps as children
|
|
879
|
-
if (iteratorFn === children.entries) {
|
|
880
|
-
var mapsAsChildrenAddendum = '';
|
|
881
|
-
if (ReactCurrentOwner_1.current) {
|
|
882
|
-
var mapsAsChildrenOwnerName = ReactCurrentOwner_1.current.getName();
|
|
883
|
-
if (mapsAsChildrenOwnerName) {
|
|
884
|
-
mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', mapsAsChildrenAddendum);
|
|
888
|
-
didWarnAboutMaps = true;
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
var iterator = iteratorFn.call(children);
|
|
893
|
-
var step;
|
|
894
|
-
var ii = 0;
|
|
895
|
-
while (!(step = iterator.next()).done) {
|
|
896
|
-
child = step.value;
|
|
897
|
-
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
898
|
-
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
899
|
-
}
|
|
900
|
-
} else if (type === 'object') {
|
|
901
|
-
var addendum = '';
|
|
902
|
-
{
|
|
903
|
-
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.';
|
|
904
|
-
if (ReactCurrentOwner_1.current) {
|
|
905
|
-
var name = ReactCurrentOwner_1.current.getName();
|
|
906
|
-
if (name) {
|
|
907
|
-
addendum += '\n\nCheck the render method of `' + name + '`.';
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
var childrenString = '' + children;
|
|
912
|
-
invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
return subtreeCount;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
/**
|
|
920
|
-
* Traverses children that are typically specified as `props.children`, but
|
|
921
|
-
* might also be specified through attributes:
|
|
922
|
-
*
|
|
923
|
-
* - `traverseAllChildren(this.props.children, ...)`
|
|
924
|
-
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
|
|
925
|
-
*
|
|
926
|
-
* The `traverseContext` is an optional argument that is passed through the
|
|
927
|
-
* entire traversal. It can be used to store accumulations or anything else that
|
|
928
|
-
* the callback might find relevant.
|
|
929
|
-
*
|
|
930
|
-
* @param {?*} children Children tree object.
|
|
931
|
-
* @param {!function} callback To invoke upon traversing each child.
|
|
932
|
-
* @param {?*} traverseContext Context for traversal.
|
|
933
|
-
* @return {!number} The number of children in this subtree.
|
|
934
|
-
*/
|
|
935
|
-
function traverseAllChildren(children, callback, traverseContext) {
|
|
936
|
-
if (children == null) {
|
|
937
|
-
return 0;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
var traverseAllChildren_1 = traverseAllChildren;
|
|
944
|
-
|
|
945
|
-
var twoArgumentPooler = PooledClass_1.twoArgumentPooler;
|
|
946
|
-
var fourArgumentPooler = PooledClass_1.fourArgumentPooler;
|
|
947
|
-
|
|
948
|
-
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
949
|
-
function escapeUserProvidedKey(text) {
|
|
950
|
-
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* PooledClass representing the bookkeeping associated with performing a child
|
|
955
|
-
* traversal. Allows avoiding binding callbacks.
|
|
956
|
-
*
|
|
957
|
-
* @constructor ForEachBookKeeping
|
|
958
|
-
* @param {!function} forEachFunction Function to perform traversal with.
|
|
959
|
-
* @param {?*} forEachContext Context to perform context with.
|
|
960
|
-
*/
|
|
961
|
-
function ForEachBookKeeping(forEachFunction, forEachContext) {
|
|
962
|
-
this.func = forEachFunction;
|
|
963
|
-
this.context = forEachContext;
|
|
964
|
-
this.count = 0;
|
|
965
|
-
}
|
|
966
|
-
ForEachBookKeeping.prototype.destructor = function () {
|
|
967
|
-
this.func = null;
|
|
968
|
-
this.context = null;
|
|
969
|
-
this.count = 0;
|
|
970
|
-
};
|
|
971
|
-
PooledClass_1.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
|
972
|
-
|
|
973
|
-
function forEachSingleChild(bookKeeping, child, name) {
|
|
974
|
-
var func = bookKeeping.func,
|
|
975
|
-
context = bookKeeping.context;
|
|
976
|
-
|
|
977
|
-
func.call(context, child, bookKeeping.count++);
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
/**
|
|
981
|
-
* Iterates through children that are typically specified as `props.children`.
|
|
982
|
-
*
|
|
983
|
-
* See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
|
|
984
|
-
*
|
|
985
|
-
* The provided forEachFunc(child, index) will be called for each
|
|
986
|
-
* leaf child.
|
|
987
|
-
*
|
|
988
|
-
* @param {?*} children Children tree container.
|
|
989
|
-
* @param {function(*, int)} forEachFunc
|
|
990
|
-
* @param {*} forEachContext Context for forEachContext.
|
|
991
|
-
*/
|
|
992
|
-
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
993
|
-
if (children == null) {
|
|
994
|
-
return children;
|
|
995
|
-
}
|
|
996
|
-
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
997
|
-
traverseAllChildren_1(children, forEachSingleChild, traverseContext);
|
|
998
|
-
ForEachBookKeeping.release(traverseContext);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* PooledClass representing the bookkeeping associated with performing a child
|
|
1003
|
-
* mapping. Allows avoiding binding callbacks.
|
|
1004
|
-
*
|
|
1005
|
-
* @constructor MapBookKeeping
|
|
1006
|
-
* @param {!*} mapResult Object containing the ordered map of results.
|
|
1007
|
-
* @param {!function} mapFunction Function to perform mapping with.
|
|
1008
|
-
* @param {?*} mapContext Context to perform mapping with.
|
|
1009
|
-
*/
|
|
1010
|
-
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
|
|
1011
|
-
this.result = mapResult;
|
|
1012
|
-
this.keyPrefix = keyPrefix;
|
|
1013
|
-
this.func = mapFunction;
|
|
1014
|
-
this.context = mapContext;
|
|
1015
|
-
this.count = 0;
|
|
1016
|
-
}
|
|
1017
|
-
MapBookKeeping.prototype.destructor = function () {
|
|
1018
|
-
this.result = null;
|
|
1019
|
-
this.keyPrefix = null;
|
|
1020
|
-
this.func = null;
|
|
1021
|
-
this.context = null;
|
|
1022
|
-
this.count = 0;
|
|
1023
|
-
};
|
|
1024
|
-
PooledClass_1.addPoolingTo(MapBookKeeping, fourArgumentPooler);
|
|
1025
|
-
|
|
1026
|
-
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
1027
|
-
var result = bookKeeping.result,
|
|
1028
|
-
keyPrefix = bookKeeping.keyPrefix,
|
|
1029
|
-
func = bookKeeping.func,
|
|
1030
|
-
context = bookKeeping.context;
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
1034
|
-
if (Array.isArray(mappedChild)) {
|
|
1035
|
-
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
|
|
1036
|
-
} else if (mappedChild != null) {
|
|
1037
|
-
if (ReactElement_1.isValidElement(mappedChild)) {
|
|
1038
|
-
mappedChild = ReactElement_1.cloneAndReplaceKey(mappedChild,
|
|
1039
|
-
// Keep both the (mapped) and old keys if they differ, just as
|
|
1040
|
-
// traverseAllChildren used to do for objects as children
|
|
1041
|
-
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
|
1042
|
-
}
|
|
1043
|
-
result.push(mappedChild);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
1048
|
-
var escapedPrefix = '';
|
|
1049
|
-
if (prefix != null) {
|
|
1050
|
-
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
|
1051
|
-
}
|
|
1052
|
-
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
|
|
1053
|
-
traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
|
|
1054
|
-
MapBookKeeping.release(traverseContext);
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
/**
|
|
1058
|
-
* Maps children that are typically specified as `props.children`.
|
|
1059
|
-
*
|
|
1060
|
-
* See https://facebook.github.io/react/docs/react-api.html#react.children.map
|
|
1061
|
-
*
|
|
1062
|
-
* The provided mapFunction(child, key, index) will be called for each
|
|
1063
|
-
* leaf child.
|
|
1064
|
-
*
|
|
1065
|
-
* @param {?*} children Children tree container.
|
|
1066
|
-
* @param {function(*, int)} func The map function.
|
|
1067
|
-
* @param {*} context Context for mapFunction.
|
|
1068
|
-
* @return {object} Object containing the ordered map of results.
|
|
1069
|
-
*/
|
|
1070
|
-
function mapChildren(children, func, context) {
|
|
1071
|
-
if (children == null) {
|
|
1072
|
-
return children;
|
|
1073
|
-
}
|
|
1074
|
-
var result = [];
|
|
1075
|
-
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
|
1076
|
-
return result;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
function forEachSingleChildDummy(traverseContext, child, name) {
|
|
1080
|
-
return null;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* Count the number of children that are typically specified as
|
|
1085
|
-
* `props.children`.
|
|
1086
|
-
*
|
|
1087
|
-
* See https://facebook.github.io/react/docs/react-api.html#react.children.count
|
|
1088
|
-
*
|
|
1089
|
-
* @param {?*} children Children tree container.
|
|
1090
|
-
* @return {number} The number of children.
|
|
1091
|
-
*/
|
|
1092
|
-
function countChildren(children, context) {
|
|
1093
|
-
return traverseAllChildren_1(children, forEachSingleChildDummy, null);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Flatten a children object (typically specified as `props.children`) and
|
|
1098
|
-
* return an array with appropriately re-keyed children.
|
|
1099
|
-
*
|
|
1100
|
-
* See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
|
|
1101
|
-
*/
|
|
1102
|
-
function toArray(children) {
|
|
1103
|
-
var result = [];
|
|
1104
|
-
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
|
|
1105
|
-
return result;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
var ReactChildren = {
|
|
1109
|
-
forEach: forEachChildren,
|
|
1110
|
-
map: mapChildren,
|
|
1111
|
-
mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
|
|
1112
|
-
count: countChildren,
|
|
1113
|
-
toArray: toArray
|
|
1114
|
-
};
|
|
1115
|
-
|
|
1116
|
-
var ReactChildren_1 = ReactChildren;
|
|
1117
|
-
|
|
1118
|
-
var ReactComponent$1 = ReactBaseClasses.Component;
|
|
1119
|
-
|
|
1120
|
-
var MIXINS_KEY = 'mixins';
|
|
1121
|
-
|
|
1122
|
-
// Helper function to allow the creation of anonymous functions which do not
|
|
1123
|
-
// have .name set to the name of the variable being assigned to.
|
|
1124
|
-
function identity(fn) {
|
|
1125
|
-
return fn;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
/**
|
|
1129
|
-
* Policies that describe methods in `ReactClassInterface`.
|
|
1130
|
-
*/
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* Composite components are higher-level components that compose other composite
|
|
1135
|
-
* or host components.
|
|
1136
|
-
*
|
|
1137
|
-
* To create a new type of `ReactClass`, pass a specification of
|
|
1138
|
-
* your new class to `React.createClass`. The only requirement of your class
|
|
1139
|
-
* specification is that you implement a `render` method.
|
|
1140
|
-
*
|
|
1141
|
-
* var MyComponent = React.createClass({
|
|
1142
|
-
* render: function() {
|
|
1143
|
-
* return <div>Hello World</div>;
|
|
1144
|
-
* }
|
|
1145
|
-
* });
|
|
1146
|
-
*
|
|
1147
|
-
* The class specification supports a specific protocol of methods that have
|
|
1148
|
-
* special meaning (e.g. `render`). See `ReactClassInterface` for
|
|
1149
|
-
* more the comprehensive protocol. Any other properties and methods in the
|
|
1150
|
-
* class specification will be available on the prototype.
|
|
1151
|
-
*
|
|
1152
|
-
* @interface ReactClassInterface
|
|
1153
|
-
* @internal
|
|
1154
|
-
*/
|
|
1155
|
-
var ReactClassInterface = {
|
|
1156
|
-
/**
|
|
1157
|
-
* An array of Mixin objects to include when defining your component.
|
|
1158
|
-
*
|
|
1159
|
-
* @type {array}
|
|
1160
|
-
* @optional
|
|
1161
|
-
*/
|
|
1162
|
-
mixins: 'DEFINE_MANY',
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* An object containing properties and methods that should be defined on
|
|
1166
|
-
* the component's constructor instead of its prototype (static methods).
|
|
1167
|
-
*
|
|
1168
|
-
* @type {object}
|
|
1169
|
-
* @optional
|
|
1170
|
-
*/
|
|
1171
|
-
statics: 'DEFINE_MANY',
|
|
1172
|
-
|
|
1173
|
-
/**
|
|
1174
|
-
* Definition of prop types for this component.
|
|
1175
|
-
*
|
|
1176
|
-
* @type {object}
|
|
1177
|
-
* @optional
|
|
1178
|
-
*/
|
|
1179
|
-
propTypes: 'DEFINE_MANY',
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
* Definition of context types for this component.
|
|
1183
|
-
*
|
|
1184
|
-
* @type {object}
|
|
1185
|
-
* @optional
|
|
1186
|
-
*/
|
|
1187
|
-
contextTypes: 'DEFINE_MANY',
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
* Definition of context types this component sets for its children.
|
|
1191
|
-
*
|
|
1192
|
-
* @type {object}
|
|
1193
|
-
* @optional
|
|
1194
|
-
*/
|
|
1195
|
-
childContextTypes: 'DEFINE_MANY',
|
|
1196
|
-
|
|
1197
|
-
// ==== Definition methods ====
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* Invoked when the component is mounted. Values in the mapping will be set on
|
|
1201
|
-
* `this.props` if that prop is not specified (i.e. using an `in` check).
|
|
1202
|
-
*
|
|
1203
|
-
* This method is invoked before `getInitialState` and therefore cannot rely
|
|
1204
|
-
* on `this.state` or use `this.setState`.
|
|
1205
|
-
*
|
|
1206
|
-
* @return {object}
|
|
1207
|
-
* @optional
|
|
1208
|
-
*/
|
|
1209
|
-
getDefaultProps: 'DEFINE_MANY_MERGED',
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
* Invoked once before the component is mounted. The return value will be used
|
|
1213
|
-
* as the initial value of `this.state`.
|
|
1214
|
-
*
|
|
1215
|
-
* getInitialState: function() {
|
|
1216
|
-
* return {
|
|
1217
|
-
* isOn: false,
|
|
1218
|
-
* fooBaz: new BazFoo()
|
|
1219
|
-
* }
|
|
1220
|
-
* }
|
|
1221
|
-
*
|
|
1222
|
-
* @return {object}
|
|
1223
|
-
* @optional
|
|
1224
|
-
*/
|
|
1225
|
-
getInitialState: 'DEFINE_MANY_MERGED',
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* @return {object}
|
|
1229
|
-
* @optional
|
|
1230
|
-
*/
|
|
1231
|
-
getChildContext: 'DEFINE_MANY_MERGED',
|
|
1232
|
-
|
|
1233
|
-
/**
|
|
1234
|
-
* Uses props from `this.props` and state from `this.state` to render the
|
|
1235
|
-
* structure of the component.
|
|
1236
|
-
*
|
|
1237
|
-
* No guarantees are made about when or how often this method is invoked, so
|
|
1238
|
-
* it must not have side effects.
|
|
1239
|
-
*
|
|
1240
|
-
* render: function() {
|
|
1241
|
-
* var name = this.props.name;
|
|
1242
|
-
* return <div>Hello, {name}!</div>;
|
|
1243
|
-
* }
|
|
1244
|
-
*
|
|
1245
|
-
* @return {ReactComponent}
|
|
1246
|
-
* @required
|
|
1247
|
-
*/
|
|
1248
|
-
render: 'DEFINE_ONCE',
|
|
1249
|
-
|
|
1250
|
-
// ==== Delegate methods ====
|
|
1251
|
-
|
|
1252
|
-
/**
|
|
1253
|
-
* Invoked when the component is initially created and about to be mounted.
|
|
1254
|
-
* This may have side effects, but any external subscriptions or data created
|
|
1255
|
-
* by this method must be cleaned up in `componentWillUnmount`.
|
|
1256
|
-
*
|
|
1257
|
-
* @optional
|
|
1258
|
-
*/
|
|
1259
|
-
componentWillMount: 'DEFINE_MANY',
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* Invoked when the component has been mounted and has a DOM representation.
|
|
1263
|
-
* However, there is no guarantee that the DOM node is in the document.
|
|
1264
|
-
*
|
|
1265
|
-
* Use this as an opportunity to operate on the DOM when the component has
|
|
1266
|
-
* been mounted (initialized and rendered) for the first time.
|
|
1267
|
-
*
|
|
1268
|
-
* @param {DOMElement} rootNode DOM element representing the component.
|
|
1269
|
-
* @optional
|
|
1270
|
-
*/
|
|
1271
|
-
componentDidMount: 'DEFINE_MANY',
|
|
1272
|
-
|
|
1273
|
-
/**
|
|
1274
|
-
* Invoked before the component receives new props.
|
|
1275
|
-
*
|
|
1276
|
-
* Use this as an opportunity to react to a prop transition by updating the
|
|
1277
|
-
* state using `this.setState`. Current props are accessed via `this.props`.
|
|
1278
|
-
*
|
|
1279
|
-
* componentWillReceiveProps: function(nextProps, nextContext) {
|
|
1280
|
-
* this.setState({
|
|
1281
|
-
* likesIncreasing: nextProps.likeCount > this.props.likeCount
|
|
1282
|
-
* });
|
|
1283
|
-
* }
|
|
1284
|
-
*
|
|
1285
|
-
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
|
|
1286
|
-
* transition may cause a state change, but the opposite is not true. If you
|
|
1287
|
-
* need it, you are probably looking for `componentWillUpdate`.
|
|
1288
|
-
*
|
|
1289
|
-
* @param {object} nextProps
|
|
1290
|
-
* @optional
|
|
1291
|
-
*/
|
|
1292
|
-
componentWillReceiveProps: 'DEFINE_MANY',
|
|
1293
|
-
|
|
1294
|
-
/**
|
|
1295
|
-
* Invoked while deciding if the component should be updated as a result of
|
|
1296
|
-
* receiving new props, state and/or context.
|
|
1297
|
-
*
|
|
1298
|
-
* Use this as an opportunity to `return false` when you're certain that the
|
|
1299
|
-
* transition to the new props/state/context will not require a component
|
|
1300
|
-
* update.
|
|
1301
|
-
*
|
|
1302
|
-
* shouldComponentUpdate: function(nextProps, nextState, nextContext) {
|
|
1303
|
-
* return !equal(nextProps, this.props) ||
|
|
1304
|
-
* !equal(nextState, this.state) ||
|
|
1305
|
-
* !equal(nextContext, this.context);
|
|
1306
|
-
* }
|
|
1307
|
-
*
|
|
1308
|
-
* @param {object} nextProps
|
|
1309
|
-
* @param {?object} nextState
|
|
1310
|
-
* @param {?object} nextContext
|
|
1311
|
-
* @return {boolean} True if the component should update.
|
|
1312
|
-
* @optional
|
|
1313
|
-
*/
|
|
1314
|
-
shouldComponentUpdate: 'DEFINE_ONCE',
|
|
1315
|
-
|
|
1316
|
-
/**
|
|
1317
|
-
* Invoked when the component is about to update due to a transition from
|
|
1318
|
-
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
|
|
1319
|
-
* and `nextContext`.
|
|
1320
|
-
*
|
|
1321
|
-
* Use this as an opportunity to perform preparation before an update occurs.
|
|
1322
|
-
*
|
|
1323
|
-
* NOTE: You **cannot** use `this.setState()` in this method.
|
|
1324
|
-
*
|
|
1325
|
-
* @param {object} nextProps
|
|
1326
|
-
* @param {?object} nextState
|
|
1327
|
-
* @param {?object} nextContext
|
|
1328
|
-
* @param {ReactReconcileTransaction} transaction
|
|
1329
|
-
* @optional
|
|
1330
|
-
*/
|
|
1331
|
-
componentWillUpdate: 'DEFINE_MANY',
|
|
1332
|
-
|
|
1333
|
-
/**
|
|
1334
|
-
* Invoked when the component's DOM representation has been updated.
|
|
1335
|
-
*
|
|
1336
|
-
* Use this as an opportunity to operate on the DOM when the component has
|
|
1337
|
-
* been updated.
|
|
1338
|
-
*
|
|
1339
|
-
* @param {object} prevProps
|
|
1340
|
-
* @param {?object} prevState
|
|
1341
|
-
* @param {?object} prevContext
|
|
1342
|
-
* @param {DOMElement} rootNode DOM element representing the component.
|
|
1343
|
-
* @optional
|
|
1344
|
-
*/
|
|
1345
|
-
componentDidUpdate: 'DEFINE_MANY',
|
|
1346
|
-
|
|
1347
|
-
/**
|
|
1348
|
-
* Invoked when the component is about to be removed from its parent and have
|
|
1349
|
-
* its DOM representation destroyed.
|
|
1350
|
-
*
|
|
1351
|
-
* Use this as an opportunity to deallocate any external resources.
|
|
1352
|
-
*
|
|
1353
|
-
* NOTE: There is no `componentDidUnmount` since your component will have been
|
|
1354
|
-
* destroyed by that point.
|
|
1355
|
-
*
|
|
1356
|
-
* @optional
|
|
1357
|
-
*/
|
|
1358
|
-
componentWillUnmount: 'DEFINE_MANY',
|
|
1359
|
-
|
|
1360
|
-
// ==== Advanced methods ====
|
|
1361
|
-
|
|
1362
|
-
/**
|
|
1363
|
-
* Updates the component's currently mounted DOM representation.
|
|
1364
|
-
*
|
|
1365
|
-
* By default, this implements React's rendering and reconciliation algorithm.
|
|
1366
|
-
* Sophisticated clients may wish to override this.
|
|
1367
|
-
*
|
|
1368
|
-
* @param {ReactReconcileTransaction} transaction
|
|
1369
|
-
* @internal
|
|
1370
|
-
* @overridable
|
|
1371
|
-
*/
|
|
1372
|
-
updateComponent: 'OVERRIDE_BASE'
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
/**
|
|
1376
|
-
* Mapping from class specification keys to special processing functions.
|
|
1377
|
-
*
|
|
1378
|
-
* Although these are declared like instance properties in the specification
|
|
1379
|
-
* when defining classes using `React.createClass`, they are actually static
|
|
1380
|
-
* and are accessible on the constructor instead of the prototype. Despite
|
|
1381
|
-
* being static, they must be defined outside of the "statics" key under
|
|
1382
|
-
* which all other static methods are defined.
|
|
1383
|
-
*/
|
|
1384
|
-
var RESERVED_SPEC_KEYS = {
|
|
1385
|
-
displayName: function (Constructor, displayName) {
|
|
1386
|
-
Constructor.displayName = displayName;
|
|
1387
|
-
},
|
|
1388
|
-
mixins: function (Constructor, mixins) {
|
|
1389
|
-
if (mixins) {
|
|
1390
|
-
for (var i = 0; i < mixins.length; i++) {
|
|
1391
|
-
mixSpecIntoComponent(Constructor, mixins[i]);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
},
|
|
1395
|
-
childContextTypes: function (Constructor, childContextTypes) {
|
|
1396
|
-
{
|
|
1397
|
-
validateTypeDef(Constructor, childContextTypes, 'child context');
|
|
1398
|
-
}
|
|
1399
|
-
Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
|
|
1400
|
-
},
|
|
1401
|
-
contextTypes: function (Constructor, contextTypes) {
|
|
1402
|
-
{
|
|
1403
|
-
validateTypeDef(Constructor, contextTypes, 'context');
|
|
1404
|
-
}
|
|
1405
|
-
Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
|
|
1406
|
-
},
|
|
1407
|
-
/**
|
|
1408
|
-
* Special case getDefaultProps which should move into statics but requires
|
|
1409
|
-
* automatic merging.
|
|
1410
|
-
*/
|
|
1411
|
-
getDefaultProps: function (Constructor, getDefaultProps) {
|
|
1412
|
-
if (Constructor.getDefaultProps) {
|
|
1413
|
-
Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
|
|
1414
|
-
} else {
|
|
1415
|
-
Constructor.getDefaultProps = getDefaultProps;
|
|
1416
|
-
}
|
|
1417
|
-
},
|
|
1418
|
-
propTypes: function (Constructor, propTypes) {
|
|
1419
|
-
{
|
|
1420
|
-
validateTypeDef(Constructor, propTypes, 'prop');
|
|
1421
|
-
}
|
|
1422
|
-
Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
|
|
1423
|
-
},
|
|
1424
|
-
statics: function (Constructor, statics) {
|
|
1425
|
-
mixStaticSpecIntoComponent(Constructor, statics);
|
|
1426
|
-
},
|
|
1427
|
-
autobind: function () {} };
|
|
1428
|
-
|
|
1429
|
-
function validateTypeDef(Constructor, typeDef, location) {
|
|
1430
|
-
for (var propName in typeDef) {
|
|
1431
|
-
if (typeDef.hasOwnProperty(propName)) {
|
|
1432
|
-
// use a warning instead of an invariant so components
|
|
1433
|
-
// don't show up in prod but only in true
|
|
1434
|
-
warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', location, propName);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
function validateMethodOverride(isAlreadyDefined, name) {
|
|
1440
|
-
var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
|
|
1441
|
-
|
|
1442
|
-
// Disallow overriding of base class methods unless explicitly allowed.
|
|
1443
|
-
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
1444
|
-
!(specPolicy === 'OVERRIDE_BASE') ? 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) : void 0;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
// Disallow defining methods more than once unless explicitly allowed.
|
|
1448
|
-
if (isAlreadyDefined) {
|
|
1449
|
-
!(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED') ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : void 0;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
/**
|
|
1454
|
-
* Mixin helper which handles policy validation and reserved
|
|
1455
|
-
* specification keys when building React classes.
|
|
1456
|
-
*/
|
|
1457
|
-
function mixSpecIntoComponent(Constructor, spec) {
|
|
1458
|
-
if (!spec) {
|
|
1459
|
-
{
|
|
1460
|
-
var typeofSpec = typeof spec;
|
|
1461
|
-
var isMixinValid = typeofSpec === 'object' && spec !== null;
|
|
1462
|
-
|
|
1463
|
-
warning(isMixinValid, "%s: You're attempting to include a mixin that is either null " + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec);
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
!(typeof spec !== 'function') ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : void 0;
|
|
1470
|
-
!!ReactElement_1.isValidElement(spec) ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : void 0;
|
|
1471
|
-
|
|
1472
|
-
var proto = Constructor.prototype;
|
|
1473
|
-
var autoBindPairs = proto.__reactAutoBindPairs;
|
|
1474
|
-
|
|
1475
|
-
// By handling mixins before any other properties, we ensure the same
|
|
1476
|
-
// chaining order is applied to methods with DEFINE_MANY policy, whether
|
|
1477
|
-
// mixins are listed before or after these methods in the spec.
|
|
1478
|
-
if (spec.hasOwnProperty(MIXINS_KEY)) {
|
|
1479
|
-
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
for (var name in spec) {
|
|
1483
|
-
if (!spec.hasOwnProperty(name)) {
|
|
1484
|
-
continue;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
if (name === MIXINS_KEY) {
|
|
1488
|
-
// We have already handled mixins in a special case above.
|
|
1489
|
-
continue;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
var property = spec[name];
|
|
1493
|
-
var isAlreadyDefined = proto.hasOwnProperty(name);
|
|
1494
|
-
validateMethodOverride(isAlreadyDefined, name);
|
|
1495
|
-
|
|
1496
|
-
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
|
|
1497
|
-
RESERVED_SPEC_KEYS[name](Constructor, property);
|
|
1498
|
-
} else {
|
|
1499
|
-
// Setup methods on prototype:
|
|
1500
|
-
// The following member methods should not be automatically bound:
|
|
1501
|
-
// 1. Expected ReactClass methods (in the "interface").
|
|
1502
|
-
// 2. Overridden methods (that were mixed in).
|
|
1503
|
-
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
|
|
1504
|
-
var isFunction = typeof property === 'function';
|
|
1505
|
-
var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
|
|
1506
|
-
|
|
1507
|
-
if (shouldAutoBind) {
|
|
1508
|
-
autoBindPairs.push(name, property);
|
|
1509
|
-
proto[name] = property;
|
|
1510
|
-
} else {
|
|
1511
|
-
if (isAlreadyDefined) {
|
|
1512
|
-
var specPolicy = ReactClassInterface[name];
|
|
1513
|
-
|
|
1514
|
-
// These cases should already be caught by validateMethodOverride.
|
|
1515
|
-
!(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY')) ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : void 0;
|
|
1516
|
-
|
|
1517
|
-
// For methods which are defined more than once, call the existing
|
|
1518
|
-
// methods before calling the new property, merging if appropriate.
|
|
1519
|
-
if (specPolicy === 'DEFINE_MANY_MERGED') {
|
|
1520
|
-
proto[name] = createMergedResultFunction(proto[name], property);
|
|
1521
|
-
} else if (specPolicy === 'DEFINE_MANY') {
|
|
1522
|
-
proto[name] = createChainedFunction(proto[name], property);
|
|
1523
|
-
}
|
|
1524
|
-
} else {
|
|
1525
|
-
proto[name] = property;
|
|
1526
|
-
{
|
|
1527
|
-
// Add verbose displayName to the function, which helps when looking
|
|
1528
|
-
// at profiling tools.
|
|
1529
|
-
if (typeof property === 'function' && spec.displayName) {
|
|
1530
|
-
proto[name].displayName = spec.displayName + '_' + name;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
1540
|
-
if (!statics) {
|
|
1541
|
-
return;
|
|
1542
|
-
}
|
|
1543
|
-
for (var name in statics) {
|
|
1544
|
-
var property = statics[name];
|
|
1545
|
-
if (!statics.hasOwnProperty(name)) {
|
|
1546
|
-
continue;
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
var isReserved = name in RESERVED_SPEC_KEYS;
|
|
1550
|
-
!!isReserved ? 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) : void 0;
|
|
1551
|
-
|
|
1552
|
-
var isInherited = name in Constructor;
|
|
1553
|
-
!!isInherited ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : void 0;
|
|
1554
|
-
Constructor[name] = property;
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
/**
|
|
1559
|
-
* Merge two objects, but throw if both contain the same key.
|
|
1560
|
-
*
|
|
1561
|
-
* @param {object} one The first object, which is mutated.
|
|
1562
|
-
* @param {object} two The second object
|
|
1563
|
-
* @return {object} one after it has been mutated to contain everything in two.
|
|
1564
|
-
*/
|
|
1565
|
-
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
1566
|
-
!(one && two && typeof one === 'object' && typeof two === 'object') ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : void 0;
|
|
1567
|
-
|
|
1568
|
-
for (var key in two) {
|
|
1569
|
-
if (two.hasOwnProperty(key)) {
|
|
1570
|
-
!(one[key] === undefined) ? 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) : void 0;
|
|
1571
|
-
one[key] = two[key];
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
return one;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* Creates a function that invokes two functions and merges their return values.
|
|
1579
|
-
*
|
|
1580
|
-
* @param {function} one Function to invoke first.
|
|
1581
|
-
* @param {function} two Function to invoke second.
|
|
1582
|
-
* @return {function} Function that invokes the two argument functions.
|
|
1583
|
-
* @private
|
|
1584
|
-
*/
|
|
1585
|
-
function createMergedResultFunction(one, two) {
|
|
1586
|
-
return function mergedResult() {
|
|
1587
|
-
var a = one.apply(this, arguments);
|
|
1588
|
-
var b = two.apply(this, arguments);
|
|
1589
|
-
if (a == null) {
|
|
1590
|
-
return b;
|
|
1591
|
-
} else if (b == null) {
|
|
1592
|
-
return a;
|
|
1593
|
-
}
|
|
1594
|
-
var c = {};
|
|
1595
|
-
mergeIntoWithNoDuplicateKeys(c, a);
|
|
1596
|
-
mergeIntoWithNoDuplicateKeys(c, b);
|
|
1597
|
-
return c;
|
|
1598
|
-
};
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
/**
|
|
1602
|
-
* Creates a function that invokes two functions and ignores their return vales.
|
|
1603
|
-
*
|
|
1604
|
-
* @param {function} one Function to invoke first.
|
|
1605
|
-
* @param {function} two Function to invoke second.
|
|
1606
|
-
* @return {function} Function that invokes the two argument functions.
|
|
1607
|
-
* @private
|
|
1608
|
-
*/
|
|
1609
|
-
function createChainedFunction(one, two) {
|
|
1610
|
-
return function chainedFunction() {
|
|
1611
|
-
one.apply(this, arguments);
|
|
1612
|
-
two.apply(this, arguments);
|
|
1613
|
-
};
|
|
1614
|
-
}
|
|
1615
|
-
|
|
1616
|
-
/**
|
|
1617
|
-
* Binds a method to the component.
|
|
1618
|
-
*
|
|
1619
|
-
* @param {object} component Component whose method is going to be bound.
|
|
1620
|
-
* @param {function} method Method to be bound.
|
|
1621
|
-
* @return {function} The bound method.
|
|
1622
|
-
*/
|
|
1623
|
-
function bindAutoBindMethod(component, method) {
|
|
1624
|
-
var boundMethod = method.bind(component);
|
|
1625
|
-
{
|
|
1626
|
-
boundMethod.__reactBoundContext = component;
|
|
1627
|
-
boundMethod.__reactBoundMethod = method;
|
|
1628
|
-
boundMethod.__reactBoundArguments = null;
|
|
1629
|
-
var componentName = component.constructor.displayName;
|
|
1630
|
-
var _bind = boundMethod.bind;
|
|
1631
|
-
boundMethod.bind = function (newThis) {
|
|
1632
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1633
|
-
args[_key - 1] = arguments[_key];
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
// User is trying to bind() an autobound method; we effectively will
|
|
1637
|
-
// ignore the value of "this" that the user is trying to use, so
|
|
1638
|
-
// let's warn.
|
|
1639
|
-
if (newThis !== component && newThis !== null) {
|
|
1640
|
-
warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance.\n\nSee %s', componentName);
|
|
1641
|
-
} else if (!args.length) {
|
|
1642
|
-
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.\n\nSee %s', componentName);
|
|
1643
|
-
return boundMethod;
|
|
1644
|
-
}
|
|
1645
|
-
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
1646
|
-
reboundMethod.__reactBoundContext = component;
|
|
1647
|
-
reboundMethod.__reactBoundMethod = method;
|
|
1648
|
-
reboundMethod.__reactBoundArguments = args;
|
|
1649
|
-
return reboundMethod;
|
|
1650
|
-
};
|
|
1651
|
-
}
|
|
1652
|
-
return boundMethod;
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
805
|
/**
|
|
1656
|
-
*
|
|
806
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
807
|
+
* All rights reserved.
|
|
1657
808
|
*
|
|
1658
|
-
*
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
var pairs = component.__reactAutoBindPairs;
|
|
1662
|
-
for (var i = 0; i < pairs.length; i += 2) {
|
|
1663
|
-
var autoBindKey = pairs[i];
|
|
1664
|
-
var method = pairs[i + 1];
|
|
1665
|
-
component[autoBindKey] = bindAutoBindMethod(component, method);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
/**
|
|
1670
|
-
* Add more to the ReactClass base class. These are all legacy features and
|
|
1671
|
-
* therefore not already part of the modern ReactComponent.
|
|
1672
|
-
*/
|
|
1673
|
-
var ReactClassMixin = {
|
|
1674
|
-
/**
|
|
1675
|
-
* TODO: This will be deprecated because state should always keep a consistent
|
|
1676
|
-
* type signature and the only use case for this, is to avoid that.
|
|
1677
|
-
*/
|
|
1678
|
-
replaceState: function (newState, callback) {
|
|
1679
|
-
this.updater.enqueueReplaceState(this, newState, callback, 'replaceState');
|
|
1680
|
-
},
|
|
1681
|
-
|
|
1682
|
-
/**
|
|
1683
|
-
* Checks whether or not this composite component is mounted.
|
|
1684
|
-
* @return {boolean} True if mounted, false otherwise.
|
|
1685
|
-
* @protected
|
|
1686
|
-
* @final
|
|
1687
|
-
*/
|
|
1688
|
-
isMounted: function () {
|
|
1689
|
-
return this.updater.isMounted(this);
|
|
1690
|
-
}
|
|
1691
|
-
};
|
|
1692
|
-
|
|
1693
|
-
var ReactClassComponent = function () {};
|
|
1694
|
-
_assign(ReactClassComponent.prototype, ReactComponent$1.prototype, ReactClassMixin);
|
|
1695
|
-
|
|
1696
|
-
/**
|
|
1697
|
-
* Module for creating composite components.
|
|
809
|
+
* This source code is licensed under the BSD-style license found in the
|
|
810
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
811
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1698
812
|
*
|
|
1699
|
-
* @
|
|
813
|
+
* @providesModule ReactTypeOfWork
|
|
814
|
+
*
|
|
1700
815
|
*/
|
|
1701
|
-
var ReactClass = {
|
|
1702
|
-
/**
|
|
1703
|
-
* Creates a composite component class given a class specification.
|
|
1704
|
-
* See https://facebook.github.io/react/docs/react-api.html#createclass
|
|
1705
|
-
*
|
|
1706
|
-
* @param {object} spec Class specification (which must define `render`).
|
|
1707
|
-
* @return {function} Component constructor function.
|
|
1708
|
-
* @public
|
|
1709
|
-
*/
|
|
1710
|
-
createClass: function (spec) {
|
|
1711
|
-
// To keep our warnings more understandable, we'll use a little hack here to
|
|
1712
|
-
// ensure that Constructor.name !== 'Constructor'. This makes sure we don't
|
|
1713
|
-
// unnecessarily identify a class without displayName as 'Constructor'.
|
|
1714
|
-
var Constructor = identity(function (props, context, updater) {
|
|
1715
|
-
// This constructor gets overridden by mocks. The argument is used
|
|
1716
|
-
// by mocks to assert on what gets mounted.
|
|
1717
|
-
|
|
1718
|
-
{
|
|
1719
|
-
warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory');
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
// Wire up auto-binding
|
|
1723
|
-
if (this.__reactAutoBindPairs.length) {
|
|
1724
|
-
bindAutoBindMethods(this);
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
this.props = props;
|
|
1728
|
-
this.context = context;
|
|
1729
|
-
this.refs = emptyObject;
|
|
1730
|
-
this.updater = updater || ReactNoopUpdateQueue_1;
|
|
1731
|
-
|
|
1732
|
-
this.state = null;
|
|
1733
|
-
|
|
1734
|
-
// ReactClasses doesn't have constructors. Instead, they use the
|
|
1735
|
-
// getInitialState and componentWillMount methods for initialization.
|
|
1736
|
-
|
|
1737
|
-
var initialState = this.getInitialState ? this.getInitialState() : null;
|
|
1738
|
-
{
|
|
1739
|
-
// We allow auto-mocks to proceed as if they're returning null.
|
|
1740
|
-
if (initialState === undefined && this.getInitialState._isMockFunction) {
|
|
1741
|
-
// This is probably bad practice. Consider warning here and
|
|
1742
|
-
// deprecating this convenience.
|
|
1743
|
-
initialState = null;
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : void 0;
|
|
1747
|
-
|
|
1748
|
-
this.state = initialState;
|
|
1749
|
-
});
|
|
1750
|
-
Constructor.prototype = new ReactClassComponent();
|
|
1751
|
-
Constructor.prototype.constructor = Constructor;
|
|
1752
|
-
Constructor.prototype.__reactAutoBindPairs = [];
|
|
1753
|
-
|
|
1754
|
-
mixSpecIntoComponent(Constructor, spec);
|
|
1755
|
-
|
|
1756
|
-
// Initialize the defaultProps property after all mixins have been merged.
|
|
1757
|
-
if (Constructor.getDefaultProps) {
|
|
1758
|
-
Constructor.defaultProps = Constructor.getDefaultProps();
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
{
|
|
1762
|
-
// This is a tag to indicate that the use of these method names is ok,
|
|
1763
|
-
// since it's used with createClass. If it's not, then it's likely a
|
|
1764
|
-
// mistake so we'll warn you to use the static property, property
|
|
1765
|
-
// initializer or constructor respectively.
|
|
1766
|
-
if (Constructor.getDefaultProps) {
|
|
1767
|
-
Constructor.getDefaultProps.isReactClassApproved = {};
|
|
1768
|
-
}
|
|
1769
|
-
if (Constructor.prototype.getInitialState) {
|
|
1770
|
-
Constructor.prototype.getInitialState.isReactClassApproved = {};
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
!Constructor.prototype.render ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : void 0;
|
|
1775
|
-
|
|
1776
|
-
{
|
|
1777
|
-
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');
|
|
1778
|
-
warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component');
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
// Reduce time spent doing lookups by setting these on the prototype.
|
|
1782
|
-
for (var methodName in ReactClassInterface) {
|
|
1783
|
-
if (!Constructor.prototype[methodName]) {
|
|
1784
|
-
Constructor.prototype[methodName] = null;
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
816
|
|
|
1788
|
-
|
|
1789
|
-
|
|
817
|
+
var ReactTypeOfWork = {
|
|
818
|
+
IndeterminateComponent: 0, // Before we know whether it is functional or class
|
|
819
|
+
FunctionalComponent: 1,
|
|
820
|
+
ClassComponent: 2,
|
|
821
|
+
HostRoot: 3, // Root of a host tree. Could be nested inside another node.
|
|
822
|
+
HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
|
|
823
|
+
HostComponent: 5,
|
|
824
|
+
HostText: 6,
|
|
825
|
+
CoroutineComponent: 7,
|
|
826
|
+
CoroutineHandlerPhase: 8,
|
|
827
|
+
YieldComponent: 9,
|
|
828
|
+
Fragment: 10
|
|
1790
829
|
};
|
|
1791
830
|
|
|
1792
|
-
var ReactClass_1 = ReactClass;
|
|
1793
|
-
|
|
1794
831
|
/**
|
|
1795
832
|
* Copyright 2013-present, Facebook, Inc.
|
|
1796
833
|
* All rights reserved.
|
|
@@ -1818,101 +855,13 @@ function getComponentName(instanceOrFiber) {
|
|
|
1818
855
|
return type;
|
|
1819
856
|
}
|
|
1820
857
|
if (typeof type === 'function') {
|
|
1821
|
-
return type.displayName || type.name;
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
return null;
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
var getComponentName_1 = getComponentName;
|
|
1828
|
-
|
|
1829
|
-
/**
|
|
1830
|
-
* Copyright 2013-present, Facebook, Inc.
|
|
1831
|
-
* All rights reserved.
|
|
1832
|
-
*
|
|
1833
|
-
* This source code is licensed under the BSD-style license found in the
|
|
1834
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1835
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
1838
|
-
* @providesModule ReactPropTypesSecret
|
|
1839
|
-
*/
|
|
1840
|
-
|
|
1841
|
-
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
1842
|
-
|
|
1843
|
-
var ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
1844
|
-
|
|
1845
|
-
var loggedTypeFailures = {};
|
|
1846
|
-
|
|
1847
|
-
/**
|
|
1848
|
-
* Assert that the values match with the type specs.
|
|
1849
|
-
* Error messages are memorized and will only be shown once.
|
|
1850
|
-
*
|
|
1851
|
-
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
1852
|
-
* @param {object} values Runtime values that need to be type-checked
|
|
1853
|
-
* @param {string} location e.g. "prop", "context", "child context"
|
|
1854
|
-
* @param {string} componentName Name of the component for error messages.
|
|
1855
|
-
* @param {?Function} getStack Returns the component stack.
|
|
1856
|
-
* @private
|
|
1857
|
-
*/
|
|
1858
|
-
function checkPropTypes$1(typeSpecs, values, location, componentName, getStack) {
|
|
1859
|
-
{
|
|
1860
|
-
for (var typeSpecName in typeSpecs) {
|
|
1861
|
-
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
1862
|
-
var error;
|
|
1863
|
-
// Prop type validation may throw. In case they do, we don't want to
|
|
1864
|
-
// fail the render phase where it didn't fail before. So we log it.
|
|
1865
|
-
// After these have been cleaned up, we'll let them throw.
|
|
1866
|
-
try {
|
|
1867
|
-
// This is intentionally an invariant that gets caught. It's the same
|
|
1868
|
-
// behavior as without this statement except with a better message.
|
|
1869
|
-
!(typeof typeSpecs[typeSpecName] === 'function') ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', location, typeSpecName) : void 0;
|
|
1870
|
-
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret_1);
|
|
1871
|
-
} catch (ex) {
|
|
1872
|
-
error = ex;
|
|
1873
|
-
}
|
|
1874
|
-
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', location, typeSpecName, typeof error);
|
|
1875
|
-
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
1876
|
-
// Only monitor this failure once because there tends to be a lot of the
|
|
1877
|
-
// same error.
|
|
1878
|
-
loggedTypeFailures[error.message] = true;
|
|
1879
|
-
|
|
1880
|
-
var stack = getStack ? getStack() : '';
|
|
1881
|
-
|
|
1882
|
-
warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
var checkPropTypes_1 = checkPropTypes$1;
|
|
1890
|
-
|
|
1891
|
-
/**
|
|
1892
|
-
* Copyright 2013-present, Facebook, Inc.
|
|
1893
|
-
* All rights reserved.
|
|
1894
|
-
*
|
|
1895
|
-
* This source code is licensed under the BSD-style license found in the
|
|
1896
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1897
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1898
|
-
*
|
|
1899
|
-
* @providesModule ReactTypeOfWork
|
|
1900
|
-
*
|
|
1901
|
-
*/
|
|
858
|
+
return type.displayName || type.name;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
1902
863
|
|
|
1903
|
-
var
|
|
1904
|
-
IndeterminateComponent: 0, // Before we know whether it is functional or class
|
|
1905
|
-
FunctionalComponent: 1,
|
|
1906
|
-
ClassComponent: 2,
|
|
1907
|
-
HostRoot: 3, // Root of a host tree. Could be nested inside another node.
|
|
1908
|
-
HostPortal: 4, // A subtree. Could be an entry point to a different renderer.
|
|
1909
|
-
HostComponent: 5,
|
|
1910
|
-
HostText: 6,
|
|
1911
|
-
CoroutineComponent: 7,
|
|
1912
|
-
CoroutineHandlerPhase: 8,
|
|
1913
|
-
YieldComponent: 9,
|
|
1914
|
-
Fragment: 10
|
|
1915
|
-
};
|
|
864
|
+
var getComponentName_1 = getComponentName;
|
|
1916
865
|
|
|
1917
866
|
var IndeterminateComponent = ReactTypeOfWork.IndeterminateComponent;
|
|
1918
867
|
var FunctionalComponent = ReactTypeOfWork.FunctionalComponent;
|
|
@@ -1947,7 +896,7 @@ function describeFiber(fiber) {
|
|
|
1947
896
|
// This function can only be called with a work-in-progress fiber and
|
|
1948
897
|
// only during begin or complete phase. Do not call it under any other
|
|
1949
898
|
// circumstances.
|
|
1950
|
-
function getStackAddendumByWorkInProgressFiber$
|
|
899
|
+
function getStackAddendumByWorkInProgressFiber$1(workInProgress) {
|
|
1951
900
|
var info = '';
|
|
1952
901
|
var node = workInProgress;
|
|
1953
902
|
do {
|
|
@@ -1959,11 +908,11 @@ function getStackAddendumByWorkInProgressFiber$2(workInProgress) {
|
|
|
1959
908
|
}
|
|
1960
909
|
|
|
1961
910
|
var ReactFiberComponentTreeHook = {
|
|
1962
|
-
getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$
|
|
911
|
+
getStackAddendumByWorkInProgressFiber: getStackAddendumByWorkInProgressFiber$1,
|
|
1963
912
|
describeComponentFrame: describeComponentFrame$1
|
|
1964
913
|
};
|
|
1965
914
|
|
|
1966
|
-
var getStackAddendumByWorkInProgressFiber
|
|
915
|
+
var getStackAddendumByWorkInProgressFiber = ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;
|
|
1967
916
|
var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
|
|
1968
917
|
|
|
1969
918
|
|
|
@@ -1973,10 +922,9 @@ var describeComponentFrame = ReactFiberComponentTreeHook.describeComponentFrame;
|
|
|
1973
922
|
function isNative(fn) {
|
|
1974
923
|
// Based on isNative() from Lodash
|
|
1975
924
|
var funcToString = Function.prototype.toString;
|
|
1976
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1977
925
|
var reIsNative = RegExp('^' + funcToString
|
|
1978
926
|
// Take an example native function source for comparison
|
|
1979
|
-
.call(hasOwnProperty)
|
|
927
|
+
.call(Object.prototype.hasOwnProperty)
|
|
1980
928
|
// Strip regex characters so we can use it for regex
|
|
1981
929
|
.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
|
|
1982
930
|
// Remove hasOwnProperty from the template to make it generic
|
|
@@ -2219,7 +1167,7 @@ var ReactComponentTreeHook = {
|
|
|
2219
1167
|
var workInProgress = currentOwner;
|
|
2220
1168
|
// Safe because if current owner exists, we are reconciling,
|
|
2221
1169
|
// and it is guaranteed to be the work-in-progress version.
|
|
2222
|
-
info += getStackAddendumByWorkInProgressFiber
|
|
1170
|
+
info += getStackAddendumByWorkInProgressFiber(workInProgress);
|
|
2223
1171
|
} else if (typeof currentOwner._debugID === 'number') {
|
|
2224
1172
|
info += ReactComponentTreeHook.getStackAddendumByID(currentOwner._debugID);
|
|
2225
1173
|
}
|
|
@@ -2282,21 +1230,329 @@ var ReactComponentTreeHook = {
|
|
|
2282
1230
|
},
|
|
2283
1231
|
|
|
2284
1232
|
|
|
2285
|
-
getRootIDs: getRootIDs,
|
|
2286
|
-
getRegisteredIDs: getItemIDs
|
|
1233
|
+
getRootIDs: getRootIDs,
|
|
1234
|
+
getRegisteredIDs: getItemIDs
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
var ReactComponentTreeHook_1 = ReactComponentTreeHook;
|
|
1238
|
+
|
|
1239
|
+
{
|
|
1240
|
+
var _require = ReactComponentTreeHook_1,
|
|
1241
|
+
getCurrentStackAddendum = _require.getCurrentStackAddendum;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
var SEPARATOR = '.';
|
|
1245
|
+
var SUBSEPARATOR = ':';
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* This is inlined from ReactElement since this file is shared between
|
|
1249
|
+
* isomorphic and renderers. We could extract this to a
|
|
1250
|
+
*
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* TODO: Test that a single child and an array with one item have the same key
|
|
1255
|
+
* pattern.
|
|
1256
|
+
*/
|
|
1257
|
+
|
|
1258
|
+
var didWarnAboutMaps = false;
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* Generate a key string that identifies a component within a set.
|
|
1262
|
+
*
|
|
1263
|
+
* @param {*} component A component that could contain a manual key.
|
|
1264
|
+
* @param {number} index Index that is used if a manual key is not provided.
|
|
1265
|
+
* @return {string}
|
|
1266
|
+
*/
|
|
1267
|
+
function getComponentKey(component, index) {
|
|
1268
|
+
// Do some typechecking here since we call this blindly. We want to ensure
|
|
1269
|
+
// that we don't block potential future ES APIs.
|
|
1270
|
+
if (typeof component === 'object' && component !== null && component.key != null) {
|
|
1271
|
+
// Explicit key
|
|
1272
|
+
return KeyEscapeUtils_1.escape(component.key);
|
|
1273
|
+
}
|
|
1274
|
+
// Implicit key determined by the index in the set
|
|
1275
|
+
return index.toString(36);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* @param {?*} children Children tree container.
|
|
1280
|
+
* @param {!string} nameSoFar Name of the key path so far.
|
|
1281
|
+
* @param {!function} callback Callback to invoke with each child found.
|
|
1282
|
+
* @param {?*} traverseContext Used to pass information throughout the traversal
|
|
1283
|
+
* process.
|
|
1284
|
+
* @return {!number} The number of children in this subtree.
|
|
1285
|
+
*/
|
|
1286
|
+
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
|
1287
|
+
var type = typeof children;
|
|
1288
|
+
|
|
1289
|
+
if (type === 'undefined' || type === 'boolean') {
|
|
1290
|
+
// All of the above are perceived as null.
|
|
1291
|
+
children = null;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
if (children === null || type === 'string' || type === 'number' ||
|
|
1295
|
+
// The following is inlined from ReactElement. This means we can optimize
|
|
1296
|
+
// some checks. React Fiber also inlines this logic for similar purposes.
|
|
1297
|
+
type === 'object' && children.$$typeof === ReactElementSymbol) {
|
|
1298
|
+
callback(traverseContext, children,
|
|
1299
|
+
// If it's the only child, treat the name as if it was wrapped in an array
|
|
1300
|
+
// so that it's consistent if the number of children grows.
|
|
1301
|
+
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
|
1302
|
+
return 1;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
var child;
|
|
1306
|
+
var nextName;
|
|
1307
|
+
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
1308
|
+
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
1309
|
+
|
|
1310
|
+
if (Array.isArray(children)) {
|
|
1311
|
+
for (var i = 0; i < children.length; i++) {
|
|
1312
|
+
child = children[i];
|
|
1313
|
+
nextName = nextNamePrefix + getComponentKey(child, i);
|
|
1314
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
1315
|
+
}
|
|
1316
|
+
} else {
|
|
1317
|
+
var iteratorFn = getIteratorFn_1(children);
|
|
1318
|
+
if (iteratorFn) {
|
|
1319
|
+
{
|
|
1320
|
+
// Warn about using Maps as children
|
|
1321
|
+
if (iteratorFn === children.entries) {
|
|
1322
|
+
warning(didWarnAboutMaps, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.%s', getCurrentStackAddendum());
|
|
1323
|
+
didWarnAboutMaps = true;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
var iterator = iteratorFn.call(children);
|
|
1328
|
+
var step;
|
|
1329
|
+
var ii = 0;
|
|
1330
|
+
while (!(step = iterator.next()).done) {
|
|
1331
|
+
child = step.value;
|
|
1332
|
+
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
1333
|
+
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
|
|
1334
|
+
}
|
|
1335
|
+
} else if (type === 'object') {
|
|
1336
|
+
var addendum = '';
|
|
1337
|
+
{
|
|
1338
|
+
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentStackAddendum();
|
|
1339
|
+
}
|
|
1340
|
+
var childrenString = '' + children;
|
|
1341
|
+
invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
return subtreeCount;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Traverses children that are typically specified as `props.children`, but
|
|
1350
|
+
* might also be specified through attributes:
|
|
1351
|
+
*
|
|
1352
|
+
* - `traverseAllChildren(this.props.children, ...)`
|
|
1353
|
+
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
|
|
1354
|
+
*
|
|
1355
|
+
* The `traverseContext` is an optional argument that is passed through the
|
|
1356
|
+
* entire traversal. It can be used to store accumulations or anything else that
|
|
1357
|
+
* the callback might find relevant.
|
|
1358
|
+
*
|
|
1359
|
+
* @param {?*} children Children tree object.
|
|
1360
|
+
* @param {!function} callback To invoke upon traversing each child.
|
|
1361
|
+
* @param {?*} traverseContext Context for traversal.
|
|
1362
|
+
* @return {!number} The number of children in this subtree.
|
|
1363
|
+
*/
|
|
1364
|
+
function traverseAllChildren(children, callback, traverseContext) {
|
|
1365
|
+
if (children == null) {
|
|
1366
|
+
return 0;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
var traverseAllChildren_1 = traverseAllChildren;
|
|
1373
|
+
|
|
1374
|
+
var twoArgumentPooler = PooledClass_1.twoArgumentPooler;
|
|
1375
|
+
var fourArgumentPooler = PooledClass_1.fourArgumentPooler;
|
|
1376
|
+
|
|
1377
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
1378
|
+
function escapeUserProvidedKey(text) {
|
|
1379
|
+
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* PooledClass representing the bookkeeping associated with performing a child
|
|
1384
|
+
* traversal. Allows avoiding binding callbacks.
|
|
1385
|
+
*
|
|
1386
|
+
* @constructor ForEachBookKeeping
|
|
1387
|
+
* @param {!function} forEachFunction Function to perform traversal with.
|
|
1388
|
+
* @param {?*} forEachContext Context to perform context with.
|
|
1389
|
+
*/
|
|
1390
|
+
function ForEachBookKeeping(forEachFunction, forEachContext) {
|
|
1391
|
+
this.func = forEachFunction;
|
|
1392
|
+
this.context = forEachContext;
|
|
1393
|
+
this.count = 0;
|
|
1394
|
+
}
|
|
1395
|
+
ForEachBookKeeping.prototype.destructor = function () {
|
|
1396
|
+
this.func = null;
|
|
1397
|
+
this.context = null;
|
|
1398
|
+
this.count = 0;
|
|
1399
|
+
};
|
|
1400
|
+
PooledClass_1.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
|
|
1401
|
+
|
|
1402
|
+
function forEachSingleChild(bookKeeping, child, name) {
|
|
1403
|
+
var func = bookKeeping.func,
|
|
1404
|
+
context = bookKeeping.context;
|
|
1405
|
+
|
|
1406
|
+
func.call(context, child, bookKeeping.count++);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Iterates through children that are typically specified as `props.children`.
|
|
1411
|
+
*
|
|
1412
|
+
* See https://facebook.github.io/react/docs/react-api.html#react.children.foreach
|
|
1413
|
+
*
|
|
1414
|
+
* The provided forEachFunc(child, index) will be called for each
|
|
1415
|
+
* leaf child.
|
|
1416
|
+
*
|
|
1417
|
+
* @param {?*} children Children tree container.
|
|
1418
|
+
* @param {function(*, int)} forEachFunc
|
|
1419
|
+
* @param {*} forEachContext Context for forEachContext.
|
|
1420
|
+
*/
|
|
1421
|
+
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
1422
|
+
if (children == null) {
|
|
1423
|
+
return children;
|
|
1424
|
+
}
|
|
1425
|
+
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
|
|
1426
|
+
traverseAllChildren_1(children, forEachSingleChild, traverseContext);
|
|
1427
|
+
ForEachBookKeeping.release(traverseContext);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* PooledClass representing the bookkeeping associated with performing a child
|
|
1432
|
+
* mapping. Allows avoiding binding callbacks.
|
|
1433
|
+
*
|
|
1434
|
+
* @constructor MapBookKeeping
|
|
1435
|
+
* @param {!*} mapResult Object containing the ordered map of results.
|
|
1436
|
+
* @param {!function} mapFunction Function to perform mapping with.
|
|
1437
|
+
* @param {?*} mapContext Context to perform mapping with.
|
|
1438
|
+
*/
|
|
1439
|
+
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
|
|
1440
|
+
this.result = mapResult;
|
|
1441
|
+
this.keyPrefix = keyPrefix;
|
|
1442
|
+
this.func = mapFunction;
|
|
1443
|
+
this.context = mapContext;
|
|
1444
|
+
this.count = 0;
|
|
1445
|
+
}
|
|
1446
|
+
MapBookKeeping.prototype.destructor = function () {
|
|
1447
|
+
this.result = null;
|
|
1448
|
+
this.keyPrefix = null;
|
|
1449
|
+
this.func = null;
|
|
1450
|
+
this.context = null;
|
|
1451
|
+
this.count = 0;
|
|
1452
|
+
};
|
|
1453
|
+
PooledClass_1.addPoolingTo(MapBookKeeping, fourArgumentPooler);
|
|
1454
|
+
|
|
1455
|
+
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
1456
|
+
var result = bookKeeping.result,
|
|
1457
|
+
keyPrefix = bookKeeping.keyPrefix,
|
|
1458
|
+
func = bookKeeping.func,
|
|
1459
|
+
context = bookKeeping.context;
|
|
1460
|
+
|
|
1461
|
+
|
|
1462
|
+
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
1463
|
+
if (Array.isArray(mappedChild)) {
|
|
1464
|
+
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
|
|
1465
|
+
} else if (mappedChild != null) {
|
|
1466
|
+
if (ReactElement_1.isValidElement(mappedChild)) {
|
|
1467
|
+
mappedChild = ReactElement_1.cloneAndReplaceKey(mappedChild,
|
|
1468
|
+
// Keep both the (mapped) and old keys if they differ, just as
|
|
1469
|
+
// traverseAllChildren used to do for objects as children
|
|
1470
|
+
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
|
1471
|
+
}
|
|
1472
|
+
result.push(mappedChild);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
1477
|
+
var escapedPrefix = '';
|
|
1478
|
+
if (prefix != null) {
|
|
1479
|
+
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
|
1480
|
+
}
|
|
1481
|
+
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
|
|
1482
|
+
traverseAllChildren_1(children, mapSingleChildIntoContext, traverseContext);
|
|
1483
|
+
MapBookKeeping.release(traverseContext);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Maps children that are typically specified as `props.children`.
|
|
1488
|
+
*
|
|
1489
|
+
* See https://facebook.github.io/react/docs/react-api.html#react.children.map
|
|
1490
|
+
*
|
|
1491
|
+
* The provided mapFunction(child, key, index) will be called for each
|
|
1492
|
+
* leaf child.
|
|
1493
|
+
*
|
|
1494
|
+
* @param {?*} children Children tree container.
|
|
1495
|
+
* @param {function(*, int)} func The map function.
|
|
1496
|
+
* @param {*} context Context for mapFunction.
|
|
1497
|
+
* @return {object} Object containing the ordered map of results.
|
|
1498
|
+
*/
|
|
1499
|
+
function mapChildren(children, func, context) {
|
|
1500
|
+
if (children == null) {
|
|
1501
|
+
return children;
|
|
1502
|
+
}
|
|
1503
|
+
var result = [];
|
|
1504
|
+
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
|
1505
|
+
return result;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
function forEachSingleChildDummy(traverseContext, child, name) {
|
|
1509
|
+
return null;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Count the number of children that are typically specified as
|
|
1514
|
+
* `props.children`.
|
|
1515
|
+
*
|
|
1516
|
+
* See https://facebook.github.io/react/docs/react-api.html#react.children.count
|
|
1517
|
+
*
|
|
1518
|
+
* @param {?*} children Children tree container.
|
|
1519
|
+
* @return {number} The number of children.
|
|
1520
|
+
*/
|
|
1521
|
+
function countChildren(children, context) {
|
|
1522
|
+
return traverseAllChildren_1(children, forEachSingleChildDummy, null);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Flatten a children object (typically specified as `props.children`) and
|
|
1527
|
+
* return an array with appropriately re-keyed children.
|
|
1528
|
+
*
|
|
1529
|
+
* See https://facebook.github.io/react/docs/react-api.html#react.children.toarray
|
|
1530
|
+
*/
|
|
1531
|
+
function toArray(children) {
|
|
1532
|
+
var result = [];
|
|
1533
|
+
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
|
|
1534
|
+
return result;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
var ReactChildren = {
|
|
1538
|
+
forEach: forEachChildren,
|
|
1539
|
+
map: mapChildren,
|
|
1540
|
+
mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
|
|
1541
|
+
count: countChildren,
|
|
1542
|
+
toArray: toArray
|
|
2287
1543
|
};
|
|
2288
1544
|
|
|
2289
|
-
var
|
|
1545
|
+
var ReactChildren_1 = ReactChildren;
|
|
2290
1546
|
|
|
2291
1547
|
var ReactDebugCurrentFrame$1 = {};
|
|
2292
1548
|
|
|
2293
1549
|
{
|
|
2294
|
-
var _require$
|
|
2295
|
-
getStackAddendumByID = _require$
|
|
2296
|
-
getCurrentStackAddendum$
|
|
1550
|
+
var _require$2 = ReactComponentTreeHook_1,
|
|
1551
|
+
getStackAddendumByID = _require$2.getStackAddendumByID,
|
|
1552
|
+
getCurrentStackAddendum$2 = _require$2.getCurrentStackAddendum;
|
|
2297
1553
|
|
|
2298
|
-
var _require2 = ReactFiberComponentTreeHook,
|
|
2299
|
-
getStackAddendumByWorkInProgressFiber = _require2.getStackAddendumByWorkInProgressFiber;
|
|
1554
|
+
var _require2$1 = ReactFiberComponentTreeHook,
|
|
1555
|
+
getStackAddendumByWorkInProgressFiber$2 = _require2$1.getStackAddendumByWorkInProgressFiber;
|
|
2300
1556
|
|
|
2301
1557
|
// Component that is being worked on
|
|
2302
1558
|
|
|
@@ -2320,10 +1576,10 @@ var ReactDebugCurrentFrame$1 = {};
|
|
|
2320
1576
|
// The stack will only be correct if this is a work in progress
|
|
2321
1577
|
// version and we're calling it during reconciliation.
|
|
2322
1578
|
var workInProgress = current;
|
|
2323
|
-
stack = getStackAddendumByWorkInProgressFiber(workInProgress);
|
|
1579
|
+
stack = getStackAddendumByWorkInProgressFiber$2(workInProgress);
|
|
2324
1580
|
}
|
|
2325
1581
|
} else if (element !== null) {
|
|
2326
|
-
stack = getCurrentStackAddendum$
|
|
1582
|
+
stack = getCurrentStackAddendum$2(element);
|
|
2327
1583
|
}
|
|
2328
1584
|
return stack;
|
|
2329
1585
|
};
|
|
@@ -2332,12 +1588,12 @@ var ReactDebugCurrentFrame$1 = {};
|
|
|
2332
1588
|
var ReactDebugCurrentFrame_1 = ReactDebugCurrentFrame$1;
|
|
2333
1589
|
|
|
2334
1590
|
{
|
|
2335
|
-
var checkPropTypes =
|
|
1591
|
+
var checkPropTypes$1 = checkPropTypes;
|
|
2336
1592
|
var warning$2 = warning;
|
|
2337
1593
|
var ReactDebugCurrentFrame = ReactDebugCurrentFrame_1;
|
|
2338
1594
|
|
|
2339
|
-
var _require = ReactComponentTreeHook_1,
|
|
2340
|
-
getCurrentStackAddendum = _require.getCurrentStackAddendum;
|
|
1595
|
+
var _require$1 = ReactComponentTreeHook_1,
|
|
1596
|
+
getCurrentStackAddendum$1 = _require$1.getCurrentStackAddendum;
|
|
2341
1597
|
}
|
|
2342
1598
|
|
|
2343
1599
|
function getDeclarationErrorAddendum() {
|
|
@@ -2396,13 +1652,11 @@ function validateExplicitKey(element, parentType) {
|
|
|
2396
1652
|
}
|
|
2397
1653
|
element._store.validated = true;
|
|
2398
1654
|
|
|
2399
|
-
var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
|
|
2400
|
-
|
|
2401
1655
|
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
2402
|
-
if (
|
|
1656
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
2403
1657
|
return;
|
|
2404
1658
|
}
|
|
2405
|
-
|
|
1659
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
2406
1660
|
|
|
2407
1661
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
2408
1662
|
// property, it may be the creator of the child that's responsible for
|
|
@@ -2413,7 +1667,7 @@ function validateExplicitKey(element, parentType) {
|
|
|
2413
1667
|
childOwner = ' It was passed a child from ' + getComponentName_1(element._owner) + '.';
|
|
2414
1668
|
}
|
|
2415
1669
|
|
|
2416
|
-
warning$2(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getCurrentStackAddendum(element));
|
|
1670
|
+
warning$2(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, getCurrentStackAddendum$1(element));
|
|
2417
1671
|
}
|
|
2418
1672
|
|
|
2419
1673
|
/**
|
|
@@ -2476,10 +1730,10 @@ function validatePropTypes(element) {
|
|
|
2476
1730
|
// Avoid triggering that warning during validation using the temporary workaround,
|
|
2477
1731
|
// __propTypesSecretDontUseThesePlease.
|
|
2478
1732
|
// TODO (bvaughn) Revert this particular change any time after April 1 ReactNative tag.
|
|
2479
|
-
var propTypes = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
|
|
1733
|
+
var propTypes$$1 = typeof componentClass.__propTypesSecretDontUseThesePlease === 'object' ? componentClass.__propTypesSecretDontUseThesePlease : componentClass.propTypes;
|
|
2480
1734
|
|
|
2481
|
-
if (propTypes) {
|
|
2482
|
-
checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
1735
|
+
if (propTypes$$1) {
|
|
1736
|
+
checkPropTypes$1(propTypes$$1, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
2483
1737
|
}
|
|
2484
1738
|
if (typeof componentClass.getDefaultProps === 'function') {
|
|
2485
1739
|
warning$2(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
|
|
@@ -2504,7 +1758,7 @@ var ReactElementValidator$2 = {
|
|
|
2504
1758
|
info += getDeclarationErrorAddendum();
|
|
2505
1759
|
}
|
|
2506
1760
|
|
|
2507
|
-
info += getCurrentStackAddendum();
|
|
1761
|
+
info += getCurrentStackAddendum$1();
|
|
2508
1762
|
|
|
2509
1763
|
warning$2(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info);
|
|
2510
1764
|
}
|
|
@@ -2595,7 +1849,6 @@ var createDOMFactory = ReactElement_1.createFactory;
|
|
|
2595
1849
|
|
|
2596
1850
|
/**
|
|
2597
1851
|
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
|
|
2598
|
-
* This is also accessible via `React.DOM`.
|
|
2599
1852
|
*
|
|
2600
1853
|
* @public
|
|
2601
1854
|
*/
|
|
@@ -2738,414 +1991,7 @@ var ReactDOMFactories = {
|
|
|
2738
1991
|
|
|
2739
1992
|
var ReactDOMFactories_1 = ReactDOMFactories;
|
|
2740
1993
|
|
|
2741
|
-
|
|
2742
|
-
* Collection of methods that allow declaration and validation of props that are
|
|
2743
|
-
* supplied to React components. Example usage:
|
|
2744
|
-
*
|
|
2745
|
-
* var Props = require('ReactPropTypes');
|
|
2746
|
-
* var MyArticle = React.createClass({
|
|
2747
|
-
* propTypes: {
|
|
2748
|
-
* // An optional string prop named "description".
|
|
2749
|
-
* description: Props.string,
|
|
2750
|
-
*
|
|
2751
|
-
* // A required enum prop named "category".
|
|
2752
|
-
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
2753
|
-
*
|
|
2754
|
-
* // A prop named "dialog" that requires an instance of Dialog.
|
|
2755
|
-
* dialog: Props.instanceOf(Dialog).isRequired
|
|
2756
|
-
* },
|
|
2757
|
-
* render: function() { ... }
|
|
2758
|
-
* });
|
|
2759
|
-
*
|
|
2760
|
-
* A more formal specification of how these methods are used:
|
|
2761
|
-
*
|
|
2762
|
-
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
2763
|
-
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
2764
|
-
*
|
|
2765
|
-
* Each and every declaration produces a function with the same signature. This
|
|
2766
|
-
* allows the creation of custom validation functions. For example:
|
|
2767
|
-
*
|
|
2768
|
-
* var MyLink = React.createClass({
|
|
2769
|
-
* propTypes: {
|
|
2770
|
-
* // An optional string or URI prop named "href".
|
|
2771
|
-
* href: function(props, propName, componentName) {
|
|
2772
|
-
* var propValue = props[propName];
|
|
2773
|
-
* if (propValue != null && typeof propValue !== 'string' &&
|
|
2774
|
-
* !(propValue instanceof URI)) {
|
|
2775
|
-
* return new Error(
|
|
2776
|
-
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
2777
|
-
* componentName
|
|
2778
|
-
* );
|
|
2779
|
-
* }
|
|
2780
|
-
* }
|
|
2781
|
-
* },
|
|
2782
|
-
* render: function() {...}
|
|
2783
|
-
* });
|
|
2784
|
-
*
|
|
2785
|
-
* @internal
|
|
2786
|
-
*/
|
|
2787
|
-
|
|
2788
|
-
var ANONYMOUS = '<<anonymous>>';
|
|
2789
|
-
|
|
2790
|
-
var ReactPropTypes;
|
|
2791
|
-
|
|
2792
|
-
{
|
|
2793
|
-
// Keep in sync with production version below
|
|
2794
|
-
ReactPropTypes = {
|
|
2795
|
-
array: createPrimitiveTypeChecker('array'),
|
|
2796
|
-
bool: createPrimitiveTypeChecker('boolean'),
|
|
2797
|
-
func: createPrimitiveTypeChecker('function'),
|
|
2798
|
-
number: createPrimitiveTypeChecker('number'),
|
|
2799
|
-
object: createPrimitiveTypeChecker('object'),
|
|
2800
|
-
string: createPrimitiveTypeChecker('string'),
|
|
2801
|
-
symbol: createPrimitiveTypeChecker('symbol'),
|
|
2802
|
-
|
|
2803
|
-
any: createAnyTypeChecker(),
|
|
2804
|
-
arrayOf: createArrayOfTypeChecker,
|
|
2805
|
-
element: createElementTypeChecker(),
|
|
2806
|
-
instanceOf: createInstanceTypeChecker,
|
|
2807
|
-
node: createNodeChecker(),
|
|
2808
|
-
objectOf: createObjectOfTypeChecker,
|
|
2809
|
-
oneOf: createEnumTypeChecker,
|
|
2810
|
-
oneOfType: createUnionTypeChecker,
|
|
2811
|
-
shape: createShapeTypeChecker
|
|
2812
|
-
};
|
|
2813
|
-
}
|
|
2814
|
-
|
|
2815
|
-
/**
|
|
2816
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
2817
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
2818
|
-
*/
|
|
2819
|
-
/*eslint-disable no-self-compare*/
|
|
2820
|
-
function is(x, y) {
|
|
2821
|
-
// SameValue algorithm
|
|
2822
|
-
if (x === y) {
|
|
2823
|
-
// Steps 1-5, 7-10
|
|
2824
|
-
// Steps 6.b-6.e: +0 != -0
|
|
2825
|
-
return x !== 0 || 1 / x === 1 / y;
|
|
2826
|
-
} else {
|
|
2827
|
-
// Step 6.a: NaN == NaN
|
|
2828
|
-
return x !== x && y !== y;
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
/*eslint-enable no-self-compare*/
|
|
2832
|
-
|
|
2833
|
-
/**
|
|
2834
|
-
* We use an Error-like object for backward compatibility as people may call
|
|
2835
|
-
* PropTypes directly and inspect their output. However, we don't use real
|
|
2836
|
-
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
2837
|
-
* is prohibitively expensive if they are created too often, such as what
|
|
2838
|
-
* happens in oneOfType() for any type before the one that matched.
|
|
2839
|
-
*/
|
|
2840
|
-
function PropTypeError(message) {
|
|
2841
|
-
this.message = message;
|
|
2842
|
-
this.stack = '';
|
|
2843
|
-
}
|
|
2844
|
-
// Make `instanceof Error` still work for returned errors.
|
|
2845
|
-
PropTypeError.prototype = Error.prototype;
|
|
2846
|
-
|
|
2847
|
-
function createChainableTypeChecker(validate) {
|
|
2848
|
-
{
|
|
2849
|
-
var manualPropTypeCallCache = {};
|
|
2850
|
-
}
|
|
2851
|
-
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
2852
|
-
componentName = componentName || ANONYMOUS;
|
|
2853
|
-
propFullName = propFullName || propName;
|
|
2854
|
-
{
|
|
2855
|
-
if (secret !== ReactPropTypesSecret_1 && typeof console !== 'undefined') {
|
|
2856
|
-
var cacheKey = componentName + ':' + propName;
|
|
2857
|
-
if (!manualPropTypeCallCache[cacheKey]) {
|
|
2858
|
-
warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);
|
|
2859
|
-
manualPropTypeCallCache[cacheKey] = true;
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
if (props[propName] == null) {
|
|
2864
|
-
if (isRequired) {
|
|
2865
|
-
if (props[propName] === null) {
|
|
2866
|
-
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
2867
|
-
}
|
|
2868
|
-
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
2869
|
-
}
|
|
2870
|
-
return null;
|
|
2871
|
-
} else {
|
|
2872
|
-
return validate(props, propName, componentName, location, propFullName);
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
|
|
2876
|
-
var chainedCheckType = checkType.bind(null, false);
|
|
2877
|
-
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
2878
|
-
|
|
2879
|
-
return chainedCheckType;
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
function createPrimitiveTypeChecker(expectedType) {
|
|
2883
|
-
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
2884
|
-
var propValue = props[propName];
|
|
2885
|
-
var propType = getPropType(propValue);
|
|
2886
|
-
if (propType !== expectedType) {
|
|
2887
|
-
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
2888
|
-
// check, but we can offer a more precise error message here rather than
|
|
2889
|
-
// 'of type `object`'.
|
|
2890
|
-
var preciseType = getPreciseType(propValue);
|
|
2891
|
-
|
|
2892
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
|
2893
|
-
}
|
|
2894
|
-
return null;
|
|
2895
|
-
}
|
|
2896
|
-
return createChainableTypeChecker(validate);
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
function createAnyTypeChecker() {
|
|
2900
|
-
return createChainableTypeChecker(emptyFunction.thatReturnsNull);
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
function createArrayOfTypeChecker(typeChecker) {
|
|
2904
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2905
|
-
if (typeof typeChecker !== 'function') {
|
|
2906
|
-
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
2907
|
-
}
|
|
2908
|
-
var propValue = props[propName];
|
|
2909
|
-
if (!Array.isArray(propValue)) {
|
|
2910
|
-
var propType = getPropType(propValue);
|
|
2911
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
2912
|
-
}
|
|
2913
|
-
for (var i = 0; i < propValue.length; i++) {
|
|
2914
|
-
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
|
|
2915
|
-
if (error instanceof Error) {
|
|
2916
|
-
return error;
|
|
2917
|
-
}
|
|
2918
|
-
}
|
|
2919
|
-
return null;
|
|
2920
|
-
}
|
|
2921
|
-
return createChainableTypeChecker(validate);
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
function createElementTypeChecker() {
|
|
2925
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2926
|
-
var propValue = props[propName];
|
|
2927
|
-
if (!ReactElement_1.isValidElement(propValue)) {
|
|
2928
|
-
var propType = getPropType(propValue);
|
|
2929
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
2930
|
-
}
|
|
2931
|
-
return null;
|
|
2932
|
-
}
|
|
2933
|
-
return createChainableTypeChecker(validate);
|
|
2934
|
-
}
|
|
2935
|
-
|
|
2936
|
-
function createInstanceTypeChecker(expectedClass) {
|
|
2937
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2938
|
-
if (!(props[propName] instanceof expectedClass)) {
|
|
2939
|
-
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
2940
|
-
var actualClassName = getClassName(props[propName]);
|
|
2941
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
2942
|
-
}
|
|
2943
|
-
return null;
|
|
2944
|
-
}
|
|
2945
|
-
return createChainableTypeChecker(validate);
|
|
2946
|
-
}
|
|
2947
|
-
|
|
2948
|
-
function createEnumTypeChecker(expectedValues) {
|
|
2949
|
-
if (!Array.isArray(expectedValues)) {
|
|
2950
|
-
warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
|
|
2951
|
-
return emptyFunction.thatReturnsNull;
|
|
2952
|
-
}
|
|
2953
|
-
|
|
2954
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2955
|
-
var propValue = props[propName];
|
|
2956
|
-
for (var i = 0; i < expectedValues.length; i++) {
|
|
2957
|
-
if (is(propValue, expectedValues[i])) {
|
|
2958
|
-
return null;
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
|
|
2962
|
-
var valuesString = JSON.stringify(expectedValues);
|
|
2963
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
2964
|
-
}
|
|
2965
|
-
return createChainableTypeChecker(validate);
|
|
2966
|
-
}
|
|
2967
|
-
|
|
2968
|
-
function createObjectOfTypeChecker(typeChecker) {
|
|
2969
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2970
|
-
if (typeof typeChecker !== 'function') {
|
|
2971
|
-
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
2972
|
-
}
|
|
2973
|
-
var propValue = props[propName];
|
|
2974
|
-
var propType = getPropType(propValue);
|
|
2975
|
-
if (propType !== 'object') {
|
|
2976
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
2977
|
-
}
|
|
2978
|
-
for (var key in propValue) {
|
|
2979
|
-
if (propValue.hasOwnProperty(key)) {
|
|
2980
|
-
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
2981
|
-
if (error instanceof Error) {
|
|
2982
|
-
return error;
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
return null;
|
|
2987
|
-
}
|
|
2988
|
-
return createChainableTypeChecker(validate);
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2991
|
-
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
2992
|
-
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
2993
|
-
warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
|
|
2994
|
-
return emptyFunction.thatReturnsNull;
|
|
2995
|
-
}
|
|
2996
|
-
|
|
2997
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
2998
|
-
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
2999
|
-
var checker = arrayOfTypeCheckers[i];
|
|
3000
|
-
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
|
|
3001
|
-
return null;
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
|
|
3005
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
|
3006
|
-
}
|
|
3007
|
-
return createChainableTypeChecker(validate);
|
|
3008
|
-
}
|
|
3009
|
-
|
|
3010
|
-
function createNodeChecker() {
|
|
3011
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
3012
|
-
if (!isNode(props[propName])) {
|
|
3013
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
3014
|
-
}
|
|
3015
|
-
return null;
|
|
3016
|
-
}
|
|
3017
|
-
return createChainableTypeChecker(validate);
|
|
3018
|
-
}
|
|
3019
|
-
|
|
3020
|
-
function createShapeTypeChecker(shapeTypes) {
|
|
3021
|
-
function validate(props, propName, componentName, location, propFullName) {
|
|
3022
|
-
var propValue = props[propName];
|
|
3023
|
-
var propType = getPropType(propValue);
|
|
3024
|
-
if (propType !== 'object') {
|
|
3025
|
-
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
3026
|
-
}
|
|
3027
|
-
for (var key in shapeTypes) {
|
|
3028
|
-
var checker = shapeTypes[key];
|
|
3029
|
-
if (!checker) {
|
|
3030
|
-
continue;
|
|
3031
|
-
}
|
|
3032
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
|
|
3033
|
-
if (error) {
|
|
3034
|
-
return error;
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
return null;
|
|
3038
|
-
}
|
|
3039
|
-
return createChainableTypeChecker(validate);
|
|
3040
|
-
}
|
|
3041
|
-
|
|
3042
|
-
function isNode(propValue) {
|
|
3043
|
-
switch (typeof propValue) {
|
|
3044
|
-
case 'number':
|
|
3045
|
-
case 'string':
|
|
3046
|
-
case 'undefined':
|
|
3047
|
-
return true;
|
|
3048
|
-
case 'boolean':
|
|
3049
|
-
return !propValue;
|
|
3050
|
-
case 'object':
|
|
3051
|
-
if (Array.isArray(propValue)) {
|
|
3052
|
-
return propValue.every(isNode);
|
|
3053
|
-
}
|
|
3054
|
-
if (propValue === null || ReactElement_1.isValidElement(propValue)) {
|
|
3055
|
-
return true;
|
|
3056
|
-
}
|
|
3057
|
-
|
|
3058
|
-
var iteratorFn = getIteratorFn_1(propValue);
|
|
3059
|
-
if (iteratorFn) {
|
|
3060
|
-
var iterator = iteratorFn.call(propValue);
|
|
3061
|
-
var step;
|
|
3062
|
-
if (iteratorFn !== propValue.entries) {
|
|
3063
|
-
while (!(step = iterator.next()).done) {
|
|
3064
|
-
if (!isNode(step.value)) {
|
|
3065
|
-
return false;
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
} else {
|
|
3069
|
-
// Iterator will provide entry [k,v] tuples rather than values.
|
|
3070
|
-
while (!(step = iterator.next()).done) {
|
|
3071
|
-
var entry = step.value;
|
|
3072
|
-
if (entry) {
|
|
3073
|
-
if (!isNode(entry[1])) {
|
|
3074
|
-
return false;
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
} else {
|
|
3080
|
-
return false;
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3083
|
-
return true;
|
|
3084
|
-
default:
|
|
3085
|
-
return false;
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
|
|
3089
|
-
function isSymbol(propType, propValue) {
|
|
3090
|
-
// Native Symbol.
|
|
3091
|
-
if (propType === 'symbol') {
|
|
3092
|
-
return true;
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
|
-
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
3096
|
-
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
3097
|
-
return true;
|
|
3098
|
-
}
|
|
3099
|
-
|
|
3100
|
-
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
3101
|
-
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
3102
|
-
return true;
|
|
3103
|
-
}
|
|
3104
|
-
|
|
3105
|
-
return false;
|
|
3106
|
-
}
|
|
3107
|
-
|
|
3108
|
-
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
3109
|
-
function getPropType(propValue) {
|
|
3110
|
-
var propType = typeof propValue;
|
|
3111
|
-
if (Array.isArray(propValue)) {
|
|
3112
|
-
return 'array';
|
|
3113
|
-
}
|
|
3114
|
-
if (propValue instanceof RegExp) {
|
|
3115
|
-
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
3116
|
-
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
3117
|
-
// passes PropTypes.object.
|
|
3118
|
-
return 'object';
|
|
3119
|
-
}
|
|
3120
|
-
if (isSymbol(propType, propValue)) {
|
|
3121
|
-
return 'symbol';
|
|
3122
|
-
}
|
|
3123
|
-
return propType;
|
|
3124
|
-
}
|
|
3125
|
-
|
|
3126
|
-
// This handles more types than `getPropType`. Only used for error messages.
|
|
3127
|
-
// See `createPrimitiveTypeChecker`.
|
|
3128
|
-
function getPreciseType(propValue) {
|
|
3129
|
-
var propType = getPropType(propValue);
|
|
3130
|
-
if (propType === 'object') {
|
|
3131
|
-
if (propValue instanceof Date) {
|
|
3132
|
-
return 'date';
|
|
3133
|
-
} else if (propValue instanceof RegExp) {
|
|
3134
|
-
return 'regexp';
|
|
3135
|
-
}
|
|
3136
|
-
}
|
|
3137
|
-
return propType;
|
|
3138
|
-
}
|
|
3139
|
-
|
|
3140
|
-
// Returns class name of the object, if any.
|
|
3141
|
-
function getClassName(propValue) {
|
|
3142
|
-
if (!propValue.constructor || !propValue.constructor.name) {
|
|
3143
|
-
return ANONYMOUS;
|
|
3144
|
-
}
|
|
3145
|
-
return propValue.constructor.name;
|
|
3146
|
-
}
|
|
3147
|
-
|
|
3148
|
-
var ReactPropTypes_1 = ReactPropTypes;
|
|
1994
|
+
var ReactPropTypes = propTypes;
|
|
3149
1995
|
|
|
3150
1996
|
/**
|
|
3151
1997
|
* Copyright 2013-present, Facebook, Inc.
|
|
@@ -3158,7 +2004,7 @@ var ReactPropTypes_1 = ReactPropTypes;
|
|
|
3158
2004
|
* @providesModule ReactVersion
|
|
3159
2005
|
*/
|
|
3160
2006
|
|
|
3161
|
-
var ReactVersion = '16.0.0-alpha.
|
|
2007
|
+
var ReactVersion = '16.0.0-alpha.12';
|
|
3162
2008
|
|
|
3163
2009
|
/**
|
|
3164
2010
|
* Returns the first child in a collection of children and verifies that there
|
|
@@ -3181,11 +2027,22 @@ function onlyChild(children) {
|
|
|
3181
2027
|
|
|
3182
2028
|
var onlyChild_1 = onlyChild;
|
|
3183
2029
|
|
|
2030
|
+
var Component = ReactBaseClasses.Component;
|
|
2031
|
+
|
|
2032
|
+
var isValidElement = ReactElement_1.isValidElement;
|
|
2033
|
+
|
|
2034
|
+
|
|
2035
|
+
|
|
2036
|
+
|
|
2037
|
+
var createClass = factory(Component, isValidElement, ReactNoopUpdateQueue_1);
|
|
2038
|
+
|
|
3184
2039
|
var createElement = ReactElement_1.createElement;
|
|
3185
2040
|
var createFactory = ReactElement_1.createFactory;
|
|
3186
2041
|
var cloneElement = ReactElement_1.cloneElement;
|
|
3187
2042
|
|
|
3188
2043
|
{
|
|
2044
|
+
var warning$1 = warning;
|
|
2045
|
+
var canDefineProperty = canDefineProperty_1;
|
|
3189
2046
|
var ReactElementValidator = ReactElementValidator_1;
|
|
3190
2047
|
createElement = ReactElementValidator.createElement;
|
|
3191
2048
|
createFactory = ReactElementValidator.createFactory;
|
|
@@ -3196,16 +2053,6 @@ var createMixin = function (mixin) {
|
|
|
3196
2053
|
return mixin;
|
|
3197
2054
|
};
|
|
3198
2055
|
|
|
3199
|
-
{
|
|
3200
|
-
var warnedForCreateMixin = false;
|
|
3201
|
-
|
|
3202
|
-
createMixin = function (mixin) {
|
|
3203
|
-
warning(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. You ' + 'can use this mixin directly instead.');
|
|
3204
|
-
warnedForCreateMixin = true;
|
|
3205
|
-
return mixin;
|
|
3206
|
-
};
|
|
3207
|
-
}
|
|
3208
|
-
|
|
3209
2056
|
var React = {
|
|
3210
2057
|
// Modern
|
|
3211
2058
|
|
|
@@ -3224,12 +2071,13 @@ var React = {
|
|
|
3224
2071
|
cloneElement: cloneElement,
|
|
3225
2072
|
isValidElement: ReactElement_1.isValidElement,
|
|
3226
2073
|
|
|
3227
|
-
|
|
2074
|
+
// TODO (bvaughn) Remove these getters before 16.0.0
|
|
2075
|
+
PropTypes: ReactPropTypes,
|
|
2076
|
+
checkPropTypes: checkPropTypes,
|
|
2077
|
+
createClass: createClass,
|
|
3228
2078
|
|
|
3229
2079
|
// Classic
|
|
3230
2080
|
|
|
3231
|
-
PropTypes: ReactPropTypes_1,
|
|
3232
|
-
createClass: ReactClass_1.createClass,
|
|
3233
2081
|
createFactory: createFactory,
|
|
3234
2082
|
createMixin: createMixin,
|
|
3235
2083
|
|
|
@@ -3237,26 +2085,74 @@ var React = {
|
|
|
3237
2085
|
// since they are just generating DOM strings.
|
|
3238
2086
|
DOM: ReactDOMFactories_1,
|
|
3239
2087
|
|
|
3240
|
-
version: ReactVersion
|
|
3241
|
-
};
|
|
3242
|
-
|
|
3243
|
-
var React_1 = React;
|
|
2088
|
+
version: ReactVersion,
|
|
3244
2089
|
|
|
3245
|
-
// `version` will be added here by the React module.
|
|
3246
|
-
var ReactUMDEntry = _assign({
|
|
3247
2090
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
|
|
3248
2091
|
ReactCurrentOwner: ReactCurrentOwner_1
|
|
3249
2092
|
}
|
|
3250
|
-
}
|
|
2093
|
+
};
|
|
3251
2094
|
|
|
3252
2095
|
{
|
|
3253
|
-
|
|
2096
|
+
objectAssign$1(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
3254
2097
|
// These should not be included in production.
|
|
3255
2098
|
ReactComponentTreeHook: ReactComponentTreeHook_1,
|
|
3256
2099
|
ReactDebugCurrentFrame: ReactDebugCurrentFrame_1
|
|
3257
2100
|
});
|
|
2101
|
+
|
|
2102
|
+
var warnedForCheckPropTypes = false;
|
|
2103
|
+
var warnedForCreateMixin = false;
|
|
2104
|
+
var warnedForCreateClass = false;
|
|
2105
|
+
var warnedForPropTypes = false;
|
|
2106
|
+
|
|
2107
|
+
React.createMixin = function (mixin) {
|
|
2108
|
+
warning$1(warnedForCreateMixin, 'React.createMixin is deprecated and should not be used. You ' + 'can use this mixin directly instead.');
|
|
2109
|
+
warnedForCreateMixin = true;
|
|
2110
|
+
return mixin;
|
|
2111
|
+
};
|
|
2112
|
+
|
|
2113
|
+
// TODO (bvaughn) Remove all of these accessors before 16.0.0
|
|
2114
|
+
if (canDefineProperty) {
|
|
2115
|
+
Object.defineProperty(React, 'checkPropTypes', {
|
|
2116
|
+
get: function () {
|
|
2117
|
+
warning$1(warnedForCheckPropTypes, 'checkPropTypes has been moved to a separate package. ' + 'Accessing React.checkPropTypes is no longer supported ' + 'and will be removed completely in React 16. ' + 'Use the prop-types package on npm instead. ' + '(https://fb.me/migrating-from-react-proptypes)');
|
|
2118
|
+
warnedForCheckPropTypes = true;
|
|
2119
|
+
return checkPropTypes;
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
|
|
2123
|
+
Object.defineProperty(React, 'createClass', {
|
|
2124
|
+
get: function () {
|
|
2125
|
+
warning$1(warnedForCreateClass, 'React.createClass is no longer supported. Use a plain JavaScript ' + "class instead. If you're not yet ready to migrate, " + 'create-react-class is available on npm as a drop-in replacement. ' + '(https://fb.me/migrating-from-react-create-class)');
|
|
2126
|
+
warnedForCreateClass = true;
|
|
2127
|
+
return createClass;
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
|
|
2131
|
+
Object.defineProperty(React, 'PropTypes', {
|
|
2132
|
+
get: function () {
|
|
2133
|
+
warning$1(warnedForPropTypes, 'PropTypes has been moved to a separate package. ' + 'Accessing React.PropTypes is no longer supported ' + 'and will be removed completely in React 16. ' + 'Use the prop-types package on npm instead. ' + '(https://fb.me/migrating-from-react-proptypes)');
|
|
2134
|
+
warnedForPropTypes = true;
|
|
2135
|
+
return ReactPropTypes;
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
// React.DOM factories are deprecated. Wrap these methods so that
|
|
2141
|
+
// invocations of the React.DOM namespace and alert users to switch
|
|
2142
|
+
// to the `react-addons-dom-factories` package.
|
|
2143
|
+
React.DOM = {};
|
|
2144
|
+
var warnedForFactories = false;
|
|
2145
|
+
Object.keys(ReactDOMFactories_1).forEach(function (factory$$1) {
|
|
2146
|
+
React.DOM[factory$$1] = function () {
|
|
2147
|
+
if (!warnedForFactories) {
|
|
2148
|
+
warning$1(false, 'Accessing factories like React.DOM.%s has been deprecated ' + 'and will be removed in the future. Use the ' + 'react-addons-dom-factories package instead.', factory$$1);
|
|
2149
|
+
warnedForFactories = true;
|
|
2150
|
+
}
|
|
2151
|
+
return ReactDOMFactories_1[factory$$1].apply(ReactDOMFactories_1, arguments);
|
|
2152
|
+
};
|
|
2153
|
+
});
|
|
3258
2154
|
}
|
|
3259
2155
|
|
|
3260
|
-
var
|
|
2156
|
+
var React_1 = React;
|
|
3261
2157
|
|
|
3262
|
-
module.exports =
|
|
2158
|
+
module.exports = React_1;
|