react 0.8.0 → 0.10.0
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/README.md +0 -8
- package/addons.js +0 -3
- package/lib/AutoFocusMixin.js +32 -0
- package/lib/CSSCore.js +23 -22
- package/lib/CSSProperty.js +32 -1
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/ChangeEventPlugin.js +27 -5
- package/lib/ClientReactRootIndex.js +30 -0
- package/lib/CompositionEventPlugin.js +58 -10
- package/lib/DOMChildrenOperations.js +39 -3
- package/lib/DOMProperty.js +9 -5
- package/lib/DOMPropertyOperations.js +21 -8
- package/lib/Danger.js +9 -8
- package/lib/DefaultDOMPropertyConfig.js +23 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +38 -5
- package/lib/EventConstants.js +4 -1
- package/lib/EventListener.js +42 -34
- package/lib/EventPluginHub.js +118 -13
- package/lib/EventPluginRegistry.js +62 -18
- package/lib/EventPluginUtils.js +33 -4
- package/lib/EventPropagators.js +7 -43
- package/lib/ExecutionEnvironment.js +4 -1
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +160 -0
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/PooledClass.js +7 -1
- package/lib/React.js +30 -4
- package/lib/ReactBrowserComponentMixin.js +42 -0
- package/lib/ReactCSSTransitionGroup.js +65 -0
- package/lib/{ReactTransitionableChild.js → ReactCSSTransitionGroupChild.js} +22 -36
- package/lib/ReactChildren.js +4 -4
- package/lib/ReactComponent.js +163 -83
- package/lib/ReactComponentBrowserEnvironment.js +55 -71
- package/lib/ReactCompositeComponent.js +686 -119
- package/lib/ReactContext.js +67 -0
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +19 -6
- package/lib/ReactDOMButton.js +6 -1
- package/lib/ReactDOMComponent.js +66 -24
- package/lib/ReactDOMForm.js +13 -3
- package/lib/ReactDOMIDOperations.js +106 -61
- package/lib/ReactDOMImg.js +61 -0
- package/lib/ReactDOMInput.js +28 -15
- package/lib/ReactDOMOption.js +13 -8
- package/lib/ReactDOMSelect.js +38 -18
- package/lib/ReactDOMSelection.js +1 -1
- package/lib/ReactDOMTextarea.js +19 -11
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +60 -26
- package/lib/ReactDefaultPerf.js +208 -371
- package/lib/ReactDefaultPerfAnalysis.js +199 -0
- package/lib/ReactErrorUtils.js +6 -15
- package/lib/ReactEventEmitter.js +144 -146
- package/lib/ReactEventEmitterMixin.js +1 -33
- package/lib/ReactEventTopLevelCallback.js +75 -15
- package/lib/ReactInjection.js +43 -0
- package/lib/ReactInputSelection.js +3 -2
- package/lib/ReactInstanceHandles.js +36 -20
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +136 -104
- package/lib/ReactMountReady.js +2 -2
- package/lib/ReactMultiChild.js +40 -49
- package/lib/ReactMultiChildUpdateTypes.js +3 -1
- package/lib/ReactOwner.js +17 -4
- package/lib/ReactPerf.js +6 -9
- package/lib/ReactPropTransferer.js +41 -22
- package/lib/ReactPropTypeLocationNames.js +31 -0
- package/lib/{ReactComponentEnvironment.js → ReactPropTypeLocations.js} +11 -6
- package/lib/ReactPropTypes.js +249 -48
- package/lib/ReactPutListenerQueue.js +61 -0
- package/lib/ReactReconcileTransaction.js +28 -7
- package/lib/ReactRootIndex.js +36 -0
- package/lib/ReactServerRendering.js +46 -19
- package/lib/ReactServerRenderingTransaction.js +116 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +394 -0
- package/lib/ReactTextComponent.js +33 -6
- package/lib/{ReactTransitionKeySet.js → ReactTransitionChildMapping.js} +43 -48
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +133 -58
- package/lib/ReactUpdates.js +15 -12
- package/lib/ReactWithAddons.js +15 -3
- package/lib/SelectEventPlugin.js +23 -40
- package/lib/ServerReactRootIndex.js +36 -0
- package/lib/SimpleEventPlugin.js +55 -7
- package/lib/SyntheticClipboardEvent.js +8 -2
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +44 -0
- package/lib/SyntheticEvent.js +3 -2
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +5 -3
- package/lib/SyntheticMouseEvent.js +1 -1
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +11 -8
- package/lib/Transaction.js +62 -37
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/cloneWithProps.js +59 -0
- package/lib/containsNode.js +1 -1
- package/lib/copyProperties.js +1 -1
- package/lib/createArrayFrom.js +11 -14
- package/lib/createFullPageComponent.js +63 -0
- package/lib/createNodesFromMarkup.js +1 -1
- package/lib/createObjectFrom.js +1 -1
- package/lib/cx.js +3 -3
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +27 -0
- package/lib/escapeTextForBrowser.js +1 -1
- package/lib/flattenChildren.js +6 -3
- package/lib/focusNode.js +33 -0
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getActiveElement.js +5 -4
- package/lib/getEventKey.js +85 -0
- package/lib/getEventTarget.js +1 -1
- package/lib/getMarkupWrap.js +11 -1
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +6 -4
- package/lib/getUnboundedScrollPosition.js +3 -3
- package/lib/hyphenate.js +1 -1
- package/lib/instantiateReactComponent.js +70 -0
- package/lib/invariant.js +20 -12
- package/lib/isEventSupported.js +8 -12
- package/lib/isNode.js +2 -2
- package/lib/isTextInputElement.js +1 -1
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +1 -1
- package/lib/keyMirror.js +1 -1
- package/lib/keyOf.js +1 -1
- package/lib/memoizeStringOnly.js +1 -1
- package/lib/merge.js +1 -1
- package/lib/mergeHelpers.js +6 -7
- package/lib/mergeInto.js +1 -1
- package/lib/mixInto.js +1 -1
- package/lib/monitorCodeUse.js +37 -0
- package/lib/objMap.js +1 -1
- package/lib/objMapKeyVal.js +1 -1
- package/lib/onlyChild.js +43 -0
- package/lib/performanceNow.js +1 -1
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +61 -0
- package/lib/toArray.js +75 -0
- package/lib/traverseAllChildren.js +72 -9
- package/lib/update.js +159 -0
- package/lib/warning.js +48 -0
- package/package.json +3 -3
- package/react.js +0 -3
- package/ReactJSErrors.js +0 -40
- package/lib/$.js +0 -46
- package/lib/CallbackRegistry.js +0 -91
- package/lib/LinkedValueMixin.js +0 -68
- package/lib/ex.js +0 -49
- package/lib/filterAttributes.js +0 -45
- package/lib/ge.js +0 -76
- package/lib/mutateHTMLNodeWithMarkup.js +0 -100
package/lib/ReactMountReady.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -66,7 +66,7 @@ mixInto(ReactMountReady, {
|
|
|
66
66
|
for (var i = 0, l = queue.length; i < l; i++) {
|
|
67
67
|
var component = queue[i].component;
|
|
68
68
|
var callback = queue[i].callback;
|
|
69
|
-
callback.call(component
|
|
69
|
+
callback.call(component);
|
|
70
70
|
}
|
|
71
71
|
queue.length = 0;
|
|
72
72
|
}
|
package/lib/ReactMultiChild.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -23,19 +23,8 @@ var ReactComponent = require("./ReactComponent");
|
|
|
23
23
|
var ReactMultiChildUpdateTypes = require("./ReactMultiChildUpdateTypes");
|
|
24
24
|
|
|
25
25
|
var flattenChildren = require("./flattenChildren");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* Given a `curChild` and `newChild`, determines if `curChild` should be
|
|
29
|
-
* updated as opposed to being destroyed or replaced.
|
|
30
|
-
*
|
|
31
|
-
* @param {?ReactComponent} curChild
|
|
32
|
-
* @param {?ReactComponent} newChild
|
|
33
|
-
* @return {boolean} True if `curChild` should be updated with `newChild`.
|
|
34
|
-
* @protected
|
|
35
|
-
*/
|
|
36
|
-
function shouldUpdateChild(curChild, newChild) {
|
|
37
|
-
return curChild && newChild && curChild.constructor === newChild.constructor;
|
|
38
|
-
}
|
|
26
|
+
var instantiateReactComponent = require("./instantiateReactComponent");
|
|
27
|
+
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
39
28
|
|
|
40
29
|
/**
|
|
41
30
|
* Updating children of a component may trigger recursive updates. The depth is
|
|
@@ -153,7 +142,7 @@ function enqueueTextContent(parentID, textContent) {
|
|
|
153
142
|
*/
|
|
154
143
|
function processQueue() {
|
|
155
144
|
if (updateQueue.length) {
|
|
156
|
-
ReactComponent.
|
|
145
|
+
ReactComponent.BackendIDOperations.dangerouslyProcessChildrenUpdates(
|
|
157
146
|
updateQueue,
|
|
158
147
|
markupQueue
|
|
159
148
|
);
|
|
@@ -203,16 +192,19 @@ var ReactMultiChild = {
|
|
|
203
192
|
this._renderedChildren = children;
|
|
204
193
|
for (var name in children) {
|
|
205
194
|
var child = children[name];
|
|
206
|
-
if (children.hasOwnProperty(name)
|
|
195
|
+
if (children.hasOwnProperty(name)) {
|
|
196
|
+
// The rendered children must be turned into instances as they're
|
|
197
|
+
// mounted.
|
|
198
|
+
var childInstance = instantiateReactComponent(child);
|
|
199
|
+
children[name] = childInstance;
|
|
207
200
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
208
|
-
var rootID = this._rootNodeID +
|
|
209
|
-
var mountImage =
|
|
201
|
+
var rootID = this._rootNodeID + name;
|
|
202
|
+
var mountImage = childInstance.mountComponent(
|
|
210
203
|
rootID,
|
|
211
204
|
transaction,
|
|
212
205
|
this._mountDepth + 1
|
|
213
206
|
);
|
|
214
|
-
|
|
215
|
-
child._mountIndex = index;
|
|
207
|
+
childInstance._mountIndex = index;
|
|
216
208
|
mountImages.push(mountImage);
|
|
217
209
|
index++;
|
|
218
210
|
}
|
|
@@ -228,24 +220,24 @@ var ReactMultiChild = {
|
|
|
228
220
|
*/
|
|
229
221
|
updateTextContent: function(nextContent) {
|
|
230
222
|
updateDepth++;
|
|
223
|
+
var errorThrown = true;
|
|
231
224
|
try {
|
|
232
225
|
var prevChildren = this._renderedChildren;
|
|
233
226
|
// Remove any rendered children.
|
|
234
227
|
for (var name in prevChildren) {
|
|
235
|
-
if (prevChildren.hasOwnProperty(name)
|
|
236
|
-
prevChildren[name]) {
|
|
228
|
+
if (prevChildren.hasOwnProperty(name)) {
|
|
237
229
|
this._unmountChildByName(prevChildren[name], name);
|
|
238
230
|
}
|
|
239
231
|
}
|
|
240
232
|
// Set new text content.
|
|
241
233
|
this.setTextContent(nextContent);
|
|
242
|
-
|
|
234
|
+
errorThrown = false;
|
|
235
|
+
} finally {
|
|
243
236
|
updateDepth--;
|
|
244
|
-
|
|
245
|
-
|
|
237
|
+
if (!updateDepth) {
|
|
238
|
+
errorThrown ? clearQueue() : processQueue();
|
|
239
|
+
}
|
|
246
240
|
}
|
|
247
|
-
updateDepth--;
|
|
248
|
-
updateDepth || processQueue();
|
|
249
241
|
},
|
|
250
242
|
|
|
251
243
|
/**
|
|
@@ -257,15 +249,16 @@ var ReactMultiChild = {
|
|
|
257
249
|
*/
|
|
258
250
|
updateChildren: function(nextNestedChildren, transaction) {
|
|
259
251
|
updateDepth++;
|
|
252
|
+
var errorThrown = true;
|
|
260
253
|
try {
|
|
261
254
|
this._updateChildren(nextNestedChildren, transaction);
|
|
262
|
-
|
|
255
|
+
errorThrown = false;
|
|
256
|
+
} finally {
|
|
263
257
|
updateDepth--;
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
if (!updateDepth) {
|
|
259
|
+
errorThrown ? clearQueue() : processQueue();
|
|
260
|
+
}
|
|
266
261
|
}
|
|
267
|
-
updateDepth--;
|
|
268
|
-
updateDepth || processQueue();
|
|
269
262
|
},
|
|
270
263
|
|
|
271
264
|
/**
|
|
@@ -294,7 +287,7 @@ var ReactMultiChild = {
|
|
|
294
287
|
}
|
|
295
288
|
var prevChild = prevChildren && prevChildren[name];
|
|
296
289
|
var nextChild = nextChildren[name];
|
|
297
|
-
if (
|
|
290
|
+
if (shouldUpdateReactComponent(prevChild, nextChild)) {
|
|
298
291
|
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
299
292
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
300
293
|
prevChild.receiveComponent(nextChild, transaction);
|
|
@@ -305,20 +298,17 @@ var ReactMultiChild = {
|
|
|
305
298
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
306
299
|
this._unmountChildByName(prevChild, name);
|
|
307
300
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
if (nextChild) {
|
|
315
|
-
nextIndex++;
|
|
301
|
+
// The child must be instantiated before it's mounted.
|
|
302
|
+
var nextChildInstance = instantiateReactComponent(nextChild);
|
|
303
|
+
this._mountChildByNameAtIndex(
|
|
304
|
+
nextChildInstance, name, nextIndex, transaction
|
|
305
|
+
);
|
|
316
306
|
}
|
|
307
|
+
nextIndex++;
|
|
317
308
|
}
|
|
318
309
|
// Remove children that are no longer present.
|
|
319
310
|
for (name in prevChildren) {
|
|
320
311
|
if (prevChildren.hasOwnProperty(name) &&
|
|
321
|
-
prevChildren[name] &&
|
|
322
312
|
!(nextChildren && nextChildren[name])) {
|
|
323
313
|
this._unmountChildByName(prevChildren[name], name);
|
|
324
314
|
}
|
|
@@ -335,7 +325,8 @@ var ReactMultiChild = {
|
|
|
335
325
|
var renderedChildren = this._renderedChildren;
|
|
336
326
|
for (var name in renderedChildren) {
|
|
337
327
|
var renderedChild = renderedChildren[name];
|
|
338
|
-
|
|
328
|
+
// TODO: When is this not true?
|
|
329
|
+
if (renderedChild.unmountComponent) {
|
|
339
330
|
renderedChild.unmountComponent();
|
|
340
331
|
}
|
|
341
332
|
}
|
|
@@ -363,10 +354,11 @@ var ReactMultiChild = {
|
|
|
363
354
|
* Creates a child component.
|
|
364
355
|
*
|
|
365
356
|
* @param {ReactComponent} child Component to create.
|
|
357
|
+
* @param {string} mountImage Markup to insert.
|
|
366
358
|
* @protected
|
|
367
359
|
*/
|
|
368
|
-
createChild: function(child) {
|
|
369
|
-
enqueueMarkup(this._rootNodeID,
|
|
360
|
+
createChild: function(child, mountImage) {
|
|
361
|
+
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
|
|
370
362
|
},
|
|
371
363
|
|
|
372
364
|
/**
|
|
@@ -402,15 +394,14 @@ var ReactMultiChild = {
|
|
|
402
394
|
*/
|
|
403
395
|
_mountChildByNameAtIndex: function(child, name, index, transaction) {
|
|
404
396
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
405
|
-
var rootID = this._rootNodeID +
|
|
397
|
+
var rootID = this._rootNodeID + name;
|
|
406
398
|
var mountImage = child.mountComponent(
|
|
407
399
|
rootID,
|
|
408
400
|
transaction,
|
|
409
401
|
this._mountDepth + 1
|
|
410
402
|
);
|
|
411
|
-
child._mountImage = mountImage;
|
|
412
403
|
child._mountIndex = index;
|
|
413
|
-
this.createChild(child);
|
|
404
|
+
this.createChild(child, mountImage);
|
|
414
405
|
this._renderedChildren = this._renderedChildren || {};
|
|
415
406
|
this._renderedChildren[name] = child;
|
|
416
407
|
},
|
|
@@ -425,9 +416,9 @@ var ReactMultiChild = {
|
|
|
425
416
|
* @private
|
|
426
417
|
*/
|
|
427
418
|
_unmountChildByName: function(child, name) {
|
|
419
|
+
// TODO: When is this not true?
|
|
428
420
|
if (ReactComponent.isValidComponent(child)) {
|
|
429
421
|
this.removeChild(child);
|
|
430
|
-
child._mountImage = null;
|
|
431
422
|
child._mountIndex = null;
|
|
432
423
|
child.unmountComponent();
|
|
433
424
|
delete this._renderedChildren[name];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* @providesModule ReactMultiChildUpdateTypes
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
19
21
|
var keyMirror = require("./keyMirror");
|
|
20
22
|
|
|
21
23
|
/**
|
package/lib/ReactOwner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
"use strict";
|
|
20
20
|
|
|
21
|
+
var emptyObject = require("./emptyObject");
|
|
21
22
|
var invariant = require("./invariant");
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -77,7 +78,11 @@ var ReactOwner = {
|
|
|
77
78
|
addComponentAsRefTo: function(component, ref, owner) {
|
|
78
79
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
79
80
|
ReactOwner.isValidOwner(owner),
|
|
80
|
-
'addComponentAsRefTo(...): Only a ReactOwner can have refs.'
|
|
81
|
+
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
|
|
82
|
+
'usually means that you\'re trying to add a ref to a component that ' +
|
|
83
|
+
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
84
|
+
'component\'s `render` method). Try rendering this component inside of ' +
|
|
85
|
+
'a new top-level component which will hold the ref.'
|
|
81
86
|
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
82
87
|
owner.attachRef(ref, component);
|
|
83
88
|
},
|
|
@@ -94,7 +99,11 @@ var ReactOwner = {
|
|
|
94
99
|
removeComponentAsRefFrom: function(component, ref, owner) {
|
|
95
100
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
96
101
|
ReactOwner.isValidOwner(owner),
|
|
97
|
-
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs.'
|
|
102
|
+
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
|
|
103
|
+
'usually means that you\'re trying to remove a ref to a component that ' +
|
|
104
|
+
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
105
|
+
'component\'s `render` method). Try rendering this component inside of ' +
|
|
106
|
+
'a new top-level component which will hold the ref.'
|
|
98
107
|
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
99
108
|
// Check that `component` is still the current ref because we do not want to
|
|
100
109
|
// detach the ref if another component stole it.
|
|
@@ -110,6 +119,10 @@ var ReactOwner = {
|
|
|
110
119
|
*/
|
|
111
120
|
Mixin: {
|
|
112
121
|
|
|
122
|
+
construct: function() {
|
|
123
|
+
this.refs = emptyObject;
|
|
124
|
+
},
|
|
125
|
+
|
|
113
126
|
/**
|
|
114
127
|
* Lazily allocates the refs object and stores `component` as `ref`.
|
|
115
128
|
*
|
|
@@ -124,7 +137,7 @@ var ReactOwner = {
|
|
|
124
137
|
'attachRef(%s, ...): Only a component\'s owner can store a ref to it.',
|
|
125
138
|
ref
|
|
126
139
|
) : invariant(component.isOwnedBy(this)));
|
|
127
|
-
var refs = this.refs
|
|
140
|
+
var refs = this.refs === emptyObject ? (this.refs = {}) : this.refs;
|
|
128
141
|
refs[ref] = component;
|
|
129
142
|
},
|
|
130
143
|
|
package/lib/ReactPerf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
|
|
20
20
|
"use strict";
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* ReactPerf is a general AOP system designed to measure performance. This
|
|
24
|
+
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
|
|
25
|
+
*/
|
|
22
26
|
var ReactPerf = {
|
|
23
27
|
/**
|
|
24
28
|
* Boolean to enable/disable measurement. Set to false by default to prevent
|
|
@@ -33,7 +37,7 @@ var ReactPerf = {
|
|
|
33
37
|
storedMeasure: _noMeasure,
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
|
-
* Use this to wrap methods you want to measure.
|
|
40
|
+
* Use this to wrap methods you want to measure. Zero overhead in production.
|
|
37
41
|
*
|
|
38
42
|
* @param {string} objName
|
|
39
43
|
* @param {string} fnName
|
|
@@ -66,13 +70,6 @@ var ReactPerf = {
|
|
|
66
70
|
}
|
|
67
71
|
};
|
|
68
72
|
|
|
69
|
-
if ("production" !== process.env.NODE_ENV) {
|
|
70
|
-
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
71
|
-
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
|
|
72
|
-
ReactPerf.enableMeasure = ReactPerf.enableMeasure ||
|
|
73
|
-
(/[?&]react_perf\b/).test(url);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
73
|
/**
|
|
77
74
|
* Simply passes through the measured function, without measuring it.
|
|
78
75
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013 Facebook, Inc.
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -42,6 +42,8 @@ function createTransferStrategy(mergeStrategy) {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Transfer strategies dictate how props are transferred by `transferPropsTo`.
|
|
45
|
+
* NOTE: if you add any more exceptions to this list you should be sure to
|
|
46
|
+
* update `cloneWithProps()` accordingly.
|
|
45
47
|
*/
|
|
46
48
|
var TransferStrategies = {
|
|
47
49
|
/**
|
|
@@ -52,6 +54,10 @@ var TransferStrategies = {
|
|
|
52
54
|
* Transfer the `className` prop by merging them.
|
|
53
55
|
*/
|
|
54
56
|
className: createTransferStrategy(joinClasses),
|
|
57
|
+
/**
|
|
58
|
+
* Never transfer the `key` prop.
|
|
59
|
+
*/
|
|
60
|
+
key: emptyFunction,
|
|
55
61
|
/**
|
|
56
62
|
* Never transfer the `ref` prop.
|
|
57
63
|
*/
|
|
@@ -72,6 +78,33 @@ var ReactPropTransferer = {
|
|
|
72
78
|
|
|
73
79
|
TransferStrategies: TransferStrategies,
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Merge two props objects using TransferStrategies.
|
|
83
|
+
*
|
|
84
|
+
* @param {object} oldProps original props (they take precedence)
|
|
85
|
+
* @param {object} newProps new props to merge in
|
|
86
|
+
* @return {object} a new object containing both sets of props merged.
|
|
87
|
+
*/
|
|
88
|
+
mergeProps: function(oldProps, newProps) {
|
|
89
|
+
var props = merge(oldProps);
|
|
90
|
+
|
|
91
|
+
for (var thisKey in newProps) {
|
|
92
|
+
if (!newProps.hasOwnProperty(thisKey)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var transferStrategy = TransferStrategies[thisKey];
|
|
97
|
+
|
|
98
|
+
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
|
|
99
|
+
transferStrategy(props, thisKey, newProps[thisKey]);
|
|
100
|
+
} else if (!props.hasOwnProperty(thisKey)) {
|
|
101
|
+
props[thisKey] = newProps[thisKey];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return props;
|
|
106
|
+
},
|
|
107
|
+
|
|
75
108
|
/**
|
|
76
109
|
* @lends {ReactPropTransferer.prototype}
|
|
77
110
|
*/
|
|
@@ -92,37 +125,23 @@ var ReactPropTransferer = {
|
|
|
92
125
|
*/
|
|
93
126
|
transferPropsTo: function(component) {
|
|
94
127
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
95
|
-
component.
|
|
128
|
+
component._owner === this,
|
|
96
129
|
'%s: You can\'t call transferPropsTo() on a component that you ' +
|
|
97
130
|
'don\'t own, %s. This usually means you are calling ' +
|
|
98
131
|
'transferPropsTo() on a component passed in as props or children.',
|
|
99
132
|
this.constructor.displayName,
|
|
100
133
|
component.constructor.displayName
|
|
101
|
-
) : invariant(component.
|
|
134
|
+
) : invariant(component._owner === this));
|
|
135
|
+
|
|
136
|
+
component.props = ReactPropTransferer.mergeProps(
|
|
137
|
+
component.props,
|
|
138
|
+
this.props
|
|
139
|
+
);
|
|
102
140
|
|
|
103
|
-
var props = {};
|
|
104
|
-
for (var thatKey in component.props) {
|
|
105
|
-
if (component.props.hasOwnProperty(thatKey)) {
|
|
106
|
-
props[thatKey] = component.props[thatKey];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
for (var thisKey in this.props) {
|
|
110
|
-
if (!this.props.hasOwnProperty(thisKey)) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
var transferStrategy = TransferStrategies[thisKey];
|
|
114
|
-
if (transferStrategy) {
|
|
115
|
-
transferStrategy(props, thisKey, this.props[thisKey]);
|
|
116
|
-
} else if (!props.hasOwnProperty(thisKey)) {
|
|
117
|
-
props[thisKey] = this.props[thisKey];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
component.props = props;
|
|
121
141
|
return component;
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
}
|
|
125
|
-
|
|
126
145
|
};
|
|
127
146
|
|
|
128
147
|
module.exports = ReactPropTransferer;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-2014 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule ReactPropTypeLocationNames
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var ReactPropTypeLocationNames = {};
|
|
22
|
+
|
|
23
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
24
|
+
ReactPropTypeLocationNames = {
|
|
25
|
+
prop: 'prop',
|
|
26
|
+
context: 'context',
|
|
27
|
+
childContext: 'child context'
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = ReactPropTypeLocationNames;
|