react 0.14.10 → 15.0.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/LICENSE +1 -1
- package/dist/react-with-addons.js +4900 -4627
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4556 -4059
- package/dist/react.min.js +7 -7
- package/lib/AutoFocusUtils.js +3 -15
- package/lib/BeforeInputEventPlugin.js +8 -25
- package/lib/CSSProperty.js +10 -1
- package/lib/CSSPropertyOperations.js +49 -19
- package/lib/CallbackQueue.js +16 -4
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +91 -61
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +18 -39
- package/lib/DOMPropertyOperations.js +42 -53
- package/lib/Danger.js +13 -14
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +22 -66
- package/lib/EventPluginRegistry.js +30 -9
- package/lib/EventPluginUtils.js +61 -36
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +4 -4
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +6 -7
- package/lib/MetaMatchers.js +2 -2
- package/lib/OrderedMap.js +17 -16
- package/lib/PooledClass.js +2 -2
- package/lib/React.js +50 -20
- package/lib/ReactBrowserEventEmitter.js +19 -26
- package/lib/ReactCSSTransitionGroup.js +4 -5
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +15 -13
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +44 -92
- package/lib/ReactComponent.js +9 -10
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +4 -4
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +166 -74
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +27 -15
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +186 -250
- package/lib/ReactDOMComponentFlags.js +18 -0
- package/lib/ReactDOMComponentTree.js +186 -0
- package/lib/ReactDOMContainerInfo.js +32 -0
- package/lib/ReactDOMDebugTool.js +61 -0
- package/lib/ReactDOMEmptyComponent.js +60 -0
- package/lib/ReactDOMFactories.js +1 -2
- package/lib/ReactDOMFeatureFlags.js +2 -2
- package/lib/ReactDOMIDOperations.js +5 -60
- package/lib/ReactDOMInput.js +73 -23
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +14 -12
- package/lib/ReactDOMSelect.js +43 -19
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +87 -45
- package/lib/ReactDOMTextarea.js +39 -11
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugInstanceMap.js +102 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +4 -3
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +105 -26
- package/lib/ReactDefaultPerfAnalysis.js +23 -15
- package/lib/ReactElement.js +63 -23
- package/lib/ReactElementValidator.js +9 -9
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +23 -77
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +6 -6
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -12
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +88 -460
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +6 -5
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +2 -25
- package/lib/ReactOwner.js +7 -6
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +5 -4
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +20 -9
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +17 -35
- package/lib/ReactServerRenderingTransaction.js +11 -29
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +47 -28
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +4 -3
- package/lib/ReactUMDEntry.js +26 -0
- package/lib/ReactUpdateQueue.js +24 -66
- package/lib/ReactUpdates.js +29 -11
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -21
- package/lib/ReactWithAddonsUMDEntry.js +26 -0
- package/lib/ResponderEventPlugin.js +54 -66
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +5 -5
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +57 -17
- package/lib/SyntheticAnimationEvent.js +39 -0
- package/lib/SyntheticClipboardEvent.js +2 -3
- package/lib/SyntheticCompositionEvent.js +2 -3
- package/lib/SyntheticDragEvent.js +2 -3
- package/lib/SyntheticEvent.js +102 -21
- package/lib/SyntheticFocusEvent.js +2 -3
- package/lib/SyntheticInputEvent.js +2 -3
- package/lib/SyntheticKeyboardEvent.js +2 -3
- package/lib/SyntheticMouseEvent.js +2 -3
- package/lib/SyntheticTouchEvent.js +2 -3
- package/lib/SyntheticTransitionEvent.js +39 -0
- package/lib/SyntheticUIEvent.js +2 -3
- package/lib/SyntheticWheelEvent.js +2 -3
- package/lib/TapEventPlugin.js +3 -12
- package/lib/Transaction.js +3 -3
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +2 -2
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +3 -2
- package/lib/canDefineProperty.js +1 -1
- package/lib/createHierarchyRenderer.js +1 -1
- package/lib/createMicrosoftUnsafeLocalFunction.js +32 -0
- package/lib/dangerousStyleValue.js +25 -3
- package/lib/deprecated.js +7 -4
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +2 -2
- package/lib/forEachAccumulated.js +2 -1
- package/lib/getEventCharCode.js +2 -2
- package/lib/getEventKey.js +1 -2
- package/lib/getEventModifierState.js +1 -2
- package/lib/getEventTarget.js +8 -2
- package/lib/getIteratorFn.js +2 -2
- package/lib/getNativeComponentFromComposite.js +30 -0
- package/lib/getNodeForCharacterOffset.js +2 -1
- package/lib/getTestDocument.js +1 -1
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/getVendorPrefixedEventName.js +101 -0
- package/lib/instantiateReactComponent.js +12 -13
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +2 -2
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +5 -4
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +6 -14
- package/lib/setTextContent.js +1 -1
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +2 -3
- package/lib/sliceChildren.js +1 -1
- package/lib/traverseAllChildren.js +8 -8
- package/lib/update.js +16 -15
- package/lib/validateDOMNesting.js +18 -13
- package/package.json +23 -32
- package/addons.js +0 -13
- package/cjs/react-jsx-dev-runtime.development.js +0 -861
- package/cjs/react-jsx-dev-runtime.production.min.js +0 -9
- package/cjs/react-jsx-runtime.development.js +0 -883
- package/cjs/react-jsx-runtime.production.min.js +0 -10
- package/jsx-dev-runtime.js +0 -7
- package/jsx-runtime.js +0 -7
- package/lib/Object.assign.js +0 -47
- package/lib/React.native.js +0 -5
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- package/lib/ReactIsomorphic.js +0 -74
- package/lib/ReactRootIndex.js +0 -29
- package/lib/ServerReactRootIndex.js +0 -29
- package/lib/cloneWithProps.js +0 -54
- package/lib/webcomponents.js +0 -6379
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2014-
|
|
2
|
+
* Copyright 2014-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var invariant = require('fbjs/lib/invariant');
|
|
16
17
|
|
|
17
18
|
var autoGenerateWrapperClass = null;
|
|
@@ -34,7 +35,7 @@ var ReactNativeComponentInjection = {
|
|
|
34
35
|
// This accepts a keyed object with classes as values. Each key represents a
|
|
35
36
|
// tag. That particular tag will use this class instead of the generic one.
|
|
36
37
|
injectComponentClasses: function (componentClasses) {
|
|
37
|
-
|
|
38
|
+
_assign(tagToComponentClass, componentClasses);
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
|
|
@@ -63,8 +64,8 @@ function getComponentClassForElement(element) {
|
|
|
63
64
|
* @return {function} The internal class constructor function.
|
|
64
65
|
*/
|
|
65
66
|
function createInternalComponent(element) {
|
|
66
|
-
!genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) :
|
|
67
|
-
return new genericComponentClass(element
|
|
67
|
+
!genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : void 0;
|
|
68
|
+
return new genericComponentClass(element);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactNodeTypes
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
|
|
16
|
+
var invariant = require('fbjs/lib/invariant');
|
|
17
|
+
|
|
18
|
+
var ReactNodeTypes = {
|
|
19
|
+
NATIVE: 0,
|
|
20
|
+
COMPOSITE: 1,
|
|
21
|
+
EMPTY: 2,
|
|
22
|
+
|
|
23
|
+
getType: function (node) {
|
|
24
|
+
if (node === null || node === false) {
|
|
25
|
+
return ReactNodeTypes.EMPTY;
|
|
26
|
+
} else if (ReactElement.isValidElement(node)) {
|
|
27
|
+
if (typeof node.type === 'function') {
|
|
28
|
+
return ReactNodeTypes.COMPOSITE;
|
|
29
|
+
} else {
|
|
30
|
+
return ReactNodeTypes.NATIVE;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Unexpected node: %s', node) : invariant(false) : void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = ReactNodeTypes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2015, Facebook, Inc.
|
|
2
|
+
* Copyright 2015-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -15,7 +15,7 @@ var warning = require('fbjs/lib/warning');
|
|
|
15
15
|
|
|
16
16
|
function warnTDZ(publicInstance, callerName) {
|
|
17
17
|
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
-
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') :
|
|
18
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : void 0;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -89,30 +89,7 @@ var ReactNoopUpdateQueue = {
|
|
|
89
89
|
*/
|
|
90
90
|
enqueueSetState: function (publicInstance, partialState) {
|
|
91
91
|
warnTDZ(publicInstance, 'setState');
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sets a subset of the props.
|
|
96
|
-
*
|
|
97
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
98
|
-
* @param {object} partialProps Subset of the next props.
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
enqueueSetProps: function (publicInstance, partialProps) {
|
|
102
|
-
warnTDZ(publicInstance, 'setProps');
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Replaces all of the props.
|
|
107
|
-
*
|
|
108
|
-
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
109
|
-
* @param {object} props New props.
|
|
110
|
-
* @internal
|
|
111
|
-
*/
|
|
112
|
-
enqueueReplaceProps: function (publicInstance, props) {
|
|
113
|
-
warnTDZ(publicInstance, 'replaceProps');
|
|
114
92
|
}
|
|
115
|
-
|
|
116
93
|
};
|
|
117
94
|
|
|
118
95
|
module.exports = ReactNoopUpdateQueue;
|
package/lib/ReactOwner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -64,7 +64,7 @@ var ReactOwner = {
|
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
66
|
addComponentAsRefTo: function (component, ref, owner) {
|
|
67
|
-
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) :
|
|
67
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : void 0;
|
|
68
68
|
owner.attachRef(ref, component);
|
|
69
69
|
},
|
|
70
70
|
|
|
@@ -78,10 +78,11 @@ var ReactOwner = {
|
|
|
78
78
|
* @internal
|
|
79
79
|
*/
|
|
80
80
|
removeComponentAsRefFrom: function (component, ref, owner) {
|
|
81
|
-
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) :
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
81
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : void 0;
|
|
82
|
+
var ownerPublicInstance = owner.getPublicInstance();
|
|
83
|
+
// Check that `component`'s owner is still alive and that `component` is still the current ref
|
|
84
|
+
// because we do not want to detach the ref if another component stole it.
|
|
85
|
+
if (ownerPublicInstance && ownerPublicInstance.refs[ref] === component.getPublicInstance()) {
|
|
85
86
|
owner.detachRef(ref);
|
|
86
87
|
}
|
|
87
88
|
}
|
package/lib/ReactPerf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactPerf
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -16,6 +15,7 @@
|
|
|
16
15
|
* ReactPerf is a general AOP system designed to measure performance. This
|
|
17
16
|
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
|
|
18
17
|
*/
|
|
18
|
+
|
|
19
19
|
var ReactPerf = {
|
|
20
20
|
/**
|
|
21
21
|
* Boolean to enable/disable measurement. Set to false by default to prevent
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
16
17
|
var joinClasses = require('fbjs/lib/joinClasses');
|
|
17
18
|
|
|
@@ -36,7 +37,7 @@ var transferStrategyMerge = createTransferStrategy(function (a, b) {
|
|
|
36
37
|
// `merge` overrides the first object's (`props[key]` above) keys using the
|
|
37
38
|
// second object's (`value`) keys. An object's style's existing `propA` would
|
|
38
39
|
// get overridden. Flip the order here.
|
|
39
|
-
return
|
|
40
|
+
return _assign({}, b, a);
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -100,7 +101,7 @@ var ReactPropTransferer = {
|
|
|
100
101
|
* @return {object} a new object containing both sets of props merged.
|
|
101
102
|
*/
|
|
102
103
|
mergeProps: function (oldProps, newProps) {
|
|
103
|
-
return transferInto(
|
|
104
|
+
return transferInto(_assign({}, oldProps), newProps);
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
};
|
package/lib/ReactPropTypes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -85,6 +85,24 @@ var ReactPropTypes = {
|
|
|
85
85
|
shape: createShapeTypeChecker
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
90
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
91
|
+
*/
|
|
92
|
+
/*eslint-disable no-self-compare*/
|
|
93
|
+
function is(x, y) {
|
|
94
|
+
// SameValue algorithm
|
|
95
|
+
if (x === y) {
|
|
96
|
+
// Steps 1-5, 7-10
|
|
97
|
+
// Steps 6.b-6.e: +0 != -0
|
|
98
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
99
|
+
} else {
|
|
100
|
+
// Step 6.a: NaN == NaN
|
|
101
|
+
return x !== x && y !== y;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/*eslint-enable no-self-compare*/
|
|
105
|
+
|
|
88
106
|
function createChainableTypeChecker(validate) {
|
|
89
107
|
function checkType(isRequired, props, propName, componentName, location, propFullName) {
|
|
90
108
|
componentName = componentName || ANONYMOUS;
|
|
@@ -130,6 +148,9 @@ function createAnyTypeChecker() {
|
|
|
130
148
|
|
|
131
149
|
function createArrayOfTypeChecker(typeChecker) {
|
|
132
150
|
function validate(props, propName, componentName, location, propFullName) {
|
|
151
|
+
if (typeof typeChecker !== 'function') {
|
|
152
|
+
return new Error('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
153
|
+
}
|
|
133
154
|
var propValue = props[propName];
|
|
134
155
|
if (!Array.isArray(propValue)) {
|
|
135
156
|
var locationName = ReactPropTypeLocationNames[location];
|
|
@@ -137,7 +158,7 @@ function createArrayOfTypeChecker(typeChecker) {
|
|
|
137
158
|
return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
138
159
|
}
|
|
139
160
|
for (var i = 0; i < propValue.length; i++) {
|
|
140
|
-
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']'
|
|
161
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
|
|
141
162
|
if (error instanceof Error) {
|
|
142
163
|
return error;
|
|
143
164
|
}
|
|
@@ -181,7 +202,7 @@ function createEnumTypeChecker(expectedValues) {
|
|
|
181
202
|
function validate(props, propName, componentName, location, propFullName) {
|
|
182
203
|
var propValue = props[propName];
|
|
183
204
|
for (var i = 0; i < expectedValues.length; i++) {
|
|
184
|
-
if (propValue
|
|
205
|
+
if (is(propValue, expectedValues[i])) {
|
|
185
206
|
return null;
|
|
186
207
|
}
|
|
187
208
|
}
|
|
@@ -195,6 +216,9 @@ function createEnumTypeChecker(expectedValues) {
|
|
|
195
216
|
|
|
196
217
|
function createObjectOfTypeChecker(typeChecker) {
|
|
197
218
|
function validate(props, propName, componentName, location, propFullName) {
|
|
219
|
+
if (typeof typeChecker !== 'function') {
|
|
220
|
+
return new Error('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
221
|
+
}
|
|
198
222
|
var propValue = props[propName];
|
|
199
223
|
var propType = getPropType(propValue);
|
|
200
224
|
if (propType !== 'object') {
|
|
@@ -203,7 +227,7 @@ function createObjectOfTypeChecker(typeChecker) {
|
|
|
203
227
|
}
|
|
204
228
|
for (var key in propValue) {
|
|
205
229
|
if (propValue.hasOwnProperty(key)) {
|
|
206
|
-
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key
|
|
230
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
207
231
|
if (error instanceof Error) {
|
|
208
232
|
return error;
|
|
209
233
|
}
|
|
@@ -224,7 +248,7 @@ function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
|
224
248
|
function validate(props, propName, componentName, location, propFullName) {
|
|
225
249
|
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
226
250
|
var checker = arrayOfTypeCheckers[i];
|
|
227
|
-
if (checker(props, propName, componentName, location, propFullName
|
|
251
|
+
if (checker(props, propName, componentName, location, propFullName) == null) {
|
|
228
252
|
return null;
|
|
229
253
|
}
|
|
230
254
|
}
|
|
@@ -259,7 +283,7 @@ function createShapeTypeChecker(shapeTypes) {
|
|
|
259
283
|
if (!checker) {
|
|
260
284
|
continue;
|
|
261
285
|
}
|
|
262
|
-
var error = checker(propValue, key, componentName, location, propFullName + '.' + key
|
|
286
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
|
|
263
287
|
if (error) {
|
|
264
288
|
return error;
|
|
265
289
|
}
|
|
@@ -348,7 +372,7 @@ function getPreciseType(propValue) {
|
|
|
348
372
|
// Returns class name of the object, if any.
|
|
349
373
|
function getClassName(propValue) {
|
|
350
374
|
if (!propValue.constructor || !propValue.constructor.name) {
|
|
351
|
-
return
|
|
375
|
+
return ANONYMOUS;
|
|
352
376
|
}
|
|
353
377
|
return propValue.constructor.name;
|
|
354
378
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the BSD-style license found in the
|
|
@@ -7,20 +7,18 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactReconcileTransaction
|
|
10
|
-
* @typechecks static-only
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var CallbackQueue = require('./CallbackQueue');
|
|
16
17
|
var PooledClass = require('./PooledClass');
|
|
17
18
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
18
|
-
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
|
|
19
19
|
var ReactInputSelection = require('./ReactInputSelection');
|
|
20
20
|
var Transaction = require('./Transaction');
|
|
21
21
|
|
|
22
|
-
var assign = require('./Object.assign');
|
|
23
|
-
|
|
24
22
|
/**
|
|
25
23
|
* Ensures that, when possible, the selection range (currently selected text
|
|
26
24
|
* input) is not disturbed by performing the transaction.
|
|
@@ -64,7 +62,7 @@ var EVENT_SUPPRESSION = {
|
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
64
|
* Provides a queue for collecting `componentDidMount` and
|
|
67
|
-
* `componentDidUpdate` callbacks during the
|
|
65
|
+
* `componentDidUpdate` callbacks during the transaction.
|
|
68
66
|
*/
|
|
69
67
|
var ON_DOM_READY_QUEUEING = {
|
|
70
68
|
/**
|
|
@@ -103,7 +101,7 @@ var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_REA
|
|
|
103
101
|
*
|
|
104
102
|
* @class ReactReconcileTransaction
|
|
105
103
|
*/
|
|
106
|
-
function ReactReconcileTransaction(
|
|
104
|
+
function ReactReconcileTransaction(useCreateElement) {
|
|
107
105
|
this.reinitializeTransaction();
|
|
108
106
|
// Only server-side rendering really needs this option (see
|
|
109
107
|
// `ReactServerRendering`), but server-side uses
|
|
@@ -112,7 +110,7 @@ function ReactReconcileTransaction(forceHTML) {
|
|
|
112
110
|
// `ReactTextComponent` checks it in `mountComponent`.`
|
|
113
111
|
this.renderToStaticMarkup = false;
|
|
114
112
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
115
|
-
this.useCreateElement =
|
|
113
|
+
this.useCreateElement = useCreateElement;
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
var Mixin = {
|
|
@@ -134,6 +132,19 @@ var Mixin = {
|
|
|
134
132
|
return this.reactMountReady;
|
|
135
133
|
},
|
|
136
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Save current transaction state -- if the return value from this method is
|
|
137
|
+
* passed to `rollback`, the transaction will be reset to that state.
|
|
138
|
+
*/
|
|
139
|
+
checkpoint: function () {
|
|
140
|
+
// reactMountReady is the our only stateful wrapper
|
|
141
|
+
return this.reactMountReady.checkpoint();
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
rollback: function (checkpoint) {
|
|
145
|
+
this.reactMountReady.rollback(checkpoint);
|
|
146
|
+
},
|
|
147
|
+
|
|
137
148
|
/**
|
|
138
149
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
139
150
|
* instance to be reused.
|
|
@@ -144,7 +155,7 @@ var Mixin = {
|
|
|
144
155
|
}
|
|
145
156
|
};
|
|
146
157
|
|
|
147
|
-
|
|
158
|
+
_assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
|
|
148
159
|
|
|
149
160
|
PooledClass.addPoolingTo(ReactReconcileTransaction);
|
|
150
161
|
|
package/lib/ReactReconciler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2013-
|
|
2
|
+
* Copyright 2013-present, 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 ReactRef = require('./ReactRef');
|
|
15
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Helper to call ReactRef.attachRefs with this composite component, split out
|
|
@@ -27,29 +28,44 @@ var ReactReconciler = {
|
|
|
27
28
|
* Initializes the component, renders markup, and registers event listeners.
|
|
28
29
|
*
|
|
29
30
|
* @param {ReactComponent} internalInstance
|
|
30
|
-
* @param {string} rootID DOM ID of the root node.
|
|
31
31
|
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
|
|
32
|
+
* @param {?object} the containing native component instance
|
|
33
|
+
* @param {?object} info about the native container
|
|
32
34
|
* @return {?string} Rendered markup to be inserted into the DOM.
|
|
33
35
|
* @final
|
|
34
36
|
* @internal
|
|
35
37
|
*/
|
|
36
|
-
mountComponent: function (internalInstance,
|
|
37
|
-
var markup = internalInstance.mountComponent(
|
|
38
|
+
mountComponent: function (internalInstance, transaction, nativeParent, nativeContainerInfo, context) {
|
|
39
|
+
var markup = internalInstance.mountComponent(transaction, nativeParent, nativeContainerInfo, context);
|
|
38
40
|
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
39
41
|
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
40
42
|
}
|
|
43
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
44
|
+
ReactInstrumentation.debugTool.onMountComponent(internalInstance);
|
|
45
|
+
}
|
|
41
46
|
return markup;
|
|
42
47
|
},
|
|
43
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Returns a value that can be passed to
|
|
51
|
+
* ReactComponentEnvironment.replaceNodeWithMarkup.
|
|
52
|
+
*/
|
|
53
|
+
getNativeNode: function (internalInstance) {
|
|
54
|
+
return internalInstance.getNativeNode();
|
|
55
|
+
},
|
|
56
|
+
|
|
44
57
|
/**
|
|
45
58
|
* Releases any resources allocated by `mountComponent`.
|
|
46
59
|
*
|
|
47
60
|
* @final
|
|
48
61
|
* @internal
|
|
49
62
|
*/
|
|
50
|
-
unmountComponent: function (internalInstance) {
|
|
63
|
+
unmountComponent: function (internalInstance, safely) {
|
|
51
64
|
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
|
|
52
|
-
internalInstance.unmountComponent();
|
|
65
|
+
internalInstance.unmountComponent(safely);
|
|
66
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
67
|
+
ReactInstrumentation.debugTool.onUnmountComponent(internalInstance);
|
|
68
|
+
}
|
|
53
69
|
},
|
|
54
70
|
|
|
55
71
|
/**
|
|
@@ -89,6 +105,10 @@ var ReactReconciler = {
|
|
|
89
105
|
if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
90
106
|
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
91
107
|
}
|
|
108
|
+
|
|
109
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
110
|
+
ReactInstrumentation.debugTool.onUpdateComponent(internalInstance);
|
|
111
|
+
}
|
|
92
112
|
},
|
|
93
113
|
|
|
94
114
|
/**
|
|
@@ -100,6 +120,9 @@ var ReactReconciler = {
|
|
|
100
120
|
*/
|
|
101
121
|
performUpdateIfNecessary: function (internalInstance, transaction) {
|
|
102
122
|
internalInstance.performUpdateIfNecessary(transaction);
|
|
123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
124
|
+
ReactInstrumentation.debugTool.onUpdateComponent(internalInstance);
|
|
125
|
+
}
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
};
|