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
|
@@ -0,0 +1,70 @@
|
|
|
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 instantiateReactComponent
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
var warning = require("./warning");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Validate a `componentDescriptor`. This should be exposed publicly in a follow
|
|
26
|
+
* up diff.
|
|
27
|
+
*
|
|
28
|
+
* @param {object} descriptor
|
|
29
|
+
* @return {boolean} Returns true if this is a valid descriptor of a Component.
|
|
30
|
+
*/
|
|
31
|
+
function isValidComponentDescriptor(descriptor) {
|
|
32
|
+
return (
|
|
33
|
+
typeof descriptor.constructor === 'function' &&
|
|
34
|
+
typeof descriptor.constructor.prototype.construct === 'function' &&
|
|
35
|
+
typeof descriptor.constructor.prototype.mountComponent === 'function' &&
|
|
36
|
+
typeof descriptor.constructor.prototype.receiveComponent === 'function'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Given a `componentDescriptor` create an instance that will actually be
|
|
42
|
+
* mounted. Currently it just extracts an existing clone from composite
|
|
43
|
+
* components but this is an implementation detail which will change.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} descriptor
|
|
46
|
+
* @return {object} A new instance of componentDescriptor's constructor.
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
49
|
+
function instantiateReactComponent(descriptor) {
|
|
50
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
51
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
52
|
+
isValidComponentDescriptor(descriptor),
|
|
53
|
+
'Only React Components are valid for mounting.'
|
|
54
|
+
) : null);
|
|
55
|
+
// We use the clone of a composite component instead of the original
|
|
56
|
+
// instance. This allows us to warn you if you're are accessing the wrong
|
|
57
|
+
// instance.
|
|
58
|
+
var instance = descriptor.__realComponentInstance || descriptor;
|
|
59
|
+
instance._descriptor = descriptor;
|
|
60
|
+
return instance;
|
|
61
|
+
}
|
|
62
|
+
// In prod we don't clone, we simply use the same instance for unaffected
|
|
63
|
+
// behavior. We have to keep the descriptor around for comparison later on.
|
|
64
|
+
// This should ideally be accepted in the constructor of the instance but
|
|
65
|
+
// since that is currently overloaded, we just manually attach it here.
|
|
66
|
+
descriptor._descriptor = descriptor;
|
|
67
|
+
return descriptor;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = instantiateReactComponent;
|
package/lib/invariant.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.
|
|
@@ -16,26 +16,32 @@
|
|
|
16
16
|
* @providesModule invariant
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* Use invariant() to assert state which your program assumes to be true.
|
|
21
23
|
*
|
|
22
|
-
* Provide sprintf
|
|
23
|
-
* what broke and what you were
|
|
24
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
25
|
+
* to provide information about what broke and what you were
|
|
26
|
+
* expecting.
|
|
24
27
|
*
|
|
25
28
|
* The invariant message will be stripped in production, but the invariant
|
|
26
29
|
* will remain to ensure logic does not differ in production.
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
var invariant = function(condition) {
|
|
30
33
|
if (!condition) {
|
|
31
|
-
|
|
34
|
+
var error = new Error(
|
|
35
|
+
'Minified exception occured; use the non-minified dev environment for ' +
|
|
36
|
+
'the full error message and additional helpful warnings.'
|
|
37
|
+
);
|
|
38
|
+
error.framesToPop = 1;
|
|
39
|
+
throw error;
|
|
32
40
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = invariant;
|
|
41
|
+
};
|
|
36
42
|
|
|
37
43
|
if ("production" !== process.env.NODE_ENV) {
|
|
38
|
-
|
|
44
|
+
invariant = function(condition, format, a, b, c, d, e, f) {
|
|
39
45
|
if (format === undefined) {
|
|
40
46
|
throw new Error('invariant requires an error message argument');
|
|
41
47
|
}
|
|
@@ -43,12 +49,14 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
43
49
|
if (!condition) {
|
|
44
50
|
var args = [a, b, c, d, e, f];
|
|
45
51
|
var argIndex = 0;
|
|
46
|
-
|
|
52
|
+
var error = new Error(
|
|
47
53
|
'Invariant Violation: ' +
|
|
48
54
|
format.replace(/%s/g, function() { return args[argIndex++]; })
|
|
49
55
|
);
|
|
56
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
57
|
+
throw error;
|
|
50
58
|
}
|
|
51
59
|
};
|
|
52
|
-
|
|
53
|
-
module.exports = invariantDev;
|
|
54
60
|
}
|
|
61
|
+
|
|
62
|
+
module.exports = invariant;
|
package/lib/isEventSupported.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.
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
|
|
21
21
|
var ExecutionEnvironment = require("./ExecutionEnvironment");
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var useHasFeature;
|
|
24
24
|
if (ExecutionEnvironment.canUseDOM) {
|
|
25
|
-
testNode = document.createElement('div');
|
|
26
25
|
useHasFeature =
|
|
27
26
|
document.implementation &&
|
|
28
27
|
document.implementation.hasFeature &&
|
|
29
|
-
//
|
|
28
|
+
// always returns true in newer browsers as per the standard.
|
|
29
|
+
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
30
30
|
document.implementation.hasFeature('', '') !== true;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -45,21 +45,18 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
45
45
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
46
46
|
*/
|
|
47
47
|
function isEventSupported(eventNameSuffix, capture) {
|
|
48
|
-
if (!
|
|
48
|
+
if (!ExecutionEnvironment.canUseDOM ||
|
|
49
|
+
capture && !('addEventListener' in document)) {
|
|
49
50
|
return false;
|
|
50
51
|
}
|
|
51
|
-
var element = document.createElement('div');
|
|
52
52
|
|
|
53
53
|
var eventName = 'on' + eventNameSuffix;
|
|
54
|
-
var isSupported = eventName in
|
|
54
|
+
var isSupported = eventName in document;
|
|
55
55
|
|
|
56
56
|
if (!isSupported) {
|
|
57
|
+
var element = document.createElement('div');
|
|
57
58
|
element.setAttribute(eventName, 'return;');
|
|
58
59
|
isSupported = typeof element[eventName] === 'function';
|
|
59
|
-
if (typeof element[eventName] !== 'undefined') {
|
|
60
|
-
element[eventName] = undefined;
|
|
61
|
-
}
|
|
62
|
-
element.removeAttribute(eventName);
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
|
|
@@ -67,7 +64,6 @@ function isEventSupported(eventNameSuffix, capture) {
|
|
|
67
64
|
isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
element = null;
|
|
71
67
|
return isSupported;
|
|
72
68
|
}
|
|
73
69
|
|
package/lib/isNode.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,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
function isNode(object) {
|
|
25
25
|
return !!(object && (
|
|
26
|
-
typeof Node
|
|
26
|
+
typeof Node === 'function' ? object instanceof Node :
|
|
27
27
|
typeof object === 'object' &&
|
|
28
28
|
typeof object.nodeType === 'number' &&
|
|
29
29
|
typeof object.nodeName === 'string'
|
package/lib/isTextNode.js
CHANGED
package/lib/joinClasses.js
CHANGED
package/lib/keyMirror.js
CHANGED
package/lib/keyOf.js
CHANGED
package/lib/memoizeStringOnly.js
CHANGED
package/lib/merge.js
CHANGED
package/lib/mergeHelpers.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,9 +66,9 @@ var mergeHelpers = {
|
|
|
66
66
|
checkMergeArrayArgs: function(one, two) {
|
|
67
67
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
68
68
|
Array.isArray(one) && Array.isArray(two),
|
|
69
|
-
'
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
'Tried to merge arrays, instead got %s and %s.',
|
|
70
|
+
one,
|
|
71
|
+
two
|
|
72
72
|
) : invariant(Array.isArray(one) && Array.isArray(two)));
|
|
73
73
|
},
|
|
74
74
|
|
|
@@ -87,9 +87,8 @@ var mergeHelpers = {
|
|
|
87
87
|
checkMergeObjectArg: function(arg) {
|
|
88
88
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
89
89
|
!isTerminal(arg) && !Array.isArray(arg),
|
|
90
|
-
'
|
|
91
|
-
|
|
92
|
-
'the callers.'
|
|
90
|
+
'Tried to merge an object, instead got %s.',
|
|
91
|
+
arg
|
|
93
92
|
) : invariant(!isTerminal(arg) && !Array.isArray(arg)));
|
|
94
93
|
},
|
|
95
94
|
|
package/lib/mergeInto.js
CHANGED
package/lib/mixInto.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 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 monitorCodeUse
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
var invariant = require("./invariant");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Provides open-source compatible instrumentation for monitoring certain API
|
|
25
|
+
* uses before we're ready to issue a warning or refactor. It accepts an event
|
|
26
|
+
* name which may only contain the characters [a-z0-9_] and an optional data
|
|
27
|
+
* object with further information.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
function monitorCodeUse(eventName, data) {
|
|
31
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
32
|
+
eventName && !/[^a-z0-9_]/.test(eventName),
|
|
33
|
+
'You must provide an eventName using only the characters [a-z0-9_]'
|
|
34
|
+
) : invariant(eventName && !/[^a-z0-9_]/.test(eventName)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = monitorCodeUse;
|
package/lib/objMap.js
CHANGED
package/lib/objMapKeyVal.js
CHANGED
package/lib/onlyChild.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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 onlyChild
|
|
17
|
+
*/
|
|
18
|
+
"use strict";
|
|
19
|
+
|
|
20
|
+
var ReactComponent = require("./ReactComponent");
|
|
21
|
+
|
|
22
|
+
var invariant = require("./invariant");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns the first child in a collection of children and verifies that there
|
|
26
|
+
* is only one child in the collection. The current implementation of this
|
|
27
|
+
* function assumes that a single child gets passed without a wrapper, but the
|
|
28
|
+
* purpose of this helper function is to abstract away the particular structure
|
|
29
|
+
* of children.
|
|
30
|
+
*
|
|
31
|
+
* @param {?object} children Child collection structure.
|
|
32
|
+
* @return {ReactComponent} The first and only `ReactComponent` contained in the
|
|
33
|
+
* structure.
|
|
34
|
+
*/
|
|
35
|
+
function onlyChild(children) {
|
|
36
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
37
|
+
ReactComponent.isValidComponent(children),
|
|
38
|
+
'onlyChild must be passed a children with exactly one child.'
|
|
39
|
+
) : invariant(ReactComponent.isValidComponent(children)));
|
|
40
|
+
return children;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = onlyChild;
|
package/lib/performanceNow.js
CHANGED
package/lib/shallowEqual.js
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
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 shouldUpdateReactComponent
|
|
17
|
+
* @typechecks static-only
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Given a `prevComponentInstance` and `nextComponent`, determines if
|
|
24
|
+
* `prevComponentInstance` should be updated as opposed to being destroyed or
|
|
25
|
+
* replaced by a new instance. The second argument is a descriptor. Future
|
|
26
|
+
* versions of the reconciler should only compare descriptors to other
|
|
27
|
+
* descriptors.
|
|
28
|
+
*
|
|
29
|
+
* @param {?object} prevComponentInstance
|
|
30
|
+
* @param {?object} nextDescriptor
|
|
31
|
+
* @return {boolean} True if `prevComponentInstance` should be updated.
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
34
|
+
function shouldUpdateReactComponent(prevComponentInstance, nextDescriptor) {
|
|
35
|
+
// TODO: Remove warning after a release.
|
|
36
|
+
if (prevComponentInstance && nextDescriptor &&
|
|
37
|
+
prevComponentInstance.constructor === nextDescriptor.constructor && (
|
|
38
|
+
(prevComponentInstance.props && prevComponentInstance.props.key) ===
|
|
39
|
+
(nextDescriptor.props && nextDescriptor.props.key)
|
|
40
|
+
)) {
|
|
41
|
+
if (prevComponentInstance._owner === nextDescriptor._owner) {
|
|
42
|
+
return true;
|
|
43
|
+
} else {
|
|
44
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
45
|
+
if (prevComponentInstance.state) {
|
|
46
|
+
console.warn(
|
|
47
|
+
'A recent change to React has been found to impact your code. ' +
|
|
48
|
+
'A mounted component will now be unmounted and replaced by a ' +
|
|
49
|
+
'component (of the same class) if their owners are different. ' +
|
|
50
|
+
'Previously, ownership was not considered when updating.',
|
|
51
|
+
prevComponentInstance,
|
|
52
|
+
nextDescriptor
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = shouldUpdateReactComponent;
|