react 0.12.2 → 0.13.0-alpha.1
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/dist/JSXTransformer.js +6 -4
- package/dist/react-with-addons.js +4022 -3267
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3853 -3358
- package/dist/react.min.js +6 -6
- package/lib/BeforeInputEventPlugin.js +388 -111
- package/lib/CSSPropertyOperations.js +20 -0
- package/lib/ChangeEventPlugin.js +2 -2
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +0 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +87 -0
- package/lib/HTMLDOMPropertyConfig.js +1 -0
- package/lib/Object.assign.js +3 -1
- package/lib/React.js +14 -49
- package/lib/ReactBrowserComponentMixin.js +2 -12
- package/lib/ReactBrowserEventEmitter.js +2 -4
- package/lib/ReactCSSTransitionGroup.js +3 -0
- package/lib/ReactCSSTransitionGroupChild.js +8 -0
- package/lib/ReactChildReconciler.js +121 -0
- package/lib/ReactClass.js +916 -0
- package/lib/ReactComponent.js +36 -286
- package/lib/ReactComponentBrowserEnvironment.js +9 -82
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactCompositeComponent.js +608 -1026
- package/lib/ReactContext.js +5 -1
- package/lib/ReactDOM.js +2 -7
- package/lib/ReactDOMButton.js +4 -5
- package/lib/ReactDOMComponent.js +97 -69
- package/lib/ReactDOMForm.js +4 -5
- package/lib/ReactDOMIDOperations.js +55 -73
- package/lib/ReactDOMImg.js +3 -5
- package/lib/ReactDOMInput.js +4 -5
- package/lib/ReactDOMOption.js +4 -5
- package/lib/ReactDOMSelect.js +55 -63
- package/lib/ReactDOMSelection.js +5 -1
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +54 -34
- package/lib/ReactDOMTextarea.js +4 -5
- package/lib/ReactDefaultInjection.js +13 -7
- package/lib/ReactDefaultPerf.js +6 -5
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +17 -11
- package/lib/ReactElementValidator.js +74 -37
- package/lib/ReactEmptyComponent.js +17 -10
- package/lib/ReactInjection.js +6 -4
- package/lib/ReactInputSelection.js +2 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactMount.js +193 -64
- package/lib/ReactMultiChild.js +32 -42
- package/lib/ReactNativeComponent.js +45 -8
- package/lib/ReactOwner.js +3 -47
- package/lib/ReactPerf.js +20 -0
- package/lib/ReactPropTransferer.js +0 -55
- package/lib/ReactPropTypes.js +1 -17
- package/lib/ReactRef.js +96 -0
- package/lib/ReactServerRendering.js +3 -2
- package/lib/ReactTestUtils.js +82 -25
- package/lib/ReactTransitionGroup.js +47 -6
- package/lib/ReactUpdates.js +43 -42
- package/lib/SyntheticMouseEvent.js +1 -3
- package/lib/ViewportMetrics.js +1 -4
- package/lib/accumulate.js +47 -0
- package/lib/cloneWithProps.js +2 -2
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +2 -2
- package/lib/findDOMNode.js +52 -0
- package/lib/flattenChildren.js +1 -14
- package/lib/getIteratorFn.js +42 -0
- package/lib/instantiateReactComponent.js +88 -65
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +1 -2
- package/lib/shouldUpdateReactComponent.js +13 -5
- package/lib/traverseAllChildren.js +110 -54
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/deprecated.js +0 -47
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
var BeforeInputEventPlugin = require("./BeforeInputEventPlugin");
|
|
15
15
|
var ChangeEventPlugin = require("./ChangeEventPlugin");
|
|
16
16
|
var ClientReactRootIndex = require("./ClientReactRootIndex");
|
|
17
|
-
var CompositionEventPlugin = require("./CompositionEventPlugin");
|
|
18
17
|
var DefaultEventPluginOrder = require("./DefaultEventPluginOrder");
|
|
19
18
|
var EnterLeaveEventPlugin = require("./EnterLeaveEventPlugin");
|
|
20
19
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
@@ -28,14 +27,17 @@ var ReactDOMComponent = require("./ReactDOMComponent");
|
|
|
28
27
|
var ReactDOMButton = require("./ReactDOMButton");
|
|
29
28
|
var ReactDOMForm = require("./ReactDOMForm");
|
|
30
29
|
var ReactDOMImg = require("./ReactDOMImg");
|
|
30
|
+
var ReactDOMIDOperations = require("./ReactDOMIDOperations");
|
|
31
31
|
var ReactDOMInput = require("./ReactDOMInput");
|
|
32
32
|
var ReactDOMOption = require("./ReactDOMOption");
|
|
33
33
|
var ReactDOMSelect = require("./ReactDOMSelect");
|
|
34
34
|
var ReactDOMTextarea = require("./ReactDOMTextarea");
|
|
35
|
+
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
|
|
35
36
|
var ReactEventListener = require("./ReactEventListener");
|
|
36
37
|
var ReactInjection = require("./ReactInjection");
|
|
37
38
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
38
39
|
var ReactMount = require("./ReactMount");
|
|
40
|
+
var ReactReconcileTransaction = require("./ReactReconcileTransaction");
|
|
39
41
|
var SelectEventPlugin = require("./SelectEventPlugin");
|
|
40
42
|
var ServerReactRootIndex = require("./ServerReactRootIndex");
|
|
41
43
|
var SimpleEventPlugin = require("./SimpleEventPlugin");
|
|
@@ -63,7 +65,6 @@ function inject() {
|
|
|
63
65
|
SimpleEventPlugin: SimpleEventPlugin,
|
|
64
66
|
EnterLeaveEventPlugin: EnterLeaveEventPlugin,
|
|
65
67
|
ChangeEventPlugin: ChangeEventPlugin,
|
|
66
|
-
CompositionEventPlugin: CompositionEventPlugin,
|
|
67
68
|
MobileSafariClickEventPlugin: MobileSafariClickEventPlugin,
|
|
68
69
|
SelectEventPlugin: SelectEventPlugin,
|
|
69
70
|
BeforeInputEventPlugin: BeforeInputEventPlugin
|
|
@@ -73,6 +74,14 @@ function inject() {
|
|
|
73
74
|
ReactDOMComponent
|
|
74
75
|
);
|
|
75
76
|
|
|
77
|
+
ReactInjection.NativeComponent.injectTextComponentClass(
|
|
78
|
+
ReactDOMTextComponent
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// This needs to happen before createFullPageComponent() otherwise the mixin
|
|
82
|
+
// won't be included.
|
|
83
|
+
ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
|
|
84
|
+
|
|
76
85
|
ReactInjection.NativeComponent.injectComponentClasses({
|
|
77
86
|
'button': ReactDOMButton,
|
|
78
87
|
'form': ReactDOMForm,
|
|
@@ -87,17 +96,13 @@ function inject() {
|
|
|
87
96
|
'body': createFullPageComponent('body')
|
|
88
97
|
});
|
|
89
98
|
|
|
90
|
-
// This needs to happen after createFullPageComponent() otherwise the mixin
|
|
91
|
-
// gets double injected.
|
|
92
|
-
ReactInjection.CompositeComponent.injectMixin(ReactBrowserComponentMixin);
|
|
93
|
-
|
|
94
99
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
|
|
95
100
|
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
|
|
96
101
|
|
|
97
102
|
ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
|
|
98
103
|
|
|
99
104
|
ReactInjection.Updates.injectReconcileTransaction(
|
|
100
|
-
|
|
105
|
+
ReactReconcileTransaction
|
|
101
106
|
);
|
|
102
107
|
ReactInjection.Updates.injectBatchingStrategy(
|
|
103
108
|
ReactDefaultBatchingStrategy
|
|
@@ -110,6 +115,7 @@ function inject() {
|
|
|
110
115
|
);
|
|
111
116
|
|
|
112
117
|
ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
|
|
118
|
+
ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
|
|
113
119
|
|
|
114
120
|
if ("production" !== process.env.NODE_ENV) {
|
|
115
121
|
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
|
package/lib/ReactDefaultPerf.js
CHANGED
|
@@ -169,7 +169,7 @@ var ReactDefaultPerf = {
|
|
|
169
169
|
rv = func.apply(this, args);
|
|
170
170
|
totalTime = performanceNow() - start;
|
|
171
171
|
|
|
172
|
-
if (fnName === '
|
|
172
|
+
if (fnName === '_mountImageIntoNode') {
|
|
173
173
|
var mountID = ReactMount.getID(args[1]);
|
|
174
174
|
ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
|
|
175
175
|
} else if (fnName === 'dangerouslyProcessChildrenUpdates') {
|
|
@@ -206,9 +206,9 @@ var ReactDefaultPerf = {
|
|
|
206
206
|
}
|
|
207
207
|
return rv;
|
|
208
208
|
} else if (moduleName === 'ReactCompositeComponent' && (
|
|
209
|
-
|
|
210
|
-
fnName === '
|
|
211
|
-
fnName === '_renderValidatedComponent')) {
|
|
209
|
+
(// TODO: receiveComponent()?
|
|
210
|
+
(fnName === 'mountComponent' ||
|
|
211
|
+
fnName === 'updateComponent' || fnName === '_renderValidatedComponent')))) {
|
|
212
212
|
|
|
213
213
|
var rootNodeID = fnName === 'mountComponent' ?
|
|
214
214
|
args[0] :
|
|
@@ -244,7 +244,8 @@ var ReactDefaultPerf = {
|
|
|
244
244
|
|
|
245
245
|
entry.displayNames[rootNodeID] = {
|
|
246
246
|
current: this.constructor.displayName,
|
|
247
|
-
owner: this._owner ?
|
|
247
|
+
owner: this._currentElement._owner ?
|
|
248
|
+
this._currentElement._owner.constructor.displayName : '<root>'
|
|
248
249
|
};
|
|
249
250
|
|
|
250
251
|
return rv;
|
|
@@ -14,7 +14,7 @@ var assign = require("./Object.assign");
|
|
|
14
14
|
// Don't try to save users less than 1.2ms (a number I made up)
|
|
15
15
|
var DONT_CARE_THRESHOLD = 1.2;
|
|
16
16
|
var DOM_OPERATION_TYPES = {
|
|
17
|
-
'
|
|
17
|
+
'_mountImageIntoNode': 'set innerHTML',
|
|
18
18
|
INSERT_MARKUP: 'set innerHTML',
|
|
19
19
|
MOVE_EXISTING: 'move',
|
|
20
20
|
REMOVE_NODE: 'remove',
|
package/lib/ReactElement.js
CHANGED
|
@@ -106,7 +106,21 @@ var ReactElement = function(type, key, ref, owner, context, props) {
|
|
|
106
106
|
// an external backing store so that we can freeze the whole object.
|
|
107
107
|
// This can be replaced with a WeakMap once they are implemented in
|
|
108
108
|
// commonly used development environments.
|
|
109
|
-
this._store = {
|
|
109
|
+
this._store = { props: props };
|
|
110
|
+
|
|
111
|
+
// To make comparing ReactElements easier for testing purposes, we make
|
|
112
|
+
// the validation flag non-enumerable (where possible, which should
|
|
113
|
+
// include every environment we run tests in), so the test framework
|
|
114
|
+
// ignores it.
|
|
115
|
+
try {
|
|
116
|
+
Object.defineProperty(this._store, 'validated', {
|
|
117
|
+
configurable: false,
|
|
118
|
+
enumerable: false,
|
|
119
|
+
writable: true
|
|
120
|
+
});
|
|
121
|
+
} catch (x) {
|
|
122
|
+
}
|
|
123
|
+
this._store.validated = false;
|
|
110
124
|
|
|
111
125
|
// We're not allowed to set props directly on the object so we early
|
|
112
126
|
// return and rely on the prototype membrane to forward to the backing
|
|
@@ -141,16 +155,7 @@ ReactElement.createElement = function(type, config, children) {
|
|
|
141
155
|
|
|
142
156
|
if (config != null) {
|
|
143
157
|
ref = config.ref === undefined ? null : config.ref;
|
|
144
|
-
|
|
145
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
146
|
-
config.key !== null,
|
|
147
|
-
'createElement(...): Encountered component with a `key` of null. In ' +
|
|
148
|
-
'a future version, this will be treated as equivalent to the string ' +
|
|
149
|
-
'\'null\'; instead, provide an explicit key or use undefined.'
|
|
150
|
-
) : null);
|
|
151
|
-
}
|
|
152
|
-
// TODO: Change this back to `config.key === undefined`
|
|
153
|
-
key = config.key == null ? null : '' + config.key;
|
|
158
|
+
key = config.key === undefined ? null : '' + config.key;
|
|
154
159
|
// Remaining properties are added to a new props object
|
|
155
160
|
for (propName in config) {
|
|
156
161
|
if (config.hasOwnProperty(propName) &&
|
|
@@ -199,6 +204,7 @@ ReactElement.createFactory = function(type) {
|
|
|
199
204
|
// easily accessed on elements. E.g. <Foo />.type === Foo.type.
|
|
200
205
|
// This should not be named `constructor` since this may not be the function
|
|
201
206
|
// that created the element, and it may not even be a constructor.
|
|
207
|
+
// Legacy hook TODO: Warn if this is accessed
|
|
202
208
|
factory.type = type;
|
|
203
209
|
return factory;
|
|
204
210
|
};
|
|
@@ -22,6 +22,7 @@ var ReactElement = require("./ReactElement");
|
|
|
22
22
|
var ReactPropTypeLocations = require("./ReactPropTypeLocations");
|
|
23
23
|
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
24
24
|
|
|
25
|
+
var getIteratorFn = require("./getIteratorFn");
|
|
25
26
|
var monitorCodeUse = require("./monitorCodeUse");
|
|
26
27
|
var warning = require("./warning");
|
|
27
28
|
|
|
@@ -40,6 +41,24 @@ var loggedTypeFailures = {};
|
|
|
40
41
|
|
|
41
42
|
var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Gets the instance's name for use in warnings.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
* @return {?string} Display name or undefined
|
|
49
|
+
*/
|
|
50
|
+
function getName(instance) {
|
|
51
|
+
var publicInstance = instance && instance.getPublicInstance();
|
|
52
|
+
if (!publicInstance) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
var constructor = publicInstance.constructor;
|
|
56
|
+
if (!constructor) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return constructor.displayName || constructor.name || undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
/**
|
|
44
63
|
* Gets the current owner's displayName for use in warnings.
|
|
45
64
|
*
|
|
@@ -48,29 +67,31 @@ var NUMERIC_PROPERTY_REGEX = /^\d+$/;
|
|
|
48
67
|
*/
|
|
49
68
|
function getCurrentOwnerDisplayName() {
|
|
50
69
|
var current = ReactCurrentOwner.current;
|
|
51
|
-
return
|
|
70
|
+
return (
|
|
71
|
+
current && getName(current) || undefined
|
|
72
|
+
);
|
|
52
73
|
}
|
|
53
74
|
|
|
54
75
|
/**
|
|
55
|
-
* Warn if the
|
|
56
|
-
* This
|
|
76
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
77
|
+
* This element is in an array. The array could grow and shrink or be
|
|
57
78
|
* reordered. All children that haven't already been validated are required to
|
|
58
79
|
* have a "key" property assigned to it.
|
|
59
80
|
*
|
|
60
81
|
* @internal
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {*} parentType
|
|
82
|
+
* @param {ReactElement} element Element that requires a key.
|
|
83
|
+
* @param {*} parentType element's parent's type.
|
|
63
84
|
*/
|
|
64
|
-
function validateExplicitKey(
|
|
65
|
-
if (
|
|
85
|
+
function validateExplicitKey(element, parentType) {
|
|
86
|
+
if (element._store.validated || element.key != null) {
|
|
66
87
|
return;
|
|
67
88
|
}
|
|
68
|
-
|
|
89
|
+
element._store.validated = true;
|
|
69
90
|
|
|
70
91
|
warnAndMonitorForKeyUse(
|
|
71
92
|
'react_key_warning',
|
|
72
|
-
'Each child in an array should have a unique "key" prop.',
|
|
73
|
-
|
|
93
|
+
'Each child in an array or iterator should have a unique "key" prop.',
|
|
94
|
+
element,
|
|
74
95
|
parentType
|
|
75
96
|
);
|
|
76
97
|
}
|
|
@@ -81,17 +102,17 @@ function validateExplicitKey(component, parentType) {
|
|
|
81
102
|
*
|
|
82
103
|
* @internal
|
|
83
104
|
* @param {string} name Property name of the key.
|
|
84
|
-
* @param {
|
|
85
|
-
* @param {*} parentType
|
|
105
|
+
* @param {ReactElement} element Component that requires a key.
|
|
106
|
+
* @param {*} parentType element's parent's type.
|
|
86
107
|
*/
|
|
87
|
-
function validatePropertyKey(name,
|
|
108
|
+
function validatePropertyKey(name, element, parentType) {
|
|
88
109
|
if (!NUMERIC_PROPERTY_REGEX.test(name)) {
|
|
89
110
|
return;
|
|
90
111
|
}
|
|
91
112
|
warnAndMonitorForKeyUse(
|
|
92
113
|
'react_numeric_key_warning',
|
|
93
114
|
'Child objects should have non-numeric keys so ordering is preserved.',
|
|
94
|
-
|
|
115
|
+
element,
|
|
95
116
|
parentType
|
|
96
117
|
);
|
|
97
118
|
}
|
|
@@ -102,12 +123,12 @@ function validatePropertyKey(name, component, parentType) {
|
|
|
102
123
|
* @internal
|
|
103
124
|
* @param {string} warningID The id used when logging.
|
|
104
125
|
* @param {string} message The base warning that gets output.
|
|
105
|
-
* @param {
|
|
106
|
-
* @param {*} parentType
|
|
126
|
+
* @param {ReactElement} element Component that requires a key.
|
|
127
|
+
* @param {*} parentType element's parent's type.
|
|
107
128
|
*/
|
|
108
|
-
function warnAndMonitorForKeyUse(warningID, message,
|
|
129
|
+
function warnAndMonitorForKeyUse(warningID, message, element, parentType) {
|
|
109
130
|
var ownerName = getCurrentOwnerDisplayName();
|
|
110
|
-
var parentName = parentType.displayName;
|
|
131
|
+
var parentName = parentType.displayName || parentType.name;
|
|
111
132
|
|
|
112
133
|
var useName = ownerName || parentName;
|
|
113
134
|
var memoizer = ownerHasKeyUseWarning[warningID];
|
|
@@ -118,15 +139,17 @@ function warnAndMonitorForKeyUse(warningID, message, component, parentType) {
|
|
|
118
139
|
|
|
119
140
|
message += ownerName ?
|
|
120
141
|
(" Check the render method of " + ownerName + ".") :
|
|
121
|
-
(" Check the
|
|
142
|
+
(" Check the React.render call using <" + parentName + ">.");
|
|
122
143
|
|
|
123
144
|
// Usually the current owner is the offender, but if it accepts children as a
|
|
124
145
|
// property, it may be the creator of the child that's responsible for
|
|
125
146
|
// assigning it a key.
|
|
126
147
|
var childOwnerName = null;
|
|
127
|
-
if (
|
|
148
|
+
if (element &&
|
|
149
|
+
element._owner &&
|
|
150
|
+
element._owner !== ReactCurrentOwner.current) {
|
|
128
151
|
// Name of the component that originally created this child.
|
|
129
|
-
childOwnerName =
|
|
152
|
+
childOwnerName = getName(element._owner);
|
|
130
153
|
|
|
131
154
|
message += (" It was passed a child from " + childOwnerName + ".");
|
|
132
155
|
}
|
|
@@ -155,30 +178,43 @@ function monitorUseOfObjectMap() {
|
|
|
155
178
|
}
|
|
156
179
|
|
|
157
180
|
/**
|
|
158
|
-
* Ensure that every
|
|
181
|
+
* Ensure that every element either is passed in a static location, in an
|
|
159
182
|
* array with an explicit keys property defined, or in an object literal
|
|
160
183
|
* with valid key property.
|
|
161
184
|
*
|
|
162
185
|
* @internal
|
|
163
|
-
* @param {
|
|
164
|
-
* @param {*} parentType
|
|
165
|
-
* @return {boolean}
|
|
186
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
187
|
+
* @param {*} parentType node's parent's type.
|
|
166
188
|
*/
|
|
167
|
-
function validateChildKeys(
|
|
168
|
-
if (Array.isArray(
|
|
169
|
-
for (var i = 0; i <
|
|
170
|
-
var child =
|
|
189
|
+
function validateChildKeys(node, parentType) {
|
|
190
|
+
if (Array.isArray(node)) {
|
|
191
|
+
for (var i = 0; i < node.length; i++) {
|
|
192
|
+
var child = node[i];
|
|
171
193
|
if (ReactElement.isValidElement(child)) {
|
|
172
194
|
validateExplicitKey(child, parentType);
|
|
173
195
|
}
|
|
174
196
|
}
|
|
175
|
-
} else if (ReactElement.isValidElement(
|
|
176
|
-
// This
|
|
177
|
-
|
|
178
|
-
} else if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
197
|
+
} else if (ReactElement.isValidElement(node)) {
|
|
198
|
+
// This element was passed in a valid location.
|
|
199
|
+
node._store.validated = true;
|
|
200
|
+
} else if (node) {
|
|
201
|
+
var iteratorFn = getIteratorFn(node);
|
|
202
|
+
// Entry iterators provide implicit keys.
|
|
203
|
+
if (iteratorFn && iteratorFn !== node.entries) {
|
|
204
|
+
var iterator = iteratorFn.call(node);
|
|
205
|
+
var step;
|
|
206
|
+
while (!(step = iterator.next()).done) {
|
|
207
|
+
if (ReactElement.isValidElement(step.value)) {
|
|
208
|
+
validateExplicitKey(step.value, parentType);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
} else if (typeof node === 'object') {
|
|
212
|
+
monitorUseOfObjectMap();
|
|
213
|
+
for (var key in node) {
|
|
214
|
+
if (node.hasOwnProperty(key)) {
|
|
215
|
+
validatePropertyKey(key, node[key], parentType);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
182
218
|
}
|
|
183
219
|
}
|
|
184
220
|
}
|
|
@@ -243,7 +279,7 @@ var ReactElementValidator = {
|
|
|
243
279
|
}
|
|
244
280
|
|
|
245
281
|
if (type) {
|
|
246
|
-
var name = type.displayName;
|
|
282
|
+
var name = type.displayName || type.name;
|
|
247
283
|
if (type.propTypes) {
|
|
248
284
|
checkPropTypes(
|
|
249
285
|
name,
|
|
@@ -269,6 +305,7 @@ var ReactElementValidator = {
|
|
|
269
305
|
null,
|
|
270
306
|
type
|
|
271
307
|
);
|
|
308
|
+
// Legacy hook TODO: Warn if this is accessed
|
|
272
309
|
validatedFactory.type = type;
|
|
273
310
|
return validatedFactory;
|
|
274
311
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
14
|
var ReactElement = require("./ReactElement");
|
|
15
|
+
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
15
16
|
|
|
16
17
|
var invariant = require("./invariant");
|
|
17
18
|
|
|
@@ -26,17 +27,25 @@ var ReactEmptyComponentInjection = {
|
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var ReactEmptyComponentType = function() {};
|
|
31
|
+
ReactEmptyComponentType.prototype.componentDidMount = function() {
|
|
32
|
+
var internalInstance = ReactInstanceMap.get(this);
|
|
33
|
+
registerNullComponentID(internalInstance._rootNodeID);
|
|
34
|
+
};
|
|
35
|
+
ReactEmptyComponentType.prototype.componentWillUnmount = function() {
|
|
36
|
+
var internalInstance = ReactInstanceMap.get(this);
|
|
37
|
+
deregisterNullComponentID(internalInstance._rootNodeID);
|
|
38
|
+
};
|
|
39
|
+
ReactEmptyComponentType.prototype.render = function() {
|
|
33
40
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
34
41
|
component,
|
|
35
42
|
'Trying to return null from a render, but no null placeholder component ' +
|
|
36
43
|
'was injected.'
|
|
37
44
|
) : invariant(component));
|
|
38
45
|
return component();
|
|
39
|
-
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var emptyElement = ReactElement.createElement(ReactEmptyComponentType);
|
|
40
49
|
|
|
41
50
|
/**
|
|
42
51
|
* Mark the component as having rendered to null.
|
|
@@ -59,15 +68,13 @@ function deregisterNullComponentID(id) {
|
|
|
59
68
|
* @return {boolean} True if the component is rendered to null.
|
|
60
69
|
*/
|
|
61
70
|
function isNullComponentID(id) {
|
|
62
|
-
return nullComponentIdsRegistry[id];
|
|
71
|
+
return !!nullComponentIdsRegistry[id];
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
var ReactEmptyComponent = {
|
|
66
|
-
|
|
67
|
-
getEmptyComponent: getEmptyComponent,
|
|
75
|
+
emptyElement: emptyElement,
|
|
68
76
|
injection: ReactEmptyComponentInjection,
|
|
69
|
-
isNullComponentID: isNullComponentID
|
|
70
|
-
registerNullComponentID: registerNullComponentID
|
|
77
|
+
isNullComponentID: isNullComponentID
|
|
71
78
|
};
|
|
72
79
|
|
|
73
80
|
module.exports = ReactEmptyComponent;
|
package/lib/ReactInjection.js
CHANGED
|
@@ -13,18 +13,20 @@
|
|
|
13
13
|
|
|
14
14
|
var DOMProperty = require("./DOMProperty");
|
|
15
15
|
var EventPluginHub = require("./EventPluginHub");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var ReactComponentEnvironment = require("./ReactComponentEnvironment");
|
|
17
|
+
var ReactClass = require("./ReactClass");
|
|
18
18
|
var ReactEmptyComponent = require("./ReactEmptyComponent");
|
|
19
19
|
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
|
20
20
|
var ReactNativeComponent = require("./ReactNativeComponent");
|
|
21
|
+
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
21
22
|
var ReactPerf = require("./ReactPerf");
|
|
22
23
|
var ReactRootIndex = require("./ReactRootIndex");
|
|
23
24
|
var ReactUpdates = require("./ReactUpdates");
|
|
24
25
|
|
|
25
26
|
var ReactInjection = {
|
|
26
|
-
Component:
|
|
27
|
-
|
|
27
|
+
Component: ReactComponentEnvironment.injection,
|
|
28
|
+
Class: ReactClass.injection,
|
|
29
|
+
DOMComponent: ReactDOMComponent.injection,
|
|
28
30
|
DOMProperty: DOMProperty.injection,
|
|
29
31
|
EmptyComponent: ReactEmptyComponent.injection,
|
|
30
32
|
EventPluginHub: EventPluginHub.injection,
|