react 15.1.0 → 15.2.0-rc.1
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/dist/react-with-addons.js +2034 -1313
- package/dist/react-with-addons.min.js +7 -6
- package/dist/react.js +1832 -1244
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +9 -9
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +6 -4
- package/lib/DOMPropertyOperations.js +17 -3
- package/lib/Danger.js +10 -8
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +3 -1
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +15 -6
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +94 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +66 -106
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +7 -1
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMInput.js +52 -16
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -3
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -32
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +41 -15
- package/lib/ReactDebugTool.js +88 -27
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactMount.js +24 -16
- package/lib/ReactMultiChild.js +31 -9
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +1 -1
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +5 -3
- package/lib/ReactNoop.js +76 -0
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +1 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +4 -2
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +126 -0
- package/lib/ReactTestReconcileTransaction.js +100 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +17 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +40 -6
- package/lib/ReactUpdateQueue.js +9 -1
- package/lib/ReactUpdates.js +9 -8
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +8 -6
- package/lib/ResponderTouchHistoryStore.js +6 -4
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +3 -1
- package/lib/accumulateInto.js +3 -1
- package/lib/checkReactTypeSpec.js +71 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +13 -4
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/instantiateReactComponent.js +13 -12
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +38 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-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 ReactTestReconcileTransaction
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
17
|
+
var PooledClass = require('./PooledClass');
|
|
18
|
+
var Transaction = require('./Transaction');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
|
|
22
|
+
* the performing of the transaction.
|
|
23
|
+
*/
|
|
24
|
+
var ON_DOM_READY_QUEUEING = {
|
|
25
|
+
/**
|
|
26
|
+
* Initializes the internal `onDOMReady` queue.
|
|
27
|
+
*/
|
|
28
|
+
initialize: function () {
|
|
29
|
+
this.reactMountReady.reset();
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* After DOM is flushed, invoke all registered `onDOMReady` callbacks.
|
|
34
|
+
*/
|
|
35
|
+
close: function () {
|
|
36
|
+
this.reactMountReady.notifyAll();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Executed within the scope of the `Transaction` instance. Consider these as
|
|
42
|
+
* being member methods, but with an implied ordering while being isolated from
|
|
43
|
+
* each other.
|
|
44
|
+
*/
|
|
45
|
+
var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Currently:
|
|
49
|
+
* - The order that these are listed in the transaction is critical:
|
|
50
|
+
* - Suppresses events.
|
|
51
|
+
* - Restores selection range.
|
|
52
|
+
*
|
|
53
|
+
* Future:
|
|
54
|
+
* - Restore document/overflow scroll positions that were unintentionally
|
|
55
|
+
* modified via DOM insertions above the top viewport boundary.
|
|
56
|
+
* - Implement/integrate with customized constraint based layout system and keep
|
|
57
|
+
* track of which dimensions must be remeasured.
|
|
58
|
+
*
|
|
59
|
+
* @class ReactTestReconcileTransaction
|
|
60
|
+
*/
|
|
61
|
+
function ReactTestReconcileTransaction() {
|
|
62
|
+
this.reinitializeTransaction();
|
|
63
|
+
this.reactMountReady = CallbackQueue.getPooled(null);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var Mixin = {
|
|
67
|
+
/**
|
|
68
|
+
* @see Transaction
|
|
69
|
+
* @abstract
|
|
70
|
+
* @final
|
|
71
|
+
* @return {array<object>} List of operation wrap procedures.
|
|
72
|
+
* TODO: convert to array<TransactionWrapper>
|
|
73
|
+
*/
|
|
74
|
+
getTransactionWrappers: function () {
|
|
75
|
+
return TRANSACTION_WRAPPERS;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @return {object} The queue to collect `onDOMReady` callbacks with.
|
|
80
|
+
* TODO: convert to ReactMountReady
|
|
81
|
+
*/
|
|
82
|
+
getReactMountReady: function () {
|
|
83
|
+
return this.reactMountReady;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
88
|
+
* instance to be reused.
|
|
89
|
+
*/
|
|
90
|
+
destructor: function () {
|
|
91
|
+
CallbackQueue.release(this.reactMountReady);
|
|
92
|
+
this.reactMountReady = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
_assign(ReactTestReconcileTransaction.prototype, Transaction.Mixin, ReactTestReconcileTransaction, Mixin);
|
|
97
|
+
|
|
98
|
+
PooledClass.addPoolingTo(ReactTestReconcileTransaction);
|
|
99
|
+
|
|
100
|
+
module.exports = ReactTestReconcileTransaction;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*
|
|
9
|
+
* @providesModule ReactTestRenderer
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var _assign = require('object-assign');
|
|
15
|
+
|
|
16
|
+
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
17
|
+
|
|
18
|
+
var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
|
|
19
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
20
|
+
var ReactMultiChild = require('./ReactMultiChild');
|
|
21
|
+
var ReactHostComponent = require('./ReactHostComponent');
|
|
22
|
+
var ReactTestMount = require('./ReactTestMount');
|
|
23
|
+
var ReactTestReconcileTransaction = require('./ReactTestReconcileTransaction');
|
|
24
|
+
var ReactUpdates = require('./ReactUpdates');
|
|
25
|
+
|
|
26
|
+
var renderSubtreeIntoContainer = require('./renderSubtreeIntoContainer');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Drill down (through composites and empty components) until we get a native or
|
|
30
|
+
* native text component.
|
|
31
|
+
*
|
|
32
|
+
* This is pretty polymorphic but unavoidable with the current structure we have
|
|
33
|
+
* for `_renderedChildren`.
|
|
34
|
+
*/
|
|
35
|
+
function getRenderedHostOrTextFromComponent(component) {
|
|
36
|
+
var rendered;
|
|
37
|
+
while (rendered = component._renderedComponent) {
|
|
38
|
+
component = rendered;
|
|
39
|
+
}
|
|
40
|
+
return component;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// =============================================================================
|
|
44
|
+
|
|
45
|
+
var ReactTestComponent = function (element) {
|
|
46
|
+
this._currentElement = element;
|
|
47
|
+
this._renderedChildren = null;
|
|
48
|
+
this._topLevelWrapper = null;
|
|
49
|
+
};
|
|
50
|
+
ReactTestComponent.prototype.mountComponent = function (transaction, nativeParent, nativeContainerInfo, context) {
|
|
51
|
+
var element = this._currentElement;
|
|
52
|
+
this.mountChildren(element.props.children, transaction, context);
|
|
53
|
+
};
|
|
54
|
+
ReactTestComponent.prototype.receiveComponent = function (nextElement, transaction, context) {
|
|
55
|
+
this._currentElement = nextElement;
|
|
56
|
+
this.updateChildren(nextElement.props.children, transaction, context);
|
|
57
|
+
};
|
|
58
|
+
ReactTestComponent.prototype.getHostNode = function () {};
|
|
59
|
+
ReactTestComponent.prototype.unmountComponent = function () {};
|
|
60
|
+
ReactTestComponent.prototype.toJSON = function () {
|
|
61
|
+
var _currentElement$props = this._currentElement.props;
|
|
62
|
+
var children = _currentElement$props.children;
|
|
63
|
+
|
|
64
|
+
var props = _objectWithoutProperties(_currentElement$props, ['children']);
|
|
65
|
+
|
|
66
|
+
var childrenJSON = [];
|
|
67
|
+
for (var key in this._renderedChildren) {
|
|
68
|
+
var inst = this._renderedChildren[key];
|
|
69
|
+
inst = getRenderedHostOrTextFromComponent(inst);
|
|
70
|
+
var json = inst.toJSON();
|
|
71
|
+
if (json !== undefined) {
|
|
72
|
+
childrenJSON.push(json);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
var object = {
|
|
76
|
+
type: this._currentElement.type,
|
|
77
|
+
props: props,
|
|
78
|
+
children: childrenJSON.length ? childrenJSON : null
|
|
79
|
+
};
|
|
80
|
+
Object.defineProperty(object, '$$typeof', {
|
|
81
|
+
value: Symbol['for']('react.test.json')
|
|
82
|
+
});
|
|
83
|
+
return object;
|
|
84
|
+
};
|
|
85
|
+
_assign(ReactTestComponent.prototype, ReactMultiChild.Mixin);
|
|
86
|
+
|
|
87
|
+
// =============================================================================
|
|
88
|
+
|
|
89
|
+
var ReactTestTextComponent = function (element) {
|
|
90
|
+
this._currentElement = element;
|
|
91
|
+
};
|
|
92
|
+
ReactTestTextComponent.prototype.mountComponent = function () {};
|
|
93
|
+
ReactTestTextComponent.prototype.receiveComponent = function (nextElement) {
|
|
94
|
+
this._currentElement = nextElement;
|
|
95
|
+
};
|
|
96
|
+
ReactTestTextComponent.prototype.getHostNode = function () {};
|
|
97
|
+
ReactTestTextComponent.prototype.unmountComponent = function () {};
|
|
98
|
+
ReactTestTextComponent.prototype.toJSON = function () {
|
|
99
|
+
return this._currentElement;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// =============================================================================
|
|
103
|
+
|
|
104
|
+
var ReactTestEmptyComponent = function (element) {
|
|
105
|
+
this._currentElement = null;
|
|
106
|
+
};
|
|
107
|
+
ReactTestEmptyComponent.prototype.mountComponent = function () {};
|
|
108
|
+
ReactTestEmptyComponent.prototype.receiveComponent = function () {};
|
|
109
|
+
ReactTestEmptyComponent.prototype.getHostNode = function () {};
|
|
110
|
+
ReactTestEmptyComponent.prototype.unmountComponent = function () {};
|
|
111
|
+
ReactTestEmptyComponent.prototype.toJSON = function () {};
|
|
112
|
+
|
|
113
|
+
// =============================================================================
|
|
114
|
+
|
|
115
|
+
ReactUpdates.injection.injectReconcileTransaction(ReactTestReconcileTransaction);
|
|
116
|
+
ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
|
|
117
|
+
|
|
118
|
+
ReactHostComponent.injection.injectGenericComponentClass(ReactTestComponent);
|
|
119
|
+
ReactHostComponent.injection.injectTextComponentClass(ReactTestTextComponent);
|
|
120
|
+
ReactEmptyComponent.injection.injectEmptyComponentFactory(function () {
|
|
121
|
+
return new ReactTestEmptyComponent();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
var ReactTestRenderer = {
|
|
125
|
+
create: ReactTestMount.render,
|
|
126
|
+
|
|
127
|
+
/* eslint-disable camelcase */
|
|
128
|
+
unstable_batchedUpdates: ReactUpdates.batchedUpdates,
|
|
129
|
+
unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/* eslint-enable camelcase */
|
|
133
|
+
module.exports = ReactTestRenderer;
|
package/lib/ReactTestUtils.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant'),
|
|
15
|
+
_assign = require('object-assign');
|
|
15
16
|
|
|
16
17
|
var EventConstants = require('./EventConstants');
|
|
17
18
|
var EventPluginHub = require('./EventPluginHub');
|
|
@@ -25,6 +26,8 @@ var ReactElement = require('./ReactElement');
|
|
|
25
26
|
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
26
27
|
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
27
28
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
29
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
30
|
+
var ReactReconciler = require('./ReactReconciler');
|
|
28
31
|
var ReactUpdates = require('./ReactUpdates');
|
|
29
32
|
var SyntheticEvent = require('./SyntheticEvent');
|
|
30
33
|
|
|
@@ -146,7 +149,7 @@ var ReactTestUtils = {
|
|
|
146
149
|
if (!inst) {
|
|
147
150
|
return [];
|
|
148
151
|
}
|
|
149
|
-
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') :
|
|
152
|
+
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : _prodInvariant('10') : void 0;
|
|
150
153
|
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
|
|
151
154
|
},
|
|
152
155
|
|
|
@@ -166,7 +169,7 @@ var ReactTestUtils = {
|
|
|
166
169
|
var classList = className.split(/\s+/);
|
|
167
170
|
|
|
168
171
|
if (!Array.isArray(classNames)) {
|
|
169
|
-
!(classNames !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a
|
|
172
|
+
!(classNames !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'TestUtils.scryRenderedDOMComponentsWithClass expects a className as a second argument.') : _prodInvariant('11') : void 0;
|
|
170
173
|
classNames = classNames.split(/\s+/);
|
|
171
174
|
}
|
|
172
175
|
return classNames.every(function (name) {
|
|
@@ -328,7 +331,7 @@ NoopInternalComponent.prototype = {
|
|
|
328
331
|
this._currentElement = element;
|
|
329
332
|
},
|
|
330
333
|
|
|
331
|
-
|
|
334
|
+
getHostNode: function () {
|
|
332
335
|
return undefined;
|
|
333
336
|
},
|
|
334
337
|
|
|
@@ -340,7 +343,11 @@ NoopInternalComponent.prototype = {
|
|
|
340
343
|
};
|
|
341
344
|
|
|
342
345
|
var ShallowComponentWrapper = function (element) {
|
|
346
|
+
// TODO: Consolidate with instantiateReactComponent
|
|
343
347
|
this._debugID = nextDebugID++;
|
|
348
|
+
var displayName = element.type.displayName || element.type.name || 'Unknown';
|
|
349
|
+
ReactInstrumentation.debugTool.onSetDisplayName(this._debugID, displayName);
|
|
350
|
+
|
|
344
351
|
this.construct(element);
|
|
345
352
|
};
|
|
346
353
|
_assign(ShallowComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
|
|
@@ -358,8 +365,8 @@ ReactShallowRenderer.prototype.render = function (element, context) {
|
|
|
358
365
|
// conjunction with an inline-requires transform.
|
|
359
366
|
ReactDefaultInjection.inject();
|
|
360
367
|
|
|
361
|
-
!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.' : '') :
|
|
362
|
-
!(typeof element.type !== 'string') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactShallowRenderer render(): Shallow rendering works only with custom
|
|
368
|
+
!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.' : '') : _prodInvariant('12', typeof element === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' : '') : void 0;
|
|
369
|
+
!(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) : _prodInvariant('13', element.type) : void 0;
|
|
363
370
|
|
|
364
371
|
if (!context) {
|
|
365
372
|
context = emptyObject;
|
|
@@ -381,16 +388,16 @@ ReactShallowRenderer.prototype.getRenderOutput = function () {
|
|
|
381
388
|
|
|
382
389
|
ReactShallowRenderer.prototype.unmount = function () {
|
|
383
390
|
if (this._instance) {
|
|
384
|
-
this._instance
|
|
391
|
+
ReactReconciler.unmountComponent(this._instance, false);
|
|
385
392
|
}
|
|
386
393
|
};
|
|
387
394
|
|
|
388
395
|
ReactShallowRenderer.prototype._render = function (element, transaction, context) {
|
|
389
396
|
if (this._instance) {
|
|
390
|
-
this._instance
|
|
397
|
+
ReactReconciler.receiveComponent(this._instance, element, transaction, context);
|
|
391
398
|
} else {
|
|
392
399
|
var instance = new ShallowComponentWrapper(element);
|
|
393
|
-
|
|
400
|
+
ReactReconciler.mountComponent(instance, transaction, null, null, context);
|
|
394
401
|
this._instance = instance;
|
|
395
402
|
}
|
|
396
403
|
};
|
|
@@ -406,7 +413,7 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
406
413
|
function makeSimulator(eventType) {
|
|
407
414
|
return function (domComponentOrNode, eventData) {
|
|
408
415
|
var node;
|
|
409
|
-
!!React.isValidElement(domComponentOrNode) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'TestUtils.Simulate expects a component instance and not a ReactElement.
|
|
416
|
+
!!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.') : _prodInvariant('14') : void 0;
|
|
410
417
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
411
418
|
node = findDOMNode(domComponentOrNode);
|
|
412
419
|
} else if (domComponentOrNode.tagName) {
|
|
@@ -19,12 +19,18 @@ var ReactTransitionChildMapping = {
|
|
|
19
19
|
* simple syntactic sugar around flattenChildren().
|
|
20
20
|
*
|
|
21
21
|
* @param {*} children `this.props.children`
|
|
22
|
+
* @param {number=} selfDebugID Optional debugID of the current internal instance.
|
|
22
23
|
* @return {object} Mapping of key to child
|
|
23
24
|
*/
|
|
24
|
-
getChildMapping: function (children) {
|
|
25
|
+
getChildMapping: function (children, selfDebugID) {
|
|
25
26
|
if (!children) {
|
|
26
27
|
return children;
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
return flattenChildren(children, selfDebugID);
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
return flattenChildren(children);
|
|
29
35
|
},
|
|
30
36
|
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
var _assign = require('object-assign');
|
|
15
15
|
|
|
16
16
|
var React = require('./React');
|
|
17
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
17
18
|
var ReactTransitionChildMapping = require('./ReactTransitionChildMapping');
|
|
18
19
|
|
|
19
20
|
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
|
-
* A basis for
|
|
23
|
+
* A basis for animations. When children are declaratively added or removed,
|
|
23
24
|
* special lifecycle hooks are called.
|
|
24
25
|
* See https://facebook.github.io/react/docs/animation.html#low-level-api-reacttransitiongroup
|
|
25
26
|
*/
|
|
@@ -40,6 +41,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
40
41
|
|
|
41
42
|
getInitialState: function () {
|
|
42
43
|
return {
|
|
44
|
+
// TODO: can we get useful debug information to show at this point?
|
|
43
45
|
children: ReactTransitionChildMapping.getChildMapping(this.props.children)
|
|
44
46
|
};
|
|
45
47
|
},
|
|
@@ -60,7 +62,12 @@ var ReactTransitionGroup = React.createClass({
|
|
|
60
62
|
},
|
|
61
63
|
|
|
62
64
|
componentWillReceiveProps: function (nextProps) {
|
|
63
|
-
var nextChildMapping
|
|
65
|
+
var nextChildMapping;
|
|
66
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
67
|
+
nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children, ReactInstanceMap.get(this)._debugID);
|
|
68
|
+
} else {
|
|
69
|
+
nextChildMapping = ReactTransitionChildMapping.getChildMapping(nextProps.children);
|
|
70
|
+
}
|
|
64
71
|
var prevChildMapping = this.state.children;
|
|
65
72
|
|
|
66
73
|
this.setState({
|
|
@@ -116,7 +123,12 @@ var ReactTransitionGroup = React.createClass({
|
|
|
116
123
|
|
|
117
124
|
delete this.currentlyTransitioningKeys[key];
|
|
118
125
|
|
|
119
|
-
var currentChildMapping
|
|
126
|
+
var currentChildMapping;
|
|
127
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
128
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children, ReactInstanceMap.get(this)._debugID);
|
|
129
|
+
} else {
|
|
130
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
131
|
+
}
|
|
120
132
|
|
|
121
133
|
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
|
|
122
134
|
// This was removed before it had fully appeared. Remove it.
|
|
@@ -144,7 +156,12 @@ var ReactTransitionGroup = React.createClass({
|
|
|
144
156
|
|
|
145
157
|
delete this.currentlyTransitioningKeys[key];
|
|
146
158
|
|
|
147
|
-
var currentChildMapping
|
|
159
|
+
var currentChildMapping;
|
|
160
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
161
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children, ReactInstanceMap.get(this)._debugID);
|
|
162
|
+
} else {
|
|
163
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
164
|
+
}
|
|
148
165
|
|
|
149
166
|
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
|
|
150
167
|
// This was removed before it had fully entered. Remove it.
|
|
@@ -175,7 +192,12 @@ var ReactTransitionGroup = React.createClass({
|
|
|
175
192
|
|
|
176
193
|
delete this.currentlyTransitioningKeys[key];
|
|
177
194
|
|
|
178
|
-
var currentChildMapping
|
|
195
|
+
var currentChildMapping;
|
|
196
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
197
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children, ReactInstanceMap.get(this)._debugID);
|
|
198
|
+
} else {
|
|
199
|
+
currentChildMapping = ReactTransitionChildMapping.getChildMapping(this.props.children);
|
|
200
|
+
}
|
|
179
201
|
|
|
180
202
|
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
|
|
181
203
|
// This entered again before it fully left. Add it again.
|
|
@@ -204,7 +226,19 @@ var ReactTransitionGroup = React.createClass({
|
|
|
204
226
|
childrenToRender.push(React.cloneElement(this.props.childFactory(child), { ref: key, key: key }));
|
|
205
227
|
}
|
|
206
228
|
}
|
|
207
|
-
|
|
229
|
+
|
|
230
|
+
// Do not forward ReactTransitionGroup props to primitive DOM nodes
|
|
231
|
+
var props = _assign({}, this.props);
|
|
232
|
+
delete props.transitionLeave;
|
|
233
|
+
delete props.transitionName;
|
|
234
|
+
delete props.transitionAppear;
|
|
235
|
+
delete props.transitionEnter;
|
|
236
|
+
delete props.childFactory;
|
|
237
|
+
delete props.transitionLeaveTimeout;
|
|
238
|
+
delete props.transitionEnterTimeout;
|
|
239
|
+
delete props.component;
|
|
240
|
+
|
|
241
|
+
return React.createElement(this.props.component, props, childrenToRender);
|
|
208
242
|
}
|
|
209
243
|
});
|
|
210
244
|
|
package/lib/ReactUpdateQueue.js
CHANGED
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var ReactCurrentOwner = require('./ReactCurrentOwner');
|
|
15
17
|
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
18
|
+
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
16
19
|
var ReactUpdates = require('./ReactUpdates');
|
|
17
20
|
|
|
18
21
|
var invariant = require('fbjs/lib/invariant');
|
|
@@ -189,6 +192,11 @@ var ReactUpdateQueue = {
|
|
|
189
192
|
* @internal
|
|
190
193
|
*/
|
|
191
194
|
enqueueSetState: function (publicInstance, partialState) {
|
|
195
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
196
|
+
ReactInstrumentation.debugTool.onSetState();
|
|
197
|
+
process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : void 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
192
200
|
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
|
|
193
201
|
|
|
194
202
|
if (!internalInstance) {
|
|
@@ -207,7 +215,7 @@ var ReactUpdateQueue = {
|
|
|
207
215
|
},
|
|
208
216
|
|
|
209
217
|
validateCallback: function (callback, callerName) {
|
|
210
|
-
!(!callback || typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): Expected the last optional `callback` argument to be a
|
|
218
|
+
!(!callback || typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.', callerName, formatUnexpectedArgument(callback)) : _prodInvariant('122', callerName, formatUnexpectedArgument(callback)) : void 0;
|
|
211
219
|
}
|
|
212
220
|
|
|
213
221
|
};
|