react 0.12.2 → 0.13.0-beta.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 +986 -511
- package/dist/react-with-addons.js +6076 -4560
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +5386 -4170
- package/dist/react.min.js +6 -7
- package/lib/AutoFocusMixin.js +2 -2
- package/lib/BeforeInputEventPlugin.js +388 -115
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +2 -2
- package/lib/CSSPropertyOperations.js +58 -11
- package/lib/CallbackQueue.js +3 -3
- package/lib/ChangeEventPlugin.js +4 -4
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +10 -47
- package/lib/DOMProperty.js +2 -2
- package/lib/DOMPropertyOperations.js +11 -16
- package/lib/Danger.js +8 -7
- package/lib/DefaultEventPluginOrder.js +3 -4
- package/lib/EnterLeaveEventPlugin.js +2 -2
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +1 -1
- package/lib/EventPluginHub.js +10 -8
- package/lib/EventPluginRegistry.js +2 -2
- package/lib/EventPluginUtils.js +4 -4
- package/lib/EventPropagators.js +2 -2
- package/lib/ExecutionEnvironment.js +3 -4
- package/lib/FallbackCompositionState.js +89 -0
- package/lib/HTMLDOMPropertyConfig.js +23 -10
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +4 -4
- package/lib/LocalEventTrapMixin.js +10 -3
- package/lib/MobileSafariClickEventPlugin.js +2 -2
- package/lib/Object.assign.js +4 -2
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +19 -58
- package/lib/ReactBrowserComponentMixin.js +4 -14
- package/lib/ReactBrowserEventEmitter.js +6 -8
- package/lib/ReactCSSTransitionGroup.js +5 -2
- package/lib/ReactCSSTransitionGroupChild.js +20 -7
- package/lib/ReactChildReconciler.js +125 -0
- package/lib/ReactChildren.js +13 -10
- package/lib/ReactClass.js +918 -0
- package/lib/ReactComponent.js +98 -406
- package/lib/ReactComponentBrowserEnvironment.js +11 -84
- package/lib/ReactComponentEnvironment.js +57 -0
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +574 -1140
- package/lib/ReactContext.js +17 -3
- package/lib/ReactCurrentOwner.js +2 -2
- package/lib/ReactDOM.js +4 -9
- package/lib/ReactDOMButton.js +6 -7
- package/lib/ReactDOMComponent.js +123 -105
- package/lib/ReactDOMForm.js +6 -7
- package/lib/ReactDOMIDOperations.js +59 -77
- package/lib/ReactDOMIframe.js +43 -0
- package/lib/ReactDOMImg.js +5 -7
- package/lib/ReactDOMInput.js +6 -7
- package/lib/ReactDOMOption.js +6 -7
- package/lib/ReactDOMSelect.js +58 -66
- package/lib/ReactDOMSelection.js +7 -3
- package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
- package/lib/ReactDOMTextarea.js +6 -7
- package/lib/ReactDefaultBatchingStrategy.js +5 -5
- package/lib/ReactDefaultInjection.js +39 -9
- package/lib/ReactDefaultPerf.js +17 -8
- package/lib/ReactDefaultPerfAnalysis.js +2 -2
- package/lib/ReactElement.js +23 -15
- package/lib/ReactElementValidator.js +206 -89
- package/lib/ReactEmptyComponent.js +33 -15
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +4 -5
- package/lib/ReactFragment.js +172 -0
- package/lib/ReactInjection.js +8 -6
- package/lib/ReactInputSelection.js +4 -5
- package/lib/ReactInstanceHandles.js +4 -3
- package/lib/ReactInstanceMap.js +47 -0
- package/lib/ReactLifeCycle.js +35 -0
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +2 -2
- package/lib/ReactMount.js +264 -71
- package/lib/ReactMultiChild.js +50 -48
- package/lib/ReactMultiChildUpdateTypes.js +2 -2
- package/lib/ReactNativeComponent.js +59 -25
- package/lib/ReactOwner.js +5 -49
- package/lib/ReactPerf.js +22 -2
- package/lib/ReactPropTransferer.js +3 -58
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +2 -2
- package/lib/ReactPropTypes.js +17 -25
- package/lib/ReactPutListenerQueue.js +2 -2
- package/lib/ReactReconcileTransaction.js +2 -2
- package/lib/ReactReconciler.js +121 -0
- package/lib/ReactRef.js +69 -0
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerRendering.js +6 -4
- package/lib/ReactServerRenderingTransaction.js +2 -2
- package/lib/ReactStateSetters.js +2 -2
- package/lib/ReactTestUtils.js +113 -27
- package/lib/ReactTransitionChildMapping.js +8 -4
- package/lib/ReactTransitionEvents.js +2 -2
- package/lib/ReactTransitionGroup.js +53 -12
- package/lib/ReactUpdateQueue.js +295 -0
- package/lib/ReactUpdates.js +54 -62
- package/lib/ReactWithAddons.js +4 -2
- package/lib/SVGDOMPropertyConfig.js +2 -2
- package/lib/SelectEventPlugin.js +4 -4
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +4 -4
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -2
- package/lib/SyntheticEvent.js +12 -4
- package/lib/SyntheticFocusEvent.js +2 -2
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -2
- package/lib/SyntheticMouseEvent.js +3 -5
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +2 -2
- package/lib/Transaction.js +4 -4
- package/lib/ViewportMetrics.js +3 -6
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +2 -2
- package/lib/camelize.js +1 -1
- package/lib/camelizeStyleName.js +1 -1
- package/lib/cloneWithProps.js +4 -4
- package/lib/containsNode.js +1 -1
- package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
- package/lib/createFullPageComponent.js +4 -4
- package/lib/createNodesFromMarkup.js +4 -4
- package/lib/cx.js +1 -1
- package/lib/dangerousStyleValue.js +2 -2
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +1 -1
- package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
- package/lib/findDOMNode.js +51 -0
- package/lib/flattenChildren.js +12 -23
- package/lib/focusNode.js +1 -1
- package/lib/forEachAccumulated.js +2 -2
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +2 -2
- package/lib/getEventModifierState.js +2 -2
- package/lib/getEventTarget.js +2 -2
- package/lib/getIteratorFn.js +42 -0
- package/lib/getMarkupWrap.js +1 -1
- package/lib/getNodeForCharacterOffset.js +3 -3
- package/lib/getReactRootElementInContainer.js +2 -2
- package/lib/getTextContentAccessor.js +2 -2
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +1 -1
- package/lib/hyphenateStyleName.js +1 -1
- package/lib/instantiateReactComponent.js +90 -68
- package/lib/invariant.js +1 -1
- package/lib/isEventSupported.js +2 -2
- package/lib/isNode.js +4 -5
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +1 -1
- package/lib/joinClasses.js +2 -2
- package/lib/keyMirror.js +2 -2
- package/lib/keyOf.js +1 -1
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +5 -6
- package/lib/onlyChild.js +2 -2
- package/lib/performance.js +1 -1
- package/lib/performanceNow.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +26 -0
- package/lib/setInnerHTML.js +13 -2
- package/lib/setTextContent.js +40 -0
- package/lib/shallowEqual.js +2 -2
- package/lib/shouldUpdateReactComponent.js +71 -7
- package/lib/toArray.js +2 -2
- package/lib/traverseAllChildren.js +114 -56
- package/lib/update.js +2 -2
- package/lib/warning.js +20 -2
- package/package.json +1 -1
- package/lib/CompositionEventPlugin.js +0 -257
- package/lib/ReactLegacyElement.js +0 -243
- package/lib/copyProperties.js +0 -54
- package/lib/deprecated.js +0 -47
- package/lib/merge.js +0 -34
- package/lib/mergeInto.js +0 -24
- package/lib/monitorCodeUse.js +0 -30
package/lib/ReactMultiChild.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -10,14 +10,13 @@
|
|
|
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
|
|
20
|
-
var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
18
|
+
var ReactReconciler = require("./ReactReconciler");
|
|
19
|
+
var ReactChildReconciler = require("./ReactChildReconciler");
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Updating children of a component may trigger recursive updates. The depth is
|
|
@@ -135,7 +134,7 @@ function enqueueTextContent(parentID, textContent) {
|
|
|
135
134
|
*/
|
|
136
135
|
function processQueue() {
|
|
137
136
|
if (updateQueue.length) {
|
|
138
|
-
|
|
137
|
+
ReactComponentEnvironment.processChildrenUpdates(
|
|
139
138
|
updateQueue,
|
|
140
139
|
markupQueue
|
|
141
140
|
);
|
|
@@ -178,26 +177,25 @@ var ReactMultiChild = {
|
|
|
178
177
|
* @return {array} An array of mounted representations.
|
|
179
178
|
* @internal
|
|
180
179
|
*/
|
|
181
|
-
mountChildren: function(nestedChildren, transaction) {
|
|
182
|
-
var children =
|
|
180
|
+
mountChildren: function(nestedChildren, transaction, context) {
|
|
181
|
+
var children = ReactChildReconciler.instantiateChildren(
|
|
182
|
+
nestedChildren, transaction, context
|
|
183
|
+
);
|
|
184
|
+
this._renderedChildren = children;
|
|
183
185
|
var mountImages = [];
|
|
184
186
|
var index = 0;
|
|
185
|
-
this._renderedChildren = children;
|
|
186
187
|
for (var name in children) {
|
|
187
|
-
var child = children[name];
|
|
188
188
|
if (children.hasOwnProperty(name)) {
|
|
189
|
-
|
|
190
|
-
// mounted.
|
|
191
|
-
var childInstance = instantiateReactComponent(child, null);
|
|
192
|
-
children[name] = childInstance;
|
|
189
|
+
var child = children[name];
|
|
193
190
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
194
191
|
var rootID = this._rootNodeID + name;
|
|
195
|
-
var mountImage =
|
|
192
|
+
var mountImage = ReactReconciler.mountComponent(
|
|
193
|
+
child,
|
|
196
194
|
rootID,
|
|
197
195
|
transaction,
|
|
198
|
-
|
|
196
|
+
context
|
|
199
197
|
);
|
|
200
|
-
|
|
198
|
+
child._mountIndex = index;
|
|
201
199
|
mountImages.push(mountImage);
|
|
202
200
|
index++;
|
|
203
201
|
}
|
|
@@ -217,6 +215,8 @@ var ReactMultiChild = {
|
|
|
217
215
|
try {
|
|
218
216
|
var prevChildren = this._renderedChildren;
|
|
219
217
|
// Remove any rendered children.
|
|
218
|
+
ReactChildReconciler.unmountChildren(prevChildren);
|
|
219
|
+
// TODO: The setTextContent operation should be enough
|
|
220
220
|
for (var name in prevChildren) {
|
|
221
221
|
if (prevChildren.hasOwnProperty(name)) {
|
|
222
222
|
this._unmountChildByName(prevChildren[name], name);
|
|
@@ -228,7 +228,11 @@ var ReactMultiChild = {
|
|
|
228
228
|
} finally {
|
|
229
229
|
updateDepth--;
|
|
230
230
|
if (!updateDepth) {
|
|
231
|
-
|
|
231
|
+
if (errorThrown) {
|
|
232
|
+
clearQueue();
|
|
233
|
+
} else {
|
|
234
|
+
processQueue();
|
|
235
|
+
}
|
|
232
236
|
}
|
|
233
237
|
}
|
|
234
238
|
},
|
|
@@ -240,17 +244,22 @@ var ReactMultiChild = {
|
|
|
240
244
|
* @param {ReactReconcileTransaction} transaction
|
|
241
245
|
* @internal
|
|
242
246
|
*/
|
|
243
|
-
updateChildren: function(nextNestedChildren, transaction) {
|
|
247
|
+
updateChildren: function(nextNestedChildren, transaction, context) {
|
|
244
248
|
updateDepth++;
|
|
245
249
|
var errorThrown = true;
|
|
246
250
|
try {
|
|
247
|
-
this._updateChildren(nextNestedChildren, transaction);
|
|
251
|
+
this._updateChildren(nextNestedChildren, transaction, context);
|
|
248
252
|
errorThrown = false;
|
|
249
253
|
} finally {
|
|
250
254
|
updateDepth--;
|
|
251
255
|
if (!updateDepth) {
|
|
252
|
-
|
|
256
|
+
if (errorThrown) {
|
|
257
|
+
clearQueue();
|
|
258
|
+
} else {
|
|
259
|
+
processQueue();
|
|
260
|
+
}
|
|
253
261
|
}
|
|
262
|
+
|
|
254
263
|
}
|
|
255
264
|
},
|
|
256
265
|
|
|
@@ -263,9 +272,12 @@ var ReactMultiChild = {
|
|
|
263
272
|
* @final
|
|
264
273
|
* @protected
|
|
265
274
|
*/
|
|
266
|
-
_updateChildren: function(nextNestedChildren, transaction) {
|
|
267
|
-
var nextChildren = flattenChildren(nextNestedChildren);
|
|
275
|
+
_updateChildren: function(nextNestedChildren, transaction, context) {
|
|
268
276
|
var prevChildren = this._renderedChildren;
|
|
277
|
+
var nextChildren = ReactChildReconciler.updateChildren(
|
|
278
|
+
prevChildren, nextNestedChildren, transaction, context
|
|
279
|
+
);
|
|
280
|
+
this._renderedChildren = nextChildren;
|
|
269
281
|
if (!nextChildren && !prevChildren) {
|
|
270
282
|
return;
|
|
271
283
|
}
|
|
@@ -279,12 +291,10 @@ var ReactMultiChild = {
|
|
|
279
291
|
continue;
|
|
280
292
|
}
|
|
281
293
|
var prevChild = prevChildren && prevChildren[name];
|
|
282
|
-
var
|
|
283
|
-
|
|
284
|
-
if (shouldUpdateReactComponent(prevElement, nextElement)) {
|
|
294
|
+
var nextChild = nextChildren[name];
|
|
295
|
+
if (prevChild === nextChild) {
|
|
285
296
|
this.moveChild(prevChild, nextIndex, lastIndex);
|
|
286
297
|
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
|
|
287
|
-
prevChild.receiveComponent(nextElement, transaction);
|
|
288
298
|
prevChild._mountIndex = nextIndex;
|
|
289
299
|
} else {
|
|
290
300
|
if (prevChild) {
|
|
@@ -293,12 +303,8 @@ var ReactMultiChild = {
|
|
|
293
303
|
this._unmountChildByName(prevChild, name);
|
|
294
304
|
}
|
|
295
305
|
// The child must be instantiated before it's mounted.
|
|
296
|
-
var nextChildInstance = instantiateReactComponent(
|
|
297
|
-
nextElement,
|
|
298
|
-
null
|
|
299
|
-
);
|
|
300
306
|
this._mountChildByNameAtIndex(
|
|
301
|
-
|
|
307
|
+
nextChild, name, nextIndex, transaction, context
|
|
302
308
|
);
|
|
303
309
|
}
|
|
304
310
|
nextIndex++;
|
|
@@ -306,7 +312,7 @@ var ReactMultiChild = {
|
|
|
306
312
|
// Remove children that are no longer present.
|
|
307
313
|
for (name in prevChildren) {
|
|
308
314
|
if (prevChildren.hasOwnProperty(name) &&
|
|
309
|
-
!(nextChildren && nextChildren
|
|
315
|
+
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
310
316
|
this._unmountChildByName(prevChildren[name], name);
|
|
311
317
|
}
|
|
312
318
|
}
|
|
@@ -320,13 +326,7 @@ var ReactMultiChild = {
|
|
|
320
326
|
*/
|
|
321
327
|
unmountChildren: function() {
|
|
322
328
|
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
|
-
}
|
|
329
|
+
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
330
330
|
this._renderedChildren = null;
|
|
331
331
|
},
|
|
332
332
|
|
|
@@ -389,18 +389,22 @@ var ReactMultiChild = {
|
|
|
389
389
|
* @param {ReactReconcileTransaction} transaction
|
|
390
390
|
* @private
|
|
391
391
|
*/
|
|
392
|
-
_mountChildByNameAtIndex: function(
|
|
392
|
+
_mountChildByNameAtIndex: function(
|
|
393
|
+
child,
|
|
394
|
+
name,
|
|
395
|
+
index,
|
|
396
|
+
transaction,
|
|
397
|
+
context) {
|
|
393
398
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
394
399
|
var rootID = this._rootNodeID + name;
|
|
395
|
-
var mountImage =
|
|
400
|
+
var mountImage = ReactReconciler.mountComponent(
|
|
401
|
+
child,
|
|
396
402
|
rootID,
|
|
397
403
|
transaction,
|
|
398
|
-
|
|
404
|
+
context
|
|
399
405
|
);
|
|
400
406
|
child._mountIndex = index;
|
|
401
407
|
this.createChild(child, mountImage);
|
|
402
|
-
this._renderedChildren = this._renderedChildren || {};
|
|
403
|
-
this._renderedChildren[name] = child;
|
|
404
408
|
},
|
|
405
409
|
|
|
406
410
|
/**
|
|
@@ -415,8 +419,6 @@ var ReactMultiChild = {
|
|
|
415
419
|
_unmountChildByName: function(child, name) {
|
|
416
420
|
this.removeChild(child);
|
|
417
421
|
child._mountIndex = null;
|
|
418
|
-
child.unmountComponent();
|
|
419
|
-
delete this._renderedChildren[name];
|
|
420
422
|
}
|
|
421
423
|
|
|
422
424
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @providesModule ReactMultiChildUpdateTypes
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var keyMirror = require("./keyMirror");
|
|
15
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014, Facebook, Inc.
|
|
2
|
+
* Copyright 2014-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -9,14 +9,16 @@
|
|
|
9
9
|
* @providesModule ReactNativeComponent
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
'use strict';
|
|
13
13
|
|
|
14
14
|
var assign = require("./Object.assign");
|
|
15
15
|
var invariant = require("./invariant");
|
|
16
16
|
|
|
17
|
+
var autoGenerateWrapperClass = null;
|
|
17
18
|
var genericComponentClass = null;
|
|
18
19
|
// This registry keeps track of wrapper classes around native tags
|
|
19
20
|
var tagToComponentClass = {};
|
|
21
|
+
var textComponentClass = null;
|
|
20
22
|
|
|
21
23
|
var ReactNativeComponentInjection = {
|
|
22
24
|
// This accepts a class that receives the tag string. This is a catch all
|
|
@@ -24,45 +26,77 @@ var ReactNativeComponentInjection = {
|
|
|
24
26
|
injectGenericComponentClass: function(componentClass) {
|
|
25
27
|
genericComponentClass = componentClass;
|
|
26
28
|
},
|
|
29
|
+
// This accepts a text component class that takes the text string to be
|
|
30
|
+
// rendered as props.
|
|
31
|
+
injectTextComponentClass: function(componentClass) {
|
|
32
|
+
textComponentClass = componentClass;
|
|
33
|
+
},
|
|
27
34
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
28
35
|
// tag. That particular tag will use this class instead of the generic one.
|
|
29
36
|
injectComponentClasses: function(componentClasses) {
|
|
30
37
|
assign(tagToComponentClass, componentClasses);
|
|
38
|
+
},
|
|
39
|
+
// Temporary hack since we expect DOM refs to behave like composites,
|
|
40
|
+
// for this release.
|
|
41
|
+
injectAutoWrapper: function(wrapperFactory) {
|
|
42
|
+
autoGenerateWrapperClass = wrapperFactory;
|
|
31
43
|
}
|
|
32
44
|
};
|
|
33
45
|
|
|
34
46
|
/**
|
|
35
|
-
*
|
|
47
|
+
* Get a composite component wrapper class for a specific tag.
|
|
36
48
|
*
|
|
37
|
-
* @param {
|
|
38
|
-
* @
|
|
39
|
-
* @return {ReactComponent} component The injected empty component.
|
|
49
|
+
* @param {ReactElement} element The tag for which to get the class.
|
|
50
|
+
* @return {function} The React class constructor function.
|
|
40
51
|
*/
|
|
41
|
-
function
|
|
52
|
+
function getComponentClassForElement(element) {
|
|
53
|
+
if (typeof element.type === 'function') {
|
|
54
|
+
return element.type;
|
|
55
|
+
}
|
|
56
|
+
var tag = element.type;
|
|
42
57
|
var componentClass = tagToComponentClass[tag];
|
|
43
58
|
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);
|
|
59
|
+
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
|
|
50
60
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
return componentClass;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get a native internal component class for a specific tag.
|
|
66
|
+
*
|
|
67
|
+
* @param {ReactElement} element The element to create.
|
|
68
|
+
* @return {function} The internal class constructor function.
|
|
69
|
+
*/
|
|
70
|
+
function createInternalComponent(element) {
|
|
71
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
72
|
+
genericComponentClass,
|
|
73
|
+
'There is no registered component for the tag %s',
|
|
74
|
+
element.type
|
|
75
|
+
) : invariant(genericComponentClass));
|
|
76
|
+
return new genericComponentClass(element.type, element.props);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {ReactText} text
|
|
81
|
+
* @return {ReactComponent}
|
|
82
|
+
*/
|
|
83
|
+
function createInstanceForText(text) {
|
|
84
|
+
return new textComponentClass(text);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {ReactComponent} component
|
|
89
|
+
* @return {boolean}
|
|
90
|
+
*/
|
|
91
|
+
function isTextComponent(component) {
|
|
92
|
+
return component instanceof textComponentClass;
|
|
62
93
|
}
|
|
63
94
|
|
|
64
95
|
var ReactNativeComponent = {
|
|
65
|
-
|
|
96
|
+
getComponentClassForElement: getComponentClassForElement,
|
|
97
|
+
createInternalComponent: createInternalComponent,
|
|
98
|
+
createInstanceForText: createInstanceForText,
|
|
99
|
+
isTextComponent: isTextComponent,
|
|
66
100
|
injection: ReactNativeComponentInjection
|
|
67
101
|
};
|
|
68
102
|
|
package/lib/ReactOwner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -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
|
*
|