react 0.14.0-beta3 → 0.14.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addons.js +2 -0
- package/dist/react-dom.js +42 -0
- package/dist/react-dom.min.js +12 -0
- package/dist/react-with-addons.js +1587 -1228
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +1407 -1154
- package/dist/react.min.js +6 -6
- package/lib/CSSProperty.js +15 -3
- package/lib/CSSPropertyOperations.js +9 -1
- package/lib/ChangeEventPlugin.js +2 -1
- package/lib/DOMChildrenOperations.js +7 -1
- package/lib/DOMPropertyOperations.js +7 -1
- package/lib/Danger.js +9 -4
- package/lib/EnterLeaveEventPlugin.js +13 -5
- package/lib/EventConstants.js +1 -1
- package/lib/EventPluginHub.js +4 -7
- package/lib/EventPluginUtils.js +18 -27
- package/lib/EventPropagators.js +1 -1
- package/lib/FallbackCompositionState.js +6 -0
- package/lib/HTMLDOMPropertyConfig.js +7 -0
- package/lib/PooledClass.js +1 -3
- package/lib/React.js +14 -3
- package/lib/ReactBrowserComponentMixin.js +1 -1
- package/lib/ReactBrowserEventEmitter.js +3 -3
- package/lib/ReactCSSTransitionGroup.js +33 -18
- package/lib/ReactCSSTransitionGroupChild.js +42 -25
- package/lib/ReactChildReconciler.js +3 -5
- package/lib/ReactChildren.js +70 -30
- package/lib/ReactClass.js +7 -6
- package/lib/ReactComponent.js +5 -3
- package/lib/ReactCompositeComponent.js +44 -6
- package/lib/ReactDOM.js +7 -5
- package/lib/ReactDOMComponent.js +73 -26
- package/lib/ReactDOMFeatureFlags.js +18 -0
- package/lib/ReactDOMIDOperations.js +1 -59
- package/lib/ReactDOMInput.js +4 -0
- package/lib/ReactDOMSelect.js +1 -1
- package/lib/ReactDOMServer.js +3 -1
- package/lib/ReactDOMTextComponent.js +23 -10
- package/lib/ReactDefaultInjection.js +0 -2
- package/lib/ReactDefaultPerfAnalysis.js +0 -2
- package/lib/ReactElement.js +81 -35
- package/lib/ReactElementValidator.js +17 -68
- package/lib/ReactEmptyComponent.js +25 -61
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +44 -8
- package/lib/ReactEventListener.js +16 -9
- package/lib/ReactFragment.js +25 -116
- package/lib/ReactInjection.js +0 -2
- package/lib/ReactIsomorphic.js +4 -0
- package/lib/ReactMount.js +114 -40
- package/lib/ReactMultiChild.js +37 -4
- package/lib/ReactOwner.js +2 -2
- package/lib/ReactPropTypes.js +11 -8
- package/lib/ReactReconcileTransaction.js +4 -2
- package/lib/ReactReconciler.js +16 -17
- package/lib/ReactRef.js +14 -1
- package/lib/ReactServerRenderingTransaction.js +1 -0
- package/lib/ReactTestUtils.js +11 -8
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactUpdateQueue.js +4 -4
- package/lib/ReactUpdates.js +1 -1
- package/lib/ReactVersion.js +14 -0
- package/lib/ReactWithAddons.js +10 -1
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/SelectEventPlugin.js +11 -1
- package/lib/SimpleEventPlugin.js +2 -23
- package/lib/SyntheticEvent.js +15 -0
- package/lib/Transaction.js +1 -1
- package/lib/deprecated.js +3 -2
- package/lib/findDOMNode.js +1 -1
- package/lib/instantiateReactComponent.js +3 -5
- package/lib/reactComponentExpect.js +6 -0
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +3 -20
- package/lib/traverseAllChildren.js +10 -9
- package/package.json +2 -2
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17949
package/lib/ReactDOMInput.js
CHANGED
|
@@ -127,6 +127,10 @@ function _handleChange(event) {
|
|
|
127
127
|
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
|
+
// This will throw if radio buttons rendered by different copies of React
|
|
131
|
+
// and the same name are rendered into the same form (same as #1939).
|
|
132
|
+
// That's probably okay; we don't support it just as we don't support
|
|
133
|
+
// mixing React with non-React.
|
|
130
134
|
var otherID = ReactMount.getID(otherNode);
|
|
131
135
|
!otherID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(false) : undefined;
|
|
132
136
|
var otherInstance = instancesByReactID[otherID];
|
package/lib/ReactDOMSelect.js
CHANGED
|
@@ -21,7 +21,7 @@ var warning = require('fbjs/lib/warning');
|
|
|
21
21
|
var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2);
|
|
22
22
|
|
|
23
23
|
function updateOptionsIfPendingUpdateAndMounted() {
|
|
24
|
-
if (this.
|
|
24
|
+
if (this._rootNodeID && this._wrapperState.pendingUpdate) {
|
|
25
25
|
this._wrapperState.pendingUpdate = false;
|
|
26
26
|
|
|
27
27
|
var props = this._currentElement.props;
|
package/lib/ReactDOMServer.js
CHANGED
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
var ReactDefaultInjection = require('./ReactDefaultInjection');
|
|
15
15
|
var ReactServerRendering = require('./ReactServerRendering');
|
|
16
|
+
var ReactVersion = require('./ReactVersion');
|
|
16
17
|
|
|
17
18
|
ReactDefaultInjection.inject();
|
|
18
19
|
|
|
19
20
|
var ReactDOMServer = {
|
|
20
21
|
renderToString: ReactServerRendering.renderToString,
|
|
21
|
-
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup
|
|
22
|
+
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
|
|
23
|
+
version: ReactVersion
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
module.exports = ReactDOMServer;
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
+
var DOMChildrenOperations = require('./DOMChildrenOperations');
|
|
15
16
|
var DOMPropertyOperations = require('./DOMPropertyOperations');
|
|
16
17
|
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
17
|
-
var
|
|
18
|
+
var ReactMount = require('./ReactMount');
|
|
18
19
|
|
|
19
20
|
var assign = require('./Object.assign');
|
|
20
21
|
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
22
|
+
var setTextContent = require('./setTextContent');
|
|
21
23
|
var validateDOMNesting = require('./validateDOMNesting');
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -72,16 +74,26 @@ assign(ReactDOMTextComponent.prototype, {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
this._rootNodeID = rootID;
|
|
75
|
-
|
|
77
|
+
if (transaction.useCreateElement) {
|
|
78
|
+
var ownerDocument = context[ReactMount.ownerDocumentContextKey];
|
|
79
|
+
var el = ownerDocument.createElement('span');
|
|
80
|
+
DOMPropertyOperations.setAttributeForID(el, rootID);
|
|
81
|
+
// Populate node cache
|
|
82
|
+
ReactMount.getID(el);
|
|
83
|
+
setTextContent(el, this._stringText);
|
|
84
|
+
return el;
|
|
85
|
+
} else {
|
|
86
|
+
var escapedText = escapeTextContentForBrowser(this._stringText);
|
|
76
87
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
if (transaction.renderToStaticMarkup) {
|
|
89
|
+
// Normally we'd wrap this in a `span` for the reasons stated above, but
|
|
90
|
+
// since this is a situation where React won't take over (static pages),
|
|
91
|
+
// we can simply return the text as it is.
|
|
92
|
+
return escapedText;
|
|
93
|
+
}
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>';
|
|
96
|
+
}
|
|
85
97
|
},
|
|
86
98
|
|
|
87
99
|
/**
|
|
@@ -100,7 +112,8 @@ assign(ReactDOMTextComponent.prototype, {
|
|
|
100
112
|
// and/or updateComponent to do the actual update for consistency with
|
|
101
113
|
// other component types?
|
|
102
114
|
this._stringText = nextStringText;
|
|
103
|
-
|
|
115
|
+
var node = ReactMount.getNode(this._rootNodeID);
|
|
116
|
+
DOMChildrenOperations.updateTextContent(node, nextStringText);
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
},
|
|
@@ -22,7 +22,6 @@ var ReactBrowserComponentMixin = require('./ReactBrowserComponentMixin');
|
|
|
22
22
|
var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
|
|
23
23
|
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
24
24
|
var ReactDOMComponent = require('./ReactDOMComponent');
|
|
25
|
-
var ReactDOMIDOperations = require('./ReactDOMIDOperations');
|
|
26
25
|
var ReactDOMTextComponent = require('./ReactDOMTextComponent');
|
|
27
26
|
var ReactEventListener = require('./ReactEventListener');
|
|
28
27
|
var ReactInjection = require('./ReactInjection');
|
|
@@ -83,7 +82,6 @@ function inject() {
|
|
|
83
82
|
ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
|
|
84
83
|
|
|
85
84
|
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
|
86
|
-
ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
|
|
87
85
|
|
|
88
86
|
if (process.env.NODE_ENV !== 'production') {
|
|
89
87
|
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
@@ -23,8 +23,6 @@ var DOM_OPERATION_TYPES = {
|
|
|
23
23
|
SET_MARKUP: 'set innerHTML',
|
|
24
24
|
TEXT_CONTENT: 'set textContent',
|
|
25
25
|
'updatePropertyByID': 'update attribute',
|
|
26
|
-
'deletePropertyByID': 'delete attribute',
|
|
27
|
-
'updateStylesByID': 'update styles',
|
|
28
26
|
'dangerouslyReplaceNodeWithMarkupByID': 'replace'
|
|
29
27
|
};
|
|
30
28
|
|
package/lib/ReactElement.js
CHANGED
|
@@ -15,11 +15,27 @@ var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
|
15
15
|
|
|
16
16
|
var assign = require('./Object.assign');
|
|
17
17
|
|
|
18
|
+
// The Symbol used to tag the ReactElement type. If there is no native Symbol
|
|
19
|
+
// nor polyfill, then a plain number is used for performance.
|
|
20
|
+
var TYPE_SYMBOL = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
|
|
21
|
+
|
|
18
22
|
var RESERVED_PROPS = {
|
|
19
23
|
key: true,
|
|
20
|
-
ref: true
|
|
24
|
+
ref: true,
|
|
25
|
+
__self: true,
|
|
26
|
+
__source: true
|
|
21
27
|
};
|
|
22
28
|
|
|
29
|
+
var canDefineProperty = false;
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
try {
|
|
32
|
+
Object.defineProperty({}, 'x', {});
|
|
33
|
+
canDefineProperty = true;
|
|
34
|
+
} catch (x) {
|
|
35
|
+
// IE will fail on defineProperty
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
/**
|
|
24
40
|
* Base constructor for all React elements. This is only used to make this
|
|
25
41
|
* work with a dynamic instanceof check. Nothing should live on this prototype.
|
|
@@ -27,51 +43,75 @@ var RESERVED_PROPS = {
|
|
|
27
43
|
* @param {*} type
|
|
28
44
|
* @param {*} key
|
|
29
45
|
* @param {string|object} ref
|
|
46
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
47
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
48
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
49
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
50
|
+
* change in behavior.
|
|
51
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
52
|
+
* indicating filename, line number, and/or other information.
|
|
30
53
|
* @param {*} owner
|
|
31
54
|
* @param {*} props
|
|
32
55
|
* @internal
|
|
33
56
|
*/
|
|
34
|
-
var ReactElement = function (type, key, ref, owner, props) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.ref = ref;
|
|
57
|
+
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
58
|
+
var element = {
|
|
59
|
+
// This tag allow us to uniquely identify this as a React Element
|
|
60
|
+
$$typeof: TYPE_SYMBOL,
|
|
39
61
|
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
// Built-in properties that belong on the element
|
|
63
|
+
type: type,
|
|
64
|
+
key: key,
|
|
65
|
+
ref: ref,
|
|
66
|
+
props: props,
|
|
42
67
|
|
|
43
|
-
|
|
68
|
+
// Record the component responsible for creating this element.
|
|
69
|
+
_owner: owner
|
|
70
|
+
};
|
|
44
71
|
|
|
45
72
|
if (process.env.NODE_ENV !== 'production') {
|
|
46
73
|
// The validation flag is currently mutative. We put it on
|
|
47
74
|
// an external backing store so that we can freeze the whole object.
|
|
48
75
|
// This can be replaced with a WeakMap once they are implemented in
|
|
49
76
|
// commonly used development environments.
|
|
50
|
-
|
|
77
|
+
element._store = {};
|
|
51
78
|
|
|
52
79
|
// To make comparing ReactElements easier for testing purposes, we make
|
|
53
80
|
// the validation flag non-enumerable (where possible, which should
|
|
54
81
|
// include every environment we run tests in), so the test framework
|
|
55
82
|
// ignores it.
|
|
56
|
-
|
|
57
|
-
Object.defineProperty(
|
|
83
|
+
if (canDefineProperty) {
|
|
84
|
+
Object.defineProperty(element._store, 'validated', {
|
|
58
85
|
configurable: false,
|
|
59
86
|
enumerable: false,
|
|
60
87
|
writable: true,
|
|
61
88
|
value: false
|
|
62
89
|
});
|
|
63
|
-
|
|
64
|
-
|
|
90
|
+
// self and source are DEV only properties.
|
|
91
|
+
Object.defineProperty(element, '_self', {
|
|
92
|
+
configurable: false,
|
|
93
|
+
enumerable: false,
|
|
94
|
+
writable: false,
|
|
95
|
+
value: self
|
|
96
|
+
});
|
|
97
|
+
// Two elements created in two different places should be considered
|
|
98
|
+
// equal for testing purposes and therefore we hide it from enumeration.
|
|
99
|
+
Object.defineProperty(element, '_source', {
|
|
100
|
+
configurable: false,
|
|
101
|
+
enumerable: false,
|
|
102
|
+
writable: false,
|
|
103
|
+
value: source
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
element._store.validated = false;
|
|
107
|
+
element._self = self;
|
|
108
|
+
element._source = source;
|
|
65
109
|
}
|
|
66
|
-
Object.freeze(
|
|
67
|
-
Object.freeze(
|
|
110
|
+
Object.freeze(element.props);
|
|
111
|
+
Object.freeze(element);
|
|
68
112
|
}
|
|
69
|
-
};
|
|
70
113
|
|
|
71
|
-
|
|
72
|
-
// ReactElement should be indistinguishable from a plain object.
|
|
73
|
-
ReactElement.prototype = {
|
|
74
|
-
_isReactElement: true
|
|
114
|
+
return element;
|
|
75
115
|
};
|
|
76
116
|
|
|
77
117
|
ReactElement.createElement = function (type, config, children) {
|
|
@@ -82,10 +122,14 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
82
122
|
|
|
83
123
|
var key = null;
|
|
84
124
|
var ref = null;
|
|
125
|
+
var self = null;
|
|
126
|
+
var source = null;
|
|
85
127
|
|
|
86
128
|
if (config != null) {
|
|
87
129
|
ref = config.ref === undefined ? null : config.ref;
|
|
88
130
|
key = config.key === undefined ? null : '' + config.key;
|
|
131
|
+
self = config.__self === undefined ? null : config.__self;
|
|
132
|
+
source = config.__source === undefined ? null : config.__source;
|
|
89
133
|
// Remaining properties are added to a new props object
|
|
90
134
|
for (propName in config) {
|
|
91
135
|
if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
@@ -117,7 +161,7 @@ ReactElement.createElement = function (type, config, children) {
|
|
|
117
161
|
}
|
|
118
162
|
}
|
|
119
163
|
|
|
120
|
-
return
|
|
164
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
121
165
|
};
|
|
122
166
|
|
|
123
167
|
ReactElement.createFactory = function (type) {
|
|
@@ -131,8 +175,14 @@ ReactElement.createFactory = function (type) {
|
|
|
131
175
|
return factory;
|
|
132
176
|
};
|
|
133
177
|
|
|
178
|
+
ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
|
|
179
|
+
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
180
|
+
|
|
181
|
+
return newElement;
|
|
182
|
+
};
|
|
183
|
+
|
|
134
184
|
ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
|
|
135
|
-
var newElement =
|
|
185
|
+
var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
|
|
136
186
|
|
|
137
187
|
if (process.env.NODE_ENV !== 'production') {
|
|
138
188
|
// If the key on the original is valid, then the clone is valid
|
|
@@ -151,6 +201,12 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
151
201
|
// Reserved names are extracted
|
|
152
202
|
var key = element.key;
|
|
153
203
|
var ref = element.ref;
|
|
204
|
+
// Self is preserved since the owner is preserved.
|
|
205
|
+
var self = element._self;
|
|
206
|
+
// Source is preserved since cloneElement is unlikely to be targeted by a
|
|
207
|
+
// transpiler, and the original source is probably a better indicator of the
|
|
208
|
+
// true owner.
|
|
209
|
+
var source = element._source;
|
|
154
210
|
|
|
155
211
|
// Owner will be preserved, unless ref is overridden
|
|
156
212
|
var owner = element._owner;
|
|
@@ -185,7 +241,7 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
185
241
|
props.children = childArray;
|
|
186
242
|
}
|
|
187
243
|
|
|
188
|
-
return
|
|
244
|
+
return ReactElement(element.type, key, ref, self, source, owner, props);
|
|
189
245
|
};
|
|
190
246
|
|
|
191
247
|
/**
|
|
@@ -194,17 +250,7 @@ ReactElement.cloneElement = function (element, config, children) {
|
|
|
194
250
|
* @final
|
|
195
251
|
*/
|
|
196
252
|
ReactElement.isValidElement = function (object) {
|
|
197
|
-
|
|
198
|
-
// within it. This leads to two different instances of React on the same
|
|
199
|
-
// page. To identify a element from a different React instance we use
|
|
200
|
-
// a flag instead of an instanceof check.
|
|
201
|
-
var isElement = !!(object && object._isReactElement);
|
|
202
|
-
// if (isElement && !(object instanceof ReactElement)) {
|
|
203
|
-
// This is an indicator that you're using multiple versions of React at the
|
|
204
|
-
// same time. This will screw with ownership and stuff. Fix it, please.
|
|
205
|
-
// TODO: We could possibly warn here.
|
|
206
|
-
// }
|
|
207
|
-
return isElement;
|
|
253
|
+
return typeof object === 'object' && object !== null && object.$$typeof === TYPE_SYMBOL;
|
|
208
254
|
};
|
|
209
255
|
|
|
210
256
|
module.exports = ReactElement;
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
'use strict';
|
|
20
20
|
|
|
21
21
|
var ReactElement = require('./ReactElement');
|
|
22
|
-
var ReactFragment = require('./ReactFragment');
|
|
23
22
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
24
23
|
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
25
24
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
@@ -47,37 +46,6 @@ var ownerHasKeyUseWarning = {};
|
|
|
47
46
|
|
|
48
47
|
var loggedTypeFailures = {};
|
|
49
48
|
|
|
50
|
-
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Gets the instance's name for use in warnings.
|
|
54
|
-
*
|
|
55
|
-
* @internal
|
|
56
|
-
* @return {?string} Display name or undefined
|
|
57
|
-
*/
|
|
58
|
-
function getName(instance) {
|
|
59
|
-
var publicInstance = instance && instance.getPublicInstance();
|
|
60
|
-
if (!publicInstance) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
var constructor = publicInstance.constructor;
|
|
64
|
-
if (!constructor) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
return constructor.displayName || constructor.name || undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Gets the current owner's displayName for use in warnings.
|
|
72
|
-
*
|
|
73
|
-
* @internal
|
|
74
|
-
* @return {?string} Display name or undefined
|
|
75
|
-
*/
|
|
76
|
-
function getCurrentOwnerDisplayName() {
|
|
77
|
-
var current = ReactCurrentOwner.current;
|
|
78
|
-
return current && getName(current) || undefined;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
49
|
/**
|
|
82
50
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
83
51
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -102,27 +70,6 @@ function validateExplicitKey(element, parentType) {
|
|
|
102
70
|
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
103
71
|
}
|
|
104
72
|
|
|
105
|
-
/**
|
|
106
|
-
* Warn if the key is being defined as an object property but has an incorrect
|
|
107
|
-
* value.
|
|
108
|
-
*
|
|
109
|
-
* @internal
|
|
110
|
-
* @param {string} name Property name of the key.
|
|
111
|
-
* @param {ReactElement} element Component that requires a key.
|
|
112
|
-
* @param {*} parentType element's parent's type.
|
|
113
|
-
*/
|
|
114
|
-
function validatePropertyKey(name, element, parentType) {
|
|
115
|
-
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
|
|
119
|
-
if (addenda === null) {
|
|
120
|
-
// we already showed the warning
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
process.env.NODE_ENV !== 'production' ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
73
|
/**
|
|
127
74
|
* Shared warning and monitoring code for the key warnings.
|
|
128
75
|
*
|
|
@@ -134,18 +81,22 @@ function validatePropertyKey(name, element, parentType) {
|
|
|
134
81
|
* if the warning has already been shown before (and shouldn't be shown again).
|
|
135
82
|
*/
|
|
136
83
|
function getAddendaForKeyUse(messageType, element, parentType) {
|
|
137
|
-
var
|
|
138
|
-
|
|
84
|
+
var addendum = getDeclarationErrorAddendum();
|
|
85
|
+
if (!addendum) {
|
|
86
|
+
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
87
|
+
if (parentName) {
|
|
88
|
+
addendum = ' Check the top-level render call using <' + parentName + '>.';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
139
91
|
|
|
140
|
-
var useName = ownerName || parentName;
|
|
141
92
|
var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
|
|
142
|
-
if (memoizer[
|
|
93
|
+
if (memoizer[addendum]) {
|
|
143
94
|
return null;
|
|
144
95
|
}
|
|
145
|
-
memoizer[
|
|
96
|
+
memoizer[addendum] = true;
|
|
146
97
|
|
|
147
98
|
var addenda = {
|
|
148
|
-
parentOrOwner:
|
|
99
|
+
parentOrOwner: addendum,
|
|
149
100
|
url: ' See https://fb.me/react-warning-keys for more information.',
|
|
150
101
|
childOwner: null
|
|
151
102
|
};
|
|
@@ -155,7 +106,7 @@ function getAddendaForKeyUse(messageType, element, parentType) {
|
|
|
155
106
|
// assigning it a key.
|
|
156
107
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
157
108
|
// Give the component that originally created this child.
|
|
158
|
-
addenda.childOwner = ' It was passed a child from ' +
|
|
109
|
+
addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
|
|
159
110
|
}
|
|
160
111
|
|
|
161
112
|
return addenda;
|
|
@@ -171,6 +122,9 @@ function getAddendaForKeyUse(messageType, element, parentType) {
|
|
|
171
122
|
* @param {*} parentType node's parent's type.
|
|
172
123
|
*/
|
|
173
124
|
function validateChildKeys(node, parentType) {
|
|
125
|
+
if (typeof node !== 'object') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
174
128
|
if (Array.isArray(node)) {
|
|
175
129
|
for (var i = 0; i < node.length; i++) {
|
|
176
130
|
var child = node[i];
|
|
@@ -180,7 +134,9 @@ function validateChildKeys(node, parentType) {
|
|
|
180
134
|
}
|
|
181
135
|
} else if (ReactElement.isValidElement(node)) {
|
|
182
136
|
// This element was passed in a valid location.
|
|
183
|
-
node._store
|
|
137
|
+
if (node._store) {
|
|
138
|
+
node._store.validated = true;
|
|
139
|
+
}
|
|
184
140
|
} else if (node) {
|
|
185
141
|
var iteratorFn = getIteratorFn(node);
|
|
186
142
|
// Entry iterators provide implicit keys.
|
|
@@ -194,13 +150,6 @@ function validateChildKeys(node, parentType) {
|
|
|
194
150
|
}
|
|
195
151
|
}
|
|
196
152
|
}
|
|
197
|
-
} else if (typeof node === 'object') {
|
|
198
|
-
var fragment = ReactFragment.extractIfFragment(node);
|
|
199
|
-
for (var key in fragment) {
|
|
200
|
-
if (fragment.hasOwnProperty(key)) {
|
|
201
|
-
validatePropertyKey(key, fragment[key], parentType);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
153
|
}
|
|
205
154
|
}
|
|
206
155
|
}
|