react 0.14.0-alpha2 → 0.14.0-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/addons.js +6 -3
- package/dist/JSXTransformer.js +634 -274
- package/dist/react-with-addons.js +5350 -4954
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4777 -4408
- package/dist/react.min.js +6 -5
- package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +3 -0
- package/lib/CSSPropertyOperations.js +13 -13
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +16 -14
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +82 -117
- package/lib/DOMPropertyOperations.js +78 -33
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +8 -8
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +13 -13
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +17 -17
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +13 -3
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +50 -38
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +14 -2
- package/lib/React.js +6 -6
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +30 -7
- package/lib/ReactCSSTransitionGroup.js +16 -5
- package/lib/ReactCSSTransitionGroupChild.js +20 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +9 -9
- package/lib/ReactClass.js +65 -83
- package/lib/ReactComponent.js +22 -17
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +3 -3
- package/lib/ReactCompositeComponent.js +80 -111
- package/lib/ReactDOM.js +72 -158
- package/lib/ReactDOMButton.js +15 -26
- package/lib/ReactDOMComponent.js +378 -56
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +23 -23
- package/lib/ReactDOMInput.js +83 -99
- package/lib/ReactDOMOption.js +25 -45
- package/lib/ReactDOMSelect.js +88 -98
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +48 -61
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -71
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +22 -83
- package/lib/ReactElementValidator.js +48 -117
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactErrorUtils.js +1 -1
- package/lib/ReactEventEmitterMixin.js +3 -4
- package/lib/ReactEventListener.js +57 -12
- package/lib/ReactFragment.js +22 -17
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +8 -7
- package/lib/ReactInstanceHandles.js +12 -12
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +88 -88
- package/lib/ReactMultiChild.js +83 -22
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -8
- package/lib/ReactNoopUpdateQueue.js +118 -0
- package/lib/ReactOwner.js +3 -3
- package/lib/ReactPerf.js +2 -2
- package/lib/ReactPropTransferer.js +3 -3
- package/lib/ReactPropTypeLocationNames.js +1 -1
- package/lib/ReactPropTypeLocations.js +1 -1
- package/lib/ReactPropTypes.js +49 -11
- package/lib/ReactReconcileTransaction.js +8 -8
- package/lib/ReactReconciler.js +18 -20
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +23 -0
- package/lib/ReactServerRendering.js +22 -9
- package/lib/ReactServerRenderingTransaction.js +7 -7
- package/lib/ReactTestUtils.js +80 -58
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +61 -36
- package/lib/ReactUpdates.js +14 -17
- package/lib/ReactWithAddons.js +14 -16
- package/lib/ResponderEventPlugin.js +514 -0
- package/lib/ResponderSyntheticEvent.js +40 -0
- package/lib/ResponderTouchHistoryStore.js +180 -0
- package/lib/SVGDOMPropertyConfig.js +1 -1
- package/lib/SelectEventPlugin.js +14 -15
- package/lib/SimpleEventPlugin.js +205 -29
- package/lib/SyntheticClipboardEvent.js +3 -3
- package/lib/SyntheticCompositionEvent.js +3 -3
- package/lib/SyntheticDragEvent.js +3 -3
- package/lib/SyntheticEvent.js +9 -8
- package/lib/SyntheticFocusEvent.js +3 -3
- package/lib/SyntheticInputEvent.js +3 -3
- package/lib/SyntheticKeyboardEvent.js +6 -6
- package/lib/SyntheticMouseEvent.js +5 -5
- package/lib/SyntheticTouchEvent.js +4 -4
- package/lib/SyntheticUIEvent.js +4 -4
- package/lib/SyntheticWheelEvent.js +3 -3
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +16 -10
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +12 -7
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +47 -0
- package/lib/findDOMNode.js +11 -12
- package/lib/flattenChildren.js +4 -4
- package/lib/forEachAccumulated.js +1 -1
- package/lib/getEventCharCode.js +1 -1
- package/lib/getEventKey.js +1 -1
- package/lib/getEventModifierState.js +0 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +24 -20
- package/lib/isEventSupported.js +1 -1
- package/lib/isTextInputElement.js +2 -1
- package/lib/joinClasses.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +210 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +2 -2
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +15 -14
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +14 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +53 -1
- package/addons/CSSTransitionGroup.js +0 -1
- package/addons/LinkedStateMixin.js +0 -1
- package/addons/Perf.js +0 -1
- package/addons/PureRenderMixin.js +0 -1
- package/addons/TestUtils.js +0 -1
- package/addons/TransitionGroup.js +0 -1
- package/addons/batchedUpdates.js +0 -1
- package/addons/cloneWithProps.js +0 -1
- package/addons/createFragment.js +0 -1
- package/addons/renderSubtreeIntoContainer.js +0 -1
- package/addons/shallowCompare.js +0 -1
- package/addons/update.js +0 -1
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/LocalEventTrapMixin.js +0 -46
- package/lib/ReactContext.js +0 -32
- package/lib/ReactDOMClient.js +0 -85
- package/lib/ReactDOMForm.js +0 -47
- package/lib/ReactDOMIframe.js +0 -43
- package/lib/ReactDOMImg.js +0 -44
- package/lib/ReactLifeCycle.js +0 -35
- package/lib/camelize.js +0 -32
- package/lib/camelizeStyleName.js +0 -40
- package/lib/containsNode.js +0 -55
- package/lib/createArrayFromMixed.js +0 -85
- package/lib/createFullPageComponent.js +0 -51
- package/lib/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/emptyObject.js +0 -20
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -115
- package/lib/getUnboundedScrollPosition.js +0 -38
- package/lib/hyphenate.js +0 -33
- package/lib/hyphenateStyleName.js +0 -39
- package/lib/invariant.js +0 -49
- package/lib/isNode.js +0 -23
- package/lib/isTextNode.js +0 -25
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/performance.js +0 -23
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -61
package/lib/ReactRef.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2014-2015, 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 ReactServerBatchingStrategy
|
|
10
|
+
* @typechecks
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactServerBatchingStrategy = {
|
|
16
|
+
isBatchingUpdates: false,
|
|
17
|
+
batchedUpdates: function (callback) {
|
|
18
|
+
// Don't do anything here. During the server rendering we don't want to
|
|
19
|
+
// schedule any updates. We will simply ignore them.
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = ReactServerBatchingStrategy;
|
|
@@ -11,24 +11,29 @@
|
|
|
11
11
|
*/
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
14
|
+
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
15
|
+
var ReactElement = require('./ReactElement');
|
|
16
|
+
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
17
|
+
var ReactMarkupChecksum = require('./ReactMarkupChecksum');
|
|
18
|
+
var ReactServerBatchingStrategy = require('./ReactServerBatchingStrategy');
|
|
19
|
+
var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
|
|
20
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
18
21
|
|
|
19
|
-
var emptyObject = require(
|
|
20
|
-
var instantiateReactComponent = require(
|
|
21
|
-
var invariant = require(
|
|
22
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
23
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
24
|
+
var invariant = require('fbjs/lib/invariant');
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* @param {ReactElement} element
|
|
25
28
|
* @return {string} the HTML markup
|
|
26
29
|
*/
|
|
27
30
|
function renderToString(element) {
|
|
28
|
-
|
|
31
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
29
32
|
|
|
30
33
|
var transaction;
|
|
31
34
|
try {
|
|
35
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
36
|
+
|
|
32
37
|
var id = ReactInstanceHandles.createReactRootID();
|
|
33
38
|
transaction = ReactServerRenderingTransaction.getPooled(false);
|
|
34
39
|
|
|
@@ -39,6 +44,9 @@ function renderToString(element) {
|
|
|
39
44
|
}, null);
|
|
40
45
|
} finally {
|
|
41
46
|
ReactServerRenderingTransaction.release(transaction);
|
|
47
|
+
// Revert to the DOM batching strategy since these two renderers
|
|
48
|
+
// currently share these stateful modules.
|
|
49
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -48,10 +56,12 @@ function renderToString(element) {
|
|
|
48
56
|
* (for generating static pages)
|
|
49
57
|
*/
|
|
50
58
|
function renderToStaticMarkup(element) {
|
|
51
|
-
|
|
59
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
52
60
|
|
|
53
61
|
var transaction;
|
|
54
62
|
try {
|
|
63
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
|
|
64
|
+
|
|
55
65
|
var id = ReactInstanceHandles.createReactRootID();
|
|
56
66
|
transaction = ReactServerRenderingTransaction.getPooled(true);
|
|
57
67
|
|
|
@@ -61,6 +71,9 @@ function renderToStaticMarkup(element) {
|
|
|
61
71
|
}, null);
|
|
62
72
|
} finally {
|
|
63
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);
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var PooledClass = require(
|
|
16
|
-
var CallbackQueue = require(
|
|
17
|
-
var Transaction = require(
|
|
15
|
+
var PooledClass = require('./PooledClass');
|
|
16
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
17
|
+
var Transaction = require('./Transaction');
|
|
18
18
|
|
|
19
|
-
var assign = require(
|
|
20
|
-
var emptyFunction = require(
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
|
|
@@ -56,7 +56,7 @@ var Mixin = {
|
|
|
56
56
|
* @see Transaction
|
|
57
57
|
* @abstract
|
|
58
58
|
* @final
|
|
59
|
-
* @return {array} Empty list of operation wrap
|
|
59
|
+
* @return {array} Empty list of operation wrap procedures.
|
|
60
60
|
*/
|
|
61
61
|
getTransactionWrappers: function () {
|
|
62
62
|
return TRANSACTION_WRAPPERS;
|
|
@@ -71,7 +71,7 @@ var Mixin = {
|
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
74
|
-
* instance to be
|
|
74
|
+
* instance to be reused.
|
|
75
75
|
*/
|
|
76
76
|
destructor: function () {
|
|
77
77
|
CallbackQueue.release(this.reactMountReady);
|
package/lib/ReactTestUtils.js
CHANGED
|
@@ -11,23 +11,24 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var EventConstants = require(
|
|
15
|
-
var EventPluginHub = require(
|
|
16
|
-
var EventPropagators = require(
|
|
17
|
-
var React = require(
|
|
18
|
-
var ReactElement = require(
|
|
19
|
-
var ReactEmptyComponent = require(
|
|
20
|
-
var ReactBrowserEventEmitter = require(
|
|
21
|
-
var ReactCompositeComponent = require(
|
|
22
|
-
var ReactInstanceHandles = require(
|
|
23
|
-
var ReactInstanceMap = require(
|
|
24
|
-
var ReactMount = require(
|
|
25
|
-
var ReactUpdates = require(
|
|
26
|
-
var SyntheticEvent = require(
|
|
27
|
-
|
|
28
|
-
var assign = require(
|
|
29
|
-
var emptyObject = require(
|
|
30
|
-
var findDOMNode = require(
|
|
14
|
+
var EventConstants = require('./EventConstants');
|
|
15
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
16
|
+
var EventPropagators = require('./EventPropagators');
|
|
17
|
+
var React = require('./React');
|
|
18
|
+
var ReactElement = require('./ReactElement');
|
|
19
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
20
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
21
|
+
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
22
|
+
var ReactInstanceHandles = require('./ReactInstanceHandles');
|
|
23
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
24
|
+
var ReactMount = require('./ReactMount');
|
|
25
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
26
|
+
var SyntheticEvent = require('./SyntheticEvent');
|
|
27
|
+
|
|
28
|
+
var assign = require('./Object.assign');
|
|
29
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
30
|
+
var findDOMNode = require('./findDOMNode');
|
|
31
|
+
var invariant = require('fbjs/lib/invariant');
|
|
31
32
|
|
|
32
33
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
33
34
|
|
|
@@ -37,6 +38,27 @@ function Event(suffix) {}
|
|
|
37
38
|
* @class ReactTestUtils
|
|
38
39
|
*/
|
|
39
40
|
|
|
41
|
+
function findAllInRenderedTreeInternal(inst, test) {
|
|
42
|
+
if (!inst || !inst.getPublicInstance) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
var publicInst = inst.getPublicInstance();
|
|
46
|
+
var ret = test(publicInst) ? [publicInst] : [];
|
|
47
|
+
if (ReactTestUtils.isDOMComponent(publicInst)) {
|
|
48
|
+
var renderedChildren = inst._renderedChildren;
|
|
49
|
+
var key;
|
|
50
|
+
for (key in renderedChildren) {
|
|
51
|
+
if (!renderedChildren.hasOwnProperty(key)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
ret = ret.concat(findAllInRenderedTreeInternal(renderedChildren[key], test));
|
|
55
|
+
}
|
|
56
|
+
} else if (ReactTestUtils.isCompositeComponent(publicInst)) {
|
|
57
|
+
ret = ret.concat(findAllInRenderedTreeInternal(inst._renderedComponent, test));
|
|
58
|
+
}
|
|
59
|
+
return ret;
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
/**
|
|
41
63
|
* Todo: Support the entire DOM.scry query syntax. For now, these simple
|
|
42
64
|
* utilities will suffice for testing purposes.
|
|
@@ -64,7 +86,7 @@ var ReactTestUtils = {
|
|
|
64
86
|
isDOMComponent: function (inst) {
|
|
65
87
|
// TODO: Fix this heuristic. It's just here because composites can currently
|
|
66
88
|
// pretend to be DOM components.
|
|
67
|
-
return !!(inst && inst.
|
|
89
|
+
return !!(inst && inst.nodeType === 1 && inst.tagName);
|
|
68
90
|
},
|
|
69
91
|
|
|
70
92
|
isDOMComponentElement: function (inst) {
|
|
@@ -72,11 +94,22 @@ var ReactTestUtils = {
|
|
|
72
94
|
},
|
|
73
95
|
|
|
74
96
|
isCompositeComponent: function (inst) {
|
|
97
|
+
if (ReactTestUtils.isDOMComponent(inst)) {
|
|
98
|
+
// Accessing inst.setState warns; just return false as that'll be what
|
|
99
|
+
// this returns when we have DOM nodes as refs directly
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
75
102
|
return typeof inst.render === 'function' && typeof inst.setState === 'function';
|
|
76
103
|
},
|
|
77
104
|
|
|
78
105
|
isCompositeComponentWithType: function (inst, type) {
|
|
79
|
-
|
|
106
|
+
if (!ReactTestUtils.isCompositeComponent(inst)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
var internalInstance = ReactInstanceMap.get(inst);
|
|
110
|
+
var constructor = internalInstance._currentElement.type;
|
|
111
|
+
|
|
112
|
+
return constructor === type;
|
|
80
113
|
},
|
|
81
114
|
|
|
82
115
|
isCompositeComponentElement: function (inst) {
|
|
@@ -90,7 +123,10 @@ var ReactTestUtils = {
|
|
|
90
123
|
},
|
|
91
124
|
|
|
92
125
|
isCompositeComponentElementWithType: function (inst, type) {
|
|
93
|
-
|
|
126
|
+
var internalInstance = ReactInstanceMap.get(inst);
|
|
127
|
+
var constructor = internalInstance._currentElement.type;
|
|
128
|
+
|
|
129
|
+
return !!(ReactTestUtils.isCompositeComponentElement(inst) && constructor === type);
|
|
94
130
|
},
|
|
95
131
|
|
|
96
132
|
getRenderedChildOfCompositeComponent: function (inst) {
|
|
@@ -105,35 +141,22 @@ var ReactTestUtils = {
|
|
|
105
141
|
if (!inst) {
|
|
106
142
|
return [];
|
|
107
143
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var internalInstance = ReactInstanceMap.get(inst);
|
|
111
|
-
var renderedChildren = internalInstance._renderedComponent._renderedChildren;
|
|
112
|
-
var key;
|
|
113
|
-
for (key in renderedChildren) {
|
|
114
|
-
if (!renderedChildren.hasOwnProperty(key)) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
if (!renderedChildren[key].getPublicInstance) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
ret = ret.concat(ReactTestUtils.findAllInRenderedTree(renderedChildren[key].getPublicInstance(), test));
|
|
121
|
-
}
|
|
122
|
-
} else if (ReactTestUtils.isCompositeComponent(inst)) {
|
|
123
|
-
ret = ret.concat(ReactTestUtils.findAllInRenderedTree(ReactTestUtils.getRenderedChildOfCompositeComponent(inst), test));
|
|
124
|
-
}
|
|
125
|
-
return ret;
|
|
144
|
+
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : undefined;
|
|
145
|
+
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
|
|
126
146
|
},
|
|
127
147
|
|
|
128
148
|
/**
|
|
129
149
|
* Finds all instance of components in the rendered tree that are DOM
|
|
130
150
|
* components with the class name matching `className`.
|
|
131
|
-
* @return an array of all the matches.
|
|
151
|
+
* @return {array} an array of all the matches.
|
|
132
152
|
*/
|
|
133
153
|
scryRenderedDOMComponentsWithClass: function (root, className) {
|
|
134
154
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
if (ReactTestUtils.isDOMComponent(inst)) {
|
|
156
|
+
var instClassName = React.findDOMNode(inst).className;
|
|
157
|
+
return instClassName && ('' + instClassName).split(/\s+/).indexOf(className) !== -1;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
137
160
|
});
|
|
138
161
|
},
|
|
139
162
|
|
|
@@ -154,11 +177,11 @@ var ReactTestUtils = {
|
|
|
154
177
|
/**
|
|
155
178
|
* Finds all instance of components in the rendered tree that are DOM
|
|
156
179
|
* components with the tag name matching `tagName`.
|
|
157
|
-
* @return an array of all the matches.
|
|
180
|
+
* @return {array} an array of all the matches.
|
|
158
181
|
*/
|
|
159
182
|
scryRenderedDOMComponentsWithTag: function (root, tagName) {
|
|
160
183
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
161
|
-
return ReactTestUtils.isDOMComponent(inst) && inst.tagName === tagName.toUpperCase();
|
|
184
|
+
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
|
|
162
185
|
});
|
|
163
186
|
},
|
|
164
187
|
|
|
@@ -178,7 +201,7 @@ var ReactTestUtils = {
|
|
|
178
201
|
|
|
179
202
|
/**
|
|
180
203
|
* Finds all instances of components with type equal to `componentType`.
|
|
181
|
-
* @return an array of all the matches.
|
|
204
|
+
* @return {array} an array of all the matches.
|
|
182
205
|
*/
|
|
183
206
|
scryRenderedComponentsWithType: function (root, componentType) {
|
|
184
207
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
@@ -195,7 +218,7 @@ var ReactTestUtils = {
|
|
|
195
218
|
findRenderedComponentWithType: function (root, componentType) {
|
|
196
219
|
var all = ReactTestUtils.scryRenderedComponentsWithType(root, componentType);
|
|
197
220
|
if (all.length !== 1) {
|
|
198
|
-
throw new Error('Did not find exactly one match for componentType:' + componentType);
|
|
221
|
+
throw new Error('Did not find exactly one match for componentType:' + componentType + ' (found ' + all.length + ')');
|
|
199
222
|
}
|
|
200
223
|
return all[0];
|
|
201
224
|
},
|
|
@@ -226,7 +249,7 @@ var ReactTestUtils = {
|
|
|
226
249
|
/**
|
|
227
250
|
* Simulates a top level event being dispatched from a raw event that occured
|
|
228
251
|
* on an `Element` node.
|
|
229
|
-
* @param
|
|
252
|
+
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`
|
|
230
253
|
* @param {!Element} node The dom to simulate an event occurring on.
|
|
231
254
|
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
|
232
255
|
*/
|
|
@@ -238,8 +261,8 @@ var ReactTestUtils = {
|
|
|
238
261
|
/**
|
|
239
262
|
* Simulates a top level event being dispatched from a raw event that occured
|
|
240
263
|
* on the `ReactDOMComponent` `comp`.
|
|
241
|
-
* @param
|
|
242
|
-
* @param
|
|
264
|
+
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`.
|
|
265
|
+
* @param {!ReactDOMComponent} comp
|
|
243
266
|
* @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
|
|
244
267
|
*/
|
|
245
268
|
simulateNativeEventOnDOMComponent: function (topLevelType, comp, fakeNativeEvent) {
|
|
@@ -314,7 +337,9 @@ ReactShallowRenderer.prototype.unmount = function () {
|
|
|
314
337
|
};
|
|
315
338
|
|
|
316
339
|
ReactShallowRenderer.prototype._render = function (element, transaction, context) {
|
|
317
|
-
if (
|
|
340
|
+
if (this._instance) {
|
|
341
|
+
this._instance.receiveComponent(element, transaction, context);
|
|
342
|
+
} else {
|
|
318
343
|
var rootID = ReactInstanceHandles.createReactRootID();
|
|
319
344
|
var instance = new ShallowComponentWrapper(element.type);
|
|
320
345
|
instance.construct(element);
|
|
@@ -322,8 +347,6 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
322
347
|
instance.mountComponent(rootID, transaction, context);
|
|
323
348
|
|
|
324
349
|
this._instance = instance;
|
|
325
|
-
} else {
|
|
326
|
-
this._instance.receiveComponent(element, transaction, context);
|
|
327
350
|
}
|
|
328
351
|
};
|
|
329
352
|
|
|
@@ -350,7 +373,7 @@ function makeSimulator(eventType) {
|
|
|
350
373
|
fakeNativeEvent.target = node;
|
|
351
374
|
// We don't use SyntheticEvent.getPooled in order to not have to worry about
|
|
352
375
|
// properly destroying any properties assigned from `eventData` upon release
|
|
353
|
-
var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent);
|
|
376
|
+
var event = new SyntheticEvent(dispatchConfig, ReactMount.getID(node), fakeNativeEvent, node);
|
|
354
377
|
assign(event, eventData);
|
|
355
378
|
|
|
356
379
|
if (dispatchConfig.phasedRegistrationNames) {
|
|
@@ -372,7 +395,7 @@ function buildSimulators() {
|
|
|
372
395
|
var eventType;
|
|
373
396
|
for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
|
|
374
397
|
/**
|
|
375
|
-
* @param {!Element
|
|
398
|
+
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
|
376
399
|
* @param {?object} eventData Fake event data to use in SyntheticEvent.
|
|
377
400
|
*/
|
|
378
401
|
ReactTestUtils.Simulate[eventType] = makeSimulator(eventType);
|
|
@@ -415,22 +438,21 @@ function makeNativeSimulator(eventType) {
|
|
|
415
438
|
assign(fakeNativeEvent, nativeEventData);
|
|
416
439
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
417
440
|
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
|
418
|
-
} else if (
|
|
441
|
+
} else if (domComponentOrNode.tagName) {
|
|
419
442
|
// Will allow on actual dom nodes.
|
|
420
443
|
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
|
|
421
444
|
}
|
|
422
445
|
};
|
|
423
446
|
}
|
|
424
447
|
|
|
425
|
-
|
|
426
|
-
for (eventType in topLevelTypes) {
|
|
448
|
+
Object.keys(topLevelTypes).forEach(function (eventType) {
|
|
427
449
|
// Event type is stored as 'topClick' - we transform that to 'click'
|
|
428
450
|
var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
|
|
429
451
|
/**
|
|
430
|
-
* @param {!Element
|
|
452
|
+
* @param {!Element|ReactDOMComponent} domComponentOrNode
|
|
431
453
|
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
|
432
454
|
*/
|
|
433
455
|
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
|
|
434
|
-
}
|
|
456
|
+
});
|
|
435
457
|
|
|
436
458
|
module.exports = ReactTestUtils;
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactChildren = require(
|
|
16
|
-
var ReactFragment = require(
|
|
15
|
+
var ReactChildren = require('./ReactChildren');
|
|
16
|
+
var ReactFragment = require('./ReactFragment');
|
|
17
17
|
|
|
18
18
|
var ReactTransitionChildMapping = {
|
|
19
19
|
/**
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var React = require(
|
|
15
|
-
var ReactTransitionChildMapping = require(
|
|
14
|
+
var React = require('./React');
|
|
15
|
+
var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
|
|
16
16
|
|
|
17
|
-
var assign = require(
|
|
18
|
-
var
|
|
19
|
-
var emptyFunction = require("./emptyFunction");
|
|
17
|
+
var assign = require('./Object.assign');
|
|
18
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
20
19
|
|
|
21
20
|
var ReactTransitionGroup = React.createClass({
|
|
22
21
|
displayName: 'ReactTransitionGroup',
|
|
@@ -196,7 +195,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
196
195
|
// already been removed. In case you need this behavior you can provide
|
|
197
196
|
// a childFactory function to wrap every child, even the ones that are
|
|
198
197
|
// leaving.
|
|
199
|
-
childrenToRender.push(
|
|
198
|
+
childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
return React.createElement(this.props.component, this.props, childrenToRender);
|