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
package/lib/ReactRef.js
CHANGED
|
@@ -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
|
|
@@ -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 ReactServerBatchingStrategy
|
|
10
|
-
* @typechecks
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
@@ -1,19 +1,18 @@
|
|
|
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
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @typechecks static-only
|
|
10
9
|
* @providesModule ReactServerRendering
|
|
11
10
|
*/
|
|
12
11
|
'use strict';
|
|
13
12
|
|
|
13
|
+
var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
|
|
14
14
|
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
15
15
|
var ReactElement = require('./ReactElement');
|
|
16
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
17
16
|
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
18
17
|
var ReactServerBatchingStrategy = require('./ReactServerBatchingStrategy');
|
|
19
18
|
var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
|
|
@@ -27,20 +26,20 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
27
26
|
* @param {ReactElement} element
|
|
28
27
|
* @return {string} the HTML markup
|
|
29
28
|
*/
|
|
30
|
-
function
|
|
31
|
-
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
32
|
-
|
|
29
|
+
function renderToStringImpl(element, makeStaticMarkup) {
|
|
33
30
|
var transaction;
|
|
34
31
|
try {
|
|
35
32
|
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
transaction = ReactServerRenderingTransaction.getPooled(false);
|
|
34
|
+
transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup);
|
|
39
35
|
|
|
40
36
|
return transaction.perform(function () {
|
|
41
|
-
var componentInstance = instantiateReactComponent(element
|
|
42
|
-
var markup = componentInstance.mountComponent(
|
|
43
|
-
|
|
37
|
+
var componentInstance = instantiateReactComponent(element);
|
|
38
|
+
var markup = componentInstance.mountComponent(transaction, null, ReactDOMContainerInfo(), emptyObject);
|
|
39
|
+
if (!makeStaticMarkup) {
|
|
40
|
+
markup = ReactMarkupChecksum.addChecksumToMarkup(markup);
|
|
41
|
+
}
|
|
42
|
+
return markup;
|
|
44
43
|
}, null);
|
|
45
44
|
} finally {
|
|
46
45
|
ReactServerRenderingTransaction.release(transaction);
|
|
@@ -50,31 +49,14 @@ function renderToString(element) {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
function renderToStaticMarkup(element) {
|
|
59
|
-
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
60
|
-
|
|
61
|
-
var transaction;
|
|
62
|
-
try {
|
|
63
|
-
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
64
|
-
|
|
65
|
-
var id = ReactInstanceHandles.createReactRootID();
|
|
66
|
-
transaction = ReactServerRenderingTransaction.getPooled(true);
|
|
52
|
+
function renderToString(element) {
|
|
53
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : void 0;
|
|
54
|
+
return renderToStringImpl(element, false);
|
|
55
|
+
}
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}, null);
|
|
72
|
-
} finally {
|
|
73
|
-
ReactServerRenderingTransaction.release(transaction);
|
|
74
|
-
// Revert to the DOM batching strategy since these two renderers
|
|
75
|
-
// currently share these stateful modules.
|
|
76
|
-
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
77
|
-
}
|
|
57
|
+
function renderToStaticMarkup(element) {
|
|
58
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : void 0;
|
|
59
|
+
return renderToStringImpl(element, true);
|
|
78
60
|
}
|
|
79
61
|
|
|
80
62
|
module.exports = {
|
|
@@ -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
|
|
@@ -7,39 +7,25 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ReactServerRenderingTransaction
|
|
10
|
-
* @typechecks
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
'use strict';
|
|
14
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
15
16
|
var PooledClass = require('./PooledClass');
|
|
16
|
-
var CallbackQueue = require('./CallbackQueue');
|
|
17
17
|
var Transaction = require('./Transaction');
|
|
18
18
|
|
|
19
|
-
var assign = require('./Object.assign');
|
|
20
|
-
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
|
|
24
|
-
* during the performing of the transaction.
|
|
25
|
-
*/
|
|
26
|
-
var ON_DOM_READY_QUEUEING = {
|
|
27
|
-
/**
|
|
28
|
-
* Initializes the internal `onDOMReady` queue.
|
|
29
|
-
*/
|
|
30
|
-
initialize: function () {
|
|
31
|
-
this.reactMountReady.reset();
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
close: emptyFunction
|
|
35
|
-
};
|
|
36
|
-
|
|
37
19
|
/**
|
|
38
20
|
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
39
21
|
* being member methods, but with an implied ordering while being isolated from
|
|
40
22
|
* each other.
|
|
41
23
|
*/
|
|
42
|
-
var TRANSACTION_WRAPPERS = [
|
|
24
|
+
var TRANSACTION_WRAPPERS = [];
|
|
25
|
+
|
|
26
|
+
var noopCallbackQueue = {
|
|
27
|
+
enqueue: function () {}
|
|
28
|
+
};
|
|
43
29
|
|
|
44
30
|
/**
|
|
45
31
|
* @class ReactServerRenderingTransaction
|
|
@@ -48,7 +34,6 @@ var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
|
|
|
48
34
|
function ReactServerRenderingTransaction(renderToStaticMarkup) {
|
|
49
35
|
this.reinitializeTransaction();
|
|
50
36
|
this.renderToStaticMarkup = renderToStaticMarkup;
|
|
51
|
-
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
52
37
|
this.useCreateElement = false;
|
|
53
38
|
}
|
|
54
39
|
|
|
@@ -67,20 +52,17 @@ var Mixin = {
|
|
|
67
52
|
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
68
53
|
*/
|
|
69
54
|
getReactMountReady: function () {
|
|
70
|
-
return
|
|
55
|
+
return noopCallbackQueue;
|
|
71
56
|
},
|
|
72
57
|
|
|
73
58
|
/**
|
|
74
59
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
75
60
|
* instance to be reused.
|
|
76
61
|
*/
|
|
77
|
-
destructor: function () {
|
|
78
|
-
CallbackQueue.release(this.reactMountReady);
|
|
79
|
-
this.reactMountReady = null;
|
|
80
|
-
}
|
|
62
|
+
destructor: function () {}
|
|
81
63
|
};
|
|
82
64
|
|
|
83
|
-
|
|
65
|
+
_assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
|
|
84
66
|
|
|
85
67
|
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
|
|
86
68
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-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 ReactSimpleEmptyComponent
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
17
|
+
|
|
18
|
+
var ReactSimpleEmptyComponent = function (placeholderElement, instantiate) {
|
|
19
|
+
this._currentElement = null;
|
|
20
|
+
this._renderedComponent = instantiate(placeholderElement);
|
|
21
|
+
};
|
|
22
|
+
_assign(ReactSimpleEmptyComponent.prototype, {
|
|
23
|
+
mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
24
|
+
return ReactReconciler.mountComponent(this._renderedComponent, transaction, nativeParent, nativeContainerInfo, context);
|
|
25
|
+
},
|
|
26
|
+
receiveComponent: function () {},
|
|
27
|
+
getNativeNode: function () {
|
|
28
|
+
return ReactReconciler.getNativeNode(this._renderedComponent);
|
|
29
|
+
},
|
|
30
|
+
unmountComponent: function () {
|
|
31
|
+
ReactReconciler.unmountComponent(this._renderedComponent);
|
|
32
|
+
this._renderedComponent = null;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
module.exports = ReactSimpleEmptyComponent;
|
package/lib/ReactStateSetters.js
CHANGED
package/lib/ReactTestUtils.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
|
|
@@ -11,21 +11,23 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
14
16
|
var EventConstants = require('./EventConstants');
|
|
15
17
|
var EventPluginHub = require('./EventPluginHub');
|
|
18
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
16
19
|
var EventPropagators = require('./EventPropagators');
|
|
17
20
|
var React = require('./React');
|
|
21
|
+
var ReactDefaultInjection = require('./ReactDefaultInjection');
|
|
18
22
|
var ReactDOM = require('./ReactDOM');
|
|
23
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
19
24
|
var ReactElement = require('./ReactElement');
|
|
20
25
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
21
26
|
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
22
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
23
27
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
24
|
-
var ReactMount = require('./ReactMount');
|
|
25
28
|
var ReactUpdates = require('./ReactUpdates');
|
|
26
29
|
var SyntheticEvent = require('./SyntheticEvent');
|
|
27
30
|
|
|
28
|
-
var assign = require('./Object.assign');
|
|
29
31
|
var emptyObject = require('fbjs/lib/emptyObject');
|
|
30
32
|
var findDOMNode = require('./findDOMNode');
|
|
31
33
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -140,7 +142,7 @@ var ReactTestUtils = {
|
|
|
140
142
|
if (!inst) {
|
|
141
143
|
return [];
|
|
142
144
|
}
|
|
143
|
-
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) :
|
|
145
|
+
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : void 0;
|
|
144
146
|
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
|
|
145
147
|
},
|
|
146
148
|
|
|
@@ -178,7 +180,7 @@ var ReactTestUtils = {
|
|
|
178
180
|
findRenderedDOMComponentWithClass: function (root, className) {
|
|
179
181
|
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
|
|
180
182
|
if (all.length !== 1) {
|
|
181
|
-
throw new Error('Did not find exactly one match
|
|
183
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
|
|
182
184
|
}
|
|
183
185
|
return all[0];
|
|
184
186
|
},
|
|
@@ -203,7 +205,7 @@ var ReactTestUtils = {
|
|
|
203
205
|
findRenderedDOMComponentWithTag: function (root, tagName) {
|
|
204
206
|
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
|
|
205
207
|
if (all.length !== 1) {
|
|
206
|
-
throw new Error('Did not find exactly one match for tag:' + tagName);
|
|
208
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
|
|
207
209
|
}
|
|
208
210
|
return all[0];
|
|
209
211
|
},
|
|
@@ -227,7 +229,7 @@ var ReactTestUtils = {
|
|
|
227
229
|
findRenderedComponentWithType: function (root, componentType) {
|
|
228
230
|
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
|
|
229
231
|
if (all.length !== 1) {
|
|
230
|
-
throw new Error('Did not find exactly one match
|
|
232
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
|
|
231
233
|
}
|
|
232
234
|
return all[0];
|
|
233
235
|
},
|
|
@@ -299,8 +301,8 @@ var ReactShallowRenderer = function () {
|
|
|
299
301
|
this._instance = null;
|
|
300
302
|
};
|
|
301
303
|
|
|
302
|
-
ReactShallowRenderer.prototype.
|
|
303
|
-
return this._instance
|
|
304
|
+
ReactShallowRenderer.prototype.getMountedInstance = function () {
|
|
305
|
+
return this._instance ? this._instance._instance : null;
|
|
304
306
|
};
|
|
305
307
|
|
|
306
308
|
var NoopInternalComponent = function (element) {
|
|
@@ -317,6 +319,10 @@ NoopInternalComponent.prototype = {
|
|
|
317
319
|
this._currentElement = element;
|
|
318
320
|
},
|
|
319
321
|
|
|
322
|
+
getNativeNode: function () {
|
|
323
|
+
return undefined;
|
|
324
|
+
},
|
|
325
|
+
|
|
320
326
|
unmountComponent: function () {},
|
|
321
327
|
|
|
322
328
|
getPublicInstance: function () {
|
|
@@ -324,34 +330,47 @@ NoopInternalComponent.prototype = {
|
|
|
324
330
|
}
|
|
325
331
|
};
|
|
326
332
|
|
|
327
|
-
var ShallowComponentWrapper = function () {
|
|
328
|
-
|
|
333
|
+
var ShallowComponentWrapper = function (element) {
|
|
334
|
+
this.construct(element);
|
|
335
|
+
};
|
|
336
|
+
_assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
329
337
|
_instantiateReactComponent: function (element) {
|
|
330
338
|
return new NoopInternalComponent(element);
|
|
331
339
|
},
|
|
332
|
-
|
|
340
|
+
_replaceNodeWithMarkup: function () {},
|
|
333
341
|
_renderValidatedComponent: ReactCompositeComponent.Mixin._renderValidatedComponentWithoutOwnerOrContext
|
|
334
342
|
});
|
|
335
343
|
|
|
336
344
|
ReactShallowRenderer.prototype.render = function (element, context) {
|
|
337
|
-
|
|
338
|
-
|
|
345
|
+
// Ensure we've done the default injections. This might not be true in the
|
|
346
|
+
// case of a simple test that only requires React and the TestUtils in
|
|
347
|
+
// conjunction with an inline-requires transform.
|
|
348
|
+
ReactDefaultInjection.inject();
|
|
349
|
+
|
|
350
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Invalid component element.%s', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : invariant(false) : void 0;
|
|
351
|
+
!(typeof element.type !== 'string') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom ' + 'components, not primitives (%s). Instead of calling `.render(el)` and ' + 'inspecting the rendered output, look at `el.props` directly instead.', element.type) : invariant(false) : void 0;
|
|
339
352
|
|
|
340
353
|
if (!context) {
|
|
341
354
|
context = emptyObject;
|
|
342
355
|
}
|
|
343
356
|
ReactUpdates.batchedUpdates(_batchedRender, this, element, context);
|
|
357
|
+
|
|
358
|
+
return this.getRenderOutput();
|
|
344
359
|
};
|
|
345
360
|
|
|
346
361
|
function _batchedRender(renderer, element, context) {
|
|
347
|
-
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
|
|
362
|
+
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true);
|
|
348
363
|
renderer._render(element, transaction, context);
|
|
349
364
|
ReactUpdates.ReactReconcileTransaction.release(transaction);
|
|
350
365
|
}
|
|
351
366
|
|
|
367
|
+
ReactShallowRenderer.prototype.getRenderOutput = function () {
|
|
368
|
+
return this._instance && this._instance._renderedComponent && this._instance._renderedComponent._renderedOutput || null;
|
|
369
|
+
};
|
|
370
|
+
|
|
352
371
|
ReactShallowRenderer.prototype.unmount = function () {
|
|
353
372
|
if (this._instance) {
|
|
354
|
-
this._instance.unmountComponent();
|
|
373
|
+
this._instance.unmountComponent(false);
|
|
355
374
|
}
|
|
356
375
|
};
|
|
357
376
|
|
|
@@ -359,12 +378,8 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
359
378
|
if (this._instance) {
|
|
360
379
|
this._instance.receiveComponent(element, transaction, context);
|
|
361
380
|
} else {
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
instance.construct(element);
|
|
365
|
-
|
|
366
|
-
instance.mountComponent(rootID, transaction, context);
|
|
367
|
-
|
|
381
|
+
var instance = new ShallowComponentWrapper(element);
|
|
382
|
+
instance.mountComponent(transaction, null, null, context);
|
|
368
383
|
this._instance = instance;
|
|
369
384
|
}
|
|
370
385
|
};
|
|
@@ -380,20 +395,24 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
380
395
|
function makeSimulator(eventType) {
|
|
381
396
|
return function (domComponentOrNode, eventData) {
|
|
382
397
|
var node;
|
|
398
|
+
!!React.isValidElement(domComponentOrNode) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'TestUtils.Simulate expects a component instance and not a ReactElement.' + 'TestUtils.Simulate will not work if you are using shallow rendering.') : invariant(false) : void 0;
|
|
383
399
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
384
400
|
node = findDOMNode(domComponentOrNode);
|
|
385
401
|
} else if (domComponentOrNode.tagName) {
|
|
386
402
|
node = domComponentOrNode;
|
|
387
403
|
}
|
|
388
404
|
|
|
389
|
-
var dispatchConfig =
|
|
405
|
+
var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType];
|
|
390
406
|
|
|
391
407
|
var fakeNativeEvent = new Event();
|
|
392
408
|
fakeNativeEvent.target = node;
|
|
393
409
|
// We don't use SyntheticEvent.getPooled in order to not have to worry about
|
|
394
410
|
// properly destroying any properties assigned from `eventData` upon release
|
|
395
|
-
var event = new SyntheticEvent(dispatchConfig,
|
|
396
|
-
|
|
411
|
+
var event = new SyntheticEvent(dispatchConfig, ReactDOMComponentTree.getInstanceFromNode(node), fakeNativeEvent, node);
|
|
412
|
+
// Since we aren't using pooling, always persist the event. This will make
|
|
413
|
+
// sure it's marked and won't warn when setting additional properties.
|
|
414
|
+
event.persist();
|
|
415
|
+
_assign(event, eventData);
|
|
397
416
|
|
|
398
417
|
if (dispatchConfig.phasedRegistrationNames) {
|
|
399
418
|
EventPropagators.accumulateTwoPhaseDispatches(event);
|
|
@@ -412,7 +431,7 @@ function buildSimulators() {
|
|
|
412
431
|
ReactTestUtils.Simulate = {};
|
|
413
432
|
|
|
414
433
|
var eventType;
|
|
415
|
-
for (eventType in
|
|
434
|
+
for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
|
|
416
435
|
/**
|
|
417
436
|
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
|
418
437
|
* @param {?object} eventData Fake event data to use in SyntheticEvent.
|
|
@@ -454,7 +473,7 @@ buildSimulators();
|
|
|
454
473
|
function makeNativeSimulator(eventType) {
|
|
455
474
|
return function (domComponentOrNode, nativeEventData) {
|
|
456
475
|
var fakeNativeEvent = new Event(eventType);
|
|
457
|
-
|
|
476
|
+
_assign(fakeNativeEvent, nativeEventData);
|
|
458
477
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
459
478
|
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
|
460
479
|
} else if (domComponentOrNode.tagName) {
|
|
@@ -1,12 +1,11 @@
|
|
|
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
|
|
6
6
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
|
-
* @typechecks static-only
|
|
10
9
|
* @providesModule ReactTransitionChildMapping
|
|
11
10
|
*/
|
|
12
11
|
|