react 0.13.3 → 0.14.0-beta1

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 (189) hide show
  1. package/README.md +5 -2
  2. package/addons.js +7 -0
  3. package/dist/JSXTransformer.js +4101 -2432
  4. package/dist/react-with-addons.js +4389 -6277
  5. package/dist/react-with-addons.min.js +6 -8
  6. package/dist/react.js +4028 -5697
  7. package/dist/react.min.js +5 -6
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +16 -5
  9. package/lib/BeforeInputEventPlugin.js +30 -118
  10. package/lib/CSSCore.js +12 -23
  11. package/lib/CSSProperty.js +4 -3
  12. package/lib/CSSPropertyOperations.js +14 -30
  13. package/lib/CallbackQueue.js +7 -10
  14. package/lib/ChangeEventPlugin.js +26 -88
  15. package/lib/ClientReactRootIndex.js +2 -2
  16. package/lib/DOMChildrenOperations.js +13 -33
  17. package/lib/DOMProperty.js +86 -147
  18. package/lib/DOMPropertyOperations.js +91 -67
  19. package/lib/Danger.js +19 -62
  20. package/lib/DefaultEventPluginOrder.js +2 -12
  21. package/lib/EnterLeaveEventPlugin.js +11 -33
  22. package/lib/EventConstants.js +2 -2
  23. package/lib/EventListener.js +11 -13
  24. package/lib/EventPluginHub.js +44 -47
  25. package/lib/EventPluginRegistry.js +18 -74
  26. package/lib/EventPluginUtils.js +33 -44
  27. package/lib/EventPropagators.js +23 -26
  28. package/lib/ExecutionEnvironment.js +4 -8
  29. package/lib/FallbackCompositionState.js +3 -3
  30. package/lib/HTMLDOMPropertyConfig.js +15 -20
  31. package/lib/LinkedStateMixin.js +3 -6
  32. package/lib/LinkedValueUtils.js +71 -89
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +20 -11
  35. package/lib/React.js +9 -129
  36. package/lib/ReactBrowserComponentMixin.js +9 -2
  37. package/lib/ReactBrowserEventEmitter.js +26 -82
  38. package/lib/ReactCSSTransitionGroup.js +13 -24
  39. package/lib/ReactCSSTransitionGroupChild.js +26 -28
  40. package/lib/ReactChildReconciler.js +11 -19
  41. package/lib/ReactChildren.js +24 -31
  42. package/lib/ReactClass.js +96 -267
  43. package/lib/ReactComponent.js +28 -57
  44. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  45. package/lib/ReactComponentEnvironment.js +6 -12
  46. package/lib/ReactComponentWithPureRenderMixin.js +6 -7
  47. package/lib/ReactCompositeComponent.js +115 -381
  48. package/lib/ReactCurrentOwner.js +1 -3
  49. package/lib/ReactDOM.js +4 -2
  50. package/lib/ReactDOMButton.js +16 -28
  51. package/lib/ReactDOMClient.js +90 -0
  52. package/lib/ReactDOMComponent.js +468 -156
  53. package/lib/ReactDOMIDOperations.js +25 -22
  54. package/lib/ReactDOMInput.js +79 -108
  55. package/lib/ReactDOMOption.js +58 -20
  56. package/lib/ReactDOMSelect.js +95 -83
  57. package/lib/ReactDOMSelection.js +5 -20
  58. package/lib/ReactDOMServer.js +24 -0
  59. package/lib/ReactDOMTextComponent.js +17 -18
  60. package/lib/ReactDOMTextarea.js +44 -69
  61. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  62. package/lib/ReactDefaultInjection.js +20 -76
  63. package/lib/ReactDefaultPerf.js +36 -69
  64. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  65. package/lib/ReactElement.js +26 -120
  66. package/lib/ReactElementValidator.js +56 -192
  67. package/lib/ReactEmptyComponent.js +7 -11
  68. package/lib/ReactErrorUtils.js +3 -3
  69. package/lib/ReactEventEmitterMixin.js +3 -13
  70. package/lib/ReactEventListener.js +58 -40
  71. package/lib/ReactFragment.js +33 -59
  72. package/lib/ReactInjection.js +1 -1
  73. package/lib/ReactInputSelection.js +14 -23
  74. package/lib/ReactInstanceHandles.js +29 -58
  75. package/lib/ReactInstanceMap.js +5 -5
  76. package/lib/ReactIsomorphic.js +70 -0
  77. package/lib/ReactLink.js +2 -4
  78. package/lib/ReactMarkupChecksum.js +5 -10
  79. package/lib/ReactMount.js +142 -285
  80. package/lib/ReactMultiChild.js +19 -45
  81. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  82. package/lib/ReactNativeComponent.js +6 -15
  83. package/lib/ReactNoopUpdateQueue.js +118 -0
  84. package/lib/ReactOwner.js +7 -24
  85. package/lib/ReactPerf.js +8 -12
  86. package/lib/ReactPropTransferer.js +4 -4
  87. package/lib/ReactPropTypeLocationNames.js +2 -2
  88. package/lib/ReactPropTypeLocations.js +1 -1
  89. package/lib/ReactPropTypes.js +41 -61
  90. package/lib/ReactReconcileTransaction.js +11 -36
  91. package/lib/ReactReconciler.js +14 -26
  92. package/lib/ReactRef.js +5 -8
  93. package/lib/ReactRootIndex.js +2 -2
  94. package/lib/ReactServerBatchingStrategy.js +23 -0
  95. package/lib/ReactServerRendering.js +20 -15
  96. package/lib/ReactServerRenderingTransaction.js +9 -34
  97. package/lib/ReactStateSetters.js +6 -6
  98. package/lib/ReactTestUtils.js +137 -190
  99. package/lib/ReactTransitionChildMapping.js +5 -7
  100. package/lib/ReactTransitionEvents.js +5 -5
  101. package/lib/ReactTransitionGroup.js +30 -52
  102. package/lib/ReactUpdateQueue.js +69 -107
  103. package/lib/ReactUpdates.js +26 -81
  104. package/lib/ReactWithAddons.js +5 -6
  105. package/lib/SVGDOMPropertyConfig.js +39 -4
  106. package/lib/SelectEventPlugin.js +31 -33
  107. package/lib/ServerReactRootIndex.js +2 -2
  108. package/lib/SimpleEventPlugin.js +138 -130
  109. package/lib/SyntheticClipboardEvent.js +5 -9
  110. package/lib/SyntheticCompositionEvent.js +4 -10
  111. package/lib/SyntheticDragEvent.js +3 -3
  112. package/lib/SyntheticEvent.js +14 -15
  113. package/lib/SyntheticFocusEvent.js +3 -3
  114. package/lib/SyntheticInputEvent.js +4 -10
  115. package/lib/SyntheticKeyboardEvent.js +6 -6
  116. package/lib/SyntheticMouseEvent.js +10 -16
  117. package/lib/SyntheticTouchEvent.js +3 -3
  118. package/lib/SyntheticUIEvent.js +5 -5
  119. package/lib/SyntheticWheelEvent.js +13 -17
  120. package/lib/Transaction.js +22 -28
  121. package/lib/ViewportMetrics.js +2 -2
  122. package/lib/accumulateInto.js +2 -5
  123. package/lib/adler32.js +2 -4
  124. package/lib/camelize.js +4 -2
  125. package/lib/camelizeStyleName.js +2 -2
  126. package/lib/cloneWithProps.js +6 -12
  127. package/lib/containsNode.js +29 -16
  128. package/lib/createArrayFromMixed.js +17 -16
  129. package/lib/createNodesFromMarkup.js +6 -8
  130. package/lib/dangerousStyleValue.js +2 -3
  131. package/lib/deprecated.js +47 -0
  132. package/lib/emptyFunction.js +10 -4
  133. package/lib/emptyObject.js +1 -1
  134. package/lib/escapeTextContentForBrowser.js +1 -1
  135. package/lib/findDOMNode.js +7 -27
  136. package/lib/flattenChildren.js +4 -10
  137. package/lib/focusNode.js +2 -3
  138. package/lib/forEachAccumulated.js +3 -3
  139. package/lib/getActiveElement.js +4 -2
  140. package/lib/getEventCharCode.js +2 -2
  141. package/lib/getEventKey.js +1 -1
  142. package/lib/getEventModifierState.js +1 -2
  143. package/lib/getEventTarget.js +1 -1
  144. package/lib/getIteratorFn.js +2 -4
  145. package/lib/getMarkupWrap.js +18 -40
  146. package/lib/getNodeForCharacterOffset.js +1 -1
  147. package/lib/getTextContentAccessor.js +2 -4
  148. package/lib/getUnboundedScrollPosition.js +1 -1
  149. package/lib/hyphenate.js +3 -1
  150. package/lib/hyphenateStyleName.js +2 -2
  151. package/lib/instantiateReactComponent.js +23 -43
  152. package/lib/invariant.js +8 -12
  153. package/lib/isEventSupported.js +7 -10
  154. package/lib/isNode.js +4 -6
  155. package/lib/isTextInputElement.js +3 -4
  156. package/lib/isTextNode.js +3 -1
  157. package/lib/joinClasses.js +3 -3
  158. package/lib/keyMirror.js +3 -6
  159. package/lib/keyOf.js +4 -3
  160. package/lib/mapObject.js +1 -1
  161. package/lib/memoizeStringOnly.js +2 -2
  162. package/lib/onlyChild.js +2 -5
  163. package/lib/performance.js +2 -5
  164. package/lib/performanceNow.js +3 -1
  165. package/lib/quoteAttributeValueForBrowser.js +1 -1
  166. package/lib/renderSubtreeIntoContainer.js +16 -0
  167. package/lib/setInnerHTML.js +11 -8
  168. package/lib/setTextContent.js +3 -3
  169. package/lib/shallowCompare.js +24 -0
  170. package/lib/shallowEqual.js +17 -11
  171. package/lib/shouldUpdateReactComponent.js +3 -64
  172. package/lib/toArray.js +8 -19
  173. package/lib/traverseAllChildren.js +23 -90
  174. package/lib/update.js +25 -85
  175. package/lib/validateDOMNesting.js +363 -0
  176. package/lib/warning.js +15 -17
  177. package/package.json +3 -3
  178. package/react.js +53 -1
  179. package/lib/LocalEventTrapMixin.js +0 -53
  180. package/lib/MobileSafariClickEventPlugin.js +0 -56
  181. package/lib/ReactContext.js +0 -74
  182. package/lib/ReactDOMForm.js +0 -47
  183. package/lib/ReactDOMIframe.js +0 -43
  184. package/lib/ReactDOMImg.js +0 -44
  185. package/lib/ReactLifeCycle.js +0 -35
  186. package/lib/ReactPutListenerQueue.js +0 -54
  187. package/lib/createFullPageComponent.js +0 -58
  188. package/lib/cx.js +0 -52
  189. package/lib/getReactRootElementInContainer.js +0 -33
@@ -13,14 +13,12 @@
13
13
 
14
14
  var CallbackQueue = require("./CallbackQueue");
15
15
  var PooledClass = require("./PooledClass");
16
- var ReactCurrentOwner = require("./ReactCurrentOwner");
17
16
  var ReactPerf = require("./ReactPerf");
18
17
  var ReactReconciler = require("./ReactReconciler");
19
18
  var Transaction = require("./Transaction");
20
19
 
21
20
  var assign = require("./Object.assign");
22
21
  var invariant = require("./invariant");
23
- var warning = require("./warning");
24
22
 
25
23
  var dirtyComponents = [];
26
24
  var asapCallbackQueue = CallbackQueue.getPooled();
@@ -29,18 +27,14 @@ var asapEnqueued = false;
29
27
  var batchingStrategy = null;
30
28
 
31
29
  function ensureInjected() {
32
- ("production" !== process.env.NODE_ENV ? invariant(
33
- ReactUpdates.ReactReconcileTransaction && batchingStrategy,
34
- 'ReactUpdates: must inject a reconcile transaction class and batching ' +
35
- 'strategy'
36
- ) : invariant(ReactUpdates.ReactReconcileTransaction && batchingStrategy));
30
+ !(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined;
37
31
  }
38
32
 
39
33
  var NESTED_UPDATES = {
40
- initialize: function() {
34
+ initialize: function () {
41
35
  this.dirtyComponentsLength = dirtyComponents.length;
42
36
  },
43
- close: function() {
37
+ close: function () {
44
38
  if (this.dirtyComponentsLength !== dirtyComponents.length) {
45
39
  // Additional updates were enqueued by componentDidUpdate handlers or
46
40
  // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
@@ -56,10 +50,10 @@ var NESTED_UPDATES = {
56
50
  };
57
51
 
58
52
  var UPDATE_QUEUEING = {
59
- initialize: function() {
53
+ initialize: function () {
60
54
  this.callbackQueue.reset();
61
55
  },
62
- close: function() {
56
+ close: function () {
63
57
  this.callbackQueue.notifyAll();
64
58
  }
65
59
  };
@@ -70,18 +64,15 @@ function ReactUpdatesFlushTransaction() {
70
64
  this.reinitializeTransaction();
71
65
  this.dirtyComponentsLength = null;
72
66
  this.callbackQueue = CallbackQueue.getPooled();
73
- this.reconcileTransaction =
74
- ReactUpdates.ReactReconcileTransaction.getPooled();
67
+ this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled();
75
68
  }
76
69
 
77
- assign(
78
- ReactUpdatesFlushTransaction.prototype,
79
- Transaction.Mixin, {
80
- getTransactionWrappers: function() {
70
+ assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
71
+ getTransactionWrappers: function () {
81
72
  return TRANSACTION_WRAPPERS;
82
73
  },
83
74
 
84
- destructor: function() {
75
+ destructor: function () {
85
76
  this.dirtyComponentsLength = null;
86
77
  CallbackQueue.release(this.callbackQueue);
87
78
  this.callbackQueue = null;
@@ -89,25 +80,18 @@ assign(
89
80
  this.reconcileTransaction = null;
90
81
  },
91
82
 
92
- perform: function(method, scope, a) {
83
+ perform: function (method, scope, a) {
93
84
  // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
94
85
  // with this transaction's wrappers around it.
95
- return Transaction.Mixin.perform.call(
96
- this,
97
- this.reconcileTransaction.perform,
98
- this.reconcileTransaction,
99
- method,
100
- scope,
101
- a
102
- );
86
+ return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
103
87
  }
104
88
  });
105
89
 
106
90
  PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
107
91
 
108
- function batchedUpdates(callback, a, b, c, d) {
92
+ function batchedUpdates(callback, a, b, c, d, e) {
109
93
  ensureInjected();
110
- batchingStrategy.batchedUpdates(callback, a, b, c, d);
94
+ batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
111
95
  }
112
96
 
113
97
  /**
@@ -123,13 +107,7 @@ function mountOrderComparator(c1, c2) {
123
107
 
124
108
  function runBatchedUpdates(transaction) {
125
109
  var len = transaction.dirtyComponentsLength;
126
- ("production" !== process.env.NODE_ENV ? invariant(
127
- len === dirtyComponents.length,
128
- 'Expected flush transaction\'s stored dirty-components length (%s) to ' +
129
- 'match dirty-components array length (%s).',
130
- len,
131
- dirtyComponents.length
132
- ) : invariant(len === dirtyComponents.length));
110
+ !(len === dirtyComponents.length) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length) : invariant(false) : undefined;
133
111
 
134
112
  // Since reconciling a component higher in the owner hierarchy usually (not
135
113
  // always -- see shouldComponentUpdate()) will reconcile children, reconcile
@@ -148,23 +126,17 @@ function runBatchedUpdates(transaction) {
148
126
  var callbacks = component._pendingCallbacks;
149
127
  component._pendingCallbacks = null;
150
128
 
151
- ReactReconciler.performUpdateIfNecessary(
152
- component,
153
- transaction.reconcileTransaction
154
- );
129
+ ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction);
155
130
 
156
131
  if (callbacks) {
157
132
  for (var j = 0; j < callbacks.length; j++) {
158
- transaction.callbackQueue.enqueue(
159
- callbacks[j],
160
- component.getPublicInstance()
161
- );
133
+ transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
162
134
  }
163
135
  }
164
136
  }
165
137
  }
166
138
 
167
- var flushBatchedUpdates = function() {
139
+ var flushBatchedUpdates = function () {
168
140
  // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
169
141
  // array and perform any updates enqueued by mount-ready handlers (i.e.,
170
142
  // componentDidUpdate) but we need to check here too in order to catch
@@ -185,11 +157,7 @@ var flushBatchedUpdates = function() {
185
157
  }
186
158
  }
187
159
  };
188
- flushBatchedUpdates = ReactPerf.measure(
189
- 'ReactUpdates',
190
- 'flushBatchedUpdates',
191
- flushBatchedUpdates
192
- );
160
+ flushBatchedUpdates = ReactPerf.measure('ReactUpdates', 'flushBatchedUpdates', flushBatchedUpdates);
193
161
 
194
162
  /**
195
163
  * Mark a component as needing a rerender, adding an optional callback to a
@@ -203,13 +171,6 @@ function enqueueUpdate(component) {
203
171
  // verify that that's the case. (This is called by each top-level update
204
172
  // function, like setProps, setState, forceUpdate, etc.; creation and
205
173
  // destruction of top-level components is guarded in ReactMount.)
206
- ("production" !== process.env.NODE_ENV ? warning(
207
- ReactCurrentOwner.current == null,
208
- 'enqueueUpdate(): Render methods should be a pure function of props ' +
209
- 'and state; triggering nested component updates from render is not ' +
210
- 'allowed. If necessary, trigger nested updates in ' +
211
- 'componentDidUpdate.'
212
- ) : null);
213
174
 
214
175
  if (!batchingStrategy.isBatchingUpdates) {
215
176
  batchingStrategy.batchedUpdates(enqueueUpdate, component);
@@ -224,37 +185,21 @@ function enqueueUpdate(component) {
224
185
  * if no updates are currently being performed.
225
186
  */
226
187
  function asap(callback, context) {
227
- ("production" !== process.env.NODE_ENV ? invariant(
228
- batchingStrategy.isBatchingUpdates,
229
- 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
230
- 'updates are not being batched.'
231
- ) : invariant(batchingStrategy.isBatchingUpdates));
188
+ !batchingStrategy.isBatchingUpdates ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' + 'updates are not being batched.') : invariant(false) : undefined;
232
189
  asapCallbackQueue.enqueue(callback, context);
233
190
  asapEnqueued = true;
234
191
  }
235
192
 
236
193
  var ReactUpdatesInjection = {
237
- injectReconcileTransaction: function(ReconcileTransaction) {
238
- ("production" !== process.env.NODE_ENV ? invariant(
239
- ReconcileTransaction,
240
- 'ReactUpdates: must provide a reconcile transaction class'
241
- ) : invariant(ReconcileTransaction));
194
+ injectReconcileTransaction: function (ReconcileTransaction) {
195
+ !ReconcileTransaction ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined;
242
196
  ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
243
197
  },
244
198
 
245
- injectBatchingStrategy: function(_batchingStrategy) {
246
- ("production" !== process.env.NODE_ENV ? invariant(
247
- _batchingStrategy,
248
- 'ReactUpdates: must provide a batching strategy'
249
- ) : invariant(_batchingStrategy));
250
- ("production" !== process.env.NODE_ENV ? invariant(
251
- typeof _batchingStrategy.batchedUpdates === 'function',
252
- 'ReactUpdates: must provide a batchedUpdates() function'
253
- ) : invariant(typeof _batchingStrategy.batchedUpdates === 'function'));
254
- ("production" !== process.env.NODE_ENV ? invariant(
255
- typeof _batchingStrategy.isBatchingUpdates === 'boolean',
256
- 'ReactUpdates: must provide an isBatchingUpdates boolean attribute'
257
- ) : invariant(typeof _batchingStrategy.isBatchingUpdates === 'boolean'));
199
+ injectBatchingStrategy: function (_batchingStrategy) {
200
+ !_batchingStrategy ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined;
201
+ !(typeof _batchingStrategy.batchedUpdates === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined;
202
+ !(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined;
258
203
  batchingStrategy = _batchingStrategy;
259
204
  }
260
205
  };
@@ -275,4 +220,4 @@ var ReactUpdates = {
275
220
  asap: asap
276
221
  };
277
222
 
278
- module.exports = ReactUpdates;
223
+ module.exports = ReactUpdates;
@@ -20,15 +20,14 @@
20
20
 
21
21
  var LinkedStateMixin = require("./LinkedStateMixin");
22
22
  var React = require("./React");
23
- var ReactComponentWithPureRenderMixin =
24
- require("./ReactComponentWithPureRenderMixin");
23
+ var ReactComponentWithPureRenderMixin = require("./ReactComponentWithPureRenderMixin");
25
24
  var ReactCSSTransitionGroup = require("./ReactCSSTransitionGroup");
26
25
  var ReactFragment = require("./ReactFragment");
27
26
  var ReactTransitionGroup = require("./ReactTransitionGroup");
28
27
  var ReactUpdates = require("./ReactUpdates");
29
28
 
30
- var cx = require("./cx");
31
29
  var cloneWithProps = require("./cloneWithProps");
30
+ var shallowCompare = require("./shallowCompare");
32
31
  var update = require("./update");
33
32
 
34
33
  React.addons = {
@@ -38,15 +37,15 @@ React.addons = {
38
37
  TransitionGroup: ReactTransitionGroup,
39
38
 
40
39
  batchedUpdates: ReactUpdates.batchedUpdates,
41
- classSet: cx,
42
40
  cloneWithProps: cloneWithProps,
43
41
  createFragment: ReactFragment.create,
42
+ shallowCompare: shallowCompare,
44
43
  update: update
45
44
  };
46
45
 
47
- if ("production" !== process.env.NODE_ENV) {
46
+ if ('production' !== process.env.NODE_ENV) {
48
47
  React.addons.Perf = require("./ReactDefaultPerf");
49
48
  React.addons.TestUtils = require("./ReactTestUtils");
50
49
  }
51
50
 
52
- module.exports = React;
51
+ module.exports = React;
@@ -9,14 +9,17 @@
9
9
  * @providesModule SVGDOMPropertyConfig
10
10
  */
11
11
 
12
- /*jslint bitwise: true*/
13
-
14
12
  'use strict';
15
13
 
16
14
  var DOMProperty = require("./DOMProperty");
17
15
 
18
16
  var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
19
17
 
18
+ var NS = {
19
+ xlink: 'http://www.w3.org/1999/xlink',
20
+ xml: 'http://www.w3.org/XML/1998/namespace'
21
+ };
22
+
20
23
  var SVGDOMPropertyConfig = {
21
24
  Properties: {
22
25
  clipPath: MUST_USE_ATTRIBUTE,
@@ -60,10 +63,32 @@ var SVGDOMPropertyConfig = {
60
63
  x1: MUST_USE_ATTRIBUTE,
61
64
  x2: MUST_USE_ATTRIBUTE,
62
65
  x: MUST_USE_ATTRIBUTE,
66
+ xlinkActuate: MUST_USE_ATTRIBUTE,
67
+ xlinkArcrole: MUST_USE_ATTRIBUTE,
68
+ xlinkHref: MUST_USE_ATTRIBUTE,
69
+ xlinkRole: MUST_USE_ATTRIBUTE,
70
+ xlinkShow: MUST_USE_ATTRIBUTE,
71
+ xlinkTitle: MUST_USE_ATTRIBUTE,
72
+ xlinkType: MUST_USE_ATTRIBUTE,
73
+ xmlBase: MUST_USE_ATTRIBUTE,
74
+ xmlLang: MUST_USE_ATTRIBUTE,
75
+ xmlSpace: MUST_USE_ATTRIBUTE,
63
76
  y1: MUST_USE_ATTRIBUTE,
64
77
  y2: MUST_USE_ATTRIBUTE,
65
78
  y: MUST_USE_ATTRIBUTE
66
79
  },
80
+ DOMAttributeNamespaces: {
81
+ xlinkActuate: NS.xlink,
82
+ xlinkArcrole: NS.xlink,
83
+ xlinkHref: NS.xlink,
84
+ xlinkRole: NS.xlink,
85
+ xlinkShow: NS.xlink,
86
+ xlinkTitle: NS.xlink,
87
+ xlinkType: NS.xlink,
88
+ xmlBase: NS.xml,
89
+ xmlLang: NS.xml,
90
+ xmlSpace: NS.xml
91
+ },
67
92
  DOMAttributeNames: {
68
93
  clipPath: 'clip-path',
69
94
  fillOpacity: 'fill-opacity',
@@ -85,8 +110,18 @@ var SVGDOMPropertyConfig = {
85
110
  strokeOpacity: 'stroke-opacity',
86
111
  strokeWidth: 'stroke-width',
87
112
  textAnchor: 'text-anchor',
88
- viewBox: 'viewBox'
113
+ viewBox: 'viewBox',
114
+ xlinkActuate: 'xlink:actuate',
115
+ xlinkArcrole: 'xlink:arcrole',
116
+ xlinkHref: 'xlink:href',
117
+ xlinkRole: 'xlink:role',
118
+ xlinkShow: 'xlink:show',
119
+ xlinkTitle: 'xlink:title',
120
+ xlinkType: 'xlink:type',
121
+ xmlBase: 'xml:base',
122
+ xmlLang: 'xml:lang',
123
+ xmlSpace: 'xml:space'
89
124
  }
90
125
  };
91
126
 
92
- module.exports = SVGDOMPropertyConfig;
127
+ module.exports = SVGDOMPropertyConfig;
@@ -26,18 +26,10 @@ var topLevelTypes = EventConstants.topLevelTypes;
26
26
  var eventTypes = {
27
27
  select: {
28
28
  phasedRegistrationNames: {
29
- bubbled: keyOf({onSelect: null}),
30
- captured: keyOf({onSelectCapture: null})
29
+ bubbled: keyOf({ onSelect: null }),
30
+ captured: keyOf({ onSelectCapture: null })
31
31
  },
32
- dependencies: [
33
- topLevelTypes.topBlur,
34
- topLevelTypes.topContextMenu,
35
- topLevelTypes.topFocus,
36
- topLevelTypes.topKeyDown,
37
- topLevelTypes.topMouseDown,
38
- topLevelTypes.topMouseUp,
39
- topLevelTypes.topSelectionChange
40
- ]
32
+ dependencies: [topLevelTypes.topBlur, topLevelTypes.topContextMenu, topLevelTypes.topFocus, topLevelTypes.topKeyDown, topLevelTypes.topMouseDown, topLevelTypes.topMouseUp, topLevelTypes.topSelectionChange]
41
33
  }
42
34
  };
43
35
 
@@ -46,6 +38,11 @@ var activeElementID = null;
46
38
  var lastSelection = null;
47
39
  var mouseDown = false;
48
40
 
41
+ // Track whether a listener exists for this plugin. If none exist, we do
42
+ // not extract events.
43
+ var hasListener = false;
44
+ var ON_SELECT_KEY = keyOf({ onSelect: null });
45
+
49
46
  /**
50
47
  * Get an object which is a unique representation of the current selection.
51
48
  *
@@ -53,11 +50,10 @@ var mouseDown = false;
53
50
  * two identical selections on the same node will return identical objects.
54
51
  *
55
52
  * @param {DOMElement} node
56
- * @param {object}
53
+ * @return {object}
57
54
  */
58
55
  function getSelection(node) {
59
- if ('selectionStart' in node &&
60
- ReactInputSelection.hasSelectionCapabilities(node)) {
56
+ if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) {
61
57
  return {
62
58
  start: node.selectionStart,
63
59
  end: node.selectionEnd
@@ -87,14 +83,12 @@ function getSelection(node) {
87
83
  * @param {object} nativeEvent
88
84
  * @return {?SyntheticEvent}
89
85
  */
90
- function constructSelectEvent(nativeEvent) {
86
+ function constructSelectEvent(nativeEvent, nativeEventTarget) {
91
87
  // Ensure we have the right element, and that the user is not dragging a
92
88
  // selection (this matches native `select` event behavior). In HTML5, select
93
89
  // fires only on input and textarea thus if there's no focused element we
94
90
  // won't dispatch.
95
- if (mouseDown ||
96
- activeElement == null ||
97
- activeElement !== getActiveElement()) {
91
+ if (mouseDown || activeElement == null || activeElement !== getActiveElement()) {
98
92
  return null;
99
93
  }
100
94
 
@@ -103,11 +97,7 @@ function constructSelectEvent(nativeEvent) {
103
97
  if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
104
98
  lastSelection = currentSelection;
105
99
 
106
- var syntheticEvent = SyntheticEvent.getPooled(
107
- eventTypes.select,
108
- activeElementID,
109
- nativeEvent
110
- );
100
+ var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementID, nativeEvent, nativeEventTarget);
111
101
 
112
102
  syntheticEvent.type = 'select';
113
103
  syntheticEvent.target = activeElement;
@@ -116,6 +106,8 @@ function constructSelectEvent(nativeEvent) {
116
106
 
117
107
  return syntheticEvent;
118
108
  }
109
+
110
+ return null;
119
111
  }
120
112
 
121
113
  /**
@@ -144,17 +136,15 @@ var SelectEventPlugin = {
144
136
  * @return {*} An accumulation of synthetic events.
145
137
  * @see {EventPluginHub.extractEvents}
146
138
  */
147
- extractEvents: function(
148
- topLevelType,
149
- topLevelTarget,
150
- topLevelTargetID,
151
- nativeEvent) {
139
+ extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
140
+ if (!hasListener) {
141
+ return null;
142
+ }
152
143
 
153
144
  switch (topLevelType) {
154
145
  // Track the input node that has focus.
155
146
  case topLevelTypes.topFocus:
156
- if (isTextInputElement(topLevelTarget) ||
157
- topLevelTarget.contentEditable === 'true') {
147
+ if (isTextInputElement(topLevelTarget) || topLevelTarget.contentEditable === 'true') {
158
148
  activeElement = topLevelTarget;
159
149
  activeElementID = topLevelTargetID;
160
150
  lastSelection = null;
@@ -174,7 +164,7 @@ var SelectEventPlugin = {
174
164
  case topLevelTypes.topContextMenu:
175
165
  case topLevelTypes.topMouseUp:
176
166
  mouseDown = false;
177
- return constructSelectEvent(nativeEvent);
167
+ return constructSelectEvent(nativeEvent, nativeEventTarget);
178
168
 
179
169
  // Chrome and IE fire non-standard event when selection is changed (and
180
170
  // sometimes when it hasn't).
@@ -185,9 +175,17 @@ var SelectEventPlugin = {
185
175
  case topLevelTypes.topSelectionChange:
186
176
  case topLevelTypes.topKeyDown:
187
177
  case topLevelTypes.topKeyUp:
188
- return constructSelectEvent(nativeEvent);
178
+ return constructSelectEvent(nativeEvent, nativeEventTarget);
179
+ }
180
+
181
+ return null;
182
+ },
183
+
184
+ didPutListener: function (id, registrationName, listener) {
185
+ if (registrationName === ON_SELECT_KEY) {
186
+ hasListener = true;
189
187
  }
190
188
  }
191
189
  };
192
190
 
193
- module.exports = SelectEventPlugin;
191
+ module.exports = SelectEventPlugin;