react 0.13.3 → 0.14.0-beta1
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 +5 -2
- package/addons.js +7 -0
- package/dist/JSXTransformer.js +4101 -2432
- package/dist/react-with-addons.js +4389 -6277
- package/dist/react-with-addons.min.js +6 -8
- package/dist/react.js +4028 -5697
- package/dist/react.min.js +5 -6
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
- package/lib/BeforeInputEventPlugin.js +30 -118
- package/lib/CSSCore.js +12 -23
- package/lib/CSSProperty.js +4 -3
- package/lib/CSSPropertyOperations.js +14 -30
- package/lib/CallbackQueue.js +7 -10
- package/lib/ChangeEventPlugin.js +26 -88
- package/lib/ClientReactRootIndex.js +2 -2
- package/lib/DOMChildrenOperations.js +13 -33
- package/lib/DOMProperty.js +86 -147
- package/lib/DOMPropertyOperations.js +91 -67
- package/lib/Danger.js +19 -62
- package/lib/DefaultEventPluginOrder.js +2 -12
- package/lib/EnterLeaveEventPlugin.js +11 -33
- package/lib/EventConstants.js +2 -2
- package/lib/EventListener.js +11 -13
- package/lib/EventPluginHub.js +44 -47
- package/lib/EventPluginRegistry.js +18 -74
- package/lib/EventPluginUtils.js +33 -44
- package/lib/EventPropagators.js +23 -26
- package/lib/ExecutionEnvironment.js +4 -8
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +15 -20
- package/lib/LinkedStateMixin.js +3 -6
- package/lib/LinkedValueUtils.js +71 -89
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +20 -11
- package/lib/React.js +9 -129
- package/lib/ReactBrowserComponentMixin.js +9 -2
- package/lib/ReactBrowserEventEmitter.js +26 -82
- package/lib/ReactCSSTransitionGroup.js +13 -24
- package/lib/ReactCSSTransitionGroupChild.js +26 -28
- package/lib/ReactChildReconciler.js +11 -19
- package/lib/ReactChildren.js +24 -31
- package/lib/ReactClass.js +96 -267
- package/lib/ReactComponent.js +28 -57
- package/lib/ReactComponentBrowserEnvironment.js +4 -8
- package/lib/ReactComponentEnvironment.js +6 -12
- package/lib/ReactComponentWithPureRenderMixin.js +6 -7
- package/lib/ReactCompositeComponent.js +115 -381
- package/lib/ReactCurrentOwner.js +1 -3
- package/lib/ReactDOM.js +4 -2
- package/lib/ReactDOMButton.js +16 -28
- package/lib/ReactDOMClient.js +90 -0
- package/lib/ReactDOMComponent.js +468 -156
- package/lib/ReactDOMIDOperations.js +25 -22
- package/lib/ReactDOMInput.js +79 -108
- package/lib/ReactDOMOption.js +58 -20
- package/lib/ReactDOMSelect.js +95 -83
- package/lib/ReactDOMSelection.js +5 -20
- package/lib/ReactDOMServer.js +24 -0
- package/lib/ReactDOMTextComponent.js +17 -18
- package/lib/ReactDOMTextarea.js +44 -69
- package/lib/ReactDefaultBatchingStrategy.js +9 -13
- package/lib/ReactDefaultInjection.js +20 -76
- package/lib/ReactDefaultPerf.js +36 -69
- package/lib/ReactDefaultPerfAnalysis.js +8 -14
- package/lib/ReactElement.js +26 -120
- package/lib/ReactElementValidator.js +56 -192
- package/lib/ReactEmptyComponent.js +7 -11
- package/lib/ReactErrorUtils.js +3 -3
- package/lib/ReactEventEmitterMixin.js +3 -13
- package/lib/ReactEventListener.js +58 -40
- package/lib/ReactFragment.js +33 -59
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +14 -23
- package/lib/ReactInstanceHandles.js +29 -58
- package/lib/ReactInstanceMap.js +5 -5
- package/lib/ReactIsomorphic.js +70 -0
- package/lib/ReactLink.js +2 -4
- package/lib/ReactMarkupChecksum.js +5 -10
- package/lib/ReactMount.js +142 -285
- package/lib/ReactMultiChild.js +19 -45
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -15
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +7 -24
- package/lib/ReactPerf.js +8 -12
- package/lib/ReactPropTransferer.js +4 -4
- package/lib/ReactPropTypeLocationNames.js +2 -2
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +41 -61
- package/lib/ReactReconcileTransaction.js +11 -36
- package/lib/ReactReconciler.js +14 -26
- package/lib/ReactRef.js +5 -8
- package/lib/ReactRootIndex.js +2 -2
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +20 -15
- package/lib/ReactServerRenderingTransaction.js +9 -34
- package/lib/ReactStateSetters.js +6 -6
- package/lib/ReactTestUtils.js +137 -190
- package/lib/ReactTransitionChildMapping.js +5 -7
- package/lib/ReactTransitionEvents.js +5 -5
- package/lib/ReactTransitionGroup.js +30 -52
- package/lib/ReactUpdateQueue.js +69 -107
- package/lib/ReactUpdates.js +26 -81
- package/lib/ReactWithAddons.js +5 -6
- package/lib/SVGDOMPropertyConfig.js +39 -4
- package/lib/SelectEventPlugin.js +31 -33
- package/lib/ServerReactRootIndex.js +2 -2
- package/lib/SimpleEventPlugin.js +138 -130
- package/lib/SyntheticClipboardEvent.js +5 -9
- package/lib/SyntheticCompositionEvent.js +4 -10
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +14 -15
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +4 -10
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +10 -16
- package/lib/SyntheticTouchEvent.js +3 -3
- package/lib/SyntheticUIEvent.js +5 -5
- package/lib/SyntheticWheelEvent.js +13 -17
- package/lib/Transaction.js +22 -28
- package/lib/ViewportMetrics.js +2 -2
- package/lib/accumulateInto.js +2 -5
- package/lib/adler32.js +2 -4
- package/lib/camelize.js +4 -2
- package/lib/camelizeStyleName.js +2 -2
- package/lib/cloneWithProps.js +6 -12
- package/lib/containsNode.js +29 -16
- package/lib/createArrayFromMixed.js +17 -16
- package/lib/createNodesFromMarkup.js +6 -8
- package/lib/dangerousStyleValue.js +2 -3
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +10 -4
- package/lib/emptyObject.js +1 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +7 -27
- package/lib/flattenChildren.js +4 -10
- package/lib/focusNode.js +2 -3
- package/lib/forEachAccumulated.js +3 -3
- package/lib/getActiveElement.js +4 -2
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +2 -4
- package/lib/getMarkupWrap.js +18 -40
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getTextContentAccessor.js +2 -4
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +3 -1
- package/lib/hyphenateStyleName.js +2 -2
- package/lib/instantiateReactComponent.js +23 -43
- package/lib/invariant.js +8 -12
- package/lib/isEventSupported.js +7 -10
- package/lib/isNode.js +4 -6
- package/lib/isTextInputElement.js +3 -4
- package/lib/isTextNode.js +3 -1
- package/lib/joinClasses.js +3 -3
- package/lib/keyMirror.js +3 -6
- package/lib/keyOf.js +4 -3
- package/lib/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +2 -2
- package/lib/onlyChild.js +2 -5
- package/lib/performance.js +2 -5
- package/lib/performanceNow.js +3 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +16 -0
- package/lib/setInnerHTML.js +11 -8
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +24 -0
- package/lib/shallowEqual.js +17 -11
- package/lib/shouldUpdateReactComponent.js +3 -64
- package/lib/toArray.js +8 -19
- package/lib/traverseAllChildren.js +23 -90
- package/lib/update.js +25 -85
- package/lib/validateDOMNesting.js +363 -0
- package/lib/warning.js +15 -17
- package/package.json +3 -3
- package/react.js +53 -1
- package/lib/LocalEventTrapMixin.js +0 -53
- package/lib/MobileSafariClickEventPlugin.js +0 -56
- package/lib/ReactContext.js +0 -74
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/ReactPutListenerQueue.js +0 -54
- package/lib/createFullPageComponent.js +0 -58
- package/lib/cx.js +0 -52
- package/lib/getReactRootElementInContainer.js +0 -33
package/lib/ReactMultiChild.js
CHANGED
|
@@ -134,10 +134,7 @@ function enqueueTextContent(parentID, textContent) {
|
|
|
134
134
|
*/
|
|
135
135
|
function processQueue() {
|
|
136
136
|
if (updateQueue.length) {
|
|
137
|
-
ReactComponentEnvironment.processChildrenUpdates(
|
|
138
|
-
updateQueue,
|
|
139
|
-
markupQueue
|
|
140
|
-
);
|
|
137
|
+
ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
|
|
141
138
|
clearQueue();
|
|
142
139
|
}
|
|
143
140
|
}
|
|
@@ -177,10 +174,8 @@ var ReactMultiChild = {
|
|
|
177
174
|
* @return {array} An array of mounted representations.
|
|
178
175
|
* @internal
|
|
179
176
|
*/
|
|
180
|
-
mountChildren: function(nestedChildren, transaction, context) {
|
|
181
|
-
var children = ReactChildReconciler.instantiateChildren(
|
|
182
|
-
nestedChildren, transaction, context
|
|
183
|
-
);
|
|
177
|
+
mountChildren: function (nestedChildren, transaction, context) {
|
|
178
|
+
var children = ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
|
|
184
179
|
this._renderedChildren = children;
|
|
185
180
|
var mountImages = [];
|
|
186
181
|
var index = 0;
|
|
@@ -189,12 +184,7 @@ var ReactMultiChild = {
|
|
|
189
184
|
var child = children[name];
|
|
190
185
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
191
186
|
var rootID = this._rootNodeID + name;
|
|
192
|
-
var mountImage = ReactReconciler.mountComponent(
|
|
193
|
-
child,
|
|
194
|
-
rootID,
|
|
195
|
-
transaction,
|
|
196
|
-
context
|
|
197
|
-
);
|
|
187
|
+
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
198
188
|
child._mountIndex = index;
|
|
199
189
|
mountImages.push(mountImage);
|
|
200
190
|
index++;
|
|
@@ -209,7 +199,7 @@ var ReactMultiChild = {
|
|
|
209
199
|
* @param {string} nextContent String of content.
|
|
210
200
|
* @internal
|
|
211
201
|
*/
|
|
212
|
-
updateTextContent: function(nextContent) {
|
|
202
|
+
updateTextContent: function (nextContent) {
|
|
213
203
|
updateDepth++;
|
|
214
204
|
var errorThrown = true;
|
|
215
205
|
try {
|
|
@@ -244,7 +234,7 @@ var ReactMultiChild = {
|
|
|
244
234
|
* @param {ReactReconcileTransaction} transaction
|
|
245
235
|
* @internal
|
|
246
236
|
*/
|
|
247
|
-
updateChildren: function(nextNestedChildren, transaction, context) {
|
|
237
|
+
updateChildren: function (nextNestedChildren, transaction, context) {
|
|
248
238
|
updateDepth++;
|
|
249
239
|
var errorThrown = true;
|
|
250
240
|
try {
|
|
@@ -259,7 +249,6 @@ var ReactMultiChild = {
|
|
|
259
249
|
processQueue();
|
|
260
250
|
}
|
|
261
251
|
}
|
|
262
|
-
|
|
263
252
|
}
|
|
264
253
|
},
|
|
265
254
|
|
|
@@ -272,11 +261,9 @@ var ReactMultiChild = {
|
|
|
272
261
|
* @final
|
|
273
262
|
* @protected
|
|
274
263
|
*/
|
|
275
|
-
_updateChildren: function(nextNestedChildren, transaction, context) {
|
|
264
|
+
_updateChildren: function (nextNestedChildren, transaction, context) {
|
|
276
265
|
var prevChildren = this._renderedChildren;
|
|
277
|
-
var nextChildren = ReactChildReconciler.updateChildren(
|
|
278
|
-
prevChildren, nextNestedChildren, transaction, context
|
|
279
|
-
);
|
|
266
|
+
var nextChildren = ReactChildReconciler.updateChildren(prevChildren, nextNestedChildren, transaction, context);
|
|
280
267
|
this._renderedChildren = nextChildren;
|
|
281
268
|
if (!nextChildren && !prevChildren) {
|
|
282
269
|
return;
|
|
@@ -303,16 +290,13 @@ var ReactMultiChild = {
|
|
|
303
290
|
this._unmountChildByName(prevChild, name);
|
|
304
291
|
}
|
|
305
292
|
// The child must be instantiated before it's mounted.
|
|
306
|
-
this._mountChildByNameAtIndex(
|
|
307
|
-
nextChild, name, nextIndex, transaction, context
|
|
308
|
-
);
|
|
293
|
+
this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
|
|
309
294
|
}
|
|
310
295
|
nextIndex++;
|
|
311
296
|
}
|
|
312
297
|
// Remove children that are no longer present.
|
|
313
298
|
for (name in prevChildren) {
|
|
314
|
-
if (prevChildren.hasOwnProperty(name) &&
|
|
315
|
-
!(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
299
|
+
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
316
300
|
this._unmountChildByName(prevChildren[name], name);
|
|
317
301
|
}
|
|
318
302
|
}
|
|
@@ -324,7 +308,7 @@ var ReactMultiChild = {
|
|
|
324
308
|
*
|
|
325
309
|
* @internal
|
|
326
310
|
*/
|
|
327
|
-
unmountChildren: function() {
|
|
311
|
+
unmountChildren: function () {
|
|
328
312
|
var renderedChildren = this._renderedChildren;
|
|
329
313
|
ReactChildReconciler.unmountChildren(renderedChildren);
|
|
330
314
|
this._renderedChildren = null;
|
|
@@ -338,7 +322,7 @@ var ReactMultiChild = {
|
|
|
338
322
|
* @param {number} lastIndex Last index visited of the siblings of `child`.
|
|
339
323
|
* @protected
|
|
340
324
|
*/
|
|
341
|
-
moveChild: function(child, toIndex, lastIndex) {
|
|
325
|
+
moveChild: function (child, toIndex, lastIndex) {
|
|
342
326
|
// If the index of `child` is less than `lastIndex`, then it needs to
|
|
343
327
|
// be moved. Otherwise, we do not need to move it because a child will be
|
|
344
328
|
// inserted or moved before `child`.
|
|
@@ -354,7 +338,7 @@ var ReactMultiChild = {
|
|
|
354
338
|
* @param {string} mountImage Markup to insert.
|
|
355
339
|
* @protected
|
|
356
340
|
*/
|
|
357
|
-
createChild: function(child, mountImage) {
|
|
341
|
+
createChild: function (child, mountImage) {
|
|
358
342
|
enqueueMarkup(this._rootNodeID, mountImage, child._mountIndex);
|
|
359
343
|
},
|
|
360
344
|
|
|
@@ -364,7 +348,7 @@ var ReactMultiChild = {
|
|
|
364
348
|
* @param {ReactComponent} child Child to remove.
|
|
365
349
|
* @protected
|
|
366
350
|
*/
|
|
367
|
-
removeChild: function(child) {
|
|
351
|
+
removeChild: function (child) {
|
|
368
352
|
enqueueRemove(this._rootNodeID, child._mountIndex);
|
|
369
353
|
},
|
|
370
354
|
|
|
@@ -374,7 +358,7 @@ var ReactMultiChild = {
|
|
|
374
358
|
* @param {string} textContent Text content to set.
|
|
375
359
|
* @protected
|
|
376
360
|
*/
|
|
377
|
-
setTextContent: function(textContent) {
|
|
361
|
+
setTextContent: function (textContent) {
|
|
378
362
|
enqueueTextContent(this._rootNodeID, textContent);
|
|
379
363
|
},
|
|
380
364
|
|
|
@@ -389,20 +373,10 @@ var ReactMultiChild = {
|
|
|
389
373
|
* @param {ReactReconcileTransaction} transaction
|
|
390
374
|
* @private
|
|
391
375
|
*/
|
|
392
|
-
_mountChildByNameAtIndex: function(
|
|
393
|
-
child,
|
|
394
|
-
name,
|
|
395
|
-
index,
|
|
396
|
-
transaction,
|
|
397
|
-
context) {
|
|
376
|
+
_mountChildByNameAtIndex: function (child, name, index, transaction, context) {
|
|
398
377
|
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
|
|
399
378
|
var rootID = this._rootNodeID + name;
|
|
400
|
-
var mountImage = ReactReconciler.mountComponent(
|
|
401
|
-
child,
|
|
402
|
-
rootID,
|
|
403
|
-
transaction,
|
|
404
|
-
context
|
|
405
|
-
);
|
|
379
|
+
var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
|
|
406
380
|
child._mountIndex = index;
|
|
407
381
|
this.createChild(child, mountImage);
|
|
408
382
|
},
|
|
@@ -416,7 +390,7 @@ var ReactMultiChild = {
|
|
|
416
390
|
* @param {string} name Name of the child in `this._renderedChildren`.
|
|
417
391
|
* @private
|
|
418
392
|
*/
|
|
419
|
-
_unmountChildByName: function(child, name) {
|
|
393
|
+
_unmountChildByName: function (child, name) {
|
|
420
394
|
this.removeChild(child);
|
|
421
395
|
child._mountIndex = null;
|
|
422
396
|
}
|
|
@@ -425,4 +399,4 @@ var ReactMultiChild = {
|
|
|
425
399
|
|
|
426
400
|
};
|
|
427
401
|
|
|
428
|
-
module.exports = ReactMultiChild;
|
|
402
|
+
module.exports = ReactMultiChild;
|
|
@@ -16,30 +16,25 @@ var invariant = require("./invariant");
|
|
|
16
16
|
|
|
17
17
|
var autoGenerateWrapperClass = null;
|
|
18
18
|
var genericComponentClass = null;
|
|
19
|
-
// This registry keeps track of wrapper classes around native tags
|
|
19
|
+
// This registry keeps track of wrapper classes around native tags.
|
|
20
20
|
var tagToComponentClass = {};
|
|
21
21
|
var textComponentClass = null;
|
|
22
22
|
|
|
23
23
|
var ReactNativeComponentInjection = {
|
|
24
24
|
// This accepts a class that receives the tag string. This is a catch all
|
|
25
25
|
// that can render any kind of tag.
|
|
26
|
-
injectGenericComponentClass: function(componentClass) {
|
|
26
|
+
injectGenericComponentClass: function (componentClass) {
|
|
27
27
|
genericComponentClass = componentClass;
|
|
28
28
|
},
|
|
29
29
|
// This accepts a text component class that takes the text string to be
|
|
30
30
|
// rendered as props.
|
|
31
|
-
injectTextComponentClass: function(componentClass) {
|
|
31
|
+
injectTextComponentClass: function (componentClass) {
|
|
32
32
|
textComponentClass = componentClass;
|
|
33
33
|
},
|
|
34
34
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
35
35
|
// tag. That particular tag will use this class instead of the generic one.
|
|
36
|
-
injectComponentClasses: function(componentClasses) {
|
|
36
|
+
injectComponentClasses: function (componentClasses) {
|
|
37
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;
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
40
|
|
|
@@ -68,11 +63,7 @@ function getComponentClassForElement(element) {
|
|
|
68
63
|
* @return {function} The internal class constructor function.
|
|
69
64
|
*/
|
|
70
65
|
function createInternalComponent(element) {
|
|
71
|
-
|
|
72
|
-
genericComponentClass,
|
|
73
|
-
'There is no registered component for the tag %s',
|
|
74
|
-
element.type
|
|
75
|
-
) : invariant(genericComponentClass));
|
|
66
|
+
!genericComponentClass ? 'production' !== process.env.NODE_ENV ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
|
|
76
67
|
return new genericComponentClass(element.type, element.props);
|
|
77
68
|
}
|
|
78
69
|
|
|
@@ -100,4 +91,4 @@ var ReactNativeComponent = {
|
|
|
100
91
|
injection: ReactNativeComponentInjection
|
|
101
92
|
};
|
|
102
93
|
|
|
103
|
-
module.exports = ReactNativeComponent;
|
|
94
|
+
module.exports = ReactNativeComponent;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNoopUpdateQueue
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var warning = require("./warning");
|
|
15
|
+
|
|
16
|
+
function warnTDZ(publicInstance, callerName) {
|
|
17
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
18
|
+
'production' !== process.env.NODE_ENV ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This is the abstract API for an update queue.
|
|
24
|
+
*/
|
|
25
|
+
var ReactNoopUpdateQueue = {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Checks whether or not this composite component is mounted.
|
|
29
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
|
30
|
+
* @return {boolean} True if mounted, false otherwise.
|
|
31
|
+
* @protected
|
|
32
|
+
* @final
|
|
33
|
+
*/
|
|
34
|
+
isMounted: function (publicInstance) {
|
|
35
|
+
return false;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Enqueue a callback that will be executed after all the pending updates
|
|
40
|
+
* have processed.
|
|
41
|
+
*
|
|
42
|
+
* @param {ReactClass} publicInstance The instance to use as `this` context.
|
|
43
|
+
* @param {?function} callback Called after state is updated.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
enqueueCallback: function (publicInstance, callback) {},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Forces an update. This should only be invoked when it is known with
|
|
50
|
+
* certainty that we are **not** in a DOM transaction.
|
|
51
|
+
*
|
|
52
|
+
* You may want to call this when you know that some deeper aspect of the
|
|
53
|
+
* component's state has changed but `setState` was not called.
|
|
54
|
+
*
|
|
55
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
56
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
|
57
|
+
*
|
|
58
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
enqueueForceUpdate: function (publicInstance) {
|
|
62
|
+
warnTDZ(publicInstance, 'forceUpdate');
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Replaces all of the state. Always use this or `setState` to mutate state.
|
|
67
|
+
* You should treat `this.state` as immutable.
|
|
68
|
+
*
|
|
69
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
|
70
|
+
* accessing `this.state` after calling this method may return the old value.
|
|
71
|
+
*
|
|
72
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
73
|
+
* @param {object} completeState Next state.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
enqueueReplaceState: function (publicInstance, completeState) {
|
|
77
|
+
warnTDZ(publicInstance, 'replaceState');
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Sets a subset of the state. This only exists because _pendingState is
|
|
82
|
+
* internal. This provides a merging strategy that is not available to deep
|
|
83
|
+
* properties which is confusing. TODO: Expose pendingState or don't use it
|
|
84
|
+
* during the merge.
|
|
85
|
+
*
|
|
86
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
87
|
+
* @param {object} partialState Next partial state to be merged with state.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
enqueueSetState: function (publicInstance, partialState) {
|
|
91
|
+
warnTDZ(publicInstance, 'setState');
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Sets a subset of the props.
|
|
96
|
+
*
|
|
97
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
98
|
+
* @param {object} partialProps Subset of the next props.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
enqueueSetProps: function (publicInstance, partialProps) {
|
|
102
|
+
warnTDZ(publicInstance, 'setProps');
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Replaces all of the props.
|
|
107
|
+
*
|
|
108
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
109
|
+
* @param {object} props New props.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
enqueueReplaceProps: function (publicInstance, props) {
|
|
113
|
+
warnTDZ(publicInstance, 'replaceProps');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = ReactNoopUpdateQueue;
|
package/lib/ReactOwner.js
CHANGED
|
@@ -50,11 +50,8 @@ var ReactOwner = {
|
|
|
50
50
|
* @return {boolean} True if `object` is a valid owner.
|
|
51
51
|
* @final
|
|
52
52
|
*/
|
|
53
|
-
isValidOwner: function(object) {
|
|
54
|
-
return !!(
|
|
55
|
-
(object &&
|
|
56
|
-
typeof object.attachRef === 'function' && typeof object.detachRef === 'function')
|
|
57
|
-
);
|
|
53
|
+
isValidOwner: function (object) {
|
|
54
|
+
return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
|
|
58
55
|
},
|
|
59
56
|
|
|
60
57
|
/**
|
|
@@ -66,15 +63,8 @@ var ReactOwner = {
|
|
|
66
63
|
* @final
|
|
67
64
|
* @internal
|
|
68
65
|
*/
|
|
69
|
-
addComponentAsRefTo: function(component, ref, owner) {
|
|
70
|
-
(
|
|
71
|
-
ReactOwner.isValidOwner(owner),
|
|
72
|
-
'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' +
|
|
73
|
-
'usually means that you\'re trying to add a ref to a component that ' +
|
|
74
|
-
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
75
|
-
'component\'s `render` method). Try rendering this component inside of ' +
|
|
76
|
-
'a new top-level component which will hold the ref.'
|
|
77
|
-
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
66
|
+
addComponentAsRefTo: function (component, ref, owner) {
|
|
67
|
+
!ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to add a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
78
68
|
owner.attachRef(ref, component);
|
|
79
69
|
},
|
|
80
70
|
|
|
@@ -87,15 +77,8 @@ var ReactOwner = {
|
|
|
87
77
|
* @final
|
|
88
78
|
* @internal
|
|
89
79
|
*/
|
|
90
|
-
removeComponentAsRefFrom: function(component, ref, owner) {
|
|
91
|
-
(
|
|
92
|
-
ReactOwner.isValidOwner(owner),
|
|
93
|
-
'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' +
|
|
94
|
-
'usually means that you\'re trying to remove a ref to a component that ' +
|
|
95
|
-
'doesn\'t have an owner (that is, was not created inside of another ' +
|
|
96
|
-
'component\'s `render` method). Try rendering this component inside of ' +
|
|
97
|
-
'a new top-level component which will hold the ref.'
|
|
98
|
-
) : invariant(ReactOwner.isValidOwner(owner)));
|
|
80
|
+
removeComponentAsRefFrom: function (component, ref, owner) {
|
|
81
|
+
!ReactOwner.isValidOwner(owner) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to remove a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
99
82
|
// Check that `component` is still the current ref because we do not want to
|
|
100
83
|
// detach the ref if another component stole it.
|
|
101
84
|
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
|
|
@@ -105,4 +88,4 @@ var ReactOwner = {
|
|
|
105
88
|
|
|
106
89
|
};
|
|
107
90
|
|
|
108
|
-
module.exports = ReactOwner;
|
|
91
|
+
module.exports = ReactOwner;
|
package/lib/ReactPerf.js
CHANGED
|
@@ -34,17 +34,13 @@ var ReactPerf = {
|
|
|
34
34
|
* @param {string} objectName
|
|
35
35
|
* @param {object<string>} methodNames
|
|
36
36
|
*/
|
|
37
|
-
measureMethods: function(object, objectName, methodNames) {
|
|
38
|
-
if (
|
|
37
|
+
measureMethods: function (object, objectName, methodNames) {
|
|
38
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
39
39
|
for (var key in methodNames) {
|
|
40
40
|
if (!methodNames.hasOwnProperty(key)) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
object[key] = ReactPerf.measure(
|
|
44
|
-
objectName,
|
|
45
|
-
methodNames[key],
|
|
46
|
-
object[key]
|
|
47
|
-
);
|
|
43
|
+
object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]);
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
},
|
|
@@ -57,10 +53,10 @@ var ReactPerf = {
|
|
|
57
53
|
* @param {function} func
|
|
58
54
|
* @return {function}
|
|
59
55
|
*/
|
|
60
|
-
measure: function(objName, fnName, func) {
|
|
61
|
-
if (
|
|
56
|
+
measure: function (objName, fnName, func) {
|
|
57
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
62
58
|
var measuredFunc = null;
|
|
63
|
-
var wrapper = function() {
|
|
59
|
+
var wrapper = function () {
|
|
64
60
|
if (ReactPerf.enableMeasure) {
|
|
65
61
|
if (!measuredFunc) {
|
|
66
62
|
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
|
|
@@ -79,7 +75,7 @@ var ReactPerf = {
|
|
|
79
75
|
/**
|
|
80
76
|
* @param {function} measure
|
|
81
77
|
*/
|
|
82
|
-
injectMeasure: function(measure) {
|
|
78
|
+
injectMeasure: function (measure) {
|
|
83
79
|
ReactPerf.storedMeasure = measure;
|
|
84
80
|
}
|
|
85
81
|
}
|
|
@@ -97,4 +93,4 @@ function _noMeasure(objName, fnName, func) {
|
|
|
97
93
|
return func;
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
module.exports = ReactPerf;
|
|
96
|
+
module.exports = ReactPerf;
|