react 0.13.0-beta.1 → 0.13.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/JSXTransformer.js +1919 -1295
- package/dist/react-with-addons.js +1690 -1090
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1574 -1010
- package/dist/react.min.js +6 -6
- package/lib/AutoFocusMixin.js +1 -1
- package/lib/BeforeInputEventPlugin.js +1 -5
- package/lib/CSSCore.js +1 -1
- package/lib/CSSProperty.js +3 -1
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +1 -1
- package/lib/ChangeEventPlugin.js +1 -1
- package/lib/ClientReactRootIndex.js +1 -1
- package/lib/DOMChildrenOperations.js +4 -43
- package/lib/DOMProperty.js +1 -1
- package/lib/DOMPropertyOperations.js +7 -14
- package/lib/Danger.js +1 -1
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +1 -1
- package/lib/EventConstants.js +1 -1
- package/lib/EventListener.js +1 -1
- package/lib/EventPluginHub.js +1 -1
- package/lib/EventPluginRegistry.js +1 -1
- package/lib/EventPluginUtils.js +3 -3
- package/lib/EventPropagators.js +1 -1
- package/lib/ExecutionEnvironment.js +1 -1
- package/lib/FallbackCompositionState.js +1 -1
- package/lib/HTMLDOMPropertyConfig.js +12 -5
- package/lib/LinkedStateMixin.js +1 -1
- package/lib/LinkedValueUtils.js +1 -1
- package/lib/LocalEventTrapMixin.js +1 -1
- package/lib/MobileSafariClickEventPlugin.js +1 -1
- package/lib/Object.assign.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +7 -9
- package/lib/ReactBrowserComponentMixin.js +1 -1
- package/lib/ReactBrowserEventEmitter.js +2 -2
- package/lib/ReactCSSTransitionGroup.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +8 -5
- package/lib/ReactChildReconciler.js +1 -1
- package/lib/ReactChildren.js +3 -2
- package/lib/ReactClass.js +49 -23
- package/lib/ReactComponent.js +35 -19
- package/lib/ReactComponentBrowserEnvironment.js +1 -1
- package/lib/ReactComponentEnvironment.js +1 -1
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +89 -40
- package/lib/ReactContext.js +13 -3
- package/lib/ReactCurrentOwner.js +1 -1
- package/lib/ReactDOM.js +1 -1
- package/lib/ReactDOMButton.js +1 -1
- package/lib/ReactDOMComponent.js +19 -19
- package/lib/ReactDOMForm.js +1 -1
- package/lib/ReactDOMIDOperations.js +3 -3
- package/lib/ReactDOMIframe.js +43 -0
- package/lib/ReactDOMImg.js +1 -1
- package/lib/ReactDOMInput.js +1 -1
- package/lib/ReactDOMOption.js +1 -1
- package/lib/ReactDOMSelect.js +1 -1
- package/lib/ReactDOMSelection.js +1 -1
- package/lib/ReactDOMTextComponent.js +3 -5
- package/lib/ReactDOMTextarea.js +1 -1
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +25 -1
- package/lib/ReactDefaultPerf.js +5 -10
- package/lib/ReactDefaultPerfAnalysis.js +1 -1
- package/lib/ReactElement.js +56 -2
- package/lib/ReactElementValidator.js +122 -79
- package/lib/ReactEmptyComponent.js +5 -5
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +1 -1
- package/lib/ReactEventListener.js +1 -1
- package/lib/ReactFragment.js +181 -0
- package/lib/ReactInjection.js +1 -1
- package/lib/ReactInputSelection.js +1 -1
- package/lib/ReactInstanceHandles.js +1 -1
- package/lib/ReactInstanceMap.js +1 -1
- package/lib/ReactLifeCycle.js +1 -1
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +1 -1
- package/lib/ReactMount.js +32 -10
- package/lib/ReactMultiChild.js +1 -1
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +7 -20
- package/lib/ReactOwner.js +1 -1
- package/lib/ReactPerf.js +1 -1
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +7 -4
- package/lib/ReactPutListenerQueue.js +1 -1
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +15 -2
- package/lib/ReactRef.js +2 -3
- package/lib/ReactRootIndex.js +1 -1
- package/lib/ReactServerRendering.js +1 -1
- package/lib/ReactServerRenderingTransaction.js +1 -1
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +19 -7
- package/lib/ReactTransitionChildMapping.js +7 -3
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -5
- package/lib/ReactUpdateQueue.js +63 -32
- package/lib/ReactUpdates.js +7 -2
- package/lib/ReactWithAddons.js +3 -1
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +1 -1
- package/lib/ServerReactRootIndex.js +1 -1
- package/lib/SimpleEventPlugin.js +3 -3
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +1 -1
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +1 -1
- package/lib/SyntheticMouseEvent.js +1 -1
- package/lib/SyntheticTouchEvent.js +1 -1
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/Transaction.js +2 -2
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulateInto.js +1 -1
- package/lib/adler32.js +1 -1
- package/lib/camelize.js +1 -1
- package/lib/camelizeStyleName.js +1 -1
- package/lib/cloneWithProps.js +4 -4
- package/lib/containsNode.js +1 -1
- package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
- package/lib/createFullPageComponent.js +1 -1
- package/lib/createNodesFromMarkup.js +4 -4
- package/lib/cx.js +16 -1
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/emptyFunction.js +1 -1
- package/lib/emptyObject.js +1 -1
- package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +4 -5
- package/lib/findDOMNode.js +19 -1
- package/lib/flattenChildren.js +1 -1
- package/lib/focusNode.js +1 -1
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getActiveElement.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +1 -1
- package/lib/getEventTarget.js +1 -1
- package/lib/getIteratorFn.js +1 -1
- package/lib/getMarkupWrap.js +1 -1
- package/lib/getNodeForCharacterOffset.js +1 -1
- package/lib/getReactRootElementInContainer.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getUnboundedScrollPosition.js +1 -1
- package/lib/hyphenate.js +1 -1
- package/lib/hyphenateStyleName.js +1 -1
- package/lib/instantiateReactComponent.js +6 -1
- package/lib/invariant.js +1 -1
- package/lib/isEventSupported.js +1 -1
- package/lib/isNode.js +1 -1
- 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/mapObject.js +1 -1
- package/lib/memoizeStringOnly.js +1 -1
- package/lib/onlyChild.js +1 -1
- package/lib/performance.js +1 -1
- package/lib/performanceNow.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +26 -0
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +40 -0
- package/lib/shallowEqual.js +1 -1
- package/lib/shouldUpdateReactComponent.js +32 -10
- package/lib/toArray.js +2 -2
- package/lib/traverseAllChildren.js +18 -4
- package/lib/update.js +1 -1
- package/lib/warning.js +9 -2
- package/package.json +1 -1
- package/lib/copyProperties.js +0 -56
- package/lib/merge.js +0 -34
- package/lib/mergeInto.js +0 -24
- package/lib/monitorCodeUse.js +0 -30
package/lib/Object.assign.js
CHANGED
package/lib/PooledClass.js
CHANGED
package/lib/React.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
var DOMPropertyOperations = require("./DOMPropertyOperations");
|
|
17
16
|
var EventPluginUtils = require("./EventPluginUtils");
|
|
18
17
|
var ReactChildren = require("./ReactChildren");
|
|
19
18
|
var ReactComponent = require("./ReactComponent");
|
|
@@ -23,14 +22,13 @@ var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
|
23
22
|
var ReactElement = require("./ReactElement");
|
|
24
23
|
var ReactElementValidator = require("./ReactElementValidator");
|
|
25
24
|
var ReactDOM = require("./ReactDOM");
|
|
26
|
-
var ReactDOMComponent = require("./ReactDOMComponent");
|
|
27
25
|
var ReactDOMTextComponent = require("./ReactDOMTextComponent");
|
|
28
26
|
var ReactDefaultInjection = require("./ReactDefaultInjection");
|
|
29
27
|
var ReactInstanceHandles = require("./ReactInstanceHandles");
|
|
30
28
|
var ReactMount = require("./ReactMount");
|
|
31
|
-
var ReactMultiChild = require("./ReactMultiChild");
|
|
32
29
|
var ReactPerf = require("./ReactPerf");
|
|
33
30
|
var ReactPropTypes = require("./ReactPropTypes");
|
|
31
|
+
var ReactReconciler = require("./ReactReconciler");
|
|
34
32
|
var ReactServerRendering = require("./ReactServerRendering");
|
|
35
33
|
|
|
36
34
|
var assign = require("./Object.assign");
|
|
@@ -41,10 +39,12 @@ ReactDefaultInjection.inject();
|
|
|
41
39
|
|
|
42
40
|
var createElement = ReactElement.createElement;
|
|
43
41
|
var createFactory = ReactElement.createFactory;
|
|
42
|
+
var cloneElement = ReactElement.cloneElement;
|
|
44
43
|
|
|
45
44
|
if ("production" !== process.env.NODE_ENV) {
|
|
46
45
|
createElement = ReactElementValidator.createElement;
|
|
47
46
|
createFactory = ReactElementValidator.createFactory;
|
|
47
|
+
cloneElement = ReactElementValidator.cloneElement;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
var render = ReactPerf.measure('React', 'render', ReactMount.render);
|
|
@@ -64,6 +64,7 @@ var React = {
|
|
|
64
64
|
},
|
|
65
65
|
createClass: ReactClass.createClass,
|
|
66
66
|
createElement: createElement,
|
|
67
|
+
cloneElement: cloneElement,
|
|
67
68
|
createFactory: createFactory,
|
|
68
69
|
createMixin: function(mixin) {
|
|
69
70
|
// Currently a noop. Will be used to validate and trace mixins.
|
|
@@ -89,13 +90,10 @@ if (
|
|
|
89
90
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
90
91
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
|
|
91
92
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
|
|
92
|
-
// TODO: Inject a hook for notifying devtools of updates
|
|
93
93
|
CurrentOwner: ReactCurrentOwner,
|
|
94
|
-
DOMComponent: ReactDOMComponent,
|
|
95
|
-
DOMPropertyOperations: DOMPropertyOperations,
|
|
96
94
|
InstanceHandles: ReactInstanceHandles,
|
|
97
95
|
Mount: ReactMount,
|
|
98
|
-
|
|
96
|
+
Reconciler: ReactReconciler,
|
|
99
97
|
TextComponent: ReactDOMTextComponent
|
|
100
98
|
});
|
|
101
99
|
}
|
|
@@ -145,6 +143,6 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
|
|
148
|
-
React.version = '0.13.0
|
|
146
|
+
React.version = '0.13.0';
|
|
149
147
|
|
|
150
148
|
module.exports = React;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -326,7 +326,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
|
|
|
326
326
|
*
|
|
327
327
|
* @see http://www.quirksmode.org/dom/events/scroll.html
|
|
328
328
|
*/
|
|
329
|
-
ensureScrollValueMonitoring: function(){
|
|
329
|
+
ensureScrollValueMonitoring: function() {
|
|
330
330
|
if (!isMonitoringScrollValue) {
|
|
331
331
|
var refresh = ViewportMetrics.refreshScrollValues;
|
|
332
332
|
ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -18,6 +18,7 @@ var CSSCore = require("./CSSCore");
|
|
|
18
18
|
var ReactTransitionEvents = require("./ReactTransitionEvents");
|
|
19
19
|
|
|
20
20
|
var onlyChild = require("./onlyChild");
|
|
21
|
+
var warning = require("./warning");
|
|
21
22
|
|
|
22
23
|
// We don't remove the element from the DOM until we receive an animationend or
|
|
23
24
|
// transitionend event. If the user screws up and forgets to add an animation
|
|
@@ -31,12 +32,14 @@ var noEventListener = null;
|
|
|
31
32
|
|
|
32
33
|
if ("production" !== process.env.NODE_ENV) {
|
|
33
34
|
noEventListener = function() {
|
|
34
|
-
|
|
35
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
36
|
+
false,
|
|
35
37
|
'transition(): tried to perform an animation without ' +
|
|
36
38
|
'an animationend or transitionend event after timeout (' +
|
|
37
|
-
|
|
38
|
-
'transition in JS or add a CSS animation/transition.'
|
|
39
|
-
|
|
39
|
+
'%sms). You should either disable this ' +
|
|
40
|
+
'transition in JS or add a CSS animation/transition.',
|
|
41
|
+
NO_EVENT_TIMEOUT
|
|
42
|
+
) : null);
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
|
package/lib/ReactChildren.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var PooledClass = require("./PooledClass");
|
|
15
|
+
var ReactFragment = require("./ReactFragment");
|
|
15
16
|
|
|
16
17
|
var traverseAllChildren = require("./traverseAllChildren");
|
|
17
18
|
var warning = require("./warning");
|
|
@@ -121,7 +122,7 @@ function mapChildren(children, func, context) {
|
|
|
121
122
|
var traverseContext = MapBookKeeping.getPooled(mapResult, func, context);
|
|
122
123
|
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
123
124
|
MapBookKeeping.release(traverseContext);
|
|
124
|
-
return mapResult;
|
|
125
|
+
return ReactFragment.create(mapResult);
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
function forEachSingleChildDummy(traverseContext, child, name, i) {
|
package/lib/ReactClass.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
var ReactComponent = require("./ReactComponent");
|
|
15
|
+
var ReactCurrentOwner = require("./ReactCurrentOwner");
|
|
15
16
|
var ReactElement = require("./ReactElement");
|
|
16
17
|
var ReactErrorUtils = require("./ReactErrorUtils");
|
|
17
18
|
var ReactInstanceMap = require("./ReactInstanceMap");
|
|
@@ -24,7 +25,6 @@ var assign = require("./Object.assign");
|
|
|
24
25
|
var invariant = require("./invariant");
|
|
25
26
|
var keyMirror = require("./keyMirror");
|
|
26
27
|
var keyOf = require("./keyOf");
|
|
27
|
-
var monitorCodeUse = require("./monitorCodeUse");
|
|
28
28
|
var warning = require("./warning");
|
|
29
29
|
|
|
30
30
|
var MIXINS_KEY = keyOf({mixins: null});
|
|
@@ -661,18 +661,20 @@ function bindAutoBindMethod(component, method) {
|
|
|
661
661
|
// ignore the value of "this" that the user is trying to use, so
|
|
662
662
|
// let's warn.
|
|
663
663
|
if (newThis !== component && newThis !== null) {
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
665
|
+
false,
|
|
666
666
|
'bind(): React component methods may only be bound to the ' +
|
|
667
|
-
'component instance. See '
|
|
668
|
-
|
|
667
|
+
'component instance. See %s',
|
|
668
|
+
componentName
|
|
669
|
+
) : null);
|
|
669
670
|
} else if (!args.length) {
|
|
670
|
-
|
|
671
|
-
|
|
671
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
672
|
+
false,
|
|
672
673
|
'bind(): You are binding a component method to the component. ' +
|
|
673
674
|
'React does this for you automatically in a high-performance ' +
|
|
674
|
-
'way, so you can safely remove this call. See '
|
|
675
|
-
|
|
675
|
+
'way, so you can safely remove this call. See %s',
|
|
676
|
+
componentName
|
|
677
|
+
) : null);
|
|
676
678
|
return boundMethod;
|
|
677
679
|
}
|
|
678
680
|
var reboundMethod = _bind.apply(boundMethod, arguments);
|
|
@@ -716,6 +718,9 @@ var typeDeprecationDescriptor = {
|
|
|
716
718
|
displayName,
|
|
717
719
|
displayName
|
|
718
720
|
) : null);
|
|
721
|
+
Object.defineProperty(this, 'type', {
|
|
722
|
+
value: this
|
|
723
|
+
});
|
|
719
724
|
return this;
|
|
720
725
|
}
|
|
721
726
|
};
|
|
@@ -744,6 +749,21 @@ var ReactClassMixin = {
|
|
|
744
749
|
* @final
|
|
745
750
|
*/
|
|
746
751
|
isMounted: function() {
|
|
752
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
753
|
+
var owner = ReactCurrentOwner.current;
|
|
754
|
+
if (owner !== null) {
|
|
755
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
756
|
+
owner._warnedAboutRefsInRender,
|
|
757
|
+
'%s is accessing isMounted inside its render() function. ' +
|
|
758
|
+
'render() should be a pure function of props and state. It should ' +
|
|
759
|
+
'never access something that requires stale data from the previous ' +
|
|
760
|
+
'render, such as refs. Move this logic to componentDidMount and ' +
|
|
761
|
+
'componentDidUpdate instead.',
|
|
762
|
+
owner.getName() || 'A component'
|
|
763
|
+
) : null);
|
|
764
|
+
owner._warnedAboutRefsInRender = true;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
747
767
|
var internalInstance = ReactInstanceMap.get(this);
|
|
748
768
|
return (
|
|
749
769
|
internalInstance &&
|
|
@@ -810,6 +830,14 @@ var ReactClass = {
|
|
|
810
830
|
// This constructor is overridden by mocks. The argument is used
|
|
811
831
|
// by mocks to assert on what gets mounted.
|
|
812
832
|
|
|
833
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
834
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
835
|
+
this instanceof Constructor,
|
|
836
|
+
'Something is calling a React component directly. Use a factory or ' +
|
|
837
|
+
'JSX instead. See: http://fb.me/react-legacyfactory'
|
|
838
|
+
) : null);
|
|
839
|
+
}
|
|
840
|
+
|
|
813
841
|
// Wire up auto-binding
|
|
814
842
|
if (this.__reactAutoBindMap) {
|
|
815
843
|
bindAutoBindMethods(this);
|
|
@@ -873,18 +901,14 @@ var ReactClass = {
|
|
|
873
901
|
) : invariant(Constructor.prototype.render));
|
|
874
902
|
|
|
875
903
|
if ("production" !== process.env.NODE_ENV) {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
'The name is phrased as a question because the function is ' +
|
|
885
|
-
'expected to return a value.'
|
|
886
|
-
);
|
|
887
|
-
}
|
|
904
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
905
|
+
!Constructor.prototype.componentShouldUpdate,
|
|
906
|
+
'%s has a method called ' +
|
|
907
|
+
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
|
|
908
|
+
'The name is phrased as a question because the function is ' +
|
|
909
|
+
'expected to return a value.',
|
|
910
|
+
spec.displayName || 'A component'
|
|
911
|
+
) : null);
|
|
888
912
|
}
|
|
889
913
|
|
|
890
914
|
// Reduce time spent doing lookups by setting these on the prototype.
|
|
@@ -897,8 +921,10 @@ var ReactClass = {
|
|
|
897
921
|
// Legacy hook
|
|
898
922
|
Constructor.type = Constructor;
|
|
899
923
|
if ("production" !== process.env.NODE_ENV) {
|
|
900
|
-
|
|
924
|
+
try {
|
|
901
925
|
Object.defineProperty(Constructor, 'type', typeDeprecationDescriptor);
|
|
926
|
+
} catch (x) {
|
|
927
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
902
928
|
}
|
|
903
929
|
}
|
|
904
930
|
|
package/lib/ReactComponent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -36,16 +36,29 @@ function ReactComponent(props, context) {
|
|
|
36
36
|
* callback that will be executed when the call to setState is actually
|
|
37
37
|
* completed.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
39
|
+
* When a function is provided to setState, it will be called at some point in
|
|
40
|
+
* the future (not synchronously). It will be called with the up to date
|
|
41
|
+
* component arguments (state, props, context). These values can be different
|
|
42
|
+
* from this.* because your function may be called after receiveProps but before
|
|
43
|
+
* shouldComponentUpdate, and this new state, props, and context will not yet be
|
|
44
|
+
* assigned to this.
|
|
45
|
+
*
|
|
46
|
+
* @param {object|function} partialState Next partial state or function to
|
|
47
|
+
* produce next partial state to be merged with current state.
|
|
40
48
|
* @param {?function} callback Called after state is updated.
|
|
41
49
|
* @final
|
|
42
50
|
* @protected
|
|
43
51
|
*/
|
|
44
52
|
ReactComponent.prototype.setState = function(partialState, callback) {
|
|
45
53
|
("production" !== process.env.NODE_ENV ? invariant(
|
|
46
|
-
typeof partialState === 'object' ||
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
typeof partialState === 'object' ||
|
|
55
|
+
typeof partialState === 'function' ||
|
|
56
|
+
partialState == null,
|
|
57
|
+
'setState(...): takes an object of state variables to update or a ' +
|
|
58
|
+
'function which returns an object of state variables.'
|
|
59
|
+
) : invariant(typeof partialState === 'object' ||
|
|
60
|
+
typeof partialState === 'function' ||
|
|
61
|
+
partialState == null));
|
|
49
62
|
if ("production" !== process.env.NODE_ENV) {
|
|
50
63
|
("production" !== process.env.NODE_ENV ? warning(
|
|
51
64
|
partialState != null,
|
|
@@ -66,7 +79,7 @@ ReactComponent.prototype.setState = function(partialState, callback) {
|
|
|
66
79
|
* You may want to call this when you know that some deeper aspect of the
|
|
67
80
|
* component's state has changed but `setState` was not called.
|
|
68
81
|
*
|
|
69
|
-
* This will not invoke `
|
|
82
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
70
83
|
* `componentWillUpdate` and `componentDidUpdate`.
|
|
71
84
|
*
|
|
72
85
|
* @param {?function} callback Called after update is complete.
|
|
@@ -86,14 +99,15 @@ ReactComponent.prototype.forceUpdate = function(callback) {
|
|
|
86
99
|
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
87
100
|
*/
|
|
88
101
|
if ("production" !== process.env.NODE_ENV) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
var deprecatedAPIs = {
|
|
103
|
+
getDOMNode: 'getDOMNode',
|
|
104
|
+
isMounted: 'isMounted',
|
|
105
|
+
replaceProps: 'replaceProps',
|
|
106
|
+
replaceState: 'replaceState',
|
|
107
|
+
setProps: 'setProps'
|
|
108
|
+
};
|
|
109
|
+
var defineDeprecationWarning = function(methodName, displayName) {
|
|
110
|
+
try {
|
|
97
111
|
Object.defineProperty(ReactComponent.prototype, methodName, {
|
|
98
112
|
get: function() {
|
|
99
113
|
("production" !== process.env.NODE_ENV ? warning(
|
|
@@ -104,11 +118,13 @@ if ("production" !== process.env.NODE_ENV) {
|
|
|
104
118
|
return undefined;
|
|
105
119
|
}
|
|
106
120
|
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
} catch (x) {
|
|
122
|
+
// IE will fail on defineProperty (es5-shim/sham too)
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
for (var fnName in deprecatedAPIs) {
|
|
126
|
+
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
127
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -96,7 +96,8 @@ var ReactCompositeComponentMixin = {
|
|
|
96
96
|
|
|
97
97
|
// See ReactUpdateQueue
|
|
98
98
|
this._pendingElement = null;
|
|
99
|
-
this.
|
|
99
|
+
this._pendingStateQueue = null;
|
|
100
|
+
this._pendingReplaceState = false;
|
|
100
101
|
this._pendingForceUpdate = false;
|
|
101
102
|
|
|
102
103
|
this._renderedComponent = null;
|
|
@@ -132,6 +133,20 @@ var ReactCompositeComponentMixin = {
|
|
|
132
133
|
|
|
133
134
|
// Initialize the public class
|
|
134
135
|
var inst = new Component(publicProps, publicContext);
|
|
136
|
+
|
|
137
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
138
|
+
// This will throw later in _renderValidatedComponent, but add an early
|
|
139
|
+
// warning now to help debugging
|
|
140
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
141
|
+
inst.render != null,
|
|
142
|
+
'%s(...): No `render` method found on the returned component ' +
|
|
143
|
+
'instance: you may have forgotten to define `render` in your ' +
|
|
144
|
+
'component or you may have accidentally tried to render an element ' +
|
|
145
|
+
'whose type is a function that isn\'t a React component.',
|
|
146
|
+
Component.displayName || Component.name || 'Component'
|
|
147
|
+
) : null);
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
// These should be set up in the constructor, but as a convenience for
|
|
136
151
|
// simpler class abstractions, we set them up after the fact.
|
|
137
152
|
inst.props = publicProps;
|
|
@@ -191,26 +206,29 @@ var ReactCompositeComponentMixin = {
|
|
|
191
206
|
this.getName() || 'ReactCompositeComponent'
|
|
192
207
|
) : invariant(typeof initialState === 'object' && !Array.isArray(initialState)));
|
|
193
208
|
|
|
194
|
-
this.
|
|
209
|
+
this._pendingStateQueue = null;
|
|
210
|
+
this._pendingReplaceState = false;
|
|
195
211
|
this._pendingForceUpdate = false;
|
|
196
212
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
213
|
+
var renderedElement;
|
|
214
|
+
|
|
215
|
+
var previouslyMounting = ReactLifeCycle.currentlyMountingInstance;
|
|
216
|
+
ReactLifeCycle.currentlyMountingInstance = this;
|
|
217
|
+
try {
|
|
218
|
+
if (inst.componentWillMount) {
|
|
201
219
|
inst.componentWillMount();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (this._pendingState) {
|
|
208
|
-
inst.state = this._pendingState;
|
|
209
|
-
this._pendingState = null;
|
|
220
|
+
// When mounting, calls to `setState` by `componentWillMount` will set
|
|
221
|
+
// `this._pendingStateQueue` without triggering a re-render.
|
|
222
|
+
if (this._pendingStateQueue) {
|
|
223
|
+
inst.state = this._processPendingState(inst.props, inst.context);
|
|
224
|
+
}
|
|
210
225
|
}
|
|
226
|
+
|
|
227
|
+
renderedElement = this._renderValidatedComponent();
|
|
228
|
+
} finally {
|
|
229
|
+
ReactLifeCycle.currentlyMountingInstance = previouslyMounting;
|
|
211
230
|
}
|
|
212
231
|
|
|
213
|
-
var renderedElement = this._renderValidatedComponent();
|
|
214
232
|
this._renderedComponent = this._instantiateReactComponent(
|
|
215
233
|
renderedElement,
|
|
216
234
|
this._currentElement.type // The wrapping type
|
|
@@ -252,13 +270,12 @@ var ReactCompositeComponentMixin = {
|
|
|
252
270
|
this._renderedComponent = null;
|
|
253
271
|
|
|
254
272
|
// Reset pending fields
|
|
255
|
-
this.
|
|
273
|
+
this._pendingStateQueue = null;
|
|
274
|
+
this._pendingReplaceState = false;
|
|
256
275
|
this._pendingForceUpdate = false;
|
|
257
276
|
this._pendingCallbacks = null;
|
|
258
277
|
this._pendingElement = null;
|
|
259
278
|
|
|
260
|
-
ReactComponentEnvironment.unmountIDFromEnvironment(this._rootNodeID);
|
|
261
|
-
|
|
262
279
|
// These fields do not really need to be reset since this object is no
|
|
263
280
|
// longer accessible.
|
|
264
281
|
this._context = null;
|
|
@@ -444,10 +461,19 @@ var ReactCompositeComponentMixin = {
|
|
|
444
461
|
|
|
445
462
|
if (location === ReactPropTypeLocations.prop) {
|
|
446
463
|
// Preface gives us something to blacklist in warning module
|
|
447
|
-
|
|
448
|
-
|
|
464
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
465
|
+
false,
|
|
466
|
+
'Failed Composite propType: %s%s',
|
|
467
|
+
error.message,
|
|
468
|
+
addendum
|
|
469
|
+
) : null);
|
|
449
470
|
} else {
|
|
450
|
-
("production" !== process.env.NODE_ENV ? warning(
|
|
471
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
472
|
+
false,
|
|
473
|
+
'Failed Context Types: %s%s',
|
|
474
|
+
error.message,
|
|
475
|
+
addendum
|
|
476
|
+
) : null);
|
|
451
477
|
}
|
|
452
478
|
}
|
|
453
479
|
}
|
|
@@ -470,7 +496,7 @@ var ReactCompositeComponentMixin = {
|
|
|
470
496
|
},
|
|
471
497
|
|
|
472
498
|
/**
|
|
473
|
-
* If any of `_pendingElement`, `
|
|
499
|
+
* If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
|
|
474
500
|
* is set, update the component.
|
|
475
501
|
*
|
|
476
502
|
* @param {ReactReconcileTransaction} transaction
|
|
@@ -486,7 +512,7 @@ var ReactCompositeComponentMixin = {
|
|
|
486
512
|
);
|
|
487
513
|
}
|
|
488
514
|
|
|
489
|
-
if (this.
|
|
515
|
+
if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
|
|
490
516
|
if ("production" !== process.env.NODE_ENV) {
|
|
491
517
|
ReactElementValidator.checkAndWarnForMutatedProps(
|
|
492
518
|
this._currentElement
|
|
@@ -551,10 +577,8 @@ var ReactCompositeComponentMixin = {
|
|
|
551
577
|
) {
|
|
552
578
|
var inst = this._instance;
|
|
553
579
|
|
|
554
|
-
var
|
|
555
|
-
var
|
|
556
|
-
var nextContext = prevContext;
|
|
557
|
-
var nextProps = prevProps;
|
|
580
|
+
var nextContext = inst.context;
|
|
581
|
+
var nextProps = inst.props;
|
|
558
582
|
|
|
559
583
|
// Distinguish between a props update versus a simple state update
|
|
560
584
|
if (prevParentElement !== nextParentElement) {
|
|
@@ -563,12 +587,15 @@ var ReactCompositeComponentMixin = {
|
|
|
563
587
|
|
|
564
588
|
if ("production" !== process.env.NODE_ENV) {
|
|
565
589
|
if (nextUnmaskedContext != null) {
|
|
566
|
-
this._warnIfContextsDiffer(
|
|
590
|
+
this._warnIfContextsDiffer(
|
|
591
|
+
nextParentElement._context,
|
|
592
|
+
nextUnmaskedContext
|
|
593
|
+
);
|
|
567
594
|
}
|
|
568
595
|
}
|
|
569
596
|
|
|
570
597
|
// An update here will schedule an update but immediately set
|
|
571
|
-
//
|
|
598
|
+
// _pendingStateQueue which will ensure that any state updates gets
|
|
572
599
|
// immediately reconciled instead of waiting for the next batch.
|
|
573
600
|
|
|
574
601
|
if (inst.componentWillReceiveProps) {
|
|
@@ -576,8 +603,7 @@ var ReactCompositeComponentMixin = {
|
|
|
576
603
|
}
|
|
577
604
|
}
|
|
578
605
|
|
|
579
|
-
var nextState = this.
|
|
580
|
-
this._pendingState = null;
|
|
606
|
+
var nextState = this._processPendingState(nextProps, nextContext);
|
|
581
607
|
|
|
582
608
|
var shouldUpdate =
|
|
583
609
|
this._pendingForceUpdate ||
|
|
@@ -585,13 +611,12 @@ var ReactCompositeComponentMixin = {
|
|
|
585
611
|
inst.shouldComponentUpdate(nextProps, nextState, nextContext);
|
|
586
612
|
|
|
587
613
|
if ("production" !== process.env.NODE_ENV) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
}
|
|
614
|
+
("production" !== process.env.NODE_ENV ? warning(
|
|
615
|
+
typeof shouldUpdate !== 'undefined',
|
|
616
|
+
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
|
|
617
|
+
'boolean value. Make sure to return true or false.',
|
|
618
|
+
this.getName() || 'ReactCompositeComponent'
|
|
619
|
+
) : null);
|
|
595
620
|
}
|
|
596
621
|
|
|
597
622
|
if (shouldUpdate) {
|
|
@@ -616,6 +641,31 @@ var ReactCompositeComponentMixin = {
|
|
|
616
641
|
}
|
|
617
642
|
},
|
|
618
643
|
|
|
644
|
+
_processPendingState: function(props, context) {
|
|
645
|
+
var inst = this._instance;
|
|
646
|
+
var queue = this._pendingStateQueue;
|
|
647
|
+
var replace = this._pendingReplaceState;
|
|
648
|
+
this._pendingReplaceState = false;
|
|
649
|
+
this._pendingStateQueue = null;
|
|
650
|
+
|
|
651
|
+
if (!queue) {
|
|
652
|
+
return inst.state;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
var nextState = assign({}, replace ? queue[0] : inst.state);
|
|
656
|
+
for (var i = replace ? 1 : 0; i < queue.length; i++) {
|
|
657
|
+
var partial = queue[i];
|
|
658
|
+
assign(
|
|
659
|
+
nextState,
|
|
660
|
+
typeof partial === 'function' ?
|
|
661
|
+
partial.call(inst, nextState, props, context) :
|
|
662
|
+
partial
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return nextState;
|
|
667
|
+
},
|
|
668
|
+
|
|
619
669
|
/**
|
|
620
670
|
* Merges new props and state, notifies delegate methods of update and
|
|
621
671
|
* performs update.
|
|
@@ -638,7 +688,6 @@ var ReactCompositeComponentMixin = {
|
|
|
638
688
|
) {
|
|
639
689
|
var inst = this._instance;
|
|
640
690
|
|
|
641
|
-
var prevElement = this._currentElement;
|
|
642
691
|
var prevProps = inst.props;
|
|
643
692
|
var prevState = inst.state;
|
|
644
693
|
var prevContext = inst.context;
|