react 0.14.9 → 15.0.0-rc.2
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/addons.js +2 -0
- package/dist/react-with-addons.js +4299 -4138
- package/dist/react-with-addons.min.js +7 -7
- package/dist/react.js +4059 -3644
- 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 +21 -7
- package/lib/CallbackQueue.js +12 -1
- package/lib/ChangeEventPlugin.js +58 -54
- package/lib/DOMChildrenOperations.js +93 -60
- package/lib/DOMLazyTree.js +105 -0
- package/lib/{ClientReactRootIndex.js → DOMNamespaces.js} +7 -10
- package/lib/DOMProperty.js +15 -36
- package/lib/DOMPropertyOperations.js +40 -52
- package/lib/Danger.js +6 -7
- package/lib/DefaultEventPluginOrder.js +1 -1
- package/lib/EnterLeaveEventPlugin.js +24 -43
- package/lib/EventConstants.js +6 -1
- package/lib/EventPluginHub.js +20 -64
- package/lib/EventPluginRegistry.js +23 -2
- package/lib/EventPluginUtils.js +60 -35
- package/lib/EventPropagators.js +19 -17
- package/lib/FallbackCompositionState.js +1 -2
- package/lib/HTMLDOMPropertyConfig.js +131 -152
- package/lib/LinkedStateMixin.js +1 -2
- package/lib/LinkedValueUtils.js +2 -3
- package/lib/MetaMatchers.js +2 -2
- package/lib/Object.assign.js +1 -1
- package/lib/OrderedMap.js +1 -1
- package/lib/PooledClass.js +1 -1
- package/lib/React.js +1 -13
- package/lib/ReactBrowserEventEmitter.js +16 -24
- package/lib/ReactCSSTransitionGroup.js +1 -2
- package/lib/ReactCSSTransitionGroupChild.js +1 -6
- package/lib/ReactChildReconciler.js +14 -12
- package/lib/ReactChildren.js +5 -4
- package/lib/ReactClass.js +21 -70
- package/lib/ReactComponent.js +4 -5
- package/lib/ReactComponentBrowserEnvironment.js +9 -6
- package/lib/ReactComponentEnvironment.js +3 -3
- package/lib/ReactComponentWithPureRenderMixin.js +2 -2
- package/lib/ReactCompositeComponent.js +146 -55
- package/lib/ReactCurrentOwner.js +2 -1
- package/lib/ReactDOM.js +26 -14
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +162 -231
- 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 +71 -22
- package/lib/ReactDOMInstrumentation.js +16 -0
- package/lib/ReactDOMOption.js +9 -8
- package/lib/ReactDOMSelect.js +38 -15
- package/lib/ReactDOMSelection.js +4 -4
- package/lib/ReactDOMServer.js +1 -1
- package/lib/ReactDOMTextComponent.js +84 -43
- package/lib/ReactDOMTextarea.js +32 -5
- package/lib/ReactDOMTreeTraversal.js +134 -0
- package/lib/ReactDOMUnknownPropertyDevtool.js +64 -0
- package/lib/ReactDebugTool.js +72 -0
- package/lib/ReactDefaultBatchingStrategy.js +1 -1
- package/lib/ReactDefaultInjection.js +11 -15
- package/lib/ReactDefaultPerf.js +59 -19
- package/lib/ReactDefaultPerfAnalysis.js +17 -9
- package/lib/ReactElement.js +60 -21
- package/lib/ReactElementValidator.js +2 -2
- package/lib/ReactEmptyComponent.js +8 -33
- package/lib/ReactErrorUtils.js +1 -2
- package/lib/ReactEventEmitterMixin.js +3 -8
- package/lib/ReactEventListener.js +20 -75
- package/lib/ReactFeatureFlags.js +21 -0
- package/lib/ReactFragment.js +2 -2
- package/lib/ReactInjection.js +3 -3
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +4 -6
- package/lib/ReactInstanceMap.js +2 -1
- package/lib/ReactInstrumentation.js +16 -0
- package/lib/ReactInvalidSetStateWarningDevTool.js +36 -0
- package/lib/ReactIsomorphic.js +1 -1
- package/lib/ReactLink.js +2 -3
- package/lib/ReactMarkupChecksum.js +8 -3
- package/lib/ReactMount.js +74 -447
- package/lib/ReactMultiChild.js +106 -200
- package/lib/ReactMultiChildUpdateTypes.js +1 -1
- package/lib/ReactNativeComponent.js +2 -2
- package/lib/ReactNodeTypes.js +37 -0
- package/lib/ReactNoopUpdateQueue.js +1 -24
- package/lib/ReactOwner.js +5 -4
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +1 -1
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +31 -7
- package/lib/ReactReconcileTransaction.js +17 -6
- package/lib/ReactReconciler.js +29 -6
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +1 -2
- package/lib/ReactServerRendering.js +16 -34
- package/lib/ReactServerRenderingTransaction.js +8 -26
- package/lib/ReactSimpleEmptyComponent.js +36 -0
- package/lib/ReactStateSetters.js +1 -1
- package/lib/ReactTestUtils.js +30 -21
- package/lib/ReactTransitionChildMapping.js +1 -2
- package/lib/ReactTransitionEvents.js +8 -44
- package/lib/ReactTransitionGroup.js +1 -1
- package/lib/ReactUpdateQueue.js +4 -63
- package/lib/ReactUpdates.js +19 -2
- package/lib/ReactVersion.js +2 -2
- package/lib/ReactWithAddons.js +1 -14
- package/lib/ResponderEventPlugin.js +53 -65
- package/lib/ResponderSyntheticEvent.js +2 -3
- package/lib/ResponderTouchHistoryStore.js +1 -1
- package/lib/SVGDOMPropertyConfig.js +267 -94
- package/lib/SelectEventPlugin.js +13 -18
- package/lib/SimpleEventPlugin.js +56 -16
- 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 +97 -17
- 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 +1 -1
- package/lib/ViewportMetrics.js +1 -1
- package/lib/accumulate.js +1 -1
- package/lib/accumulateInto.js +1 -1
- 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 +3 -1
- package/lib/escapeTextContentForBrowser.js +1 -1
- package/lib/findDOMNode.js +15 -8
- package/lib/flattenChildren.js +1 -1
- 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 +7 -9
- package/lib/isEventSupported.js +2 -2
- package/lib/isTextInputElement.js +2 -1
- package/lib/onlyChild.js +1 -1
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +1 -1
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +5 -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 +6 -6
- package/lib/update.js +2 -2
- package/lib/validateDOMNesting.js +15 -11
- package/package.json +2 -2
- package/lib/ReactBrowserComponentMixin.js +0 -36
- package/lib/ReactEmptyComponentRegistry.js +0 -48
- 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,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
|
-
|
|
52
|
+
function renderToString(element) {
|
|
53
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
54
|
+
return renderToStringImpl(element, false);
|
|
55
|
+
}
|
|
56
|
+
|
|
58
57
|
function renderToStaticMarkup(element) {
|
|
59
58
|
!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);
|
|
67
|
-
|
|
68
|
-
return transaction.perform(function () {
|
|
69
|
-
var componentInstance = instantiateReactComponent(element, null);
|
|
70
|
-
return componentInstance.mountComponent(id, transaction, emptyObject);
|
|
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
|
-
}
|
|
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
|
|
|
15
14
|
var PooledClass = require('./PooledClass');
|
|
16
|
-
var CallbackQueue = require('./CallbackQueue');
|
|
17
15
|
var Transaction = require('./Transaction');
|
|
18
16
|
|
|
19
17
|
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
18
|
|
|
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,17 +52,14 @@ 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);
|
|
@@ -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 ReactReconciler = require('./ReactReconciler');
|
|
15
|
+
|
|
16
|
+
var assign = require('./Object.assign');
|
|
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
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
|
|
14
14
|
var EventConstants = require('./EventConstants');
|
|
15
15
|
var EventPluginHub = require('./EventPluginHub');
|
|
16
|
+
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
16
17
|
var EventPropagators = require('./EventPropagators');
|
|
17
18
|
var React = require('./React');
|
|
18
19
|
var ReactDOM = require('./ReactDOM');
|
|
20
|
+
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
|
|
19
21
|
var ReactElement = require('./ReactElement');
|
|
20
22
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
21
23
|
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
22
|
-
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
23
24
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
24
|
-
var ReactMount = require('./ReactMount');
|
|
25
25
|
var ReactUpdates = require('./ReactUpdates');
|
|
26
26
|
var SyntheticEvent = require('./SyntheticEvent');
|
|
27
27
|
|
|
@@ -178,7 +178,7 @@ var ReactTestUtils = {
|
|
|
178
178
|
findRenderedDOMComponentWithClass: function (root, className) {
|
|
179
179
|
var all = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, className);
|
|
180
180
|
if (all.length !== 1) {
|
|
181
|
-
throw new Error('Did not find exactly one match
|
|
181
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for class:' + className);
|
|
182
182
|
}
|
|
183
183
|
return all[0];
|
|
184
184
|
},
|
|
@@ -203,7 +203,7 @@ var ReactTestUtils = {
|
|
|
203
203
|
findRenderedDOMComponentWithTag: function (root, tagName) {
|
|
204
204
|
var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
|
|
205
205
|
if (all.length !== 1) {
|
|
206
|
-
throw new Error('Did not find exactly one match for tag:' + tagName);
|
|
206
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
|
|
207
207
|
}
|
|
208
208
|
return all[0];
|
|
209
209
|
},
|
|
@@ -227,7 +227,7 @@ var ReactTestUtils = {
|
|
|
227
227
|
findRenderedComponentWithType: function (root, componentType) {
|
|
228
228
|
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
|
|
229
229
|
if (all.length !== 1) {
|
|
230
|
-
throw new Error('Did not find exactly one match
|
|
230
|
+
throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for componentType:' + componentType);
|
|
231
231
|
}
|
|
232
232
|
return all[0];
|
|
233
233
|
},
|
|
@@ -299,8 +299,8 @@ var ReactShallowRenderer = function () {
|
|
|
299
299
|
this._instance = null;
|
|
300
300
|
};
|
|
301
301
|
|
|
302
|
-
ReactShallowRenderer.prototype.
|
|
303
|
-
return this._instance
|
|
302
|
+
ReactShallowRenderer.prototype.getMountedInstance = function () {
|
|
303
|
+
return this._instance ? this._instance._instance : null;
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
var NoopInternalComponent = function (element) {
|
|
@@ -317,6 +317,10 @@ NoopInternalComponent.prototype = {
|
|
|
317
317
|
this._currentElement = element;
|
|
318
318
|
},
|
|
319
319
|
|
|
320
|
+
getNativeNode: function () {
|
|
321
|
+
return undefined;
|
|
322
|
+
},
|
|
323
|
+
|
|
320
324
|
unmountComponent: function () {},
|
|
321
325
|
|
|
322
326
|
getPublicInstance: function () {
|
|
@@ -324,12 +328,14 @@ NoopInternalComponent.prototype = {
|
|
|
324
328
|
}
|
|
325
329
|
};
|
|
326
330
|
|
|
327
|
-
var ShallowComponentWrapper = function () {
|
|
331
|
+
var ShallowComponentWrapper = function (element) {
|
|
332
|
+
this.construct(element);
|
|
333
|
+
};
|
|
328
334
|
assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
329
335
|
_instantiateReactComponent: function (element) {
|
|
330
336
|
return new NoopInternalComponent(element);
|
|
331
337
|
},
|
|
332
|
-
|
|
338
|
+
_replaceNodeWithMarkup: function () {},
|
|
333
339
|
_renderValidatedComponent: ReactCompositeComponent.Mixin._renderValidatedComponentWithoutOwnerOrContext
|
|
334
340
|
});
|
|
335
341
|
|
|
@@ -341,17 +347,23 @@ ReactShallowRenderer.prototype.render = function (element, context) {
|
|
|
341
347
|
context = emptyObject;
|
|
342
348
|
}
|
|
343
349
|
ReactUpdates.batchedUpdates(_batchedRender, this, element, context);
|
|
350
|
+
|
|
351
|
+
return this.getRenderOutput();
|
|
344
352
|
};
|
|
345
353
|
|
|
346
354
|
function _batchedRender(renderer, element, context) {
|
|
347
|
-
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
|
|
355
|
+
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(true);
|
|
348
356
|
renderer._render(element, transaction, context);
|
|
349
357
|
ReactUpdates.ReactReconcileTransaction.release(transaction);
|
|
350
358
|
}
|
|
351
359
|
|
|
360
|
+
ReactShallowRenderer.prototype.getRenderOutput = function () {
|
|
361
|
+
return this._instance && this._instance._renderedComponent && this._instance._renderedComponent._renderedOutput || null;
|
|
362
|
+
};
|
|
363
|
+
|
|
352
364
|
ReactShallowRenderer.prototype.unmount = function () {
|
|
353
365
|
if (this._instance) {
|
|
354
|
-
this._instance.unmountComponent();
|
|
366
|
+
this._instance.unmountComponent(false);
|
|
355
367
|
}
|
|
356
368
|
};
|
|
357
369
|
|
|
@@ -359,12 +371,8 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
359
371
|
if (this._instance) {
|
|
360
372
|
this._instance.receiveComponent(element, transaction, context);
|
|
361
373
|
} else {
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
instance.construct(element);
|
|
365
|
-
|
|
366
|
-
instance.mountComponent(rootID, transaction, context);
|
|
367
|
-
|
|
374
|
+
var instance = new ShallowComponentWrapper(element);
|
|
375
|
+
instance.mountComponent(transaction, null, null, context);
|
|
368
376
|
this._instance = instance;
|
|
369
377
|
}
|
|
370
378
|
};
|
|
@@ -380,19 +388,20 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
380
388
|
function makeSimulator(eventType) {
|
|
381
389
|
return function (domComponentOrNode, eventData) {
|
|
382
390
|
var node;
|
|
391
|
+
!!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) : undefined;
|
|
383
392
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
384
393
|
node = findDOMNode(domComponentOrNode);
|
|
385
394
|
} else if (domComponentOrNode.tagName) {
|
|
386
395
|
node = domComponentOrNode;
|
|
387
396
|
}
|
|
388
397
|
|
|
389
|
-
var dispatchConfig =
|
|
398
|
+
var dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType];
|
|
390
399
|
|
|
391
400
|
var fakeNativeEvent = new Event();
|
|
392
401
|
fakeNativeEvent.target = node;
|
|
393
402
|
// We don't use SyntheticEvent.getPooled in order to not have to worry about
|
|
394
403
|
// properly destroying any properties assigned from `eventData` upon release
|
|
395
|
-
var event = new SyntheticEvent(dispatchConfig,
|
|
404
|
+
var event = new SyntheticEvent(dispatchConfig, ReactDOMComponentTree.getInstanceFromNode(node), fakeNativeEvent, node);
|
|
396
405
|
assign(event, eventData);
|
|
397
406
|
|
|
398
407
|
if (dispatchConfig.phasedRegistrationNames) {
|
|
@@ -412,7 +421,7 @@ function buildSimulators() {
|
|
|
412
421
|
ReactTestUtils.Simulate = {};
|
|
413
422
|
|
|
414
423
|
var eventType;
|
|
415
|
-
for (eventType in
|
|
424
|
+
for (eventType in EventPluginRegistry.eventNameDispatchConfigs) {
|
|
416
425
|
/**
|
|
417
426
|
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
|
418
427
|
* @param {?object} eventData Fake event data to use in SyntheticEvent.
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -13,56 +13,20 @@
|
|
|
13
13
|
|
|
14
14
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
* EVENT_NAME_MAP is used to determine which event fired when a
|
|
18
|
-
* transition/animation ends, based on the style property used to
|
|
19
|
-
* define that event.
|
|
20
|
-
*/
|
|
21
|
-
var EVENT_NAME_MAP = {
|
|
22
|
-
transitionend: {
|
|
23
|
-
'transition': 'transitionend',
|
|
24
|
-
'WebkitTransition': 'webkitTransitionEnd',
|
|
25
|
-
'MozTransition': 'mozTransitionEnd',
|
|
26
|
-
'OTransition': 'oTransitionEnd',
|
|
27
|
-
'msTransition': 'MSTransitionEnd'
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
animationend: {
|
|
31
|
-
'animation': 'animationend',
|
|
32
|
-
'WebkitAnimation': 'webkitAnimationEnd',
|
|
33
|
-
'MozAnimation': 'mozAnimationEnd',
|
|
34
|
-
'OAnimation': 'oAnimationEnd',
|
|
35
|
-
'msAnimation': 'MSAnimationEnd'
|
|
36
|
-
}
|
|
37
|
-
};
|
|
16
|
+
var getVendorPrefixedEventName = require('./getVendorPrefixedEventName');
|
|
38
17
|
|
|
39
18
|
var endEvents = [];
|
|
40
19
|
|
|
41
20
|
function detectEvents() {
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
// On some platforms, in particular some releases of Android 4.x,
|
|
46
|
-
// the un-prefixed "animation" and "transition" properties are defined on the
|
|
47
|
-
// style object but the events that fire will still be prefixed, so we need
|
|
48
|
-
// to check if the un-prefixed events are useable, and if not remove them
|
|
49
|
-
// from the map
|
|
50
|
-
if (!('AnimationEvent' in window)) {
|
|
51
|
-
delete EVENT_NAME_MAP.animationend.animation;
|
|
52
|
-
}
|
|
21
|
+
var animEnd = getVendorPrefixedEventName('animationend');
|
|
22
|
+
var transEnd = getVendorPrefixedEventName('transitionend');
|
|
53
23
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
24
|
+
if (animEnd) {
|
|
25
|
+
endEvents.push(animEnd);
|
|
56
26
|
}
|
|
57
27
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (var styleName in baseEvents) {
|
|
61
|
-
if (styleName in style) {
|
|
62
|
-
endEvents.push(baseEvents[styleName]);
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
28
|
+
if (transEnd) {
|
|
29
|
+
endEvents.push(transEnd);
|
|
66
30
|
}
|
|
67
31
|
}
|
|
68
32
|
|