react 0.14.0-alpha2 → 0.14.0-beta3
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 +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- 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/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/PooledClass.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var invariant = require(
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Static poolers. Several custom versions for each potential number of
|
|
@@ -53,6 +53,17 @@ var threeArgumentPooler = function (a1, a2, a3) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
var fourArgumentPooler = function (a1, a2, a3, a4) {
|
|
57
|
+
var Klass = this;
|
|
58
|
+
if (Klass.instancePool.length) {
|
|
59
|
+
var instance = Klass.instancePool.pop();
|
|
60
|
+
Klass.call(instance, a1, a2, a3, a4);
|
|
61
|
+
return instance;
|
|
62
|
+
} else {
|
|
63
|
+
return new Klass(a1, a2, a3, a4);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
56
67
|
var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
|
|
57
68
|
var Klass = this;
|
|
58
69
|
if (Klass.instancePool.length) {
|
|
@@ -66,7 +77,7 @@ var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
|
|
|
66
77
|
|
|
67
78
|
var standardReleaser = function (instance) {
|
|
68
79
|
var Klass = this;
|
|
69
|
-
|
|
80
|
+
!(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined;
|
|
70
81
|
if (instance.destructor) {
|
|
71
82
|
instance.destructor();
|
|
72
83
|
}
|
|
@@ -103,6 +114,7 @@ var PooledClass = {
|
|
|
103
114
|
oneArgumentPooler: oneArgumentPooler,
|
|
104
115
|
twoArgumentPooler: twoArgumentPooler,
|
|
105
116
|
threeArgumentPooler: threeArgumentPooler,
|
|
117
|
+
fourArgumentPooler: fourArgumentPooler,
|
|
106
118
|
fiveArgumentPooler: fiveArgumentPooler
|
|
107
119
|
};
|
|
108
120
|
|
package/lib/React.js
CHANGED
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var ReactDOMServer = require(
|
|
16
|
-
var ReactIsomorphic = require(
|
|
14
|
+
var ReactDOM = require('./ReactDOM');
|
|
15
|
+
var ReactDOMServer = require('./ReactDOMServer');
|
|
16
|
+
var ReactIsomorphic = require('./ReactIsomorphic');
|
|
17
17
|
|
|
18
|
-
var assign = require(
|
|
18
|
+
var assign = require('./Object.assign');
|
|
19
19
|
|
|
20
20
|
var React = {};
|
|
21
21
|
|
|
22
22
|
assign(React, ReactIsomorphic);
|
|
23
|
-
assign(React,
|
|
23
|
+
assign(React, ReactDOM);
|
|
24
24
|
assign(React, ReactDOMServer);
|
|
25
25
|
|
|
26
|
-
React.version = '0.14.0-
|
|
26
|
+
React.version = '0.14.0-beta3';
|
|
27
27
|
|
|
28
28
|
module.exports = React;
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactInstanceMap = require(
|
|
14
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
15
15
|
|
|
16
|
-
var findDOMNode = require(
|
|
17
|
-
var warning = require(
|
|
16
|
+
var findDOMNode = require('./findDOMNode');
|
|
17
|
+
var warning = require('fbjs/lib/warning');
|
|
18
18
|
|
|
19
19
|
var didWarnKey = '_getDOMNodeDidWarn';
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ var ReactBrowserComponentMixin = {
|
|
|
27
27
|
* @protected
|
|
28
28
|
*/
|
|
29
29
|
getDOMNode: function () {
|
|
30
|
-
|
|
30
|
+
process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + 'React.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined;
|
|
31
31
|
this.constructor[didWarnKey] = true;
|
|
32
32
|
return findDOMNode(this);
|
|
33
33
|
}
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var EventConstants = require(
|
|
16
|
-
var EventPluginHub = require(
|
|
17
|
-
var EventPluginRegistry = require(
|
|
18
|
-
var ReactEventEmitterMixin = require(
|
|
19
|
-
var ViewportMetrics = require(
|
|
15
|
+
var EventConstants = require('./EventConstants');
|
|
16
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
17
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
18
|
+
var ReactEventEmitterMixin = require('./ReactEventEmitterMixin');
|
|
19
|
+
var ViewportMetrics = require('./ViewportMetrics');
|
|
20
20
|
|
|
21
|
-
var assign = require(
|
|
22
|
-
var isEventSupported = require(
|
|
21
|
+
var assign = require('./Object.assign');
|
|
22
|
+
var isEventSupported = require('./isEventSupported');
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Summary of `ReactBrowserEventEmitter` event handling:
|
|
@@ -84,7 +84,10 @@ var reactTopListenersCounter = 0;
|
|
|
84
84
|
// lower node than `document`), binding at `document` would cause duplicate
|
|
85
85
|
// events so we don't include them here
|
|
86
86
|
var topEventMapping = {
|
|
87
|
+
topAbort: 'abort',
|
|
87
88
|
topBlur: 'blur',
|
|
89
|
+
topCanPlay: 'canplay',
|
|
90
|
+
topCanPlayThrough: 'canplaythrough',
|
|
88
91
|
topChange: 'change',
|
|
89
92
|
topClick: 'click',
|
|
90
93
|
topCompositionEnd: 'compositionend',
|
|
@@ -102,24 +105,44 @@ var topEventMapping = {
|
|
|
102
105
|
topDragOver: 'dragover',
|
|
103
106
|
topDragStart: 'dragstart',
|
|
104
107
|
topDrop: 'drop',
|
|
108
|
+
topDurationChange: 'durationchange',
|
|
109
|
+
topEmptied: 'emptied',
|
|
110
|
+
topEncrypted: 'encrypted',
|
|
111
|
+
topEnded: 'ended',
|
|
112
|
+
topError: 'error',
|
|
105
113
|
topFocus: 'focus',
|
|
106
114
|
topInput: 'input',
|
|
107
115
|
topKeyDown: 'keydown',
|
|
108
116
|
topKeyPress: 'keypress',
|
|
109
117
|
topKeyUp: 'keyup',
|
|
118
|
+
topLoadedData: 'loadeddata',
|
|
119
|
+
topLoadedMetadata: 'loadedmetadata',
|
|
120
|
+
topLoadStart: 'loadstart',
|
|
110
121
|
topMouseDown: 'mousedown',
|
|
111
122
|
topMouseMove: 'mousemove',
|
|
112
123
|
topMouseOut: 'mouseout',
|
|
113
124
|
topMouseOver: 'mouseover',
|
|
114
125
|
topMouseUp: 'mouseup',
|
|
126
|
+
topPause: 'pause',
|
|
115
127
|
topPaste: 'paste',
|
|
128
|
+
topPlay: 'play',
|
|
129
|
+
topPlaying: 'playing',
|
|
130
|
+
topProgress: 'progress',
|
|
131
|
+
topRateChange: 'ratechange',
|
|
132
|
+
topSeeking: 'seeking',
|
|
133
|
+
topSeeked: 'seeked',
|
|
116
134
|
topScroll: 'scroll',
|
|
117
135
|
topSelectionChange: 'selectionchange',
|
|
136
|
+
topStalled: 'stalled',
|
|
137
|
+
topSuspend: 'suspend',
|
|
118
138
|
topTextInput: 'textInput',
|
|
139
|
+
topTimeUpdate: 'timeupdate',
|
|
119
140
|
topTouchCancel: 'touchcancel',
|
|
120
141
|
topTouchEnd: 'touchend',
|
|
121
142
|
topTouchMove: 'touchmove',
|
|
122
143
|
topTouchStart: 'touchstart',
|
|
144
|
+
topVolumeChange: 'volumechange',
|
|
145
|
+
topWaiting: 'waiting',
|
|
123
146
|
topWheel: 'wheel'
|
|
124
147
|
};
|
|
125
148
|
|
|
@@ -12,18 +12,29 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var React = require(
|
|
15
|
+
var React = require('./React');
|
|
16
16
|
|
|
17
|
-
var assign = require(
|
|
17
|
+
var assign = require('./Object.assign');
|
|
18
18
|
|
|
19
|
-
var ReactTransitionGroup = React.createFactory(require(
|
|
20
|
-
var ReactCSSTransitionGroupChild = React.createFactory(require(
|
|
19
|
+
var ReactTransitionGroup = React.createFactory(require('./ReactTransitionGroup'));
|
|
20
|
+
var ReactCSSTransitionGroupChild = React.createFactory(require('./ReactCSSTransitionGroupChild'));
|
|
21
21
|
|
|
22
22
|
var ReactCSSTransitionGroup = React.createClass({
|
|
23
23
|
displayName: 'ReactCSSTransitionGroup',
|
|
24
24
|
|
|
25
25
|
propTypes: {
|
|
26
|
-
transitionName: React.PropTypes.string.
|
|
26
|
+
transitionName: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.shape({
|
|
27
|
+
enter: React.PropTypes.string,
|
|
28
|
+
leave: React.PropTypes.string,
|
|
29
|
+
active: React.PropTypes.string
|
|
30
|
+
}), React.PropTypes.shape({
|
|
31
|
+
enter: React.PropTypes.string,
|
|
32
|
+
enterActive: React.PropTypes.string,
|
|
33
|
+
leave: React.PropTypes.string,
|
|
34
|
+
leaveActive: React.PropTypes.string,
|
|
35
|
+
appear: React.PropTypes.string,
|
|
36
|
+
appearActive: React.PropTypes.string
|
|
37
|
+
})]).isRequired,
|
|
27
38
|
transitionAppear: React.PropTypes.bool,
|
|
28
39
|
transitionEnter: React.PropTypes.bool,
|
|
29
40
|
transitionLeave: React.PropTypes.bool
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var React = require(
|
|
15
|
+
var React = require('./React');
|
|
16
16
|
|
|
17
|
-
var CSSCore = require(
|
|
18
|
-
var ReactTransitionEvents = require(
|
|
17
|
+
var CSSCore = require('fbjs/lib/CSSCore');
|
|
18
|
+
var ReactTransitionEvents = require('./ReactTransitionEvents');
|
|
19
19
|
|
|
20
|
-
var onlyChild = require(
|
|
21
|
-
var warning = require(
|
|
20
|
+
var onlyChild = require('./onlyChild');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
22
22
|
|
|
23
23
|
// We don't remove the element from the DOM until we receive an animationend or
|
|
24
24
|
// transitionend event. If the user screws up and forgets to add an animation
|
|
@@ -29,9 +29,9 @@ var NO_EVENT_TIMEOUT = 5000;
|
|
|
29
29
|
|
|
30
30
|
var noEventListener = null;
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
33
33
|
noEventListener = function () {
|
|
34
|
-
|
|
34
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'transition(): tried to perform an animation without ' + 'an animationend or transitionend event after timeout (' + '%sms). You should either disable this ' + 'transition in JS or add a CSS animation/transition.', NO_EVENT_TIMEOUT) : undefined;
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -40,15 +40,24 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
40
40
|
|
|
41
41
|
transition: function (animationType, finishCallback) {
|
|
42
42
|
var node = React.findDOMNode(this);
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
|
|
44
|
+
if (!node) {
|
|
45
|
+
if (finishCallback) {
|
|
46
|
+
finishCallback();
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var className = this.props.name[animationType] || this.props.name + '-' + animationType;
|
|
52
|
+
var activeClassName = this.props.name[animationType + 'Active'] || className + '-active';
|
|
53
|
+
|
|
45
54
|
var noEventTimeout = null;
|
|
46
55
|
|
|
47
56
|
var endListener = function (e) {
|
|
48
57
|
if (e && e.target !== node) {
|
|
49
58
|
return;
|
|
50
59
|
}
|
|
51
|
-
if (
|
|
60
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
52
61
|
clearTimeout(noEventTimeout);
|
|
53
62
|
}
|
|
54
63
|
|
|
@@ -71,7 +80,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
|
|
|
71
80
|
// Need to do this to actually trigger a transition.
|
|
72
81
|
this.queueClass(activeClassName);
|
|
73
82
|
|
|
74
|
-
if (
|
|
83
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
75
84
|
noEventTimeout = setTimeout(noEventListener, NO_EVENT_TIMEOUT);
|
|
76
85
|
}
|
|
77
86
|
},
|
|
@@ -12,11 +12,24 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactReconciler = require(
|
|
15
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
16
16
|
|
|
17
|
-
var flattenChildren = require(
|
|
18
|
-
var instantiateReactComponent = require(
|
|
19
|
-
var shouldUpdateReactComponent = require(
|
|
17
|
+
var flattenChildren = require('./flattenChildren');
|
|
18
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
19
|
+
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
|
|
20
|
+
var traverseAllChildren = require('./traverseAllChildren');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
22
|
+
|
|
23
|
+
function instantiateChild(childInstances, child, name) {
|
|
24
|
+
// We found a component instance.
|
|
25
|
+
var keyUnique = childInstances[name] === undefined;
|
|
26
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
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.', name) : undefined;
|
|
28
|
+
}
|
|
29
|
+
if (child != null && keyUnique) {
|
|
30
|
+
childInstances[name] = instantiateReactComponent(child, null);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
20
33
|
|
|
21
34
|
/**
|
|
22
35
|
* ReactChildReconciler provides helpers for initializing or updating a set of
|
|
@@ -24,7 +37,6 @@ var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
|
|
|
24
37
|
* does diffed reordering and insertion.
|
|
25
38
|
*/
|
|
26
39
|
var ReactChildReconciler = {
|
|
27
|
-
|
|
28
40
|
/**
|
|
29
41
|
* Generates a "mount image" for each of the supplied children. In the case
|
|
30
42
|
* of `ReactDOMComponent`, a mount image is a string of markup.
|
|
@@ -34,36 +46,31 @@ var ReactChildReconciler = {
|
|
|
34
46
|
* @internal
|
|
35
47
|
*/
|
|
36
48
|
instantiateChildren: function (nestedChildNodes, transaction, context) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (children.hasOwnProperty(name)) {
|
|
40
|
-
var child = children[name];
|
|
41
|
-
// The rendered children must be turned into instances as they're
|
|
42
|
-
// mounted.
|
|
43
|
-
var childInstance = instantiateReactComponent(child, null);
|
|
44
|
-
children[name] = childInstance;
|
|
45
|
-
}
|
|
49
|
+
if (nestedChildNodes == null) {
|
|
50
|
+
return null;
|
|
46
51
|
}
|
|
47
|
-
|
|
52
|
+
var childInstances = {};
|
|
53
|
+
traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
|
|
54
|
+
return childInstances;
|
|
48
55
|
},
|
|
49
56
|
|
|
50
57
|
/**
|
|
51
58
|
* Updates the rendered children and returns a new set of children.
|
|
52
59
|
*
|
|
53
60
|
* @param {?object} prevChildren Previously initialized set of children.
|
|
54
|
-
* @param {?object}
|
|
61
|
+
* @param {?object} nextNestedChildrenElements Nested child element maps.
|
|
55
62
|
* @param {ReactReconcileTransaction} transaction
|
|
56
63
|
* @param {object} context
|
|
57
64
|
* @return {?object} A new set of child instances.
|
|
58
65
|
* @internal
|
|
59
66
|
*/
|
|
60
|
-
updateChildren: function (prevChildren,
|
|
67
|
+
updateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
|
|
61
68
|
// We currently don't have a way to track moves here but if we use iterators
|
|
62
69
|
// instead of for..in we can zip the iterators and check if an item has
|
|
63
70
|
// moved.
|
|
64
71
|
// TODO: If nothing has changed, return the prevChildren object so that we
|
|
65
72
|
// can quickly bailout if nothing has changed.
|
|
66
|
-
var nextChildren = flattenChildren(
|
|
73
|
+
var nextChildren = flattenChildren(nextNestedChildrenElements);
|
|
67
74
|
if (!nextChildren && !prevChildren) {
|
|
68
75
|
return null;
|
|
69
76
|
}
|
package/lib/ReactChildren.js
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var PooledClass = require(
|
|
15
|
-
var ReactFragment = require(
|
|
14
|
+
var PooledClass = require('./PooledClass');
|
|
15
|
+
var ReactFragment = require('./ReactFragment');
|
|
16
16
|
|
|
17
|
-
var traverseAllChildren = require(
|
|
18
|
-
var warning = require(
|
|
17
|
+
var traverseAllChildren = require('./traverseAllChildren');
|
|
18
|
+
var warning = require('fbjs/lib/warning');
|
|
19
19
|
|
|
20
20
|
var twoArgumentPooler = PooledClass.twoArgumentPooler;
|
|
21
21
|
var threeArgumentPooler = PooledClass.threeArgumentPooler;
|
|
@@ -47,7 +47,7 @@ function forEachSingleChild(traverseContext, child, name) {
|
|
|
47
47
|
* leaf child.
|
|
48
48
|
*
|
|
49
49
|
* @param {?*} children Children tree container.
|
|
50
|
-
* @param {function(*, int)} forEachFunc
|
|
50
|
+
* @param {function(*, int)} forEachFunc
|
|
51
51
|
* @param {*} forEachContext Context for forEachContext.
|
|
52
52
|
*/
|
|
53
53
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
@@ -82,8 +82,8 @@ function mapSingleChildIntoContext(traverseContext, child, name) {
|
|
|
82
82
|
var mapResult = bookKeeping.result;
|
|
83
83
|
|
|
84
84
|
var keyUnique = mapResult[name] === undefined;
|
|
85
|
-
if (
|
|
86
|
-
|
|
85
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
86
|
+
process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'ReactChildren.map(...): 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.', name) : undefined;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
if (keyUnique) {
|
|
@@ -102,8 +102,8 @@ function mapSingleChildIntoContext(traverseContext, child, name) {
|
|
|
102
102
|
* previously relying on the fact that we guarded against null children.
|
|
103
103
|
*
|
|
104
104
|
* @param {?*} children Children tree container.
|
|
105
|
-
* @param {function(*, int)}
|
|
106
|
-
* @param {*}
|
|
105
|
+
* @param {function(*, int)} func The map function.
|
|
106
|
+
* @param {*} context Context for mapFunction.
|
|
107
107
|
* @return {object} Object containing the ordered map of results.
|
|
108
108
|
*/
|
|
109
109
|
function mapChildren(children, func, context) {
|
package/lib/ReactClass.js
CHANGED
|
@@ -11,21 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactComponent = require(
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var keyOf = require("./keyOf");
|
|
28
|
-
var warning = require("./warning");
|
|
14
|
+
var ReactComponent = require('./ReactComponent');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactErrorUtils = require('./ReactErrorUtils');
|
|
17
|
+
var ReactPropTypeLocations = require('./ReactPropTypeLocations');
|
|
18
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
19
|
+
var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
|
|
20
|
+
|
|
21
|
+
var assign = require('./Object.assign');
|
|
22
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
23
|
+
var invariant = require('fbjs/lib/invariant');
|
|
24
|
+
var keyMirror = require('fbjs/lib/keyMirror');
|
|
25
|
+
var keyOf = require('fbjs/lib/keyOf');
|
|
26
|
+
var warning = require('fbjs/lib/warning');
|
|
29
27
|
|
|
30
28
|
var MIXINS_KEY = keyOf({ mixins: null });
|
|
31
29
|
|
|
@@ -56,6 +54,14 @@ var SpecPolicy = keyMirror({
|
|
|
56
54
|
|
|
57
55
|
var injectedMixins = [];
|
|
58
56
|
|
|
57
|
+
var warnedSetProps = false;
|
|
58
|
+
function warnSetProps() {
|
|
59
|
+
if (!warnedSetProps) {
|
|
60
|
+
warnedSetProps = true;
|
|
61
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call React.render again at the top level.') : undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
/**
|
|
60
66
|
* Composite components are higher-level components that compose other composite
|
|
61
67
|
* or native components.
|
|
@@ -322,13 +328,13 @@ var RESERVED_SPEC_KEYS = {
|
|
|
322
328
|
}
|
|
323
329
|
},
|
|
324
330
|
childContextTypes: function (Constructor, childContextTypes) {
|
|
325
|
-
if (
|
|
331
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
326
332
|
validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
|
|
327
333
|
}
|
|
328
334
|
Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
|
|
329
335
|
},
|
|
330
336
|
contextTypes: function (Constructor, contextTypes) {
|
|
331
|
-
if (
|
|
337
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
332
338
|
validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
|
|
333
339
|
}
|
|
334
340
|
Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
|
|
@@ -345,7 +351,7 @@ var RESERVED_SPEC_KEYS = {
|
|
|
345
351
|
}
|
|
346
352
|
},
|
|
347
353
|
propTypes: function (Constructor, propTypes) {
|
|
348
|
-
if (
|
|
354
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
349
355
|
validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
|
|
350
356
|
}
|
|
351
357
|
Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
|
|
@@ -360,7 +366,7 @@ function validateTypeDef(Constructor, typeDef, location) {
|
|
|
360
366
|
if (typeDef.hasOwnProperty(propName)) {
|
|
361
367
|
// use a warning instead of an invariant so components
|
|
362
368
|
// don't show up in prod but not in __DEV__
|
|
363
|
-
|
|
369
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
|
|
364
370
|
}
|
|
365
371
|
}
|
|
366
372
|
}
|
|
@@ -370,12 +376,12 @@ function validateMethodOverride(proto, name) {
|
|
|
370
376
|
|
|
371
377
|
// Disallow overriding of base class methods unless explicitly allowed.
|
|
372
378
|
if (ReactClassMixin.hasOwnProperty(name)) {
|
|
373
|
-
|
|
379
|
+
!(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) : invariant(false) : undefined;
|
|
374
380
|
}
|
|
375
381
|
|
|
376
382
|
// Disallow defining methods more than once unless explicitly allowed.
|
|
377
383
|
if (proto.hasOwnProperty(name)) {
|
|
378
|
-
|
|
384
|
+
!(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) : invariant(false) : undefined;
|
|
379
385
|
}
|
|
380
386
|
}
|
|
381
387
|
|
|
@@ -388,8 +394,8 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
388
394
|
return;
|
|
389
395
|
}
|
|
390
396
|
|
|
391
|
-
'
|
|
392
|
-
|
|
397
|
+
!(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
|
|
398
|
+
!!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.') : invariant(false) : undefined;
|
|
393
399
|
|
|
394
400
|
var proto = Constructor.prototype;
|
|
395
401
|
|
|
@@ -436,7 +442,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
436
442
|
var specPolicy = ReactClassInterface[name];
|
|
437
443
|
|
|
438
444
|
// These cases should already be caught by validateMethodOverride.
|
|
439
|
-
|
|
445
|
+
!(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) : invariant(false) : undefined;
|
|
440
446
|
|
|
441
447
|
// For methods which are defined more than once, call the existing
|
|
442
448
|
// methods before calling the new property, merging if appropriate.
|
|
@@ -447,7 +453,7 @@ function mixSpecIntoComponent(Constructor, spec) {
|
|
|
447
453
|
}
|
|
448
454
|
} else {
|
|
449
455
|
proto[name] = property;
|
|
450
|
-
if (
|
|
456
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
451
457
|
// Add verbose displayName to the function, which helps when looking
|
|
452
458
|
// at profiling tools.
|
|
453
459
|
if (typeof property === 'function' && spec.displayName) {
|
|
@@ -471,10 +477,10 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
471
477
|
}
|
|
472
478
|
|
|
473
479
|
var isReserved = (name in RESERVED_SPEC_KEYS);
|
|
474
|
-
|
|
480
|
+
!!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) : invariant(false) : undefined;
|
|
475
481
|
|
|
476
482
|
var isInherited = (name in Constructor);
|
|
477
|
-
|
|
483
|
+
!!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) : invariant(false) : undefined;
|
|
478
484
|
Constructor[name] = property;
|
|
479
485
|
}
|
|
480
486
|
}
|
|
@@ -487,11 +493,11 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
|
|
|
487
493
|
* @return {object} one after it has been mutated to contain everything in two.
|
|
488
494
|
*/
|
|
489
495
|
function mergeIntoWithNoDuplicateKeys(one, two) {
|
|
490
|
-
|
|
496
|
+
!(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
|
|
491
497
|
|
|
492
498
|
for (var key in two) {
|
|
493
499
|
if (two.hasOwnProperty(key)) {
|
|
494
|
-
|
|
500
|
+
!(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) : invariant(false) : undefined;
|
|
495
501
|
one[key] = two[key];
|
|
496
502
|
}
|
|
497
503
|
}
|
|
@@ -546,7 +552,7 @@ function createChainedFunction(one, two) {
|
|
|
546
552
|
*/
|
|
547
553
|
function bindAutoBindMethod(component, method) {
|
|
548
554
|
var boundMethod = method.bind(component);
|
|
549
|
-
if (
|
|
555
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
550
556
|
boundMethod.__reactBoundContext = component;
|
|
551
557
|
boundMethod.__reactBoundMethod = method;
|
|
552
558
|
boundMethod.__reactBoundArguments = null;
|
|
@@ -562,9 +568,9 @@ function bindAutoBindMethod(component, method) {
|
|
|
562
568
|
// ignore the value of "this" that the user is trying to use, so
|
|
563
569
|
// let's warn.
|
|
564
570
|
if (newThis !== component && newThis !== null) {
|
|
565
|
-
|
|
571
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
|
|
566
572
|
} else if (!args.length) {
|
|
567
|
-
|
|
573
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : undefined;
|
|
568
574
|
return boundMethod;
|
|
569
575
|
}
|
|
570
576
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
@@ -592,18 +598,6 @@ function bindAutoBindMethods(component) {
|
|
|
592
598
|
}
|
|
593
599
|
}
|
|
594
600
|
|
|
595
|
-
var typeDeprecationDescriptor = {
|
|
596
|
-
enumerable: false,
|
|
597
|
-
get: function () {
|
|
598
|
-
var displayName = this.displayName || this.name || 'Component';
|
|
599
|
-
'production' !== process.env.NODE_ENV ? warning(false, '%s.type is deprecated. Use %s directly to access the class.', displayName, displayName) : null;
|
|
600
|
-
Object.defineProperty(this, 'type', {
|
|
601
|
-
value: this
|
|
602
|
-
});
|
|
603
|
-
return this;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
|
|
607
601
|
/**
|
|
608
602
|
* Add more to the ReactClass base class. These are all legacy features and
|
|
609
603
|
* therefore not already part of the modern ReactComponent.
|
|
@@ -615,9 +609,9 @@ var ReactClassMixin = {
|
|
|
615
609
|
* type signature and the only use case for this, is to avoid that.
|
|
616
610
|
*/
|
|
617
611
|
replaceState: function (newState, callback) {
|
|
618
|
-
|
|
612
|
+
this.updater.enqueueReplaceState(this, newState);
|
|
619
613
|
if (callback) {
|
|
620
|
-
|
|
614
|
+
this.updater.enqueueCallback(this, callback);
|
|
621
615
|
}
|
|
622
616
|
},
|
|
623
617
|
|
|
@@ -628,19 +622,7 @@ var ReactClassMixin = {
|
|
|
628
622
|
* @final
|
|
629
623
|
*/
|
|
630
624
|
isMounted: function () {
|
|
631
|
-
|
|
632
|
-
var owner = ReactCurrentOwner.current;
|
|
633
|
-
if (owner !== null) {
|
|
634
|
-
'production' !== process.env.NODE_ENV ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : null;
|
|
635
|
-
owner._warnedAboutRefsInRender = true;
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
var internalInstance = ReactInstanceMap.get(this);
|
|
639
|
-
if (internalInstance) {
|
|
640
|
-
return internalInstance !== ReactLifeCycle.currentlyMountingInstance;
|
|
641
|
-
} else {
|
|
642
|
-
return false;
|
|
643
|
-
}
|
|
625
|
+
return this.updater.isMounted(this);
|
|
644
626
|
},
|
|
645
627
|
|
|
646
628
|
/**
|
|
@@ -653,9 +635,12 @@ var ReactClassMixin = {
|
|
|
653
635
|
* @deprecated
|
|
654
636
|
*/
|
|
655
637
|
setProps: function (partialProps, callback) {
|
|
656
|
-
|
|
638
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
639
|
+
warnSetProps();
|
|
640
|
+
}
|
|
641
|
+
this.updater.enqueueSetProps(this, partialProps);
|
|
657
642
|
if (callback) {
|
|
658
|
-
|
|
643
|
+
this.updater.enqueueCallback(this, callback);
|
|
659
644
|
}
|
|
660
645
|
},
|
|
661
646
|
|
|
@@ -669,9 +654,12 @@ var ReactClassMixin = {
|
|
|
669
654
|
* @deprecated
|
|
670
655
|
*/
|
|
671
656
|
replaceProps: function (newProps, callback) {
|
|
672
|
-
|
|
657
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
658
|
+
warnSetProps();
|
|
659
|
+
}
|
|
660
|
+
this.updater.enqueueReplaceProps(this, newProps);
|
|
673
661
|
if (callback) {
|
|
674
|
-
|
|
662
|
+
this.updater.enqueueCallback(this, callback);
|
|
675
663
|
}
|
|
676
664
|
}
|
|
677
665
|
};
|
|
@@ -694,12 +682,12 @@ var ReactClass = {
|
|
|
694
682
|
* @public
|
|
695
683
|
*/
|
|
696
684
|
createClass: function (spec) {
|
|
697
|
-
var Constructor = function (props, context) {
|
|
685
|
+
var Constructor = function (props, context, updater) {
|
|
698
686
|
// This constructor is overridden by mocks. The argument is used
|
|
699
687
|
// by mocks to assert on what gets mounted.
|
|
700
688
|
|
|
701
|
-
if (
|
|
702
|
-
|
|
689
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
690
|
+
process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
|
|
703
691
|
}
|
|
704
692
|
|
|
705
693
|
// Wire up auto-binding
|
|
@@ -709,13 +697,16 @@ var ReactClass = {
|
|
|
709
697
|
|
|
710
698
|
this.props = props;
|
|
711
699
|
this.context = context;
|
|
700
|
+
this.refs = emptyObject;
|
|
701
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
702
|
+
|
|
712
703
|
this.state = null;
|
|
713
704
|
|
|
714
705
|
// ReactClasses doesn't have constructors. Instead, they use the
|
|
715
706
|
// getInitialState and componentWillMount methods for initialization.
|
|
716
707
|
|
|
717
708
|
var initialState = this.getInitialState ? this.getInitialState() : null;
|
|
718
|
-
if (
|
|
709
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
719
710
|
// We allow auto-mocks to proceed as if they're returning null.
|
|
720
711
|
if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
|
|
721
712
|
// This is probably bad practice. Consider warning here and
|
|
@@ -723,7 +714,7 @@ var ReactClass = {
|
|
|
723
714
|
initialState = null;
|
|
724
715
|
}
|
|
725
716
|
}
|
|
726
|
-
|
|
717
|
+
!(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
|
|
727
718
|
|
|
728
719
|
this.state = initialState;
|
|
729
720
|
};
|
|
@@ -739,7 +730,7 @@ var ReactClass = {
|
|
|
739
730
|
Constructor.defaultProps = Constructor.getDefaultProps();
|
|
740
731
|
}
|
|
741
732
|
|
|
742
|
-
if (
|
|
733
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
743
734
|
// This is a tag to indicate that the use of these method names is ok,
|
|
744
735
|
// since it's used with createClass. If it's not, then it's likely a
|
|
745
736
|
// mistake so we'll warn you to use the static property, property
|
|
@@ -752,10 +743,11 @@ var ReactClass = {
|
|
|
752
743
|
}
|
|
753
744
|
}
|
|
754
745
|
|
|
755
|
-
|
|
746
|
+
!Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
|
|
756
747
|
|
|
757
|
-
if (
|
|
758
|
-
|
|
748
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
749
|
+
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') : undefined;
|
|
750
|
+
process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
|
|
759
751
|
}
|
|
760
752
|
|
|
761
753
|
// Reduce time spent doing lookups by setting these on the prototype.
|
|
@@ -765,14 +757,6 @@ var ReactClass = {
|
|
|
765
757
|
}
|
|
766
758
|
}
|
|
767
759
|
|
|
768
|
-
// Legacy hook
|
|
769
|
-
Constructor.type = Constructor;
|
|
770
|
-
if ('production' !== process.env.NODE_ENV) {
|
|
771
|
-
try {
|
|
772
|
-
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
|
|
773
|
-
} catch (x) {}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
760
|
return Constructor;
|
|
777
761
|
},
|
|
778
762
|
|
|
@@ -784,6 +768,4 @@ var ReactClass = {
|
|
|
784
768
|
|
|
785
769
|
};
|
|
786
770
|
|
|
787
|
-
module.exports = ReactClass;
|
|
788
|
-
|
|
789
|
-
// IE will fail on defineProperty (es5-shim/sham too)
|
|
771
|
+
module.exports = ReactClass;
|