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
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
'use strict';
|
|
14
14
|
|
|
15
|
-
var ReactCompositeComponent = require(
|
|
16
|
-
var ReactEmptyComponent = require(
|
|
17
|
-
var ReactNativeComponent = require(
|
|
15
|
+
var ReactCompositeComponent = require('./ReactCompositeComponent');
|
|
16
|
+
var ReactEmptyComponent = require('./ReactEmptyComponent');
|
|
17
|
+
var ReactNativeComponent = require('./ReactNativeComponent');
|
|
18
18
|
|
|
19
|
-
var assign = require(
|
|
20
|
-
var invariant = require(
|
|
21
|
-
var warning = require(
|
|
19
|
+
var assign = require('./Object.assign');
|
|
20
|
+
var invariant = require('fbjs/lib/invariant');
|
|
21
|
+
var warning = require('fbjs/lib/warning');
|
|
22
22
|
|
|
23
23
|
// To avoid a cyclic dependency, we create the final class in this module
|
|
24
24
|
var ReactCompositeComponentWrapper = function () {};
|
|
@@ -26,6 +26,16 @@ assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin,
|
|
|
26
26
|
_instantiateReactComponent: instantiateReactComponent
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
function getDeclarationErrorAddendum(owner) {
|
|
30
|
+
if (owner) {
|
|
31
|
+
var name = owner.getName();
|
|
32
|
+
if (name) {
|
|
33
|
+
return ' Check the render method of `' + name + '`.';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
/**
|
|
30
40
|
* Check if the type reference is a known internal type. I.e. not a user
|
|
31
41
|
* provided composite type.
|
|
@@ -41,11 +51,10 @@ function isInternalComponentType(type) {
|
|
|
41
51
|
* Given a ReactNode, create an instance that will actually be mounted.
|
|
42
52
|
*
|
|
43
53
|
* @param {ReactNode} node
|
|
44
|
-
* @param {*} parentCompositeType The composite type that resolved this.
|
|
45
54
|
* @return {object} A new instance of the element's constructor.
|
|
46
55
|
* @protected
|
|
47
56
|
*/
|
|
48
|
-
function instantiateReactComponent(node
|
|
57
|
+
function instantiateReactComponent(node) {
|
|
49
58
|
var instance;
|
|
50
59
|
|
|
51
60
|
if (node === null || node === false) {
|
|
@@ -54,16 +63,11 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
54
63
|
|
|
55
64
|
if (typeof node === 'object') {
|
|
56
65
|
var element = node;
|
|
57
|
-
|
|
58
|
-
'production' !== process.env.NODE_ENV ? warning(element && (typeof element.type === 'function' || typeof element.type === 'string'), 'Only functions or strings can be mounted as React components.') : null;
|
|
59
|
-
}
|
|
66
|
+
!(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
|
|
60
67
|
|
|
61
68
|
// Special case string values
|
|
62
|
-
if (
|
|
63
|
-
// Avoid recursion if the wrapper renders itself.
|
|
69
|
+
if (typeof element.type === 'string') {
|
|
64
70
|
instance = ReactNativeComponent.createInternalComponent(element);
|
|
65
|
-
// All native components are currently wrapped in a composite so we're
|
|
66
|
-
// safe to assume that this is what we should instantiate.
|
|
67
71
|
} else if (isInternalComponentType(element.type)) {
|
|
68
72
|
// This is temporarily available for custom components that are not string
|
|
69
73
|
// represenations. I.e. ART. Once those are updated to use the string
|
|
@@ -75,11 +79,11 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
75
79
|
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
76
80
|
instance = ReactNativeComponent.createInstanceForText(node);
|
|
77
81
|
} else {
|
|
78
|
-
|
|
82
|
+
!false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
if (
|
|
82
|
-
|
|
85
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
86
|
+
process.env.NODE_ENV !== 'production' ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined;
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
// Sets up the instance. This can probably just move into the constructor now.
|
|
@@ -91,14 +95,14 @@ function instantiateReactComponent(node, parentCompositeType) {
|
|
|
91
95
|
instance._mountIndex = 0;
|
|
92
96
|
instance._mountImage = null;
|
|
93
97
|
|
|
94
|
-
if (
|
|
98
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
95
99
|
instance._isOwnerNecessary = false;
|
|
96
100
|
instance._warnedAboutRefsInRender = false;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
// Internal instances should fully constructed at this point, so they should
|
|
100
104
|
// not get any new fields added to them at this point.
|
|
101
|
-
if (
|
|
105
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
102
106
|
if (Object.preventExtensions) {
|
|
103
107
|
Object.preventExtensions(instance);
|
|
104
108
|
}
|
package/lib/isEventSupported.js
CHANGED
|
@@ -33,7 +33,8 @@ var supportedInputTypes = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
function isTextInputElement(elem) {
|
|
36
|
-
|
|
36
|
+
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
37
|
+
return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
module.exports = isTextInputElement;
|
package/lib/joinClasses.js
CHANGED
package/lib/onlyChild.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
var ReactElement = require(
|
|
13
|
+
var ReactElement = require('./ReactElement');
|
|
14
14
|
|
|
15
|
-
var invariant = require(
|
|
15
|
+
var invariant = require('fbjs/lib/invariant');
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Returns the first child in a collection of children and verifies that there
|
|
@@ -26,7 +26,7 @@ var invariant = require("./invariant");
|
|
|
26
26
|
* structure.
|
|
27
27
|
*/
|
|
28
28
|
function onlyChild(children) {
|
|
29
|
-
|
|
29
|
+
!ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined;
|
|
30
30
|
return children;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-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 reactComponentExpect
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
var ReactInstanceMap = require('./ReactInstanceMap');
|
|
16
|
+
var ReactTestUtils = require('./ReactTestUtils');
|
|
17
|
+
|
|
18
|
+
var assign = require('./Object.assign');
|
|
19
|
+
var invariant = require('fbjs/lib/invariant');
|
|
20
|
+
|
|
21
|
+
function reactComponentExpect(instance) {
|
|
22
|
+
if (instance instanceof reactComponentExpectInternal) {
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!(this instanceof reactComponentExpect)) {
|
|
27
|
+
return new reactComponentExpect(instance);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
expect(instance).not.toBeNull();
|
|
31
|
+
|
|
32
|
+
!ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : invariant(false) : undefined;
|
|
33
|
+
var internalInstance = ReactInstanceMap.get(instance);
|
|
34
|
+
|
|
35
|
+
expect(typeof internalInstance).toBe('object');
|
|
36
|
+
expect(typeof internalInstance.constructor).toBe('function');
|
|
37
|
+
expect(ReactTestUtils.isElement(internalInstance)).toBe(false);
|
|
38
|
+
|
|
39
|
+
return new reactComponentExpectInternal(internalInstance);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function reactComponentExpectInternal(internalInstance) {
|
|
43
|
+
this._instance = internalInstance;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
assign(reactComponentExpectInternal.prototype, {
|
|
47
|
+
// Getters -------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @instance: Retrieves the backing instance.
|
|
51
|
+
*/
|
|
52
|
+
instance: function () {
|
|
53
|
+
return this._instance.getPublicInstance();
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* There are two types of components in the world.
|
|
58
|
+
* - A component created via React.createClass() - Has a single child
|
|
59
|
+
* subComponent - the return value from the .render() function. This
|
|
60
|
+
* function @subComponent expects that this._instance is component created
|
|
61
|
+
* with React.createClass().
|
|
62
|
+
* - A primitive DOM component - which has many renderedChildren, each of
|
|
63
|
+
* which may have a name that is unique with respect to its siblings. This
|
|
64
|
+
* method will fail if this._instance is a primitive component.
|
|
65
|
+
*
|
|
66
|
+
* TL;DR: An instance may have a subComponent (this._renderedComponent) or
|
|
67
|
+
* renderedChildren, but never both. Neither will actually show up until you
|
|
68
|
+
* render the component (simply instantiating is not enough).
|
|
69
|
+
*/
|
|
70
|
+
expectRenderedChild: function () {
|
|
71
|
+
this.toBeCompositeComponent();
|
|
72
|
+
var child = this._instance._renderedComponent;
|
|
73
|
+
// TODO: Hide ReactEmptyComponent instances here?
|
|
74
|
+
return new reactComponentExpectInternal(child);
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The nth child of a DOMish component instance that is not falsy.
|
|
79
|
+
*/
|
|
80
|
+
expectRenderedChildAt: function (childIndex) {
|
|
81
|
+
// Currently only dom components have arrays of children, but that will
|
|
82
|
+
// change soon.
|
|
83
|
+
this.toBeDOMComponent();
|
|
84
|
+
var renderedChildren = this._instance._renderedChildren || {};
|
|
85
|
+
for (var name in renderedChildren) {
|
|
86
|
+
if (!renderedChildren.hasOwnProperty(name)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (renderedChildren[name]) {
|
|
90
|
+
if (renderedChildren[name]._mountIndex === childIndex) {
|
|
91
|
+
return new reactComponentExpectInternal(renderedChildren[name]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
throw new Error('Child:' + childIndex + ' is not found');
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
toBeDOMComponentWithChildCount: function (count) {
|
|
99
|
+
this.toBeDOMComponent();
|
|
100
|
+
var renderedChildren = this._instance._renderedChildren;
|
|
101
|
+
expect(renderedChildren).toBeTruthy();
|
|
102
|
+
expect(Object.keys(renderedChildren).length).toBe(count);
|
|
103
|
+
return this;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
toBeDOMComponentWithNoChildren: function () {
|
|
107
|
+
this.toBeDOMComponent();
|
|
108
|
+
expect(this._instance._renderedChildren).toBeFalsy();
|
|
109
|
+
return this;
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
// Matchers ------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
toBeComponentOfType: function (constructor) {
|
|
115
|
+
expect(this._instance._currentElement.type === constructor).toBe(true);
|
|
116
|
+
return this;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A component that is created with React.createClass. Just duck typing
|
|
121
|
+
* here.
|
|
122
|
+
*/
|
|
123
|
+
toBeCompositeComponent: function () {
|
|
124
|
+
expect(typeof this.instance() === 'object' && typeof this.instance().render === 'function').toBe(true);
|
|
125
|
+
return this;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
toBeCompositeComponentWithType: function (constructor) {
|
|
129
|
+
this.toBeCompositeComponent();
|
|
130
|
+
expect(this._instance._currentElement.type === constructor).toBe(true);
|
|
131
|
+
return this;
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
toBeTextComponentWithValue: function (val) {
|
|
135
|
+
var elementType = typeof this._instance._currentElement;
|
|
136
|
+
expect(elementType === 'string' || elementType === 'number').toBe(true);
|
|
137
|
+
expect(this._instance._stringText).toBe(val);
|
|
138
|
+
return this;
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
toBePresent: function () {
|
|
142
|
+
expect(this.instance()).toBeTruthy();
|
|
143
|
+
return this;
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A terminal type of component representing some virtual dom node. Just duck
|
|
148
|
+
* typing here.
|
|
149
|
+
*/
|
|
150
|
+
toBeDOMComponent: function () {
|
|
151
|
+
expect(ReactTestUtils.isDOMComponent(this.instance())).toBe(true);
|
|
152
|
+
return this;
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated
|
|
157
|
+
* @see toBeComponentOfType
|
|
158
|
+
*/
|
|
159
|
+
toBeDOMComponentWithTag: function (tag) {
|
|
160
|
+
this.toBeDOMComponent();
|
|
161
|
+
expect(this.instance().tagName).toBe(tag.toUpperCase());
|
|
162
|
+
return this;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Check that internal state values are equal to a state of expected values.
|
|
167
|
+
*/
|
|
168
|
+
scalarStateEqual: function (stateNameToExpectedValue) {
|
|
169
|
+
expect(this.instance()).toBeTruthy();
|
|
170
|
+
for (var stateName in stateNameToExpectedValue) {
|
|
171
|
+
if (!stateNameToExpectedValue.hasOwnProperty(stateName)) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
expect(this.instance().state[stateName]).toEqual(stateNameToExpectedValue[stateName]);
|
|
175
|
+
}
|
|
176
|
+
return this;
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Check a set of props are equal to a set of expected values - only works
|
|
181
|
+
* with scalars.
|
|
182
|
+
*/
|
|
183
|
+
scalarPropsEqual: function (propNameToExpectedValue) {
|
|
184
|
+
expect(this.instance()).toBeTruthy();
|
|
185
|
+
for (var propName in propNameToExpectedValue) {
|
|
186
|
+
if (!propNameToExpectedValue.hasOwnProperty(propName)) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
expect(this.instance().props[propName]).toEqual(propNameToExpectedValue[propName]);
|
|
190
|
+
}
|
|
191
|
+
return this;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Check a set of props are equal to a set of expected values - only works
|
|
196
|
+
* with scalars.
|
|
197
|
+
*/
|
|
198
|
+
scalarContextEqual: function (contextNameToExpectedValue) {
|
|
199
|
+
expect(this.instance()).toBeTruthy();
|
|
200
|
+
for (var contextName in contextNameToExpectedValue) {
|
|
201
|
+
if (!contextNameToExpectedValue.hasOwnProperty(contextName)) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
expect(this.instance().context[contextName]).toEqual(contextNameToExpectedValue[contextName]);
|
|
205
|
+
}
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
module.exports = reactComponentExpect;
|
package/lib/setInnerHTML.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
var ExecutionEnvironment = require(
|
|
16
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
17
17
|
|
|
18
18
|
var WHITESPACE_TEST = /^[ \r\n\t\f]/;
|
|
19
19
|
var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
|
|
@@ -70,7 +70,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|
|
70
70
|
// in hopes that this is preserved even if "\uFEFF" is transformed to
|
|
71
71
|
// the actual Unicode character (by Babel, for example).
|
|
72
72
|
// https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
|
|
73
|
-
node.innerHTML = String.fromCharCode(
|
|
73
|
+
node.innerHTML = String.fromCharCode(0xFEFF) + html;
|
|
74
74
|
|
|
75
75
|
// deleteData leaves an empty `TextNode` which offsets the index of all
|
|
76
76
|
// children. Definitely want to avoid this.
|
package/lib/setTextContent.js
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
-
var ExecutionEnvironment = require(
|
|
15
|
-
var escapeTextContentForBrowser = require(
|
|
16
|
-
var setInnerHTML = require(
|
|
14
|
+
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
|
+
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
|
|
16
|
+
var setInnerHTML = require('./setInnerHTML');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Set the textContent property of a node, ensuring that whitespace is preserved
|
package/lib/shallowCompare.js
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013-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 sliceChildren
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var ReactFragment = require('./ReactFragment');
|
|
15
|
+
|
|
16
|
+
var flattenChildren = require('./flattenChildren');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Slice children that are typically specified as `props.children`. This version
|
|
20
|
+
* of slice children ignores empty child components.
|
|
21
|
+
*
|
|
22
|
+
* @param {*} children The children set to filter.
|
|
23
|
+
* @param {number} start The first zero-based index to include in the subset.
|
|
24
|
+
* @param {?number} end The non-inclusive last index of the subset.
|
|
25
|
+
* @return {object} mirrored array with mapped children
|
|
26
|
+
*/
|
|
27
|
+
function sliceChildren(children, start, end) {
|
|
28
|
+
if (children == null) {
|
|
29
|
+
return children;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var slicedChildren = {};
|
|
33
|
+
var flattenedMap = flattenChildren(children);
|
|
34
|
+
var ii = 0;
|
|
35
|
+
for (var key in flattenedMap) {
|
|
36
|
+
if (!flattenedMap.hasOwnProperty(key)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
var child = flattenedMap[key];
|
|
40
|
+
if (ii >= start) {
|
|
41
|
+
slicedChildren[key] = child;
|
|
42
|
+
}
|
|
43
|
+
ii++;
|
|
44
|
+
if (end != null && ii >= end) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return ReactFragment.create(slicedChildren);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = sliceChildren;
|