react 0.12.0 → 0.13.0-alpha.2
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 +2345 -910
- package/dist/react-with-addons.js +5273 -4111
- package/dist/react-with-addons.min.js +5 -6
- package/dist/react.js +4840 -3940
- package/dist/react.min.js +5 -6
- package/lib/AutoFocusMixin.js +1 -1
- package/lib/BeforeInputEventPlugin.js +389 -112
- package/lib/CSSProperty.js +6 -3
- package/lib/CSSPropertyOperations.js +21 -1
- package/lib/CallbackQueue.js +2 -2
- package/lib/ChangeEventPlugin.js +3 -3
- package/lib/ClientReactRootIndex.js +1 -1
- package/lib/DOMChildrenOperations.js +6 -4
- package/lib/DOMProperty.js +1 -1
- package/lib/DOMPropertyOperations.js +1 -1
- package/lib/Danger.js +7 -6
- package/lib/DefaultEventPluginOrder.js +1 -2
- package/lib/EnterLeaveEventPlugin.js +1 -1
- package/lib/EventConstants.js +1 -1
- package/lib/EventPluginHub.js +9 -7
- package/lib/EventPluginRegistry.js +1 -1
- package/lib/EventPluginUtils.js +1 -1
- package/lib/EventPropagators.js +1 -1
- package/lib/ExecutionEnvironment.js +2 -3
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +19 -7
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +3 -3
- package/lib/LocalEventTrapMixin.js +1 -1
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/Object.assign.js +3 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +17 -50
- package/lib/ReactBrowserComponentMixin.js +3 -13
- package/lib/ReactBrowserEventEmitter.js +4 -6
- package/lib/ReactCSSTransitionGroup.js +4 -1
- package/lib/ReactCSSTransitionGroupChild.js +12 -2
- package/lib/ReactChildReconciler.js +121 -0
- package/lib/ReactChildren.js +10 -8
- package/lib/ReactClass.js +874 -0
- package/lib/ReactComponent.js +45 -286
- package/lib/ReactComponentBase.js +126 -0
- package/lib/ReactComponentBrowserEnvironment.js +10 -83
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +700 -1045
- package/lib/ReactContext.js +6 -2
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +3 -8
- package/lib/ReactDOMButton.js +5 -6
- package/lib/ReactDOMComponent.js +120 -77
- package/lib/ReactDOMForm.js +5 -6
- package/lib/ReactDOMIDOperations.js +56 -74
- package/lib/ReactDOMImg.js +4 -6
- package/lib/ReactDOMInput.js +5 -6
- package/lib/ReactDOMOption.js +5 -6
- package/lib/ReactDOMSelect.js +57 -65
- package/lib/ReactDOMSelection.js +6 -2
- package/lib/ReactDOMTextComponent.js +124 -0
- package/lib/ReactDOMTextarea.js +5 -6
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +14 -8
- package/lib/ReactDefaultPerf.js +8 -7
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +22 -15
- package/lib/ReactElementValidator.js +192 -53
- package/lib/ReactEmptyComponent.js +29 -11
- package/lib/ReactEventEmitterMixin.js +1 -1
- package/lib/ReactEventListener.js +3 -3
- package/lib/ReactInjection.js +7 -5
- package/lib/ReactInputSelection.js +3 -4
- package/lib/ReactInstanceHandles.js +3 -2
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +202 -66
- package/lib/ReactMultiChild.js +44 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +47 -10
- package/lib/ReactOwner.js +4 -48
- package/lib/ReactPerf.js +21 -1
- package/lib/ReactPropTransferer.js +2 -57
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +14 -22
- package/lib/ReactPutListenerQueue.js +1 -1
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactRef.js +96 -0
- package/lib/ReactRootIndex.js +1 -1
- package/lib/ReactServerRendering.js +5 -3
- package/lib/ReactServerRenderingTransaction.js +1 -1
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +83 -26
- package/lib/ReactTransitionChildMapping.js +1 -1
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +48 -7
- package/lib/ReactUpdates.js +46 -45
- package/lib/ReactWithAddons.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +3 -3
- package/lib/ServerReactRootIndex.js +1 -1
- package/lib/SimpleEventPlugin.js +1 -1
- package/lib/SyntheticClipboardEvent.js +1 -2
- package/lib/SyntheticCompositionEvent.js +1 -2
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +11 -3
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -2
- package/lib/SyntheticKeyboardEvent.js +1 -1
- package/lib/SyntheticMouseEvent.js +2 -4
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +2 -5
- package/lib/accumulate.js +47 -0
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +3 -3
- package/lib/copyProperties.js +2 -0
- package/lib/createFullPageComponent.js +3 -3
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/escapeTextForBrowser.js +6 -6
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +11 -22
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +42 -0
- package/lib/getNodeForCharacterOffset.js +2 -2
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +89 -66
- package/lib/isEventSupported.js +1 -1
- package/lib/isNode.js +3 -4
- package/lib/isTextInputElement.js +2 -3
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/memoizeStringOnly.js +4 -5
- package/lib/onlyChild.js +1 -1
- package/lib/setInnerHTML.js +12 -1
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +48 -6
- package/lib/traverseAllChildren.js +111 -55
- package/lib/update.js +1 -1
- package/lib/warning.js +9 -2
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/ReactTextComponent.js +0 -104
- package/lib/deprecated.js +0 -47
package/lib/ReactMultiChild.js
CHANGED
|
@@ -10,14 +10,12 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
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);
|
|
@@ -228,7 +226,11 @@ var ReactMultiChild = {
|
|
|
228
226
|
} finally {
|
|
229
227
|
updateDepth--;
|
|
230
228
|
if (!updateDepth) {
|
|
231
|
-
|
|
229
|
+
if (errorThrown) {
|
|
230
|
+
clearQueue();
|
|
231
|
+
} else {
|
|
232
|
+
processQueue();
|
|
233
|
+
}
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
},
|
|
@@ -240,17 +242,22 @@ var ReactMultiChild = {
|
|
|
240
242
|
* @param {ReactReconcileTransaction} transaction
|
|
241
243
|
* @internal
|
|
242
244
|
*/
|
|
243
|
-
updateChildren: function(nextNestedChildren, transaction) {
|
|
245
|
+
updateChildren: function(nextNestedChildren, transaction, context) {
|
|
244
246
|
updateDepth++;
|
|
245
247
|
var errorThrown = true;
|
|
246
248
|
try {
|
|
247
|
-
this._updateChildren(nextNestedChildren, transaction);
|
|
249
|
+
this._updateChildren(nextNestedChildren, transaction, context);
|
|
248
250
|
errorThrown = false;
|
|
249
251
|
} finally {
|
|
250
252
|
updateDepth--;
|
|
251
253
|
if (!updateDepth) {
|
|
252
|
-
|
|
254
|
+
if (errorThrown) {
|
|
255
|
+
clearQueue();
|
|
256
|
+
} else {
|
|
257
|
+
processQueue();
|
|
258
|
+
}
|
|
253
259
|
}
|
|
260
|
+
|
|
254
261
|
}
|
|
255
262
|
},
|
|
256
263
|
|
|
@@ -263,9 +270,12 @@ var ReactMultiChild = {
|
|
|
263
270
|
* @final
|
|
264
271
|
* @protected
|
|
265
272
|
*/
|
|
266
|
-
_updateChildren: function(nextNestedChildren, transaction) {
|
|
267
|
-
var nextChildren = flattenChildren(nextNestedChildren);
|
|
273
|
+
_updateChildren: function(nextNestedChildren, transaction, context) {
|
|
268
274
|
var prevChildren = this._renderedChildren;
|
|
275
|
+
var nextChildren = ReactChildReconciler.updateChildren(
|
|
276
|
+
prevChildren, nextNestedChildren, transaction, context
|
|
277
|
+
);
|
|
278
|
+
this._renderedChildren = nextChildren;
|
|
269
279
|
if (!nextChildren && !prevChildren) {
|
|
270
280
|
return;
|
|
271
281
|
}
|
|
@@ -279,12 +289,10 @@ var ReactMultiChild = {
|
|
|
279
289
|
continue;
|
|
280
290
|
}
|
|
281
291
|
var prevChild = prevChildren && prevChildren[name];
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
292
|
+
var nextChild = nextChildren[name];
|
|
293
|
+
if (prevChild === nextChild) {
|
|
285
294
|
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
286
295
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
287
|
-
prevChild.receiveComponent(nextElement, transaction);
|
|
288
296
|
prevChild._mountIndex = nextIndex;
|
|
289
297
|
} else {
|
|
290
298
|
if (prevChild) {
|
|
@@ -293,12 +301,8 @@ var ReactMultiChild = {
|
|
|
293
301
|
this._unmountChildByName(prevChild, name);
|
|
294
302
|
}
|
|
295
303
|
// The child must be instantiated before it's mounted.
|
|
296
|
-
var nextChildInstance = instantiateReactComponent(
|
|
297
|
-
nextElement,
|
|
298
|
-
null
|
|
299
|
-
);
|
|
300
304
|
this._mountChildByNameAtIndex(
|
|
301
|
-
|
|
305
|
+
nextChild, name, nextIndex, transaction, context
|
|
302
306
|
);
|
|
303
307
|
}
|
|
304
308
|
nextIndex++;
|
|
@@ -306,7 +310,7 @@ var ReactMultiChild = {
|
|
|
306
310
|
// Remove children that are no longer present.
|
|
307
311
|
for (name in prevChildren) {
|
|
308
312
|
if (prevChildren.hasOwnProperty(name) &&
|
|
309
|
-
!(nextChildren && nextChildren
|
|
313
|
+
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
310
314
|
this._unmountChildByName(prevChildren[name], name);
|
|
311
315
|
}
|
|
312
316
|
}
|
|
@@ -320,13 +324,7 @@ var ReactMultiChild = {
|
|
|
320
324
|
*/
|
|
321
325
|
unmountChildren: function() {
|
|
322
326
|
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
|
-
}
|
|
327
|
+
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
330
328
|
this._renderedChildren = null;
|
|
331
329
|
},
|
|
332
330
|
|
|
@@ -389,18 +387,21 @@ var ReactMultiChild = {
|
|
|
389
387
|
* @param {ReactReconcileTransaction} transaction
|
|
390
388
|
* @private
|
|
391
389
|
*/
|
|
392
|
-
_mountChildByNameAtIndex: function(
|
|
390
|
+
_mountChildByNameAtIndex: function(
|
|
391
|
+
child,
|
|
392
|
+
name,
|
|
393
|
+
index,
|
|
394
|
+
transaction,
|
|
395
|
+
context) {
|
|
393
396
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
394
397
|
var rootID = this._rootNodeID + name;
|
|
395
398
|
var mountImage = child.mountComponent(
|
|
396
399
|
rootID,
|
|
397
400
|
transaction,
|
|
398
|
-
|
|
401
|
+
context
|
|
399
402
|
);
|
|
400
403
|
child._mountIndex = index;
|
|
401
404
|
this.createChild(child, mountImage);
|
|
402
|
-
this._renderedChildren = this._renderedChildren || {};
|
|
403
|
-
this._renderedChildren[name] = child;
|
|
404
405
|
},
|
|
405
406
|
|
|
406
407
|
/**
|
|
@@ -415,8 +416,6 @@ var ReactMultiChild = {
|
|
|
415
416
|
_unmountChildByName: function(child, name) {
|
|
416
417
|
this.removeChild(child);
|
|
417
418
|
child._mountIndex = null;
|
|
418
|
-
child.unmountComponent();
|
|
419
|
-
delete this._renderedChildren[name];
|
|
420
419
|
}
|
|
421
420
|
|
|
422
421
|
}
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* @providesModule ReactNativeComponent
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactClass = require("./ReactClass");
|
|
15
|
+
var ReactElement = require("./ReactElement");
|
|
13
16
|
|
|
14
17
|
var assign = require("./Object.assign");
|
|
15
18
|
var invariant = require("./invariant");
|
|
@@ -17,6 +20,7 @@ var invariant = require("./invariant");
|
|
|
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
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* @providesModule ReactOwner
|
|
10
10
|
*/
|
|
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
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @typechecks static-only
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
'use strict';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* ReactPerf is a general AOP system designed to measure performance. This
|
|
@@ -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
|
*
|
|
@@ -9,15 +9,11 @@
|
|
|
9
9
|
* @providesModule ReactPropTransferer
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
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
|
*
|
|
@@ -107,57 +101,8 @@ var ReactPropTransferer = {
|
|
|
107
101
|
*/
|
|
108
102
|
mergeProps: function(oldProps, newProps) {
|
|
109
103
|
return transferInto(assign({}, oldProps), newProps);
|
|
110
|
-
},
|
|
111
|
-
|
|
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
104
|
}
|
|
105
|
+
|
|
161
106
|
};
|
|
162
107
|
|
|
163
108
|
module.exports = ReactPropTransferer;
|