react 15.1.0-alpha.1 → 15.2.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/dist/react-with-addons.js +2145 -1396
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1941 -1329
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +15 -8
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +17 -3
- package/lib/Danger.js +10 -8
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +99 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +66 -106
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +7 -1
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMInput.js +52 -16
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +132 -45
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactErrorUtils.js +15 -65
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +9 -4
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactMount.js +25 -14
- package/lib/ReactMultiChild.js +31 -9
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +7 -1
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +5 -3
- package/lib/ReactNoop.js +76 -0
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +8 -2
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +126 -0
- package/lib/ReactTestReconcileTransaction.js +100 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +21 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +40 -6
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +9 -8
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +8 -6
- package/lib/ResponderTouchHistoryStore.js +6 -4
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +3 -1
- package/lib/accumulateInto.js +3 -1
- package/lib/checkReactTypeSpec.js +71 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +13 -4
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/instantiateReactComponent.js +20 -17
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +38 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
package/lib/LinkedValueUtils.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactPropTypes = require('./ReactPropTypes');
|
|
15
17
|
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
16
18
|
|
|
@@ -28,16 +30,16 @@ var hasReadOnlyValue = {
|
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
function _assertSingleLink(inputProps) {
|
|
31
|
-
!(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use
|
|
33
|
+
!(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use checkedLink, you probably don\'t want to use valueLink and vice versa.') : _prodInvariant('87') : void 0;
|
|
32
34
|
}
|
|
33
35
|
function _assertValueLink(inputProps) {
|
|
34
36
|
_assertSingleLink(inputProps);
|
|
35
|
-
!(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want
|
|
37
|
+
!(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want to use value or onChange, you probably don\'t want to use valueLink.') : _prodInvariant('88') : void 0;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
function _assertCheckedLink(inputProps) {
|
|
39
41
|
_assertSingleLink(inputProps);
|
|
40
|
-
!(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event.
|
|
42
|
+
!(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event. If you want to use checked or onChange, you probably don\'t want to use checkedLink') : _prodInvariant('89') : void 0;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
var propTypes = {
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactNativeAttributePayload = require('./ReactNativeAttributePayload');
|
|
15
|
-
var TextInputState = require('TextInputState');
|
|
16
|
-
var UIManager = require('UIManager');
|
|
17
|
+
var TextInputState = require('react-native/lib/TextInputState');
|
|
18
|
+
var UIManager = require('react-native/lib/UIManager');
|
|
17
19
|
|
|
18
20
|
var findNodeHandle = require('./findNodeHandle');
|
|
19
21
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -140,7 +142,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
140
142
|
// __DEV__ without actually implementing them (setting them to undefined
|
|
141
143
|
// isn't allowed by ReactClass)
|
|
142
144
|
var NativeMethodsMixin_DEV = NativeMethodsMixin;
|
|
143
|
-
!(!NativeMethodsMixin_DEV.componentWillMount && !NativeMethodsMixin_DEV.componentWillReceiveProps) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Do not override existing functions.') :
|
|
145
|
+
!(!NativeMethodsMixin_DEV.componentWillMount && !NativeMethodsMixin_DEV.componentWillReceiveProps) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Do not override existing functions.') : _prodInvariant('16') : void 0;
|
|
144
146
|
NativeMethodsMixin_DEV.componentWillMount = function () {
|
|
145
147
|
throwOnStylesProp(this, this.props);
|
|
146
148
|
};
|
|
@@ -153,7 +155,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
153
155
|
* In the future, we should cleanup callbacks by cancelling them instead of
|
|
154
156
|
* using this.
|
|
155
157
|
*/
|
|
156
|
-
|
|
158
|
+
function mountSafeCallback(context, callback) {
|
|
157
159
|
return function () {
|
|
158
160
|
if (!callback || context.isMounted && !context.isMounted()) {
|
|
159
161
|
return undefined;
|
package/lib/PooledClass.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var invariant = require('fbjs/lib/invariant');
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -77,7 +79,7 @@ var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
|
|
|
77
79
|
|
|
78
80
|
var standardReleaser = function (instance) {
|
|
79
81
|
var Klass = this;
|
|
80
|
-
!(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') :
|
|
82
|
+
!(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0;
|
|
81
83
|
instance.destructor();
|
|
82
84
|
if (Klass.instancePool.length < Klass.poolSize) {
|
|
83
85
|
Klass.instancePool.push(instance);
|
package/lib/React.js
CHANGED
|
@@ -18,7 +18,6 @@ var ReactComponent = require('./ReactComponent');
|
|
|
18
18
|
var ReactClass = require('./ReactClass');
|
|
19
19
|
var ReactDOMFactories = require('./ReactDOMFactories');
|
|
20
20
|
var ReactElement = require('./ReactElement');
|
|
21
|
-
var ReactElementValidator = require('./ReactElementValidator');
|
|
22
21
|
var ReactPropTypes = require('./ReactPropTypes');
|
|
23
22
|
var ReactVersion = require('./ReactVersion');
|
|
24
23
|
|
|
@@ -30,6 +29,7 @@ var createFactory = ReactElement.createFactory;
|
|
|
30
29
|
var cloneElement = ReactElement.cloneElement;
|
|
31
30
|
|
|
32
31
|
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
+
var ReactElementValidator = require('./ReactElementValidator');
|
|
33
33
|
createElement = ReactElementValidator.createElement;
|
|
34
34
|
createFactory = ReactElementValidator.createFactory;
|
|
35
35
|
cloneElement = ReactElementValidator.cloneElement;
|
|
@@ -85,7 +85,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
85
85
|
CSSCore.addClass(node, className);
|
|
86
86
|
|
|
87
87
|
// Need to do this to actually trigger a transition.
|
|
88
|
-
this.
|
|
88
|
+
this.queueClassAndNode(activeClassName, node);
|
|
89
89
|
|
|
90
90
|
// If the user specified a timeout delay.
|
|
91
91
|
if (userSpecifiedDelay) {
|
|
@@ -98,24 +98,29 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
this.
|
|
101
|
+
queueClassAndNode: function (className, node) {
|
|
102
|
+
this.classNameAndNodeQueue.push({
|
|
103
|
+
className: className,
|
|
104
|
+
node: node
|
|
105
|
+
});
|
|
103
106
|
|
|
104
107
|
if (!this.timeout) {
|
|
105
|
-
this.timeout = setTimeout(this.
|
|
108
|
+
this.timeout = setTimeout(this.flushClassNameAndNodeQueue, TICK);
|
|
106
109
|
}
|
|
107
110
|
},
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
flushClassNameAndNodeQueue: function () {
|
|
110
113
|
if (this.isMounted()) {
|
|
111
|
-
this.
|
|
114
|
+
this.classNameAndNodeQueue.forEach(function (obj) {
|
|
115
|
+
CSSCore.addClass(obj.node, obj.className);
|
|
116
|
+
});
|
|
112
117
|
}
|
|
113
|
-
this.
|
|
118
|
+
this.classNameAndNodeQueue.length = 0;
|
|
114
119
|
this.timeout = null;
|
|
115
120
|
},
|
|
116
121
|
|
|
117
122
|
componentWillMount: function () {
|
|
118
|
-
this.
|
|
123
|
+
this.classNameAndNodeQueue = [];
|
|
119
124
|
this.transitionTimeouts = [];
|
|
120
125
|
},
|
|
121
126
|
|
|
@@ -126,6 +131,8 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
126
131
|
this.transitionTimeouts.forEach(function (timeout) {
|
|
127
132
|
clearTimeout(timeout);
|
|
128
133
|
});
|
|
134
|
+
|
|
135
|
+
this.classNameAndNodeQueue.length = 0;
|
|
129
136
|
},
|
|
130
137
|
|
|
131
138
|
componentWillAppear: function (done) {
|
|
@@ -13,17 +13,18 @@
|
|
|
13
13
|
|
|
14
14
|
var ReactReconciler = require('./ReactReconciler');
|
|
15
15
|
|
|
16
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
16
17
|
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
17
18
|
var KeyEscapeUtils = require('./KeyEscapeUtils');
|
|
18
19
|
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
19
20
|
var traverseAllChildren = require('./traverseAllChildren');
|
|
20
21
|
var warning = require('fbjs/lib/warning');
|
|
21
22
|
|
|
22
|
-
function instantiateChild(childInstances, child, name) {
|
|
23
|
+
function instantiateChild(childInstances, child, name, selfDebugID) {
|
|
23
24
|
// We found a component instance.
|
|
24
25
|
var keyUnique = childInstances[name] === undefined;
|
|
25
26
|
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
-
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used
|
|
27
|
+
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
|
|
27
28
|
}
|
|
28
29
|
if (child != null && keyUnique) {
|
|
29
30
|
childInstances[name] = instantiateReactComponent(child);
|
|
@@ -44,12 +45,20 @@ var ReactChildReconciler = {
|
|
|
44
45
|
* @return {?object} A set of child instances.
|
|
45
46
|
* @internal
|
|
46
47
|
*/
|
|
47
|
-
instantiateChildren: function (nestedChildNodes, transaction, context
|
|
48
|
+
instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // __DEV__ only
|
|
49
|
+
) {
|
|
48
50
|
if (nestedChildNodes == null) {
|
|
49
51
|
return null;
|
|
50
52
|
}
|
|
51
53
|
var childInstances = {};
|
|
52
|
-
|
|
54
|
+
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
traverseAllChildren(nestedChildNodes, function (childInsts, child, name) {
|
|
57
|
+
return instantiateChild(childInsts, child, name, selfDebugID);
|
|
58
|
+
}, childInstances);
|
|
59
|
+
} else {
|
|
60
|
+
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
|
|
61
|
+
}
|
|
53
62
|
return childInstances;
|
|
54
63
|
},
|
|
55
64
|
|
|
@@ -86,7 +95,7 @@ var ReactChildReconciler = {
|
|
|
86
95
|
nextChildren[name] = prevChild;
|
|
87
96
|
} else {
|
|
88
97
|
if (prevChild) {
|
|
89
|
-
removedNodes[name] = ReactReconciler.
|
|
98
|
+
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
|
|
90
99
|
ReactReconciler.unmountComponent(prevChild, false);
|
|
91
100
|
}
|
|
92
101
|
// The child must be instantiated before it's mounted.
|
|
@@ -98,7 +107,7 @@ var ReactChildReconciler = {
|
|
|
98
107
|
for (name in prevChildren) {
|
|
99
108
|
if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
|
|
100
109
|
prevChild = prevChildren[name];
|
|
101
|
-
removedNodes[name] = ReactReconciler.
|
|
110
|
+
removedNodes[name] = ReactReconciler.getHostNode(prevChild);
|
|
102
111
|
ReactReconciler.unmountComponent(prevChild, false);
|
|
103
112
|
}
|
|
104
113
|
}
|
package/lib/ReactClass.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
+
_assign = require('object-assign');
|
|
15
16
|
|
|
16
17
|
var ReactComponent = require('./ReactComponent');
|
|
17
18
|
var ReactElement = require('./ReactElement');
|
|
@@ -56,7 +57,7 @@ var injectedMixins = [];
|
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Composite components are higher-level components that compose other composite
|
|
59
|
-
* or
|
|
60
|
+
* or host components.
|
|
60
61
|
*
|
|
61
62
|
* To create a new type of `ReactClass`, pass a specification of
|
|
62
63
|
* your new class to `React.createClass`. The only requirement of your class
|
|
@@ -369,12 +370,12 @@ function validateMethodOverride(isAlreadyDefined, name) {
|
|
|
369
370
|
|
|
370
371
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
371
372
|
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
372
|
-
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override
|
|
373
|
+
!(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.', name) : _prodInvariant('73', name) : void 0;
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
376
377
|
if (isAlreadyDefined) {
|
|
377
|
-
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define
|
|
378
|
+
!(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('74', name) : void 0;
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
|
|
@@ -387,8 +388,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
387
388
|
return;
|
|
388
389
|
}
|
|
389
390
|
|
|
390
|
-
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to
|
|
391
|
-
!!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to
|
|
391
|
+
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;
|
|
392
|
+
!!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;
|
|
392
393
|
|
|
393
394
|
var proto = Constructor.prototype;
|
|
394
395
|
var autoBindPairs = proto.__reactAutoBindPairs;
|
|
@@ -433,7 +434,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
433
434
|
var specPolicy = ReactClassInterface[name];
|
|
434
435
|
|
|
435
436
|
// These cases should already be caught by validateMethodOverride.
|
|
436
|
-
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s
|
|
437
|
+
!(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;
|
|
437
438
|
|
|
438
439
|
// For methods which are defined more than once, call the existing
|
|
439
440
|
// methods before calling the new property, merging if appropriate.
|
|
@@ -468,10 +469,10 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
468
469
|
}
|
|
469
470
|
|
|
470
471
|
var isReserved = name in RESERVED_SPEC_KEYS;
|
|
471
|
-
!!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved
|
|
472
|
+
!!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.', name) : _prodInvariant('78', name) : void 0;
|
|
472
473
|
|
|
473
474
|
var isInherited = name in Constructor;
|
|
474
|
-
!!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define
|
|
475
|
+
!!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('79', name) : void 0;
|
|
475
476
|
Constructor[name] = property;
|
|
476
477
|
}
|
|
477
478
|
}
|
|
@@ -484,11 +485,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
484
485
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
485
486
|
*/
|
|
486
487
|
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
487
|
-
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') :
|
|
488
|
+
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;
|
|
488
489
|
|
|
489
490
|
for (var key in two) {
|
|
490
491
|
if (two.hasOwnProperty(key)) {
|
|
491
|
-
!(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys():
|
|
492
|
+
!(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.', key) : _prodInvariant('81', key) : void 0;
|
|
492
493
|
one[key] = two[key];
|
|
493
494
|
}
|
|
494
495
|
}
|
|
@@ -666,7 +667,7 @@ var ReactClass = {
|
|
|
666
667
|
initialState = null;
|
|
667
668
|
}
|
|
668
669
|
}
|
|
669
|
-
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') :
|
|
670
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : _prodInvariant('82', Constructor.displayName || 'ReactCompositeComponent') : void 0;
|
|
670
671
|
|
|
671
672
|
this.state = initialState;
|
|
672
673
|
};
|
|
@@ -696,7 +697,7 @@ var ReactClass = {
|
|
|
696
697
|
}
|
|
697
698
|
}
|
|
698
699
|
|
|
699
|
-
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') :
|
|
700
|
+
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : _prodInvariant('83') : void 0;
|
|
700
701
|
|
|
701
702
|
if (process.env.NODE_ENV !== 'production') {
|
|
702
703
|
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
|
package/lib/ReactComponent.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
15
|
-
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
16
17
|
|
|
17
18
|
var canDefineProperty = require('./canDefineProperty');
|
|
18
19
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
@@ -59,11 +60,7 @@ ReactComponent.prototype.isReactComponent = {};
|
|
|
59
60
|
* @protected
|
|
60
61
|
*/
|
|
61
62
|
ReactComponent.prototype.setState = function (partialState, callback) {
|
|
62
|
-
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a
|
|
63
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
-
ReactInstrumentation.debugTool.onSetState();
|
|
65
|
-
process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : void 0;
|
|
66
|
-
}
|
|
63
|
+
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : _prodInvariant('85') : void 0;
|
|
67
64
|
this.updater.enqueueSetState(this, partialState);
|
|
68
65
|
if (callback) {
|
|
69
66
|
this.updater.enqueueCallback(this, callback, 'setState');
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var invariant = require('fbjs/lib/invariant');
|
|
15
17
|
|
|
16
18
|
var injected = false;
|
|
@@ -38,7 +40,7 @@ var ReactComponentEnvironment = {
|
|
|
38
40
|
|
|
39
41
|
injection: {
|
|
40
42
|
injectEnvironment: function (environment) {
|
|
41
|
-
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') :
|
|
43
|
+
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : _prodInvariant('104') : void 0;
|
|
42
44
|
ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
|
|
43
45
|
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
|
|
44
46
|
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
|
|
@@ -11,14 +11,21 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
16
|
+
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
17
|
+
|
|
14
18
|
var invariant = require('fbjs/lib/invariant');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
15
20
|
|
|
16
21
|
var tree = {};
|
|
17
|
-
var
|
|
22
|
+
var unmountedIDs = {};
|
|
23
|
+
var rootIDs = {};
|
|
18
24
|
|
|
19
25
|
function updateTree(id, update) {
|
|
20
26
|
if (!tree[id]) {
|
|
21
27
|
tree[id] = {
|
|
28
|
+
element: null,
|
|
22
29
|
parentID: null,
|
|
23
30
|
ownerID: null,
|
|
24
31
|
text: null,
|
|
@@ -27,6 +34,10 @@ function updateTree(id, update) {
|
|
|
27
34
|
isMounted: false,
|
|
28
35
|
updateCount: 0
|
|
29
36
|
};
|
|
37
|
+
// TODO: We need to do this awkward dance because TopLevelWrapper "never
|
|
38
|
+
// gets mounted" but its display name gets set in instantiateReactComponent
|
|
39
|
+
// before its debug ID is set to 0.
|
|
40
|
+
unmountedIDs[id] = true;
|
|
30
41
|
}
|
|
31
42
|
update(tree[id]);
|
|
32
43
|
}
|
|
@@ -41,6 +52,22 @@ function purgeDeep(id) {
|
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
|
|
55
|
+
function describeComponentFrame(name, source, ownerName) {
|
|
56
|
+
return '\n in ' + name + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function describeID(id) {
|
|
60
|
+
var name = ReactComponentTreeDevtool.getDisplayName(id);
|
|
61
|
+
var element = ReactComponentTreeDevtool.getElement(id);
|
|
62
|
+
var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
|
|
63
|
+
var ownerName;
|
|
64
|
+
if (ownerID) {
|
|
65
|
+
ownerName = ReactComponentTreeDevtool.getDisplayName(ownerID);
|
|
66
|
+
}
|
|
67
|
+
process.env.NODE_ENV !== 'production' ? warning(element, 'ReactComponentTreeDevtool: Missing React element for debugID %s when ' + 'building stack', id) : void 0;
|
|
68
|
+
return describeComponentFrame(name, element && element._source, ownerName);
|
|
69
|
+
}
|
|
70
|
+
|
|
44
71
|
var ReactComponentTreeDevtool = {
|
|
45
72
|
onSetDisplayName: function (id, displayName) {
|
|
46
73
|
updateTree(id, function (item) {
|
|
@@ -49,19 +76,21 @@ var ReactComponentTreeDevtool = {
|
|
|
49
76
|
},
|
|
50
77
|
onSetChildren: function (id, nextChildIDs) {
|
|
51
78
|
updateTree(id, function (item) {
|
|
52
|
-
var prevChildIDs = item.childIDs;
|
|
53
79
|
item.childIDs = nextChildIDs;
|
|
54
80
|
|
|
55
81
|
nextChildIDs.forEach(function (nextChildID) {
|
|
56
82
|
var nextChild = tree[nextChildID];
|
|
57
|
-
!nextChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected devtool events to fire for the child
|
|
58
|
-
!(nextChild.displayName != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetDisplayName() to fire for the child
|
|
59
|
-
!(nextChild.childIDs != null || nextChild.text != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetChildren() or onSetText() to fire for the child
|
|
60
|
-
!nextChild.isMounted ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onMountComponent() to fire for the child
|
|
61
|
-
|
|
62
|
-
if (prevChildIDs.indexOf(nextChildID) === -1) {
|
|
83
|
+
!nextChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected devtool events to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('68') : void 0;
|
|
84
|
+
!(nextChild.displayName != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetDisplayName() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('69') : void 0;
|
|
85
|
+
!(nextChild.childIDs != null || nextChild.text != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetChildren() or onSetText() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('70') : void 0;
|
|
86
|
+
!nextChild.isMounted ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('71') : void 0;
|
|
87
|
+
if (nextChild.parentID == null) {
|
|
63
88
|
nextChild.parentID = id;
|
|
89
|
+
// TODO: This shouldn't be necessary but mounting a new root during in
|
|
90
|
+
// componentWillMount currently causes not-yet-mounted components to
|
|
91
|
+
// be purged from our tree data so their parent ID is missing.
|
|
64
92
|
}
|
|
93
|
+
!(nextChild.parentID === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetParent() and onSetChildren() to be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id) : _prodInvariant('72', nextChildID, nextChild.parentID, id) : void 0;
|
|
65
94
|
});
|
|
66
95
|
});
|
|
67
96
|
},
|
|
@@ -70,18 +99,34 @@ var ReactComponentTreeDevtool = {
|
|
|
70
99
|
return item.ownerID = ownerID;
|
|
71
100
|
});
|
|
72
101
|
},
|
|
102
|
+
onSetParent: function (id, parentID) {
|
|
103
|
+
updateTree(id, function (item) {
|
|
104
|
+
return item.parentID = parentID;
|
|
105
|
+
});
|
|
106
|
+
},
|
|
73
107
|
onSetText: function (id, text) {
|
|
74
108
|
updateTree(id, function (item) {
|
|
75
109
|
return item.text = text;
|
|
76
110
|
});
|
|
77
111
|
},
|
|
112
|
+
onBeforeMountComponent: function (id, element) {
|
|
113
|
+
updateTree(id, function (item) {
|
|
114
|
+
return item.element = element;
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
onBeforeUpdateComponent: function (id, element) {
|
|
118
|
+
updateTree(id, function (item) {
|
|
119
|
+
return item.element = element;
|
|
120
|
+
});
|
|
121
|
+
},
|
|
78
122
|
onMountComponent: function (id) {
|
|
79
123
|
updateTree(id, function (item) {
|
|
80
124
|
return item.isMounted = true;
|
|
81
125
|
});
|
|
126
|
+
delete unmountedIDs[id];
|
|
82
127
|
},
|
|
83
128
|
onMountRootComponent: function (id) {
|
|
84
|
-
rootIDs
|
|
129
|
+
rootIDs[id] = true;
|
|
85
130
|
},
|
|
86
131
|
onUpdateComponent: function (id) {
|
|
87
132
|
updateTree(id, function (item) {
|
|
@@ -92,19 +137,47 @@ var ReactComponentTreeDevtool = {
|
|
|
92
137
|
updateTree(id, function (item) {
|
|
93
138
|
return item.isMounted = false;
|
|
94
139
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
140
|
+
unmountedIDs[id] = true;
|
|
141
|
+
delete rootIDs[id];
|
|
98
142
|
},
|
|
99
143
|
purgeUnmountedComponents: function () {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
144
|
+
if (ReactComponentTreeDevtool._preventPurging) {
|
|
145
|
+
// Should only be used for testing.
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (var id in unmountedIDs) {
|
|
150
|
+
purgeDeep(id);
|
|
151
|
+
}
|
|
152
|
+
unmountedIDs = {};
|
|
103
153
|
},
|
|
104
154
|
isMounted: function (id) {
|
|
105
155
|
var item = tree[id];
|
|
106
156
|
return item ? item.isMounted : false;
|
|
107
157
|
},
|
|
158
|
+
getCurrentStackAddendum: function (topElement) {
|
|
159
|
+
var info = '';
|
|
160
|
+
if (topElement) {
|
|
161
|
+
var type = topElement.type;
|
|
162
|
+
var name = typeof type === 'function' ? type.displayName || type.name : type;
|
|
163
|
+
var owner = topElement._owner;
|
|
164
|
+
info += describeComponentFrame(name || 'Unknown', topElement._source, owner && owner.getName());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var currentOwner = ReactCurrentOwner.current;
|
|
168
|
+
var id = currentOwner && currentOwner._debugID;
|
|
169
|
+
|
|
170
|
+
info += ReactComponentTreeDevtool.getStackAddendumByID(id);
|
|
171
|
+
return info;
|
|
172
|
+
},
|
|
173
|
+
getStackAddendumByID: function (id) {
|
|
174
|
+
var info = '';
|
|
175
|
+
while (id) {
|
|
176
|
+
info += describeID(id);
|
|
177
|
+
id = ReactComponentTreeDevtool.getParentID(id);
|
|
178
|
+
}
|
|
179
|
+
return info;
|
|
180
|
+
},
|
|
108
181
|
getChildIDs: function (id) {
|
|
109
182
|
var item = tree[id];
|
|
110
183
|
return item ? item.childIDs : [];
|
|
@@ -113,6 +186,10 @@ var ReactComponentTreeDevtool = {
|
|
|
113
186
|
var item = tree[id];
|
|
114
187
|
return item ? item.displayName : 'Unknown';
|
|
115
188
|
},
|
|
189
|
+
getElement: function (id) {
|
|
190
|
+
var item = tree[id];
|
|
191
|
+
return item ? item.element : null;
|
|
192
|
+
},
|
|
116
193
|
getOwnerID: function (id) {
|
|
117
194
|
var item = tree[id];
|
|
118
195
|
return item ? item.ownerID : null;
|
|
@@ -121,6 +198,12 @@ var ReactComponentTreeDevtool = {
|
|
|
121
198
|
var item = tree[id];
|
|
122
199
|
return item ? item.parentID : null;
|
|
123
200
|
},
|
|
201
|
+
getSource: function (id) {
|
|
202
|
+
var item = tree[id];
|
|
203
|
+
var element = item ? item.element : null;
|
|
204
|
+
var source = element != null ? element._source : null;
|
|
205
|
+
return source;
|
|
206
|
+
},
|
|
124
207
|
getText: function (id) {
|
|
125
208
|
var item = tree[id];
|
|
126
209
|
return item ? item.text : null;
|
|
@@ -130,7 +213,7 @@ var ReactComponentTreeDevtool = {
|
|
|
130
213
|
return item ? item.updateCount : 0;
|
|
131
214
|
},
|
|
132
215
|
getRootIDs: function () {
|
|
133
|
-
return rootIDs;
|
|
216
|
+
return Object.keys(rootIDs);
|
|
134
217
|
},
|
|
135
218
|
getRegisteredIDs: function () {
|
|
136
219
|
return Object.keys(tree);
|