react-test-renderer 15.5.0 → 15.5.4

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 (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,123 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var ReactDOMSelection = require('./ReactDOMSelection');
14
+
15
+ var containsNode = require('fbjs/lib/containsNode');
16
+ var focusNode = require('fbjs/lib/focusNode');
17
+ var getActiveElement = require('fbjs/lib/getActiveElement');
18
+
19
+ function isInDocument(node) {
20
+ return containsNode(document.documentElement, node);
21
+ }
22
+
23
+ /**
24
+ * @ReactInputSelection: React input selection module. Based on Selection.js,
25
+ * but modified to be suitable for react and has a couple of bug fixes (doesn't
26
+ * assume buttons have range selections allowed).
27
+ * Input selection module for React.
28
+ */
29
+ var ReactInputSelection = {
30
+
31
+ hasSelectionCapabilities: function (elem) {
32
+ var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
33
+ return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
34
+ },
35
+
36
+ getSelectionInformation: function () {
37
+ var focusedElem = getActiveElement();
38
+ return {
39
+ focusedElem: focusedElem,
40
+ selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null
41
+ };
42
+ },
43
+
44
+ /**
45
+ * @restoreSelection: If any selection information was potentially lost,
46
+ * restore it. This is useful when performing operations that could remove dom
47
+ * nodes and place them back in, resulting in focus being lost.
48
+ */
49
+ restoreSelection: function (priorSelectionInformation) {
50
+ var curFocusedElem = getActiveElement();
51
+ var priorFocusedElem = priorSelectionInformation.focusedElem;
52
+ var priorSelectionRange = priorSelectionInformation.selectionRange;
53
+ if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
54
+ if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
55
+ ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange);
56
+ }
57
+ focusNode(priorFocusedElem);
58
+ }
59
+ },
60
+
61
+ /**
62
+ * @getSelection: Gets the selection bounds of a focused textarea, input or
63
+ * contentEditable node.
64
+ * -@input: Look up selection bounds of this input
65
+ * -@return {start: selectionStart, end: selectionEnd}
66
+ */
67
+ getSelection: function (input) {
68
+ var selection;
69
+
70
+ if ('selectionStart' in input) {
71
+ // Modern browser with input or textarea.
72
+ selection = {
73
+ start: input.selectionStart,
74
+ end: input.selectionEnd
75
+ };
76
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
77
+ // IE8 input.
78
+ var range = document.selection.createRange();
79
+ // There can only be one selection per document in IE, so it must
80
+ // be in our element.
81
+ if (range.parentElement() === input) {
82
+ selection = {
83
+ start: -range.moveStart('character', -input.value.length),
84
+ end: -range.moveEnd('character', -input.value.length)
85
+ };
86
+ }
87
+ } else {
88
+ // Content editable or old IE textarea.
89
+ selection = ReactDOMSelection.getOffsets(input);
90
+ }
91
+
92
+ return selection || { start: 0, end: 0 };
93
+ },
94
+
95
+ /**
96
+ * @setSelection: Sets the selection bounds of a textarea or input and focuses
97
+ * the input.
98
+ * -@input Set selection bounds of this input or textarea
99
+ * -@offsets Object of same form that is returned from get*
100
+ */
101
+ setSelection: function (input, offsets) {
102
+ var start = offsets.start;
103
+ var end = offsets.end;
104
+ if (end === undefined) {
105
+ end = start;
106
+ }
107
+
108
+ if ('selectionStart' in input) {
109
+ input.selectionStart = start;
110
+ input.selectionEnd = Math.min(end, input.value.length);
111
+ } else if (document.selection && input.nodeName && input.nodeName.toLowerCase() === 'input') {
112
+ var range = input.createTextRange();
113
+ range.collapse(true);
114
+ range.moveStart('character', start);
115
+ range.moveEnd('character', end - start);
116
+ range.select();
117
+ } else {
118
+ ReactDOMSelection.setOffsets(input, offsets);
119
+ }
120
+ }
121
+ };
122
+
123
+ module.exports = ReactInputSelection;
@@ -0,0 +1,47 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ /**
14
+ * `ReactInstanceMap` maintains a mapping from a public facing stateful
15
+ * instance (key) and the internal representation (value). This allows public
16
+ * methods to accept the user facing instance as an argument and map them back
17
+ * to internal methods.
18
+ */
19
+
20
+ // TODO: Replace this with ES6: var ReactInstanceMap = new Map();
21
+
22
+ var ReactInstanceMap = {
23
+
24
+ /**
25
+ * This API should be called `delete` but we'd have to make sure to always
26
+ * transform these to strings for IE support. When this transform is fully
27
+ * supported we can rename it.
28
+ */
29
+ remove: function (key) {
30
+ key._reactInternalInstance = undefined;
31
+ },
32
+
33
+ get: function (key) {
34
+ return key._reactInternalInstance;
35
+ },
36
+
37
+ has: function (key) {
38
+ return key._reactInternalInstance !== undefined;
39
+ },
40
+
41
+ set: function (key, value) {
42
+ key._reactInternalInstance = value;
43
+ }
44
+
45
+ };
46
+
47
+ module.exports = ReactInstanceMap;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2016-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
+ *
10
+ */
11
+
12
+ 'use strict';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright 2016-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
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ // Trust the developer to only use ReactInstrumentation with a __DEV__ check
15
+
16
+ var debugTool = null;
17
+
18
+ if (process.env.NODE_ENV !== 'production') {
19
+ var ReactDebugTool = require('./ReactDebugTool');
20
+ debugTool = ReactDebugTool;
21
+ }
22
+
23
+ module.exports = { debugTool: debugTool };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright 2016-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
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var warning = require('fbjs/lib/warning');
15
+
16
+ if (process.env.NODE_ENV !== 'production') {
17
+ var processingChildContext = false;
18
+
19
+ var warnInvalidSetState = function () {
20
+ process.env.NODE_ENV !== 'production' ? warning(!processingChildContext, 'setState(...): Cannot call setState() inside getChildContext()') : void 0;
21
+ };
22
+ }
23
+
24
+ var ReactInvalidSetStateWarningHook = {
25
+ onBeginProcessingChildContext: function () {
26
+ processingChildContext = true;
27
+ },
28
+ onEndProcessingChildContext: function () {
29
+ processingChildContext = false;
30
+ },
31
+ onSetState: function () {
32
+ warnInvalidSetState();
33
+ }
34
+ };
35
+
36
+ module.exports = ReactInvalidSetStateWarningHook;
@@ -0,0 +1,49 @@
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
+ */
10
+
11
+ 'use strict';
12
+
13
+ var adler32 = require('./adler32');
14
+
15
+ var TAG_END = /\/?>/;
16
+ var COMMENT_START = /^<\!\-\-/;
17
+
18
+ var ReactMarkupChecksum = {
19
+ CHECKSUM_ATTR_NAME: 'data-react-checksum',
20
+
21
+ /**
22
+ * @param {string} markup Markup string
23
+ * @return {string} Markup string with checksum attribute attached
24
+ */
25
+ addChecksumToMarkup: function (markup) {
26
+ var checksum = adler32(markup);
27
+
28
+ // Add checksum (handle both parent tags, comments and self-closing tags)
29
+ if (COMMENT_START.test(markup)) {
30
+ return markup;
31
+ } else {
32
+ return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
33
+ }
34
+ },
35
+
36
+ /**
37
+ * @param {string} markup to use
38
+ * @param {DOMElement} element root React element
39
+ * @returns {boolean} whether or not the markup is the same
40
+ */
41
+ canReuseMarkup: function (markup, element) {
42
+ var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
43
+ existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
44
+ var markupChecksum = adler32(markup);
45
+ return markupChecksum === existingChecksum;
46
+ }
47
+ };
48
+
49
+ module.exports = ReactMarkupChecksum;