react 0.14.0-beta1 → 0.14.0-beta2
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 +5 -2
- package/dist/JSXTransformer.js +588 -227
- package/dist/react-with-addons.js +3118 -2707
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +3713 -3317
- package/dist/react.min.js +6 -5
- package/lib/AutoFocusUtils.js +3 -3
- 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 +12 -12
- package/lib/DOMChildrenOperations.js +10 -6
- package/lib/DOMProperty.js +8 -8
- package/lib/DOMPropertyOperations.js +9 -9
- package/lib/Danger.js +14 -14
- package/lib/DefaultEventPluginOrder.js +2 -2
- package/lib/EnterLeaveEventPlugin.js +5 -5
- package/lib/EventConstants.js +23 -1
- package/lib/EventPluginHub.js +11 -11
- package/lib/EventPluginRegistry.js +8 -8
- package/lib/EventPluginUtils.js +11 -11
- package/lib/EventPropagators.js +7 -7
- package/lib/FallbackCompositionState.js +3 -3
- package/lib/HTMLDOMPropertyConfig.js +4 -2
- 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 +2 -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 +12 -11
- package/lib/ReactChildReconciler.js +25 -18
- package/lib/ReactChildren.js +6 -6
- package/lib/ReactClass.js +42 -42
- package/lib/ReactComponent.js +13 -13
- package/lib/ReactComponentBrowserEnvironment.js +2 -2
- package/lib/ReactComponentEnvironment.js +2 -2
- package/lib/ReactComponentWithPureRenderMixin.js +1 -1
- package/lib/ReactCompositeComponent.js +38 -38
- package/lib/ReactDOM.js +72 -159
- package/lib/ReactDOMComponent.js +104 -60
- package/lib/ReactDOMFactories.js +177 -0
- package/lib/ReactDOMIDOperations.js +10 -24
- package/lib/ReactDOMInput.js +8 -8
- package/lib/ReactDOMOption.js +7 -7
- package/lib/ReactDOMSelect.js +8 -8
- package/lib/ReactDOMSelection.js +3 -3
- package/lib/ReactDOMServer.js +2 -2
- package/lib/ReactDOMTextComponent.js +11 -11
- package/lib/ReactDOMTextarea.js +11 -11
- package/lib/ReactDefaultBatchingStrategy.js +4 -4
- package/lib/ReactDefaultInjection.js +24 -24
- package/lib/ReactDefaultPerf.js +7 -7
- package/lib/ReactDefaultPerfAnalysis.js +6 -9
- package/lib/ReactElement.js +4 -4
- package/lib/ReactElementValidator.js +21 -21
- package/lib/ReactEmptyComponent.js +4 -4
- package/lib/ReactEventEmitterMixin.js +1 -1
- package/lib/ReactEventListener.js +19 -14
- package/lib/ReactFragment.js +11 -11
- package/lib/ReactInjection.js +11 -11
- package/lib/ReactInputSelection.js +4 -4
- package/lib/ReactInstanceHandles.js +10 -11
- package/lib/ReactIsomorphic.js +11 -11
- package/lib/ReactLink.js +1 -1
- package/lib/ReactMarkupChecksum.js +6 -2
- package/lib/ReactMount.js +68 -48
- package/lib/ReactMultiChild.js +83 -22
- 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 +34 -8
- package/lib/ReactReconcileTransaction.js +6 -6
- package/lib/ReactReconciler.js +12 -12
- package/lib/ReactRef.js +1 -1
- package/lib/ReactServerBatchingStrategy.js +5 -5
- package/lib/ReactServerRendering.js +12 -12
- package/lib/ReactServerRenderingTransaction.js +5 -5
- package/lib/ReactTestUtils.js +26 -27
- package/lib/ReactTransitionChildMapping.js +2 -2
- package/lib/ReactTransitionEvents.js +1 -1
- package/lib/ReactTransitionGroup.js +5 -6
- package/lib/ReactUpdateQueue.js +17 -17
- package/lib/ReactUpdates.js +14 -14
- package/lib/ReactWithAddons.js +14 -14
- 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 +9 -9
- package/lib/SimpleEventPlugin.js +201 -25
- package/lib/SyntheticClipboardEvent.js +1 -1
- package/lib/SyntheticCompositionEvent.js +1 -1
- package/lib/SyntheticDragEvent.js +1 -1
- package/lib/SyntheticEvent.js +3 -3
- 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 +6 -6
- 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 +4 -4
- package/lib/findDOMNode.js +9 -9
- package/lib/flattenChildren.js +4 -4
- package/lib/getEventKey.js +1 -1
- package/lib/getTestDocument.js +28 -0
- package/lib/getTextContentAccessor.js +1 -1
- package/lib/instantiateReactComponent.js +12 -12
- package/lib/isEventSupported.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 +1 -1
- package/lib/setTextContent.js +3 -3
- package/lib/shallowCompare.js +1 -1
- package/lib/sliceChildren.js +51 -0
- package/lib/traverseAllChildren.js +14 -13
- 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 -1
- 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/emptyObject.js +0 -20
- 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/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 -57
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var keyMirror = require(
|
|
14
|
+
var keyMirror = require('fbjs/lib/keyMirror');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* When a component's children are updated, a series of update configuration
|
|
@@ -25,6 +25,7 @@ var ReactMultiChildUpdateTypes = keyMirror({
|
|
|
25
25
|
INSERT_MARKUP: null,
|
|
26
26
|
MOVE_EXISTING: null,
|
|
27
27
|
REMOVE_NODE: null,
|
|
28
|
+
SET_MARKUP: null,
|
|
28
29
|
TEXT_CONTENT: null
|
|
29
30
|
});
|
|
30
31
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var assign = require(
|
|
15
|
-
var invariant = require(
|
|
14
|
+
var assign = require('./Object.assign');
|
|
15
|
+
var invariant = require('fbjs/lib/invariant');
|
|
16
16
|
|
|
17
17
|
var autoGenerateWrapperClass = null;
|
|
18
18
|
var genericComponentClass = null;
|
|
@@ -63,7 +63,7 @@ function getComponentClassForElement(element) {
|
|
|
63
63
|
* @return {function} The internal class constructor function.
|
|
64
64
|
*/
|
|
65
65
|
function createInternalComponent(element) {
|
|
66
|
-
!genericComponentClass ?
|
|
66
|
+
!genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
|
|
67
67
|
return new genericComponentClass(element.type, element.props);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var warning = require(
|
|
14
|
+
var warning = require('fbjs/lib/warning');
|
|
15
15
|
|
|
16
16
|
function warnTDZ(publicInstance, callerName) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
package/lib/ReactOwner.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var invariant = require(
|
|
14
|
+
var invariant = require('fbjs/lib/invariant');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* ReactOwners are capable of storing references to owned components.
|
|
@@ -64,7 +64,7 @@ var ReactOwner = {
|
|
|
64
64
|
* @internal
|
|
65
65
|
*/
|
|
66
66
|
addComponentAsRefTo: function (component, ref, owner) {
|
|
67
|
-
!ReactOwner.isValidOwner(owner) ?
|
|
67
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to add a ref to a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
68
68
|
owner.attachRef(ref, component);
|
|
69
69
|
},
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ var ReactOwner = {
|
|
|
78
78
|
* @internal
|
|
79
79
|
*/
|
|
80
80
|
removeComponentAsRefFrom: function (component, ref, owner) {
|
|
81
|
-
!ReactOwner.isValidOwner(owner) ?
|
|
81
|
+
!ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This ' + 'usually means that you\'re trying to remove a ref from a component that ' + 'doesn\'t have an owner (that is, was not created inside of another ' + 'component\'s `render` method). Try rendering this component inside of ' + 'a new top-level component which will hold the ref.') : invariant(false) : undefined;
|
|
82
82
|
// Check that `component` is still the current ref because we do not want to
|
|
83
83
|
// detach the ref if another component stole it.
|
|
84
84
|
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
|
package/lib/ReactPerf.js
CHANGED
|
@@ -35,7 +35,7 @@ var ReactPerf = {
|
|
|
35
35
|
* @param {object<string>} methodNames
|
|
36
36
|
*/
|
|
37
37
|
measureMethods: function (object, objectName, methodNames) {
|
|
38
|
-
if (
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
39
|
for (var key in methodNames) {
|
|
40
40
|
if (!methodNames.hasOwnProperty(key)) {
|
|
41
41
|
continue;
|
|
@@ -54,7 +54,7 @@ var ReactPerf = {
|
|
|
54
54
|
* @return {function}
|
|
55
55
|
*/
|
|
56
56
|
measure: function (objName, fnName, func) {
|
|
57
|
-
if (
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
58
|
var measuredFunc = null;
|
|
59
59
|
var wrapper = function () {
|
|
60
60
|
if (ReactPerf.enableMeasure) {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var assign = require(
|
|
15
|
-
var emptyFunction = require(
|
|
16
|
-
var joinClasses = require(
|
|
14
|
+
var assign = require('./Object.assign');
|
|
15
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
16
|
+
var joinClasses = require('./joinClasses');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates a transfer strategy that will merge prop values using the supplied
|
package/lib/ReactPropTypes.js
CHANGED
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ReactElement = require(
|
|
15
|
-
var ReactFragment = require(
|
|
16
|
-
var ReactPropTypeLocationNames = require(
|
|
14
|
+
var ReactElement = require('./ReactElement');
|
|
15
|
+
var ReactFragment = require('./ReactFragment');
|
|
16
|
+
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
|
|
17
17
|
|
|
18
|
-
var emptyFunction = require(
|
|
18
|
+
var emptyFunction = require('fbjs/lib/emptyFunction');
|
|
19
|
+
var getIteratorFn = require('./getIteratorFn');
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Collection of methods that allow declaration and validation of props that are
|
|
@@ -283,12 +284,37 @@ function isNode(propValue) {
|
|
|
283
284
|
if (propValue === null || ReactElement.isValidElement(propValue)) {
|
|
284
285
|
return true;
|
|
285
286
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
|
|
288
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
289
|
+
if (iteratorFn) {
|
|
290
|
+
var iterator = iteratorFn.call(propValue);
|
|
291
|
+
var step;
|
|
292
|
+
if (iteratorFn !== propValue.entries) {
|
|
293
|
+
while (!(step = iterator.next()).done) {
|
|
294
|
+
if (!isNode(step.value)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
300
|
+
while (!(step = iterator.next()).done) {
|
|
301
|
+
var entry = step.value;
|
|
302
|
+
if (entry) {
|
|
303
|
+
if (!isNode(entry[1])) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
propValue = ReactFragment.extractIfFragment(propValue);
|
|
311
|
+
for (var k in propValue) {
|
|
312
|
+
if (!isNode(propValue[k])) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
290
315
|
}
|
|
291
316
|
}
|
|
317
|
+
|
|
292
318
|
return true;
|
|
293
319
|
default:
|
|
294
320
|
return false;
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var CallbackQueue = require(
|
|
16
|
-
var PooledClass = require(
|
|
17
|
-
var ReactBrowserEventEmitter = require(
|
|
18
|
-
var ReactInputSelection = require(
|
|
19
|
-
var Transaction = require(
|
|
15
|
+
var CallbackQueue = require('./CallbackQueue');
|
|
16
|
+
var PooledClass = require('./PooledClass');
|
|
17
|
+
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
|
|
18
|
+
var ReactInputSelection = require('./ReactInputSelection');
|
|
19
|
+
var Transaction = require('./Transaction');
|
|
20
20
|
|
|
21
|
-
var assign = require(
|
|
21
|
+
var assign = require('./Object.assign');
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Ensures that, when possible, the selection range (currently selected text
|
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
|
|
@@ -66,18 +66,18 @@ var ReactReconciler = {
|
|
|
66
66
|
if (nextElement === prevElement && nextElement._owner != null
|
|
67
67
|
// TODO: Shouldn't we need to do this: `&& context === internalInstance._context`
|
|
68
68
|
) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
// Since elements are immutable after the owner is rendered,
|
|
70
|
+
// we can do a cheap identity compare here to determine if this is a
|
|
71
|
+
// superfluous reconcile. It's possible for state to be mutable but such
|
|
72
|
+
// change should trigger an update of the owner which would recreate
|
|
73
|
+
// the element. We explicitly check for the existence of an owner since
|
|
74
|
+
// it's possible for an element created outside a composite to be
|
|
75
|
+
// deeply mutated and reused.
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// TODO: Bailing out early is just a perf optimization right?
|
|
78
|
+
// TODO: Removing the return statement should affect correctness?
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
81
|
|
|
82
82
|
var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
|
|
83
83
|
|
package/lib/ReactRef.js
CHANGED
|
@@ -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
|
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 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(
|
|
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 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');
|
|
32
32
|
|
|
33
33
|
var topLevelTypes = EventConstants.topLevelTypes;
|
|
34
34
|
|
|
@@ -141,7 +141,7 @@ var ReactTestUtils = {
|
|
|
141
141
|
if (!inst) {
|
|
142
142
|
return [];
|
|
143
143
|
}
|
|
144
|
-
!ReactTestUtils.isCompositeComponent(inst) ?
|
|
144
|
+
!ReactTestUtils.isCompositeComponent(inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findAllInRenderedTree(...): instance must be a composite component') : invariant(false) : undefined;
|
|
145
145
|
return findAllInRenderedTreeInternal(ReactInstanceMap.get(inst), test);
|
|
146
146
|
},
|
|
147
147
|
|
|
@@ -181,7 +181,7 @@ var ReactTestUtils = {
|
|
|
181
181
|
*/
|
|
182
182
|
scryRenderedDOMComponentsWithTag: function (root, tagName) {
|
|
183
183
|
return ReactTestUtils.findAllInRenderedTree(root, function (inst) {
|
|
184
|
-
return ReactTestUtils.isDOMComponent(inst) && inst.tagName === tagName.toUpperCase();
|
|
184
|
+
return ReactTestUtils.isDOMComponent(inst) && inst.tagName.toUpperCase() === tagName.toUpperCase();
|
|
185
185
|
});
|
|
186
186
|
},
|
|
187
187
|
|
|
@@ -337,7 +337,9 @@ ReactShallowRenderer.prototype.unmount = function () {
|
|
|
337
337
|
};
|
|
338
338
|
|
|
339
339
|
ReactShallowRenderer.prototype._render = function (element, transaction, context) {
|
|
340
|
-
if (
|
|
340
|
+
if (this._instance) {
|
|
341
|
+
this._instance.receiveComponent(element, transaction, context);
|
|
342
|
+
} else {
|
|
341
343
|
var rootID = ReactInstanceHandles.createReactRootID();
|
|
342
344
|
var instance = new ShallowComponentWrapper(element.type);
|
|
343
345
|
instance.construct(element);
|
|
@@ -345,8 +347,6 @@ ReactShallowRenderer.prototype._render = function (element, transaction, context
|
|
|
345
347
|
instance.mountComponent(rootID, transaction, context);
|
|
346
348
|
|
|
347
349
|
this._instance = instance;
|
|
348
|
-
} else {
|
|
349
|
-
this._instance.receiveComponent(element, transaction, context);
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
|
|
@@ -438,15 +438,14 @@ function makeNativeSimulator(eventType) {
|
|
|
438
438
|
assign(fakeNativeEvent, nativeEventData);
|
|
439
439
|
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
|
|
440
440
|
ReactTestUtils.simulateNativeEventOnDOMComponent(eventType, domComponentOrNode, fakeNativeEvent);
|
|
441
|
-
} else if (
|
|
441
|
+
} else if (domComponentOrNode.tagName) {
|
|
442
442
|
// Will allow on actual dom nodes.
|
|
443
443
|
ReactTestUtils.simulateNativeEventOnNode(eventType, domComponentOrNode, fakeNativeEvent);
|
|
444
444
|
}
|
|
445
445
|
};
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
|
|
449
|
-
for (eventType in topLevelTypes) {
|
|
448
|
+
Object.keys(topLevelTypes).forEach(function (eventType) {
|
|
450
449
|
// Event type is stored as 'topClick' - we transform that to 'click'
|
|
451
450
|
var convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType;
|
|
452
451
|
/**
|
|
@@ -454,6 +453,6 @@ for (eventType in topLevelTypes) {
|
|
|
454
453
|
* @param {?Event} nativeEventData Fake native event to use in SyntheticEvent.
|
|
455
454
|
*/
|
|
456
455
|
ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator(eventType);
|
|
457
|
-
}
|
|
456
|
+
});
|
|
458
457
|
|
|
459
458
|
module.exports = ReactTestUtils;
|