react 15.3.1-rc.2 → 15.4.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.
Files changed (190) hide show
  1. package/dist/react-with-addons.js +3961 -21387
  2. package/dist/react-with-addons.min.js +3 -6
  3. package/dist/react.js +2701 -19464
  4. package/dist/react.min.js +2 -6
  5. package/lib/LinkedStateMixin.js +1 -2
  6. package/lib/PooledClass.js +3 -0
  7. package/lib/ReactAddonsDOMDependencies.js +36 -0
  8. package/lib/ReactAddonsDOMDependenciesUMDShim.js +32 -0
  9. package/lib/ReactCSSTransitionGroup.js +60 -42
  10. package/lib/ReactCSSTransitionGroupChild.js +2 -2
  11. package/lib/ReactClass.js +38 -53
  12. package/lib/ReactComponentTreeHook.js +84 -100
  13. package/lib/{DOMNamespaces.js → ReactComponentTreeHookUMDShim.js} +5 -7
  14. package/lib/ReactCurrentOwner.js +1 -1
  15. package/lib/{renderSubtreeIntoContainer.js → ReactCurrentOwnerUMDShim.js} +6 -4
  16. package/lib/ReactElement.js +6 -29
  17. package/lib/ReactElementSymbol.js +20 -0
  18. package/lib/{ReactDOMComponentFlags.js → ReactElementType.js} +4 -9
  19. package/lib/ReactElementValidator.js +1 -2
  20. package/lib/ReactPropTypeLocationNames.js +1 -0
  21. package/lib/ReactPropTypeLocations.js +2 -11
  22. package/lib/ReactPropTypes.js +30 -13
  23. package/lib/ReactPropTypesSecret.js +1 -0
  24. package/lib/ReactTransitionEvents.js +1 -1
  25. package/lib/ReactTransitionGroup.js +145 -141
  26. package/lib/ReactUMDEntry.js +11 -5
  27. package/lib/{ReactDOMFeatureFlags.js → ReactUMDShim.js} +4 -6
  28. package/lib/ReactVersion.js +1 -1
  29. package/lib/ReactWithAddons.js +15 -2
  30. package/lib/ReactWithAddonsUMDEntry.js +11 -5
  31. package/lib/canDefineProperty.js +2 -0
  32. package/lib/onlyChild.js +1 -1
  33. package/lib/traverseAllChildren.js +11 -2
  34. package/lib/update.js +6 -7
  35. package/package.json +2 -2
  36. package/lib/AutoFocusUtils.js +0 -24
  37. package/lib/BeforeInputEventPlugin.js +0 -388
  38. package/lib/CSSProperty.js +0 -148
  39. package/lib/CSSPropertyOperations.js +0 -205
  40. package/lib/CallbackQueue.js +0 -106
  41. package/lib/ChangeEventPlugin.js +0 -325
  42. package/lib/DOMChildrenOperations.js +0 -194
  43. package/lib/DOMLazyTree.js +0 -118
  44. package/lib/DOMProperty.js +0 -206
  45. package/lib/DOMPropertyOperations.js +0 -221
  46. package/lib/Danger.js +0 -48
  47. package/lib/DefaultEventPluginOrder.js +0 -27
  48. package/lib/DisabledInputUtils.js +0 -50
  49. package/lib/EnterLeaveEventPlugin.js +0 -105
  50. package/lib/EventConstants.js +0 -97
  51. package/lib/EventPluginHub.js +0 -251
  52. package/lib/EventPluginRegistry.js +0 -247
  53. package/lib/EventPluginUtils.js +0 -229
  54. package/lib/EventPropagators.js +0 -137
  55. package/lib/FallbackCompositionState.js +0 -95
  56. package/lib/HTMLDOMPropertyConfig.js +0 -209
  57. package/lib/LinkedValueUtils.js +0 -136
  58. package/lib/NativeMethodsMixin.js +0 -167
  59. package/lib/ReactBrowserEventEmitter.js +0 -317
  60. package/lib/ReactChildReconciler.js +0 -154
  61. package/lib/ReactChildrenMutationWarningHook.js +0 -54
  62. package/lib/ReactComponentBrowserEnvironment.js +0 -30
  63. package/lib/ReactComponentEnvironment.js +0 -45
  64. package/lib/ReactComponentTreeTestUtils.js +0 -87
  65. package/lib/ReactCompositeComponent.js +0 -920
  66. package/lib/ReactDOM.js +0 -110
  67. package/lib/ReactDOMButton.js +0 -24
  68. package/lib/ReactDOMComponent.js +0 -1005
  69. package/lib/ReactDOMComponentTree.js +0 -188
  70. package/lib/ReactDOMContainerInfo.js +0 -33
  71. package/lib/ReactDOMEmptyComponent.js +0 -60
  72. package/lib/ReactDOMFiber.js +0 -78
  73. package/lib/ReactDOMIDOperations.js +0 -34
  74. package/lib/ReactDOMInput.js +0 -269
  75. package/lib/ReactDOMNullInputValuePropHook.js +0 -43
  76. package/lib/ReactDOMOption.js +0 -123
  77. package/lib/ReactDOMSelect.js +0 -201
  78. package/lib/ReactDOMSelection.js +0 -212
  79. package/lib/ReactDOMServer.js +0 -26
  80. package/lib/ReactDOMTextComponent.js +0 -164
  81. package/lib/ReactDOMTextarea.js +0 -155
  82. package/lib/ReactDOMTreeTraversal.js +0 -136
  83. package/lib/ReactDOMUnknownPropertyHook.js +0 -112
  84. package/lib/ReactDebugTool.js +0 -307
  85. package/lib/ReactDefaultBatchingStrategy.js +0 -68
  86. package/lib/ReactDefaultInjection.js +0 -84
  87. package/lib/ReactEmptyComponent.js +0 -30
  88. package/lib/ReactErrorUtils.js +0 -76
  89. package/lib/ReactEventEmitterMixin.js +0 -33
  90. package/lib/ReactEventListener.js +0 -157
  91. package/lib/ReactFeatureFlags.js +0 -22
  92. package/lib/ReactHostComponent.js +0 -76
  93. package/lib/ReactHostOperationHistoryHook.js +0 -37
  94. package/lib/ReactInjection.js +0 -36
  95. package/lib/ReactInputSelection.js +0 -124
  96. package/lib/ReactInstanceHandles.js +0 -302
  97. package/lib/ReactInstanceMap.js +0 -48
  98. package/lib/ReactInstrumentation.js +0 -21
  99. package/lib/ReactInvalidSetStateWarningHook.js +0 -36
  100. package/lib/ReactMarkupChecksum.js +0 -50
  101. package/lib/ReactMount.js +0 -495
  102. package/lib/ReactMultiChild.js +0 -451
  103. package/lib/ReactMultiChildUpdateTypes.js +0 -32
  104. package/lib/ReactNative.js +0 -71
  105. package/lib/ReactNativeAttributePayload.js +0 -371
  106. package/lib/ReactNativeBaseComponent.js +0 -198
  107. package/lib/ReactNativeBridgeEventPlugin.js +0 -60
  108. package/lib/ReactNativeComponentEnvironment.js +0 -31
  109. package/lib/ReactNativeComponentTree.js +0 -68
  110. package/lib/ReactNativeContainerInfo.js +0 -21
  111. package/lib/ReactNativeDOMIDOperations.js +0 -79
  112. package/lib/ReactNativeDefaultInjection.js +0 -101
  113. package/lib/ReactNativeEventEmitter.js +0 -191
  114. package/lib/ReactNativeEventPluginOrder.js +0 -16
  115. package/lib/ReactNativeGlobalResponderHandler.js +0 -25
  116. package/lib/ReactNativeMount.js +0 -193
  117. package/lib/ReactNativePropRegistry.js +0 -52
  118. package/lib/ReactNativeReconcileTransaction.js +0 -116
  119. package/lib/ReactNativeTagHandles.js +0 -56
  120. package/lib/ReactNativeTextComponent.js +0 -71
  121. package/lib/ReactNativeTreeTraversal.js +0 -127
  122. package/lib/ReactNodeTypes.js +0 -40
  123. package/lib/ReactNoop.js +0 -173
  124. package/lib/ReactOwner.js +0 -94
  125. package/lib/ReactPerf.js +0 -494
  126. package/lib/ReactReconcileTransaction.js +0 -178
  127. package/lib/ReactReconciler.js +0 -168
  128. package/lib/ReactRef.js +0 -80
  129. package/lib/ReactServerBatchingStrategy.js +0 -22
  130. package/lib/ReactServerRendering.js +0 -90
  131. package/lib/ReactServerRenderingTransaction.js +0 -90
  132. package/lib/ReactServerUpdateQueue.js +0 -141
  133. package/lib/ReactSimpleEmptyComponent.js +0 -37
  134. package/lib/ReactTestMount.js +0 -123
  135. package/lib/ReactTestReconcileTransaction.js +0 -108
  136. package/lib/ReactTestRenderer.js +0 -144
  137. package/lib/ReactTestUtils.js +0 -518
  138. package/lib/ReactUpdateQueue.js +0 -226
  139. package/lib/ReactUpdates.js +0 -251
  140. package/lib/ResponderEventPlugin.js +0 -510
  141. package/lib/ResponderSyntheticEvent.js +0 -39
  142. package/lib/ResponderTouchHistoryStore.js +0 -184
  143. package/lib/SVGDOMPropertyConfig.js +0 -302
  144. package/lib/SelectEventPlugin.js +0 -196
  145. package/lib/SimpleEventPlugin.js +0 -635
  146. package/lib/SyntheticAnimationEvent.js +0 -39
  147. package/lib/SyntheticClipboardEvent.js +0 -38
  148. package/lib/SyntheticCompositionEvent.js +0 -36
  149. package/lib/SyntheticDragEvent.js +0 -36
  150. package/lib/SyntheticEvent.js +0 -267
  151. package/lib/SyntheticFocusEvent.js +0 -36
  152. package/lib/SyntheticInputEvent.js +0 -37
  153. package/lib/SyntheticKeyboardEvent.js +0 -84
  154. package/lib/SyntheticMouseEvent.js +0 -72
  155. package/lib/SyntheticTouchEvent.js +0 -45
  156. package/lib/SyntheticTransitionEvent.js +0 -39
  157. package/lib/SyntheticUIEvent.js +0 -59
  158. package/lib/SyntheticWheelEvent.js +0 -54
  159. package/lib/TapEventPlugin.js +0 -110
  160. package/lib/TouchHistoryMath.js +0 -99
  161. package/lib/Transaction.js +0 -233
  162. package/lib/ViewportMetrics.js +0 -27
  163. package/lib/accumulate.js +0 -46
  164. package/lib/accumulateInto.js +0 -58
  165. package/lib/adler32.js +0 -44
  166. package/lib/createMicrosoftUnsafeLocalFunction.js +0 -32
  167. package/lib/createReactNativeComponentClass.js +0 -42
  168. package/lib/dangerousStyleValue.js +0 -79
  169. package/lib/escapeTextContentForBrowser.js +0 -122
  170. package/lib/findDOMNode.js +0 -60
  171. package/lib/findNodeHandle.js +0 -91
  172. package/lib/forEachAccumulated.js +0 -31
  173. package/lib/getEventCharCode.js +0 -50
  174. package/lib/getEventKey.js +0 -102
  175. package/lib/getEventModifierState.js +0 -43
  176. package/lib/getEventTarget.js +0 -35
  177. package/lib/getHostComponentFromComposite.js +0 -30
  178. package/lib/getNodeForCharacterOffset.js +0 -74
  179. package/lib/getTestDocument.js +0 -21
  180. package/lib/getTextContentAccessor.js +0 -33
  181. package/lib/getVendorPrefixedEventName.js +0 -101
  182. package/lib/instantiateReactComponent.js +0 -119
  183. package/lib/isEventSupported.js +0 -60
  184. package/lib/isTextInputElement.js +0 -51
  185. package/lib/quoteAttributeValueForBrowser.js +0 -26
  186. package/lib/reactComponentExpect.js +0 -217
  187. package/lib/setInnerHTML.js +0 -98
  188. package/lib/setTextContent.js +0 -48
  189. package/lib/shouldUpdateReactComponent.js +0 -42
  190. package/lib/validateDOMNesting.js +0 -369
@@ -1,119 +0,0 @@
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 instantiateReactComponent
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant'),
15
- _assign = require('object-assign');
16
-
17
- var ReactCompositeComponent = require('./ReactCompositeComponent');
18
- var ReactEmptyComponent = require('./ReactEmptyComponent');
19
- var ReactHostComponent = require('./ReactHostComponent');
20
-
21
- var invariant = require('fbjs/lib/invariant');
22
- var warning = require('fbjs/lib/warning');
23
-
24
- // To avoid a cyclic dependency, we create the final class in this module
25
- var ReactCompositeComponentWrapper = function (element) {
26
- this.construct(element);
27
- };
28
- _assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
29
- _instantiateReactComponent: instantiateReactComponent
30
- });
31
-
32
- function getDeclarationErrorAddendum(owner) {
33
- if (owner) {
34
- var name = owner.getName();
35
- if (name) {
36
- return ' Check the render method of `' + name + '`.';
37
- }
38
- }
39
- return '';
40
- }
41
-
42
- /**
43
- * Check if the type reference is a known internal type. I.e. not a user
44
- * provided composite type.
45
- *
46
- * @param {function} type
47
- * @return {boolean} Returns true if this is a valid internal type.
48
- */
49
- function isInternalComponentType(type) {
50
- return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
51
- }
52
-
53
- var nextDebugID = 1;
54
-
55
- /**
56
- * Given a ReactNode, create an instance that will actually be mounted.
57
- *
58
- * @param {ReactNode} node
59
- * @param {boolean} shouldHaveDebugID
60
- * @return {object} A new instance of the element's constructor.
61
- * @protected
62
- */
63
- function instantiateReactComponent(node, shouldHaveDebugID) {
64
- var instance;
65
-
66
- if (node === null || node === false) {
67
- instance = ReactEmptyComponent.create(instantiateReactComponent);
68
- } else if (typeof node === 'object') {
69
- var element = node;
70
- !(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)) : _prodInvariant('130', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : void 0;
71
-
72
- // Special case string values
73
- if (typeof element.type === 'string') {
74
- instance = ReactHostComponent.createInternalComponent(element);
75
- } else if (isInternalComponentType(element.type)) {
76
- // This is temporarily available for custom components that are not string
77
- // representations. I.e. ART. Once those are updated to use the string
78
- // representation, we can drop this code path.
79
- instance = new element.type(element);
80
-
81
- // We renamed this. Allow the old name for compat. :(
82
- if (!instance.getHostNode) {
83
- instance.getHostNode = instance.getNativeNode;
84
- }
85
- } else {
86
- instance = new ReactCompositeComponentWrapper(element);
87
- }
88
- } else if (typeof node === 'string' || typeof node === 'number') {
89
- instance = ReactHostComponent.createInstanceForText(node);
90
- } else {
91
- !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
92
- }
93
-
94
- if (process.env.NODE_ENV !== 'production') {
95
- process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
96
- }
97
-
98
- // These two fields are used by the DOM and ART diffing algorithms
99
- // respectively. Instead of using expandos on components, we should be
100
- // storing the state needed by the diffing algorithms elsewhere.
101
- instance._mountIndex = 0;
102
- instance._mountImage = null;
103
-
104
- if (process.env.NODE_ENV !== 'production') {
105
- instance._debugID = shouldHaveDebugID ? nextDebugID++ : 0;
106
- }
107
-
108
- // Internal instances should fully constructed at this point, so they should
109
- // not get any new fields added to them at this point.
110
- if (process.env.NODE_ENV !== 'production') {
111
- if (Object.preventExtensions) {
112
- Object.preventExtensions(instance);
113
- }
114
- }
115
-
116
- return instance;
117
- }
118
-
119
- module.exports = instantiateReactComponent;
@@ -1,60 +0,0 @@
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 isEventSupported
10
- */
11
-
12
- 'use strict';
13
-
14
- var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
-
16
- var useHasFeature;
17
- if (ExecutionEnvironment.canUseDOM) {
18
- useHasFeature = document.implementation && document.implementation.hasFeature &&
19
- // always returns true in newer browsers as per the standard.
20
- // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
21
- document.implementation.hasFeature('', '') !== true;
22
- }
23
-
24
- /**
25
- * Checks if an event is supported in the current execution environment.
26
- *
27
- * NOTE: This will not work correctly for non-generic events such as `change`,
28
- * `reset`, `load`, `error`, and `select`.
29
- *
30
- * Borrows from Modernizr.
31
- *
32
- * @param {string} eventNameSuffix Event name, e.g. "click".
33
- * @param {?boolean} capture Check if the capture phase is supported.
34
- * @return {boolean} True if the event is supported.
35
- * @internal
36
- * @license Modernizr 3.0.0pre (Custom Build) | MIT
37
- */
38
- function isEventSupported(eventNameSuffix, capture) {
39
- if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
40
- return false;
41
- }
42
-
43
- var eventName = 'on' + eventNameSuffix;
44
- var isSupported = eventName in document;
45
-
46
- if (!isSupported) {
47
- var element = document.createElement('div');
48
- element.setAttribute(eventName, 'return;');
49
- isSupported = typeof element[eventName] === 'function';
50
- }
51
-
52
- if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
53
- // This is the only way to test support for the `wheel` event in IE9+.
54
- isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
55
- }
56
-
57
- return isSupported;
58
- }
59
-
60
- module.exports = isEventSupported;
@@ -1,51 +0,0 @@
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 isTextInputElement
10
- *
11
- */
12
-
13
- 'use strict';
14
-
15
- /**
16
- * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
17
- */
18
-
19
- var supportedInputTypes = {
20
- 'color': true,
21
- 'date': true,
22
- 'datetime': true,
23
- 'datetime-local': true,
24
- 'email': true,
25
- 'month': true,
26
- 'number': true,
27
- 'password': true,
28
- 'range': true,
29
- 'search': true,
30
- 'tel': true,
31
- 'text': true,
32
- 'time': true,
33
- 'url': true,
34
- 'week': true
35
- };
36
-
37
- function isTextInputElement(elem) {
38
- var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
39
-
40
- if (nodeName === 'input') {
41
- return !!supportedInputTypes[elem.type];
42
- }
43
-
44
- if (nodeName === 'textarea') {
45
- return true;
46
- }
47
-
48
- return false;
49
- }
50
-
51
- module.exports = isTextInputElement;
@@ -1,26 +0,0 @@
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 quoteAttributeValueForBrowser
10
- */
11
-
12
- 'use strict';
13
-
14
- var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
15
-
16
- /**
17
- * Escapes attribute value to prevent scripting attacks.
18
- *
19
- * @param {*} value Value to escape.
20
- * @return {string} An escaped string.
21
- */
22
- function quoteAttributeValueForBrowser(value) {
23
- return '"' + escapeTextContentForBrowser(value) + '"';
24
- }
25
-
26
- module.exports = quoteAttributeValueForBrowser;
@@ -1,217 +0,0 @@
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 reactComponentExpect
10
- */
11
-
12
- 'use strict';
13
-
14
- var _prodInvariant = require('./reactProdInvariant'),
15
- _assign = require('object-assign');
16
-
17
- var ReactInstanceMap = require('./ReactInstanceMap');
18
- var ReactTestUtils = require('./ReactTestUtils');
19
-
20
- var invariant = require('fbjs/lib/invariant');
21
-
22
- function reactComponentExpect(instance) {
23
- if (instance instanceof reactComponentExpectInternal) {
24
- return instance;
25
- }
26
-
27
- if (!(this instanceof reactComponentExpect)) {
28
- return new reactComponentExpect(instance);
29
- }
30
-
31
- expect(instance).not.toBeNull();
32
- expect(instance).not.toBeUndefined();
33
-
34
- !ReactTestUtils.isCompositeComponent(instance) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'reactComponentExpect(...): instance must be a composite component') : _prodInvariant('15') : void 0;
35
- var internalInstance = ReactInstanceMap.get(instance);
36
-
37
- expect(typeof internalInstance).toBe('object');
38
- expect(typeof internalInstance.constructor).toBe('function');
39
- expect(ReactTestUtils.isElement(internalInstance)).toBe(false);
40
-
41
- return new reactComponentExpectInternal(internalInstance);
42
- }
43
-
44
- function reactComponentExpectInternal(internalInstance) {
45
- this._instance = internalInstance;
46
- }
47
-
48
- _assign(reactComponentExpectInternal.prototype, {
49
- // Getters -------------------------------------------------------------------
50
-
51
- /**
52
- * @instance: Retrieves the backing instance.
53
- */
54
- instance: function () {
55
- return this._instance.getPublicInstance();
56
- },
57
-
58
- /**
59
- * There are two types of components in the world.
60
- * - A component created via React.createClass() - Has a single child
61
- * subComponent - the return value from the .render() function. This
62
- * function @subComponent expects that this._instance is component created
63
- * with React.createClass().
64
- * - A primitive DOM component - which has many renderedChildren, each of
65
- * which may have a name that is unique with respect to its siblings. This
66
- * method will fail if this._instance is a primitive component.
67
- *
68
- * TL;DR: An instance may have a subComponent (this._renderedComponent) or
69
- * renderedChildren, but never both. Neither will actually show up until you
70
- * render the component (simply instantiating is not enough).
71
- */
72
- expectRenderedChild: function () {
73
- this.toBeCompositeComponent();
74
- var child = this._instance._renderedComponent;
75
- // TODO: Hide ReactEmptyComponent instances here?
76
- return new reactComponentExpectInternal(child);
77
- },
78
-
79
- /**
80
- * The nth child of a DOMish component instance that is not falsy.
81
- */
82
- expectRenderedChildAt: function (childIndex) {
83
- // Currently only dom components have arrays of children, but that will
84
- // change soon.
85
- this.toBeDOMComponent();
86
- var renderedChildren = this._instance._renderedChildren || {};
87
- for (var name in renderedChildren) {
88
- if (!renderedChildren.hasOwnProperty(name)) {
89
- continue;
90
- }
91
- if (renderedChildren[name]) {
92
- if (renderedChildren[name]._mountIndex === childIndex) {
93
- return new reactComponentExpectInternal(renderedChildren[name]);
94
- }
95
- }
96
- }
97
- throw new Error('Child:' + childIndex + ' is not found');
98
- },
99
-
100
- toBeDOMComponentWithChildCount: function (count) {
101
- this.toBeDOMComponent();
102
- var renderedChildren = this._instance._renderedChildren;
103
- expect(renderedChildren).toBeTruthy();
104
- expect(Object.keys(renderedChildren).length).toBe(count);
105
- return this;
106
- },
107
-
108
- toBeDOMComponentWithNoChildren: function () {
109
- this.toBeDOMComponent();
110
- expect(this._instance._renderedChildren).toBeFalsy();
111
- return this;
112
- },
113
-
114
- // Matchers ------------------------------------------------------------------
115
-
116
- toBeComponentOfType: function (constructor) {
117
- expect(this._instance._currentElement.type === constructor).toBe(true);
118
- return this;
119
- },
120
-
121
- /**
122
- * A component that is created with React.createClass. Just duck typing
123
- * here.
124
- */
125
- toBeCompositeComponent: function () {
126
- expect(typeof this.instance() === 'object' && typeof this.instance().render === 'function').toBe(true);
127
- return this;
128
- },
129
-
130
- toBeCompositeComponentWithType: function (constructor) {
131
- this.toBeCompositeComponent();
132
- expect(this._instance._currentElement.type === constructor).toBe(true);
133
- return this;
134
- },
135
-
136
- toBeTextComponentWithValue: function (val) {
137
- var elementType = typeof this._instance._currentElement;
138
- expect(elementType === 'string' || elementType === 'number').toBe(true);
139
- expect(this._instance._stringText).toBe(val);
140
- return this;
141
- },
142
-
143
- toBeEmptyComponent: function () {
144
- var element = this._instance._currentElement;
145
- return element === null || element === false;
146
- },
147
-
148
- toBePresent: function () {
149
- expect(this.instance()).toBeTruthy();
150
- return this;
151
- },
152
-
153
- /**
154
- * A terminal type of component representing some virtual dom node. Just duck
155
- * typing here.
156
- */
157
- toBeDOMComponent: function () {
158
- expect(ReactTestUtils.isDOMComponent(this.instance())).toBe(true);
159
- return this;
160
- },
161
-
162
- /**
163
- * @deprecated
164
- * @see toBeComponentOfType
165
- */
166
- toBeDOMComponentWithTag: function (tag) {
167
- this.toBeDOMComponent();
168
- expect(this.instance().tagName).toBe(tag.toUpperCase());
169
- return this;
170
- },
171
-
172
- /**
173
- * Check that internal state values are equal to a state of expected values.
174
- */
175
- scalarStateEqual: function (stateNameToExpectedValue) {
176
- expect(this.instance()).toBeTruthy();
177
- for (var stateName in stateNameToExpectedValue) {
178
- if (!stateNameToExpectedValue.hasOwnProperty(stateName)) {
179
- continue;
180
- }
181
- expect(this.instance().state[stateName]).toEqual(stateNameToExpectedValue[stateName]);
182
- }
183
- return this;
184
- },
185
-
186
- /**
187
- * Check a set of props are equal to a set of expected values - only works
188
- * with scalars.
189
- */
190
- scalarPropsEqual: function (propNameToExpectedValue) {
191
- expect(this.instance()).toBeTruthy();
192
- for (var propName in propNameToExpectedValue) {
193
- if (!propNameToExpectedValue.hasOwnProperty(propName)) {
194
- continue;
195
- }
196
- expect(this.instance().props[propName]).toEqual(propNameToExpectedValue[propName]);
197
- }
198
- return this;
199
- },
200
-
201
- /**
202
- * Check a set of props are equal to a set of expected values - only works
203
- * with scalars.
204
- */
205
- scalarContextEqual: function (contextNameToExpectedValue) {
206
- expect(this.instance()).toBeTruthy();
207
- for (var contextName in contextNameToExpectedValue) {
208
- if (!contextNameToExpectedValue.hasOwnProperty(contextName)) {
209
- continue;
210
- }
211
- expect(this.instance().context[contextName]).toEqual(contextNameToExpectedValue[contextName]);
212
- }
213
- return this;
214
- }
215
- });
216
-
217
- module.exports = reactComponentExpect;