react 0.14.0-beta1 → 0.14.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/addons.js +8 -3
- package/dist/react-with-addons.js +5048 -4095
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +4555 -3729
- package/dist/react.min.js +6 -5
- package/lib/AutoFocusUtils.js +3 -3
- package/lib/BeforeInputEventPlugin.js +13 -13
- package/lib/CSSProperty.js +18 -3
- package/lib/CSSPropertyOperations.js +27 -14
- package/lib/CallbackQueue.js +4 -4
- package/lib/ChangeEventPlugin.js +15 -14
- package/lib/DOMChildrenOperations.js +22 -7
- package/lib/DOMProperty.js +8 -8
- package/lib/DOMPropertyOperations.js +23 -10
- package/lib/Danger.js +21 -16
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +18 -10
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +29 -21
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +34 -38
- package/lib/EventPropagators.js +8 -8
- package/lib/FallbackCompositionState.js +9 -3
- package/lib/HTMLDOMPropertyConfig.js +24 -4
- package/lib/LinkedStateMixin.js +2 -2
- package/lib/LinkedValueUtils.js +8 -8
- package/lib/MetaMatchers.js +118 -0
- package/lib/OrderedMap.js +453 -0
- package/lib/PooledClass.js +3 -5
- package/lib/React.js +18 -7
- package/lib/ReactBrowserComponentMixin.js +4 -4
- package/lib/ReactBrowserEventEmitter.js +36 -7
- package/lib/ReactCSSTransitionGroup.js +35 -9
- package/lib/ReactCSSTransitionGroupChild.js +48 -30
- package/lib/ReactChildReconciler.js +24 -19
- package/lib/ReactChildren.js +72 -32
- package/lib/ReactClass.js +46 -46
- package/lib/ReactComponent.js +18 -16
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +95 -44
- package/lib/ReactDOM.js +74 -159
- package/lib/ReactDOMComponent.js +235 -93
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
- package/lib/ReactDOMIDOperations.js +8 -81
- package/lib/ReactDOMInput.js +18 -9
- package/lib/ReactDOMOption.js +7 -7
- package/lib/ReactDOMSelect.js +9 -9
- package/lib/ReactDOMSelection.js +19 -3
- package/lib/ReactDOMServer.js +5 -3
- package/lib/ReactDOMTextComponent.js +33 -20
- package/lib/ReactDOMTextarea.js +14 -12
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +23 -25
- package/lib/ReactDefaultPerf.js +17 -11
- package/lib/ReactDefaultPerfAnalysis.js +13 -12
- package/lib/ReactElement.js +85 -39
- package/lib/ReactElementValidator.js +47 -90
- package/lib/ReactEmptyComponent.js +26 -62
- package/lib/ReactEmptyComponentRegistry.js +48 -0
- package/lib/ReactErrorUtils.js +53 -9
- package/lib/ReactEventEmitterMixin.js +2 -2
- package/lib/ReactEventListener.js +33 -21
- package/lib/ReactFragment.js +27 -118
- package/lib/ReactInjection.js +10 -12
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -11
- package/lib/ReactIsomorphic.js +15 -11
- package/lib/ReactLink.js +2 -2
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +186 -85
- package/lib/ReactMultiChild.js +119 -25
- package/lib/ReactMultiChildUpdateTypes.js +2 -1
- package/lib/ReactNativeComponent.js +3 -3
- package/lib/ReactNoopUpdateQueue.js +3 -3
- 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 +38 -9
- package/lib/ReactReconcileTransaction.js +10 -8
- package/lib/ReactReconciler.js +5 -6
- package/lib/ReactRef.js +14 -2
- package/lib/ReactServerBatchingStrategy.js +5 -5
- package/lib/ReactServerRendering.js +12 -12
- package/lib/ReactServerRenderingTransaction.js +6 -5
- package/lib/ReactTestUtils.js +47 -39
- package/lib/ReactTransitionChildMapping.js +3 -6
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +19 -19
- package/lib/ReactUpdates.js +15 -15
- package/lib/{performance.js → ReactVersion.js} +3 -12
- package/lib/ReactWithAddons.js +24 -15
- 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 +19 -9
- package/lib/SimpleEventPlugin.js +198 -43
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +18 -4
- package/lib/SyntheticFocusEvent.js +1 -1
- package/lib/SyntheticInputEvent.js +1 -1
- package/lib/SyntheticKeyboardEvent.js +4 -4
- package/lib/SyntheticMouseEvent.js +3 -3
- package/lib/SyntheticTouchEvent.js +2 -2
- package/lib/SyntheticUIEvent.js +2 -2
- package/lib/SyntheticWheelEvent.js +1 -1
- package/lib/TapEventPlugin.js +119 -0
- package/lib/Transaction.js +7 -7
- package/lib/accumulate.js +44 -0
- package/lib/accumulateInto.js +2 -2
- package/lib/adler32.js +19 -7
- package/lib/cloneWithProps.js +11 -6
- package/lib/createHierarchyRenderer.js +85 -0
- package/lib/dangerousStyleValue.js +1 -1
- package/lib/deprecated.js +7 -6
- package/lib/findDOMNode.js +9 -9
- package/lib/flattenChildren.js +4 -4
- package/lib/getEventKey.js +1 -1
- package/lib/{isTextNode.js → getTestDocument.js} +7 -11
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +15 -17
- package/lib/isEventSupported.js +1 -1
- package/lib/onlyChild.js +3 -3
- package/lib/quoteAttributeValueForBrowser.js +1 -1
- package/lib/reactComponentExpect.js +216 -0
- package/lib/renderSubtreeIntoContainer.js +1 -1
- package/lib/setInnerHTML.js +1 -1
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/shouldUpdateReactComponent.js +12 -8
- package/lib/sliceChildren.js +34 -0
- package/lib/traverseAllChildren.js +25 -18
- package/lib/update.js +13 -13
- package/lib/validateDOMNesting.js +6 -6
- package/lib/webcomponents.js +6379 -0
- package/package.json +4 -6
- package/react.js +1 -51
- package/dist/JSXTransformer.js +0 -17588
- package/lib/CSSCore.js +0 -97
- package/lib/EventListener.js +0 -84
- package/lib/ExecutionEnvironment.js +0 -38
- package/lib/ReactDOMClient.js +0 -90
- 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/createNodesFromMarkup.js +0 -84
- package/lib/emptyFunction.js +0 -38
- package/lib/focusNode.js +0 -26
- package/lib/getActiveElement.js +0 -29
- package/lib/getMarkupWrap.js +0 -93
- 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/joinClasses.js +0 -39
- package/lib/keyMirror.js +0 -48
- package/lib/keyOf.js +0 -35
- package/lib/mapObject.js +0 -51
- package/lib/memoizeStringOnly.js +0 -31
- package/lib/performanceNow.js +0 -28
- package/lib/shallowEqual.js +0 -48
- package/lib/toArray.js +0 -57
- package/lib/warning.js +0 -57
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var CallbackQueue = require(
|
|
16
|
-
var PooledClass = require(
|
|
17
|
-
var ReactBrowserEventEmitter = require(
|
|
18
|
-
var
|
|
19
|
-
var
|
|
15
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
16
|
+
var PooledClass = require('./PooledClass');
|
|
17
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
18
|
+
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
|
|
19
|
+
var ReactInputSelection = require('./ReactInputSelection');
|
|
20
|
+
var Transaction = require('./Transaction');
|
|
20
21
|
|
|
21
|
-
var assign = require(
|
|
22
|
+
var assign = require('./Object.assign');
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Ensures that, when possible, the selection range (currently selected text
|
|
@@ -53,7 +54,7 @@ var EVENT_SUPPRESSION = {
|
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* @param {boolean} previouslyEnabled Enabled status of
|
|
56
|
-
* `ReactBrowserEventEmitter` before the reconciliation
|
|
57
|
+
* `ReactBrowserEventEmitter` before the reconciliation occurred. `close`
|
|
57
58
|
* restores the previous value.
|
|
58
59
|
*/
|
|
59
60
|
close: function (previouslyEnabled) {
|
|
@@ -102,7 +103,7 @@ var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_REA
|
|
|
102
103
|
*
|
|
103
104
|
* @class ReactReconcileTransaction
|
|
104
105
|
*/
|
|
105
|
-
function ReactReconcileTransaction() {
|
|
106
|
+
function ReactReconcileTransaction(forceHTML) {
|
|
106
107
|
this.reinitializeTransaction();
|
|
107
108
|
// Only server-side rendering really needs this option (see
|
|
108
109
|
// `ReactServerRendering`), but server-side uses
|
|
@@ -111,6 +112,7 @@ function ReactReconcileTransaction() {
|
|
|
111
112
|
// `ReactTextComponent` checks it in `mountComponent`.`
|
|
112
113
|
this.renderToStaticMarkup = false;
|
|
113
114
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
115
|
+
this.useCreateElement = !forceHTML && ReactDOMFeatureFlags.useCreateElement;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
var Mixin = {
|
package/lib/ReactReconciler.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactRef = require(
|
|
14
|
+
var ReactRef = require('./ReactRef');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Helper to call ReactRef.attachRefs with this composite component, split out
|
|
@@ -35,7 +35,7 @@ var ReactReconciler = {
|
|
|
35
35
|
*/
|
|
36
36
|
mountComponent: function (internalInstance, rootID, transaction, context) {
|
|
37
37
|
var markup = internalInstance.mountComponent(rootID, transaction, context);
|
|
38
|
-
if (internalInstance._currentElement.ref != null) {
|
|
38
|
+
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
39
39
|
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
40
40
|
}
|
|
41
41
|
return markup;
|
|
@@ -63,9 +63,8 @@ var ReactReconciler = {
|
|
|
63
63
|
*/
|
|
64
64
|
receiveComponent: function (internalInstance, nextElement, transaction, context) {
|
|
65
65
|
var prevElement = internalInstance._currentElement;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
) {
|
|
66
|
+
|
|
67
|
+
if (nextElement === prevElement && context === internalInstance._context) {
|
|
69
68
|
// Since elements are immutable after the owner is rendered,
|
|
70
69
|
// we can do a cheap identity compare here to determine if this is a
|
|
71
70
|
// superfluous reconcile. It's possible for state to be mutable but such
|
|
@@ -87,7 +86,7 @@ var ReactReconciler = {
|
|
|
87
86
|
|
|
88
87
|
internalInstance.receiveComponent(nextElement, transaction, context);
|
|
89
88
|
|
|
90
|
-
if (refsChanged) {
|
|
89
|
+
if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
|
91
90
|
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
|
92
91
|
}
|
|
93
92
|
},
|
package/lib/ReactRef.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactOwner = require(
|
|
14
|
+
var ReactOwner = require('./ReactOwner');
|
|
15
15
|
|
|
16
16
|
var ReactRef = {};
|
|
17
17
|
|
|
@@ -34,6 +34,9 @@ function detachRef(ref, component, owner) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
ReactRef.attachRefs = function (instance, element) {
|
|
37
|
+
if (element === null || element === false) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
var ref = element.ref;
|
|
38
41
|
if (ref != null) {
|
|
39
42
|
attachRef(ref, instance, element._owner);
|
|
@@ -53,10 +56,19 @@ ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
|
|
|
53
56
|
// is made. It probably belongs where the key checking and
|
|
54
57
|
// instantiateReactComponent is done.
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
var prevEmpty = prevElement === null || prevElement === false;
|
|
60
|
+
var nextEmpty = nextElement === null || nextElement === false;
|
|
61
|
+
|
|
62
|
+
return(
|
|
63
|
+
// This has a few false positives w/r/t empty components.
|
|
64
|
+
prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref
|
|
65
|
+
);
|
|
57
66
|
};
|
|
58
67
|
|
|
59
68
|
ReactRef.detachRefs = function (instance, element) {
|
|
69
|
+
if (element === null || element === false) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
60
72
|
var ref = element.ref;
|
|
61
73
|
if (ref != null) {
|
|
62
74
|
detachRef(ref, instance, element._owner);
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
var ReactServerBatchingStrategy = {
|
|
16
16
|
isBatchingUpdates: false,
|
|
17
|
-
batchedUpdates: function (callback) {
|
|
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
|
+
}
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
module.exports = ReactServerBatchingStrategy;
|
|
21
|
-
|
|
22
|
-
// Don't do anything here. During the server rendering we don't want to
|
|
23
|
-
// schedule any updates. We will simply ignore them.
|
|
23
|
+
module.exports = ReactServerBatchingStrategy;
|
|
@@ -11,24 +11,24 @@
|
|
|
11
11
|
*/
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactDefaultBatchingStrategy = require(
|
|
15
|
-
var ReactElement = require(
|
|
16
|
-
var ReactInstanceHandles = require(
|
|
17
|
-
var ReactMarkupChecksum = require(
|
|
18
|
-
var ReactServerBatchingStrategy = require(
|
|
19
|
-
var ReactServerRenderingTransaction = require(
|
|
20
|
-
var ReactUpdates = require(
|
|
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');
|
|
21
21
|
|
|
22
|
-
var emptyObject = require(
|
|
23
|
-
var instantiateReactComponent = require(
|
|
24
|
-
var invariant = require(
|
|
22
|
+
var emptyObject = require('fbjs/lib/emptyObject');
|
|
23
|
+
var instantiateReactComponent = require('./instantiateReactComponent');
|
|
24
|
+
var invariant = require('fbjs/lib/invariant');
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @param {ReactElement} element
|
|
28
28
|
* @return {string} the HTML markup
|
|
29
29
|
*/
|
|
30
30
|
function renderToString(element) {
|
|
31
|
-
!ReactElement.isValidElement(element) ?
|
|
31
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
32
32
|
|
|
33
33
|
var transaction;
|
|
34
34
|
try {
|
|
@@ -56,7 +56,7 @@ function renderToString(element) {
|
|
|
56
56
|
* (for generating static pages)
|
|
57
57
|
*/
|
|
58
58
|
function renderToStaticMarkup(element) {
|
|
59
|
-
!ReactElement.isValidElement(element) ?
|
|
59
|
+
!ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
|
|
60
60
|
|
|
61
61
|
var transaction;
|
|
62
62
|
try {
|
|
@@ -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
|
|
@@ -49,6 +49,7 @@ function ReactServerRenderingTransaction(renderToStaticMarkup) {
|
|
|
49
49
|
this.reinitializeTransaction();
|
|
50
50
|
this.renderToStaticMarkup = renderToStaticMarkup;
|
|
51
51
|
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
52
|
+
this.useCreateElement = false;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
var Mixin = {
|
package/lib/ReactTestUtils.js
CHANGED
|
@@ -11,24 +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
|
|
19
|
-
var
|
|
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(
|
|
31
|
-
var invariant = require(
|
|
14
|
+
var EventConstants = require('./EventConstants');
|
|
15
|
+
var EventPluginHub = require('./EventPluginHub');
|
|
16
|
+
var EventPropagators = require('./EventPropagators');
|
|
17
|
+
var React = require('./React');
|
|
18
|
+
var ReactDOM = require('./ReactDOM');
|
|
19
|
+
var ReactElement = require('./ReactElement');
|
|
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');
|
|
32
32
|
|
|
33
33
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
34
34
|
|
|
@@ -44,6 +44,7 @@ function findAllInRenderedTreeInternal(inst, test) {
|
|
|
44
44
|
}
|
|
45
45
|
var publicInst = inst.getPublicInstance();
|
|
46
46
|
var ret = test(publicInst) ? [publicInst] : [];
|
|
47
|
+
var currentElement = inst._currentElement;
|
|
47
48
|
if (ReactTestUtils.isDOMComponent(publicInst)) {
|
|
48
49
|
var renderedChildren = inst._renderedChildren;
|
|
49
50
|
var key;
|
|
@@ -53,7 +54,7 @@ function findAllInRenderedTreeInternal(inst, test) {
|
|
|
53
54
|
}
|
|
54
55
|
ret = ret.concat(findAllInRenderedTreeInternal(renderedChildren[key], test));
|
|
55
56
|
}
|
|
56
|
-
} else if (
|
|
57
|
+
} else if (ReactElement.isValidElement(currentElement) && typeof currentElement.type === 'function') {
|
|
57
58
|
ret = ret.concat(findAllInRenderedTreeInternal(inst._renderedComponent, test));
|
|
58
59
|
}
|
|
59
60
|
return ret;
|
|
@@ -72,7 +73,7 @@ var ReactTestUtils = {
|
|
|
72
73
|
// clean up, so we're going to stop honoring the name of this method
|
|
73
74
|
// (and probably rename it eventually) if no problems arise.
|
|
74
75
|
// document.documentElement.appendChild(div);
|
|
75
|
-
return
|
|
76
|
+
return ReactDOM.render(instance, div);
|
|
76
77
|
},
|
|
77
78
|
|
|
78
79
|
isElement: function (element) {
|
|
@@ -99,7 +100,7 @@ var ReactTestUtils = {
|
|
|
99
100
|
// this returns when we have DOM nodes as refs directly
|
|
100
101
|
return false;
|
|
101
102
|
}
|
|
102
|
-
return typeof inst.render === 'function' && typeof inst.setState === 'function';
|
|
103
|
+
return inst != null && typeof inst.render === 'function' && typeof inst.setState === 'function';
|
|
103
104
|
},
|
|
104
105
|
|
|
105
106
|
isCompositeComponentWithType: function (inst, type) {
|
|
@@ -141,7 +142,7 @@ var ReactTestUtils = {
|
|
|
141
142
|
if (!inst) {
|
|
142
143
|
return [];
|
|
143
144
|
}
|
|
144
|
-
!ReactTestUtils.isCompositeComponent(inst) ?
|
|
145
|
+
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : undefined;
|
|
145
146
|
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
|
|
146
147
|
},
|
|
147
148
|
|
|
@@ -150,11 +151,16 @@ var ReactTestUtils = {
|
|
|
150
151
|
* components with the class name matching `className`.
|
|
151
152
|
* @return {array} an array of all the matches.
|
|
152
153
|
*/
|
|
153
|
-
scryRenderedDOMComponentsWithClass: function (root,
|
|
154
|
+
scryRenderedDOMComponentsWithClass: function (root, classNames) {
|
|
155
|
+
if (!Array.isArray(classNames)) {
|
|
156
|
+
classNames = classNames.split(/\s+/);
|
|
157
|
+
}
|
|
154
158
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
155
159
|
if (ReactTestUtils.isDOMComponent(inst)) {
|
|
156
|
-
var
|
|
157
|
-
return
|
|
160
|
+
var classList = ReactDOM.findDOMNode(inst).className.split(/\s+/);
|
|
161
|
+
return classNames.every(function (className) {
|
|
162
|
+
return classList.indexOf(className) !== -1;
|
|
163
|
+
});
|
|
158
164
|
}
|
|
159
165
|
return false;
|
|
160
166
|
});
|
|
@@ -181,7 +187,7 @@ var ReactTestUtils = {
|
|
|
181
187
|
*/
|
|
182
188
|
scryRenderedDOMComponentsWithTag: function (root, tagName) {
|
|
183
189
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
184
|
-
return ReactTestUtils.isDOMComponent(inst) && inst.tagName === tagName.toUpperCase();
|
|
190
|
+
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
|
|
185
191
|
});
|
|
186
192
|
},
|
|
187
193
|
|
|
@@ -247,7 +253,7 @@ var ReactTestUtils = {
|
|
|
247
253
|
},
|
|
248
254
|
|
|
249
255
|
/**
|
|
250
|
-
* Simulates a top level event being dispatched from a raw event that
|
|
256
|
+
* Simulates a top level event being dispatched from a raw event that occurred
|
|
251
257
|
* on an `Element` node.
|
|
252
258
|
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`
|
|
253
259
|
* @param {!Element} node The dom to simulate an event occurring on.
|
|
@@ -259,7 +265,7 @@ var ReactTestUtils = {
|
|
|
259
265
|
},
|
|
260
266
|
|
|
261
267
|
/**
|
|
262
|
-
* Simulates a top level event being dispatched from a raw event that
|
|
268
|
+
* Simulates a top level event being dispatched from a raw event that occurred
|
|
263
269
|
* on the `ReactDOMComponent` `comp`.
|
|
264
270
|
* @param {Object} topLevelType A type from `EventConstants.topLevelTypes`.
|
|
265
271
|
* @param {!ReactDOMComponent} comp
|
|
@@ -296,7 +302,7 @@ ReactShallowRenderer.prototype.getRenderOutput = function () {
|
|
|
296
302
|
|
|
297
303
|
var NoopInternalComponent = function (element) {
|
|
298
304
|
this._renderedOutput = element;
|
|
299
|
-
this._currentElement = element
|
|
305
|
+
this._currentElement = element;
|
|
300
306
|
};
|
|
301
307
|
|
|
302
308
|
NoopInternalComponent.prototype = {
|
|
@@ -305,7 +311,7 @@ NoopInternalComponent.prototype = {
|
|
|
305
311
|
|
|
306
312
|
receiveComponent: function (element) {
|
|
307
313
|
this._renderedOutput = element;
|
|
308
|
-
this._currentElement = element
|
|
314
|
+
this._currentElement = element;
|
|
309
315
|
},
|
|
310
316
|
|
|
311
317
|
unmountComponent: function () {}
|
|
@@ -322,10 +328,13 @@ assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
|
322
328
|
});
|
|
323
329
|
|
|
324
330
|
ReactShallowRenderer.prototype.render = function (element, context) {
|
|
331
|
+
!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) : undefined;
|
|
332
|
+
!(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) : undefined;
|
|
333
|
+
|
|
325
334
|
if (!context) {
|
|
326
335
|
context = emptyObject;
|
|
327
336
|
}
|
|
328
|
-
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
|
|
337
|
+
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(false);
|
|
329
338
|
this._render(element, transaction, context);
|
|
330
339
|
ReactUpdates.ReactReconcileTransaction.release(transaction);
|
|
331
340
|
};
|
|
@@ -337,7 +346,9 @@ ReactShallowRenderer.prototype.unmount = function () {
|
|
|
337
346
|
};
|
|
338
347
|
|
|
339
348
|
ReactShallowRenderer.prototype._render = function (element, transaction, context) {
|
|
340
|
-
if (
|
|
349
|
+
if (this._instance) {
|
|
350
|
+
this._instance.receiveComponent(element, transaction, context);
|
|
351
|
+
} else {
|
|
341
352
|
var rootID = ReactInstanceHandles.createReactRootID();
|
|
342
353
|
var instance = new ShallowComponentWrapper(element.type);
|
|
343
354
|
instance.construct(element);
|
|
@@ -345,8 +356,6 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
345
356
|
instance.mountComponent(rootID, transaction, context);
|
|
346
357
|
|
|
347
358
|
this._instance = instance;
|
|
348
|
-
} else {
|
|
349
|
-
this._instance.receiveComponent(element, transaction, context);
|
|
350
359
|
}
|
|
351
360
|
};
|
|
352
361
|
|
|
@@ -384,7 +393,7 @@ function makeSimulator(eventType) {
|
|
|
384
393
|
|
|
385
394
|
ReactUpdates.batchedUpdates(function () {
|
|
386
395
|
EventPluginHub.enqueueEvents(event);
|
|
387
|
-
EventPluginHub.processEventQueue();
|
|
396
|
+
EventPluginHub.processEventQueue(true);
|
|
388
397
|
});
|
|
389
398
|
};
|
|
390
399
|
}
|
|
@@ -438,15 +447,14 @@ function makeNativeSimulator(eventType) {
|
|
|
438
447
|
assign(fakeNativeEvent, nativeEventData);
|
|
439
448
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
440
449
|
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
|
441
|
-
} else if (
|
|
450
|
+
} else if (domComponentOrNode.tagName) {
|
|
442
451
|
// Will allow on actual dom nodes.
|
|
443
452
|
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
|
|
444
453
|
}
|
|
445
454
|
};
|
|
446
455
|
}
|
|
447
456
|
|
|
448
|
-
|
|
449
|
-
for (eventType in topLevelTypes) {
|
|
457
|
+
Object.keys(topLevelTypes).forEach(function (eventType) {
|
|
450
458
|
// Event type is stored as 'topClick' - we transform that to 'click'
|
|
451
459
|
var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
|
|
452
460
|
/**
|
|
@@ -454,6 +462,6 @@ for (eventType in topLevelTypes) {
|
|
|
454
462
|
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
|
455
463
|
*/
|
|
456
464
|
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
|
|
457
|
-
}
|
|
465
|
+
});
|
|
458
466
|
|
|
459
467
|
module.exports = ReactTestUtils;
|
|
@@ -12,13 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var
|
|
16
|
-
var ReactFragment = require("./ReactFragment");
|
|
15
|
+
var flattenChildren = require('./flattenChildren');
|
|
17
16
|
|
|
18
17
|
var ReactTransitionChildMapping = {
|
|
19
18
|
/**
|
|
20
19
|
* Given `this.props.children`, return an object mapping key to child. Just
|
|
21
|
-
* simple syntactic sugar around
|
|
20
|
+
* simple syntactic sugar around flattenChildren().
|
|
22
21
|
*
|
|
23
22
|
* @param {*} children `this.props.children`
|
|
24
23
|
* @return {object} Mapping of key to child
|
|
@@ -27,9 +26,7 @@ var ReactTransitionChildMapping = {
|
|
|
27
26
|
if (!children) {
|
|
28
27
|
return children;
|
|
29
28
|
}
|
|
30
|
-
return
|
|
31
|
-
return child;
|
|
32
|
-
}));
|
|
29
|
+
return flattenChildren(children);
|
|
33
30
|
},
|
|
34
31
|
|
|
35
32
|
/**
|