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,183 @@
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
+
12
+ 'use strict';
13
+
14
+ var _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var EventPluginUtils = require('./EventPluginUtils');
17
+
18
+ var invariant = require('fbjs/lib/invariant');
19
+ var warning = require('fbjs/lib/warning');
20
+
21
+ var isEndish = EventPluginUtils.isEndish,
22
+ isMoveish = EventPluginUtils.isMoveish,
23
+ isStartish = EventPluginUtils.isStartish;
24
+
25
+ /**
26
+ * Tracks the position and time of each active touch by `touch.identifier`. We
27
+ * should typically only see IDs in the range of 1-20 because IDs get recycled
28
+ * when touches end and start again.
29
+ */
30
+
31
+ var MAX_TOUCH_BANK = 20;
32
+ var touchBank = [];
33
+ var touchHistory = {
34
+ touchBank: touchBank,
35
+ numberActiveTouches: 0,
36
+ // If there is only one active touch, we remember its location. This prevents
37
+ // us having to loop through all of the touches all the time in the most
38
+ // common case.
39
+ indexOfSingleActiveTouch: -1,
40
+ mostRecentTimeStamp: 0
41
+ };
42
+
43
+ function timestampForTouch(touch) {
44
+ // The legacy internal implementation provides "timeStamp", which has been
45
+ // renamed to "timestamp". Let both work for now while we iron it out
46
+ // TODO (evv): rename timeStamp to timestamp in internal code
47
+ return touch.timeStamp || touch.timestamp;
48
+ }
49
+
50
+ /**
51
+ * TODO: Instead of making gestures recompute filtered velocity, we could
52
+ * include a built in velocity computation that can be reused globally.
53
+ */
54
+ function createTouchRecord(touch) {
55
+ return {
56
+ touchActive: true,
57
+ startPageX: touch.pageX,
58
+ startPageY: touch.pageY,
59
+ startTimeStamp: timestampForTouch(touch),
60
+ currentPageX: touch.pageX,
61
+ currentPageY: touch.pageY,
62
+ currentTimeStamp: timestampForTouch(touch),
63
+ previousPageX: touch.pageX,
64
+ previousPageY: touch.pageY,
65
+ previousTimeStamp: timestampForTouch(touch)
66
+ };
67
+ }
68
+
69
+ function resetTouchRecord(touchRecord, touch) {
70
+ touchRecord.touchActive = true;
71
+ touchRecord.startPageX = touch.pageX;
72
+ touchRecord.startPageY = touch.pageY;
73
+ touchRecord.startTimeStamp = timestampForTouch(touch);
74
+ touchRecord.currentPageX = touch.pageX;
75
+ touchRecord.currentPageY = touch.pageY;
76
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
77
+ touchRecord.previousPageX = touch.pageX;
78
+ touchRecord.previousPageY = touch.pageY;
79
+ touchRecord.previousTimeStamp = timestampForTouch(touch);
80
+ }
81
+
82
+ function getTouchIdentifier(_ref) {
83
+ var identifier = _ref.identifier;
84
+
85
+ !(identifier != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Touch object is missing identifier.') : _prodInvariant('138') : void 0;
86
+ process.env.NODE_ENV !== 'production' ? warning(identifier <= MAX_TOUCH_BANK, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK) : void 0;
87
+ return identifier;
88
+ }
89
+
90
+ function recordTouchStart(touch) {
91
+ var identifier = getTouchIdentifier(touch);
92
+ var touchRecord = touchBank[identifier];
93
+ if (touchRecord) {
94
+ resetTouchRecord(touchRecord, touch);
95
+ } else {
96
+ touchBank[identifier] = createTouchRecord(touch);
97
+ }
98
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
99
+ }
100
+
101
+ function recordTouchMove(touch) {
102
+ var touchRecord = touchBank[getTouchIdentifier(touch)];
103
+ if (touchRecord) {
104
+ touchRecord.touchActive = true;
105
+ touchRecord.previousPageX = touchRecord.currentPageX;
106
+ touchRecord.previousPageY = touchRecord.currentPageY;
107
+ touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
108
+ touchRecord.currentPageX = touch.pageX;
109
+ touchRecord.currentPageY = touch.pageY;
110
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
111
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
112
+ } else {
113
+ console.error('Cannot record touch move without a touch start.\n' + 'Touch Move: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
114
+ }
115
+ }
116
+
117
+ function recordTouchEnd(touch) {
118
+ var touchRecord = touchBank[getTouchIdentifier(touch)];
119
+ if (touchRecord) {
120
+ touchRecord.touchActive = false;
121
+ touchRecord.previousPageX = touchRecord.currentPageX;
122
+ touchRecord.previousPageY = touchRecord.currentPageY;
123
+ touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
124
+ touchRecord.currentPageX = touch.pageX;
125
+ touchRecord.currentPageY = touch.pageY;
126
+ touchRecord.currentTimeStamp = timestampForTouch(touch);
127
+ touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
128
+ } else {
129
+ console.error('Cannot record touch end without a touch start.\n' + 'Touch End: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
130
+ }
131
+ }
132
+
133
+ function printTouch(touch) {
134
+ return JSON.stringify({
135
+ identifier: touch.identifier,
136
+ pageX: touch.pageX,
137
+ pageY: touch.pageY,
138
+ timestamp: timestampForTouch(touch)
139
+ });
140
+ }
141
+
142
+ function printTouchBank() {
143
+ var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
144
+ if (touchBank.length > MAX_TOUCH_BANK) {
145
+ printed += ' (original size: ' + touchBank.length + ')';
146
+ }
147
+ return printed;
148
+ }
149
+
150
+ var ResponderTouchHistoryStore = {
151
+ recordTouchTrack: function (topLevelType, nativeEvent) {
152
+ if (isMoveish(topLevelType)) {
153
+ nativeEvent.changedTouches.forEach(recordTouchMove);
154
+ } else if (isStartish(topLevelType)) {
155
+ nativeEvent.changedTouches.forEach(recordTouchStart);
156
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
157
+ if (touchHistory.numberActiveTouches === 1) {
158
+ touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
159
+ }
160
+ } else if (isEndish(topLevelType)) {
161
+ nativeEvent.changedTouches.forEach(recordTouchEnd);
162
+ touchHistory.numberActiveTouches = nativeEvent.touches.length;
163
+ if (touchHistory.numberActiveTouches === 1) {
164
+ for (var i = 0; i < touchBank.length; i++) {
165
+ var touchTrackToCheck = touchBank[i];
166
+ if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {
167
+ touchHistory.indexOfSingleActiveTouch = i;
168
+ break;
169
+ }
170
+ }
171
+ if (process.env.NODE_ENV !== 'production') {
172
+ var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
173
+ process.env.NODE_ENV !== 'production' ? warning(activeRecord != null && activeRecord.touchActive, 'Cannot find single active touch.') : void 0;
174
+ }
175
+ }
176
+ }
177
+ },
178
+
179
+
180
+ touchHistory: touchHistory
181
+ };
182
+
183
+ module.exports = ResponderTouchHistoryStore;
@@ -0,0 +1,301 @@
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 NS = {
14
+ xlink: 'http://www.w3.org/1999/xlink',
15
+ xml: 'http://www.w3.org/XML/1998/namespace'
16
+ };
17
+
18
+ // We use attributes for everything SVG so let's avoid some duplication and run
19
+ // code instead.
20
+ // The following are all specified in the HTML config already so we exclude here.
21
+ // - class (as className)
22
+ // - color
23
+ // - height
24
+ // - id
25
+ // - lang
26
+ // - max
27
+ // - media
28
+ // - method
29
+ // - min
30
+ // - name
31
+ // - style
32
+ // - target
33
+ // - type
34
+ // - width
35
+ var ATTRS = {
36
+ accentHeight: 'accent-height',
37
+ accumulate: 0,
38
+ additive: 0,
39
+ alignmentBaseline: 'alignment-baseline',
40
+ allowReorder: 'allowReorder',
41
+ alphabetic: 0,
42
+ amplitude: 0,
43
+ arabicForm: 'arabic-form',
44
+ ascent: 0,
45
+ attributeName: 'attributeName',
46
+ attributeType: 'attributeType',
47
+ autoReverse: 'autoReverse',
48
+ azimuth: 0,
49
+ baseFrequency: 'baseFrequency',
50
+ baseProfile: 'baseProfile',
51
+ baselineShift: 'baseline-shift',
52
+ bbox: 0,
53
+ begin: 0,
54
+ bias: 0,
55
+ by: 0,
56
+ calcMode: 'calcMode',
57
+ capHeight: 'cap-height',
58
+ clip: 0,
59
+ clipPath: 'clip-path',
60
+ clipRule: 'clip-rule',
61
+ clipPathUnits: 'clipPathUnits',
62
+ colorInterpolation: 'color-interpolation',
63
+ colorInterpolationFilters: 'color-interpolation-filters',
64
+ colorProfile: 'color-profile',
65
+ colorRendering: 'color-rendering',
66
+ contentScriptType: 'contentScriptType',
67
+ contentStyleType: 'contentStyleType',
68
+ cursor: 0,
69
+ cx: 0,
70
+ cy: 0,
71
+ d: 0,
72
+ decelerate: 0,
73
+ descent: 0,
74
+ diffuseConstant: 'diffuseConstant',
75
+ direction: 0,
76
+ display: 0,
77
+ divisor: 0,
78
+ dominantBaseline: 'dominant-baseline',
79
+ dur: 0,
80
+ dx: 0,
81
+ dy: 0,
82
+ edgeMode: 'edgeMode',
83
+ elevation: 0,
84
+ enableBackground: 'enable-background',
85
+ end: 0,
86
+ exponent: 0,
87
+ externalResourcesRequired: 'externalResourcesRequired',
88
+ fill: 0,
89
+ fillOpacity: 'fill-opacity',
90
+ fillRule: 'fill-rule',
91
+ filter: 0,
92
+ filterRes: 'filterRes',
93
+ filterUnits: 'filterUnits',
94
+ floodColor: 'flood-color',
95
+ floodOpacity: 'flood-opacity',
96
+ focusable: 0,
97
+ fontFamily: 'font-family',
98
+ fontSize: 'font-size',
99
+ fontSizeAdjust: 'font-size-adjust',
100
+ fontStretch: 'font-stretch',
101
+ fontStyle: 'font-style',
102
+ fontVariant: 'font-variant',
103
+ fontWeight: 'font-weight',
104
+ format: 0,
105
+ from: 0,
106
+ fx: 0,
107
+ fy: 0,
108
+ g1: 0,
109
+ g2: 0,
110
+ glyphName: 'glyph-name',
111
+ glyphOrientationHorizontal: 'glyph-orientation-horizontal',
112
+ glyphOrientationVertical: 'glyph-orientation-vertical',
113
+ glyphRef: 'glyphRef',
114
+ gradientTransform: 'gradientTransform',
115
+ gradientUnits: 'gradientUnits',
116
+ hanging: 0,
117
+ horizAdvX: 'horiz-adv-x',
118
+ horizOriginX: 'horiz-origin-x',
119
+ ideographic: 0,
120
+ imageRendering: 'image-rendering',
121
+ 'in': 0,
122
+ in2: 0,
123
+ intercept: 0,
124
+ k: 0,
125
+ k1: 0,
126
+ k2: 0,
127
+ k3: 0,
128
+ k4: 0,
129
+ kernelMatrix: 'kernelMatrix',
130
+ kernelUnitLength: 'kernelUnitLength',
131
+ kerning: 0,
132
+ keyPoints: 'keyPoints',
133
+ keySplines: 'keySplines',
134
+ keyTimes: 'keyTimes',
135
+ lengthAdjust: 'lengthAdjust',
136
+ letterSpacing: 'letter-spacing',
137
+ lightingColor: 'lighting-color',
138
+ limitingConeAngle: 'limitingConeAngle',
139
+ local: 0,
140
+ markerEnd: 'marker-end',
141
+ markerMid: 'marker-mid',
142
+ markerStart: 'marker-start',
143
+ markerHeight: 'markerHeight',
144
+ markerUnits: 'markerUnits',
145
+ markerWidth: 'markerWidth',
146
+ mask: 0,
147
+ maskContentUnits: 'maskContentUnits',
148
+ maskUnits: 'maskUnits',
149
+ mathematical: 0,
150
+ mode: 0,
151
+ numOctaves: 'numOctaves',
152
+ offset: 0,
153
+ opacity: 0,
154
+ operator: 0,
155
+ order: 0,
156
+ orient: 0,
157
+ orientation: 0,
158
+ origin: 0,
159
+ overflow: 0,
160
+ overlinePosition: 'overline-position',
161
+ overlineThickness: 'overline-thickness',
162
+ paintOrder: 'paint-order',
163
+ panose1: 'panose-1',
164
+ pathLength: 'pathLength',
165
+ patternContentUnits: 'patternContentUnits',
166
+ patternTransform: 'patternTransform',
167
+ patternUnits: 'patternUnits',
168
+ pointerEvents: 'pointer-events',
169
+ points: 0,
170
+ pointsAtX: 'pointsAtX',
171
+ pointsAtY: 'pointsAtY',
172
+ pointsAtZ: 'pointsAtZ',
173
+ preserveAlpha: 'preserveAlpha',
174
+ preserveAspectRatio: 'preserveAspectRatio',
175
+ primitiveUnits: 'primitiveUnits',
176
+ r: 0,
177
+ radius: 0,
178
+ refX: 'refX',
179
+ refY: 'refY',
180
+ renderingIntent: 'rendering-intent',
181
+ repeatCount: 'repeatCount',
182
+ repeatDur: 'repeatDur',
183
+ requiredExtensions: 'requiredExtensions',
184
+ requiredFeatures: 'requiredFeatures',
185
+ restart: 0,
186
+ result: 0,
187
+ rotate: 0,
188
+ rx: 0,
189
+ ry: 0,
190
+ scale: 0,
191
+ seed: 0,
192
+ shapeRendering: 'shape-rendering',
193
+ slope: 0,
194
+ spacing: 0,
195
+ specularConstant: 'specularConstant',
196
+ specularExponent: 'specularExponent',
197
+ speed: 0,
198
+ spreadMethod: 'spreadMethod',
199
+ startOffset: 'startOffset',
200
+ stdDeviation: 'stdDeviation',
201
+ stemh: 0,
202
+ stemv: 0,
203
+ stitchTiles: 'stitchTiles',
204
+ stopColor: 'stop-color',
205
+ stopOpacity: 'stop-opacity',
206
+ strikethroughPosition: 'strikethrough-position',
207
+ strikethroughThickness: 'strikethrough-thickness',
208
+ string: 0,
209
+ stroke: 0,
210
+ strokeDasharray: 'stroke-dasharray',
211
+ strokeDashoffset: 'stroke-dashoffset',
212
+ strokeLinecap: 'stroke-linecap',
213
+ strokeLinejoin: 'stroke-linejoin',
214
+ strokeMiterlimit: 'stroke-miterlimit',
215
+ strokeOpacity: 'stroke-opacity',
216
+ strokeWidth: 'stroke-width',
217
+ surfaceScale: 'surfaceScale',
218
+ systemLanguage: 'systemLanguage',
219
+ tableValues: 'tableValues',
220
+ targetX: 'targetX',
221
+ targetY: 'targetY',
222
+ textAnchor: 'text-anchor',
223
+ textDecoration: 'text-decoration',
224
+ textRendering: 'text-rendering',
225
+ textLength: 'textLength',
226
+ to: 0,
227
+ transform: 0,
228
+ u1: 0,
229
+ u2: 0,
230
+ underlinePosition: 'underline-position',
231
+ underlineThickness: 'underline-thickness',
232
+ unicode: 0,
233
+ unicodeBidi: 'unicode-bidi',
234
+ unicodeRange: 'unicode-range',
235
+ unitsPerEm: 'units-per-em',
236
+ vAlphabetic: 'v-alphabetic',
237
+ vHanging: 'v-hanging',
238
+ vIdeographic: 'v-ideographic',
239
+ vMathematical: 'v-mathematical',
240
+ values: 0,
241
+ vectorEffect: 'vector-effect',
242
+ version: 0,
243
+ vertAdvY: 'vert-adv-y',
244
+ vertOriginX: 'vert-origin-x',
245
+ vertOriginY: 'vert-origin-y',
246
+ viewBox: 'viewBox',
247
+ viewTarget: 'viewTarget',
248
+ visibility: 0,
249
+ widths: 0,
250
+ wordSpacing: 'word-spacing',
251
+ writingMode: 'writing-mode',
252
+ x: 0,
253
+ xHeight: 'x-height',
254
+ x1: 0,
255
+ x2: 0,
256
+ xChannelSelector: 'xChannelSelector',
257
+ xlinkActuate: 'xlink:actuate',
258
+ xlinkArcrole: 'xlink:arcrole',
259
+ xlinkHref: 'xlink:href',
260
+ xlinkRole: 'xlink:role',
261
+ xlinkShow: 'xlink:show',
262
+ xlinkTitle: 'xlink:title',
263
+ xlinkType: 'xlink:type',
264
+ xmlBase: 'xml:base',
265
+ xmlns: 0,
266
+ xmlnsXlink: 'xmlns:xlink',
267
+ xmlLang: 'xml:lang',
268
+ xmlSpace: 'xml:space',
269
+ y: 0,
270
+ y1: 0,
271
+ y2: 0,
272
+ yChannelSelector: 'yChannelSelector',
273
+ z: 0,
274
+ zoomAndPan: 'zoomAndPan'
275
+ };
276
+
277
+ var SVGDOMPropertyConfig = {
278
+ Properties: {},
279
+ DOMAttributeNamespaces: {
280
+ xlinkActuate: NS.xlink,
281
+ xlinkArcrole: NS.xlink,
282
+ xlinkHref: NS.xlink,
283
+ xlinkRole: NS.xlink,
284
+ xlinkShow: NS.xlink,
285
+ xlinkTitle: NS.xlink,
286
+ xlinkType: NS.xlink,
287
+ xmlBase: NS.xml,
288
+ xmlLang: NS.xml,
289
+ xmlSpace: NS.xml
290
+ },
291
+ DOMAttributeNames: {}
292
+ };
293
+
294
+ Object.keys(ATTRS).forEach(function (key) {
295
+ SVGDOMPropertyConfig.Properties[key] = 0;
296
+ if (ATTRS[key]) {
297
+ SVGDOMPropertyConfig.DOMAttributeNames[key] = ATTRS[key];
298
+ }
299
+ });
300
+
301
+ module.exports = SVGDOMPropertyConfig;
@@ -0,0 +1,190 @@
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 EventPropagators = require('./EventPropagators');
14
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
16
+ var ReactInputSelection = require('./ReactInputSelection');
17
+ var SyntheticEvent = require('./SyntheticEvent');
18
+
19
+ var getActiveElement = require('fbjs/lib/getActiveElement');
20
+ var isTextInputElement = require('./isTextInputElement');
21
+ var shallowEqual = require('fbjs/lib/shallowEqual');
22
+
23
+ var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
24
+
25
+ var eventTypes = {
26
+ select: {
27
+ phasedRegistrationNames: {
28
+ bubbled: 'onSelect',
29
+ captured: 'onSelectCapture'
30
+ },
31
+ dependencies: ['topBlur', 'topContextMenu', 'topFocus', 'topKeyDown', 'topKeyUp', 'topMouseDown', 'topMouseUp', 'topSelectionChange']
32
+ }
33
+ };
34
+
35
+ var activeElement = null;
36
+ var activeElementInst = null;
37
+ var lastSelection = null;
38
+ var mouseDown = false;
39
+
40
+ // Track whether a listener exists for this plugin. If none exist, we do
41
+ // not extract events. See #3639.
42
+ var hasListener = false;
43
+
44
+ /**
45
+ * Get an object which is a unique representation of the current selection.
46
+ *
47
+ * The return value will not be consistent across nodes or browsers, but
48
+ * two identical selections on the same node will return identical objects.
49
+ *
50
+ * @param {DOMElement} node
51
+ * @return {object}
52
+ */
53
+ function getSelection(node) {
54
+ if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) {
55
+ return {
56
+ start: node.selectionStart,
57
+ end: node.selectionEnd
58
+ };
59
+ } else if (window.getSelection) {
60
+ var selection = window.getSelection();
61
+ return {
62
+ anchorNode: selection.anchorNode,
63
+ anchorOffset: selection.anchorOffset,
64
+ focusNode: selection.focusNode,
65
+ focusOffset: selection.focusOffset
66
+ };
67
+ } else if (document.selection) {
68
+ var range = document.selection.createRange();
69
+ return {
70
+ parentElement: range.parentElement(),
71
+ text: range.text,
72
+ top: range.boundingTop,
73
+ left: range.boundingLeft
74
+ };
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Poll selection to see whether it's changed.
80
+ *
81
+ * @param {object} nativeEvent
82
+ * @return {?SyntheticEvent}
83
+ */
84
+ function constructSelectEvent(nativeEvent, nativeEventTarget) {
85
+ // Ensure we have the right element, and that the user is not dragging a
86
+ // selection (this matches native `select` event behavior). In HTML5, select
87
+ // fires only on input and textarea thus if there's no focused element we
88
+ // won't dispatch.
89
+ if (mouseDown || activeElement == null || activeElement !== getActiveElement()) {
90
+ return null;
91
+ }
92
+
93
+ // Only fire when selection has actually changed.
94
+ var currentSelection = getSelection(activeElement);
95
+ if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
96
+ lastSelection = currentSelection;
97
+
98
+ var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementInst, nativeEvent, nativeEventTarget);
99
+
100
+ syntheticEvent.type = 'select';
101
+ syntheticEvent.target = activeElement;
102
+
103
+ EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
104
+
105
+ return syntheticEvent;
106
+ }
107
+
108
+ return null;
109
+ }
110
+
111
+ /**
112
+ * This plugin creates an `onSelect` event that normalizes select events
113
+ * across form elements.
114
+ *
115
+ * Supported elements are:
116
+ * - input (see `isTextInputElement`)
117
+ * - textarea
118
+ * - contentEditable
119
+ *
120
+ * This differs from native browser implementations in the following ways:
121
+ * - Fires on contentEditable fields as well as inputs.
122
+ * - Fires for collapsed selection.
123
+ * - Fires after user input.
124
+ */
125
+ var SelectEventPlugin = {
126
+
127
+ eventTypes: eventTypes,
128
+
129
+ extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
130
+ if (!hasListener) {
131
+ return null;
132
+ }
133
+
134
+ var targetNode = targetInst ? ReactDOMComponentTree.getNodeFromInstance(targetInst) : window;
135
+
136
+ switch (topLevelType) {
137
+ // Track the input node that has focus.
138
+ case 'topFocus':
139
+ if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
140
+ activeElement = targetNode;
141
+ activeElementInst = targetInst;
142
+ lastSelection = null;
143
+ }
144
+ break;
145
+ case 'topBlur':
146
+ activeElement = null;
147
+ activeElementInst = null;
148
+ lastSelection = null;
149
+ break;
150
+
151
+ // Don't fire the event while the user is dragging. This matches the
152
+ // semantics of the native select event.
153
+ case 'topMouseDown':
154
+ mouseDown = true;
155
+ break;
156
+ case 'topContextMenu':
157
+ case 'topMouseUp':
158
+ mouseDown = false;
159
+ return constructSelectEvent(nativeEvent, nativeEventTarget);
160
+
161
+ // Chrome and IE fire non-standard event when selection is changed (and
162
+ // sometimes when it hasn't). IE's event fires out of order with respect
163
+ // to key and input events on deletion, so we discard it.
164
+ //
165
+ // Firefox doesn't support selectionchange, so check selection status
166
+ // after each key entry. The selection changes after keydown and before
167
+ // keyup, but we check on keydown as well in the case of holding down a
168
+ // key, when multiple keydown events are fired but only one keyup is.
169
+ // This is also our approach for IE handling, for the reason above.
170
+ case 'topSelectionChange':
171
+ if (skipSelectionChangeEvent) {
172
+ break;
173
+ }
174
+ // falls through
175
+ case 'topKeyDown':
176
+ case 'topKeyUp':
177
+ return constructSelectEvent(nativeEvent, nativeEventTarget);
178
+ }
179
+
180
+ return null;
181
+ },
182
+
183
+ didPutListener: function (inst, registrationName, listener) {
184
+ if (registrationName === 'onSelect') {
185
+ hasListener = true;
186
+ }
187
+ }
188
+ };
189
+
190
+ module.exports = SelectEventPlugin;