react 0.12.0-rc1 → 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 +1862 -519
- package/dist/react-with-addons.js +4099 -3299
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3893 -3353
- package/dist/react.min.js +6 -6
- package/lib/BeforeInputEventPlugin.js +388 -111
- package/lib/CSSProperty.js +5 -2
- 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 +7 -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 +7 -6
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +24 -5
- package/lib/ReactElementValidator.js +101 -52
- 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 +46 -9
- 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/lib/warning.js +1 -1
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -232
- package/lib/deprecated.js +0 -47
package/lib/ReactMultiChild.js
CHANGED
|
@@ -12,12 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
"use strict";
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var ReactComponentEnvironment = require("./ReactComponentEnvironment");
|
|
16
16
|
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
20
|
-
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
18
|
+
var ReactChildReconciler = require("./ReactChildReconciler");
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* Updating children of a component may trigger recursive updates. The depth is
|
|
@@ -135,7 +133,7 @@ function enqueueTextContent(parentID, textContent) {
|
|
|
135
133
|
*/
|
|
136
134
|
function processQueue() {
|
|
137
135
|
if (updateQueue.length) {
|
|
138
|
-
|
|
136
|
+
ReactComponentEnvironment.processChildrenUpdates(
|
|
139
137
|
updateQueue,
|
|
140
138
|
markupQueue
|
|
141
139
|
);
|
|
@@ -178,26 +176,24 @@ var ReactMultiChild = {
|
|
|
178
176
|
* @return {array} An array of mounted representations.
|
|
179
177
|
* @internal
|
|
180
178
|
*/
|
|
181
|
-
mountChildren: function(nestedChildren, transaction) {
|
|
182
|
-
var children =
|
|
179
|
+
mountChildren: function(nestedChildren, transaction, context) {
|
|
180
|
+
var children = ReactChildReconciler.instantiateChildren(
|
|
181
|
+
nestedChildren, transaction, context
|
|
182
|
+
);
|
|
183
|
+
this._renderedChildren = children;
|
|
183
184
|
var mountImages = [];
|
|
184
185
|
var index = 0;
|
|
185
|
-
this._renderedChildren = children;
|
|
186
186
|
for (var name in children) {
|
|
187
187
|
var child = children[name];
|
|
188
188
|
if (children.hasOwnProperty(name)) {
|
|
189
|
-
// The rendered children must be turned into instances as they're
|
|
190
|
-
// mounted.
|
|
191
|
-
var childInstance = instantiateReactComponent(child, null);
|
|
192
|
-
children[name] = childInstance;
|
|
193
189
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
194
190
|
var rootID = this._rootNodeID + name;
|
|
195
|
-
var mountImage =
|
|
191
|
+
var mountImage = child.mountComponent(
|
|
196
192
|
rootID,
|
|
197
193
|
transaction,
|
|
198
|
-
|
|
194
|
+
context
|
|
199
195
|
);
|
|
200
|
-
|
|
196
|
+
child._mountIndex = index;
|
|
201
197
|
mountImages.push(mountImage);
|
|
202
198
|
index++;
|
|
203
199
|
}
|
|
@@ -217,6 +213,8 @@ var ReactMultiChild = {
|
|
|
217
213
|
try {
|
|
218
214
|
var prevChildren = this._renderedChildren;
|
|
219
215
|
// Remove any rendered children.
|
|
216
|
+
ReactChildReconciler.unmountChildren(prevChildren);
|
|
217
|
+
// TODO: The setTextContent operation should be enough
|
|
220
218
|
for (var name in prevChildren) {
|
|
221
219
|
if (prevChildren.hasOwnProperty(name)) {
|
|
222
220
|
this._unmountChildByName(prevChildren[name], name);
|
|
@@ -240,11 +238,11 @@ var ReactMultiChild = {
|
|
|
240
238
|
* @param {ReactReconcileTransaction} transaction
|
|
241
239
|
* @internal
|
|
242
240
|
*/
|
|
243
|
-
updateChildren: function(nextNestedChildren, transaction) {
|
|
241
|
+
updateChildren: function(nextNestedChildren, transaction, context) {
|
|
244
242
|
updateDepth++;
|
|
245
243
|
var errorThrown = true;
|
|
246
244
|
try {
|
|
247
|
-
this._updateChildren(nextNestedChildren, transaction);
|
|
245
|
+
this._updateChildren(nextNestedChildren, transaction, context);
|
|
248
246
|
errorThrown = false;
|
|
249
247
|
} finally {
|
|
250
248
|
updateDepth--;
|
|
@@ -263,9 +261,12 @@ var ReactMultiChild = {
|
|
|
263
261
|
* @final
|
|
264
262
|
* @protected
|
|
265
263
|
*/
|
|
266
|
-
_updateChildren: function(nextNestedChildren, transaction) {
|
|
267
|
-
var nextChildren = flattenChildren(nextNestedChildren);
|
|
264
|
+
_updateChildren: function(nextNestedChildren, transaction, context) {
|
|
268
265
|
var prevChildren = this._renderedChildren;
|
|
266
|
+
var nextChildren = ReactChildReconciler.updateChildren(
|
|
267
|
+
prevChildren, nextNestedChildren, transaction, context
|
|
268
|
+
);
|
|
269
|
+
this._renderedChildren = nextChildren;
|
|
269
270
|
if (!nextChildren && !prevChildren) {
|
|
270
271
|
return;
|
|
271
272
|
}
|
|
@@ -279,12 +280,10 @@ var ReactMultiChild = {
|
|
|
279
280
|
continue;
|
|
280
281
|
}
|
|
281
282
|
var prevChild = prevChildren && prevChildren[name];
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
283
|
+
var nextChild = nextChildren[name];
|
|
284
|
+
if (prevChild === nextChild) {
|
|
285
285
|
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
286
286
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
287
|
-
prevChild.receiveComponent(nextElement, transaction);
|
|
288
287
|
prevChild._mountIndex = nextIndex;
|
|
289
288
|
} else {
|
|
290
289
|
if (prevChild) {
|
|
@@ -293,12 +292,8 @@ var ReactMultiChild = {
|
|
|
293
292
|
this._unmountChildByName(prevChild, name);
|
|
294
293
|
}
|
|
295
294
|
// The child must be instantiated before it's mounted.
|
|
296
|
-
var nextChildInstance = instantiateReactComponent(
|
|
297
|
-
nextElement,
|
|
298
|
-
null
|
|
299
|
-
);
|
|
300
295
|
this._mountChildByNameAtIndex(
|
|
301
|
-
|
|
296
|
+
nextChild, name, nextIndex, transaction, context
|
|
302
297
|
);
|
|
303
298
|
}
|
|
304
299
|
nextIndex++;
|
|
@@ -306,7 +301,7 @@ var ReactMultiChild = {
|
|
|
306
301
|
// Remove children that are no longer present.
|
|
307
302
|
for (name in prevChildren) {
|
|
308
303
|
if (prevChildren.hasOwnProperty(name) &&
|
|
309
|
-
!(nextChildren && nextChildren
|
|
304
|
+
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
310
305
|
this._unmountChildByName(prevChildren[name], name);
|
|
311
306
|
}
|
|
312
307
|
}
|
|
@@ -320,13 +315,7 @@ var ReactMultiChild = {
|
|
|
320
315
|
*/
|
|
321
316
|
unmountChildren: function() {
|
|
322
317
|
var renderedChildren = this._renderedChildren;
|
|
323
|
-
|
|
324
|
-
var renderedChild = renderedChildren[name];
|
|
325
|
-
// TODO: When is this not true?
|
|
326
|
-
if (renderedChild.unmountComponent) {
|
|
327
|
-
renderedChild.unmountComponent();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
318
|
+
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
330
319
|
this._renderedChildren = null;
|
|
331
320
|
},
|
|
332
321
|
|
|
@@ -389,18 +378,21 @@ var ReactMultiChild = {
|
|
|
389
378
|
* @param {ReactReconcileTransaction} transaction
|
|
390
379
|
* @private
|
|
391
380
|
*/
|
|
392
|
-
_mountChildByNameAtIndex: function(
|
|
381
|
+
_mountChildByNameAtIndex: function(
|
|
382
|
+
child,
|
|
383
|
+
name,
|
|
384
|
+
index,
|
|
385
|
+
transaction,
|
|
386
|
+
context) {
|
|
393
387
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
394
388
|
var rootID = this._rootNodeID + name;
|
|
395
389
|
var mountImage = child.mountComponent(
|
|
396
390
|
rootID,
|
|
397
391
|
transaction,
|
|
398
|
-
|
|
392
|
+
context
|
|
399
393
|
);
|
|
400
394
|
child._mountIndex = index;
|
|
401
395
|
this.createChild(child, mountImage);
|
|
402
|
-
this._renderedChildren = this._renderedChildren || {};
|
|
403
|
-
this._renderedChildren[name] = child;
|
|
404
396
|
},
|
|
405
397
|
|
|
406
398
|
/**
|
|
@@ -415,8 +407,6 @@ var ReactMultiChild = {
|
|
|
415
407
|
_unmountChildByName: function(child, name) {
|
|
416
408
|
this.removeChild(child);
|
|
417
409
|
child._mountIndex = null;
|
|
418
|
-
child.unmountComponent();
|
|
419
|
-
delete this._renderedChildren[name];
|
|
420
410
|
}
|
|
421
411
|
|
|
422
412
|
}
|
|
@@ -11,12 +11,16 @@
|
|
|
11
11
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
|
+
var ReactClass = require("./ReactClass");
|
|
15
|
+
var ReactElement = require("./ReactElement");
|
|
16
|
+
|
|
14
17
|
var assign = require("./Object.assign");
|
|
15
18
|
var invariant = require("./invariant");
|
|
16
19
|
|
|
17
20
|
var genericComponentClass = null;
|
|
18
21
|
// This registry keeps track of wrapper classes around native tags
|
|
19
22
|
var tagToComponentClass = {};
|
|
23
|
+
var textComponentClass = null;
|
|
20
24
|
|
|
21
25
|
var ReactNativeComponentInjection = {
|
|
22
26
|
// This accepts a class that receives the tag string. This is a catch all
|
|
@@ -24,6 +28,11 @@ var ReactNativeComponentInjection = {
|
|
|
24
28
|
injectGenericComponentClass: function(componentClass) {
|
|
25
29
|
genericComponentClass = componentClass;
|
|
26
30
|
},
|
|
31
|
+
// This accepts a text component class that takes the text string to be
|
|
32
|
+
// rendered as props.
|
|
33
|
+
injectTextComponentClass: function(componentClass) {
|
|
34
|
+
textComponentClass = componentClass;
|
|
35
|
+
},
|
|
27
36
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
28
37
|
// tag. That particular tag will use this class instead of the generic one.
|
|
29
38
|
injectComponentClasses: function(componentClasses) {
|
|
@@ -31,6 +40,22 @@ var ReactNativeComponentInjection = {
|
|
|
31
40
|
}
|
|
32
41
|
};
|
|
33
42
|
|
|
43
|
+
function autoGenerateWrapperClass(type) {
|
|
44
|
+
return ReactClass.createClass({
|
|
45
|
+
tagName: type.toUpperCase(),
|
|
46
|
+
render: function() {
|
|
47
|
+
return new ReactElement(
|
|
48
|
+
type,
|
|
49
|
+
null,
|
|
50
|
+
null,
|
|
51
|
+
null,
|
|
52
|
+
null,
|
|
53
|
+
this.props
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
34
59
|
/**
|
|
35
60
|
* Create an internal class for a specific tag.
|
|
36
61
|
*
|
|
@@ -41,12 +66,7 @@ var ReactNativeComponentInjection = {
|
|
|
41
66
|
function createInstanceForTag(tag, props, parentType) {
|
|
42
67
|
var componentClass = tagToComponentClass[tag];
|
|
43
68
|
if (componentClass == null) {
|
|
44
|
-
|
|
45
|
-
genericComponentClass,
|
|
46
|
-
'There is no registered component for the tag %s',
|
|
47
|
-
tag
|
|
48
|
-
) : invariant(genericComponentClass));
|
|
49
|
-
return new genericComponentClass(tag, props);
|
|
69
|
+
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
|
|
50
70
|
}
|
|
51
71
|
if (parentType === tag) {
|
|
52
72
|
// Avoid recursion
|
|
@@ -57,13 +77,30 @@ function createInstanceForTag(tag, props, parentType) {
|
|
|
57
77
|
) : invariant(genericComponentClass));
|
|
58
78
|
return new genericComponentClass(tag, props);
|
|
59
79
|
}
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
return new componentClass(props);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {ReactText} text
|
|
85
|
+
* @return {ReactComponent}
|
|
86
|
+
*/
|
|
87
|
+
function createInstanceForText(text) {
|
|
88
|
+
return new textComponentClass(text);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {ReactComponent} component
|
|
93
|
+
* @return {boolean}
|
|
94
|
+
*/
|
|
95
|
+
function isTextComponent(component) {
|
|
96
|
+
return component instanceof textComponentClass;
|
|
62
97
|
}
|
|
63
98
|
|
|
64
99
|
var ReactNativeComponent = {
|
|
65
100
|
createInstanceForTag: createInstanceForTag,
|
|
66
|
-
|
|
101
|
+
createInstanceForText: createInstanceForText,
|
|
102
|
+
isTextComponent: isTextComponent,
|
|
103
|
+
injection: ReactNativeComponentInjection
|
|
67
104
|
};
|
|
68
105
|
|
|
69
106
|
module.exports = ReactNativeComponent;
|
package/lib/ReactOwner.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
|
-
var emptyObject = require("./emptyObject");
|
|
15
14
|
var invariant = require("./invariant");
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -53,9 +52,8 @@ var ReactOwner = {
|
|
|
53
52
|
*/
|
|
54
53
|
isValidOwner: function(object) {
|
|
55
54
|
return !!(
|
|
56
|
-
object &&
|
|
57
|
-
typeof object.attachRef === 'function' &&
|
|
58
|
-
typeof object.detachRef === 'function'
|
|
55
|
+
(object &&
|
|
56
|
+
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
|
|
59
57
|
);
|
|
60
58
|
},
|
|
61
59
|
|
|
@@ -100,51 +98,9 @@ var ReactOwner = {
|
|
|
100
98
|
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
101
99
|
// Check that `component` is still the current ref because we do not want to
|
|
102
100
|
// detach the ref if another component stole it.
|
|
103
|
-
if (owner.refs[ref] === component) {
|
|
101
|
+
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
|
|
104
102
|
owner.detachRef(ref);
|
|
105
103
|
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* A ReactComponent must mix this in to have refs.
|
|
110
|
-
*
|
|
111
|
-
* @lends {ReactOwner.prototype}
|
|
112
|
-
*/
|
|
113
|
-
Mixin: {
|
|
114
|
-
|
|
115
|
-
construct: function() {
|
|
116
|
-
this.refs = emptyObject;
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Lazily allocates the refs object and stores `component` as `ref`.
|
|
121
|
-
*
|
|
122
|
-
* @param {string} ref Reference name.
|
|
123
|
-
* @param {component} component Component to store as `ref`.
|
|
124
|
-
* @final
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
|
-
attachRef: function(ref, component) {
|
|
128
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
129
|
-
component.isOwnedBy(this),
|
|
130
|
-
'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
|
|
131
|
-
ref
|
|
132
|
-
) : invariant(component.isOwnedBy(this)));
|
|
133
|
-
var refs = this.refs === emptyObject ? (this.refs = {}) : this.refs;
|
|
134
|
-
refs[ref] = component;
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Detaches a reference name.
|
|
139
|
-
*
|
|
140
|
-
* @param {string} ref Name to dereference.
|
|
141
|
-
* @final
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
144
|
-
detachRef: function(ref) {
|
|
145
|
-
delete this.refs[ref];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
104
|
}
|
|
149
105
|
|
|
150
106
|
};
|
package/lib/ReactPerf.js
CHANGED
|
@@ -29,6 +29,26 @@ var ReactPerf = {
|
|
|
29
29
|
*/
|
|
30
30
|
storedMeasure: _noMeasure,
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @param {object} object
|
|
34
|
+
* @param {string} objectName
|
|
35
|
+
* @param {object<string>} methodNames
|
|
36
|
+
*/
|
|
37
|
+
measureMethods: function(object, objectName, methodNames) {
|
|
38
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
39
|
+
for (var key in methodNames) {
|
|
40
|
+
if (!methodNames.hasOwnProperty(key)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
object[key] = ReactPerf.measure(
|
|
44
|
+
objectName,
|
|
45
|
+
methodNames[key],
|
|
46
|
+
object[key]
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
|
|
32
52
|
/**
|
|
33
53
|
* Use this to wrap methods you want to measure. Zero overhead in production.
|
|
34
54
|
*
|
|
@@ -13,11 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var assign = require("./Object.assign");
|
|
15
15
|
var emptyFunction = require("./emptyFunction");
|
|
16
|
-
var invariant = require("./invariant");
|
|
17
16
|
var joinClasses = require("./joinClasses");
|
|
18
|
-
var warning = require("./warning");
|
|
19
|
-
|
|
20
|
-
var didWarn = false;
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Creates a transfer strategy that will merge prop values using the supplied
|
|
@@ -96,8 +92,6 @@ function transferInto(props, newProps) {
|
|
|
96
92
|
*/
|
|
97
93
|
var ReactPropTransferer = {
|
|
98
94
|
|
|
99
|
-
TransferStrategies: TransferStrategies,
|
|
100
|
-
|
|
101
95
|
/**
|
|
102
96
|
* Merge two props objects using TransferStrategies.
|
|
103
97
|
*
|
|
@@ -109,55 +103,6 @@ var ReactPropTransferer = {
|
|
|
109
103
|
return transferInto(assign({}, oldProps), newProps);
|
|
110
104
|
},
|
|
111
105
|
|
|
112
|
-
/**
|
|
113
|
-
* @lends {ReactPropTransferer.prototype}
|
|
114
|
-
*/
|
|
115
|
-
Mixin: {
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Transfer props from this component to a target component.
|
|
119
|
-
*
|
|
120
|
-
* Props that do not have an explicit transfer strategy will be transferred
|
|
121
|
-
* only if the target component does not already have the prop set.
|
|
122
|
-
*
|
|
123
|
-
* This is usually used to pass down props to a returned root component.
|
|
124
|
-
*
|
|
125
|
-
* @param {ReactElement} element Component receiving the properties.
|
|
126
|
-
* @return {ReactElement} The supplied `component`.
|
|
127
|
-
* @final
|
|
128
|
-
* @protected
|
|
129
|
-
*/
|
|
130
|
-
transferPropsTo: function(element) {
|
|
131
|
-
("production" !== process.env.NODE_ENV ? invariant(
|
|
132
|
-
element._owner === this,
|
|
133
|
-
'%s: You can\'t call transferPropsTo() on a component that you ' +
|
|
134
|
-
'don\'t own, %s. This usually means you are calling ' +
|
|
135
|
-
'transferPropsTo() on a component passed in as props or children.',
|
|
136
|
-
this.constructor.displayName,
|
|
137
|
-
typeof element.type === 'string' ?
|
|
138
|
-
element.type :
|
|
139
|
-
element.type.displayName
|
|
140
|
-
) : invariant(element._owner === this));
|
|
141
|
-
|
|
142
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
143
|
-
if (!didWarn) {
|
|
144
|
-
didWarn = true;
|
|
145
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
146
|
-
false,
|
|
147
|
-
'transferPropsTo is deprecated. ' +
|
|
148
|
-
'See http://fb.me/react-transferpropsto for more information.'
|
|
149
|
-
) : null);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Because elements are immutable we have to merge into the existing
|
|
154
|
-
// props object rather than clone it.
|
|
155
|
-
transferInto(element.props, this.props);
|
|
156
|
-
|
|
157
|
-
return element;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
}
|
|
161
106
|
};
|
|
162
107
|
|
|
163
108
|
module.exports = ReactPropTransferer;
|