react 0.13.2 → 0.14.0-alpha3

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 (197) hide show
  1. package/README.md +1 -1
  2. package/addons.js +7 -0
  3. package/addons/CSSTransitionGroup.js +1 -0
  4. package/addons/LinkedStateMixin.js +1 -0
  5. package/addons/Perf.js +1 -0
  6. package/addons/PureRenderMixin.js +1 -0
  7. package/addons/TestUtils.js +1 -0
  8. package/addons/TransitionGroup.js +1 -0
  9. package/addons/batchedUpdates.js +1 -0
  10. package/addons/cloneWithProps.js +1 -0
  11. package/addons/createFragment.js +1 -0
  12. package/addons/renderSubtreeIntoContainer.js +1 -0
  13. package/addons/shallowCompare.js +1 -0
  14. package/addons/update.js +1 -0
  15. package/dist/JSXTransformer.js +3355 -1685
  16. package/dist/react-with-addons.js +3320 -5133
  17. package/dist/react-with-addons.min.js +6 -7
  18. package/dist/react.js +2962 -4548
  19. package/dist/react.min.js +5 -5
  20. package/lib/AutoFocusMixin.js +4 -3
  21. package/lib/BeforeInputEventPlugin.js +30 -118
  22. package/lib/CSSCore.js +12 -23
  23. package/lib/CSSProperty.js +4 -3
  24. package/lib/CSSPropertyOperations.js +14 -30
  25. package/lib/CallbackQueue.js +7 -10
  26. package/lib/ChangeEventPlugin.js +24 -88
  27. package/lib/ClientReactRootIndex.js +2 -2
  28. package/lib/DOMChildrenOperations.js +13 -33
  29. package/lib/DOMProperty.js +41 -67
  30. package/lib/DOMPropertyOperations.js +30 -51
  31. package/lib/Danger.js +19 -62
  32. package/lib/DefaultEventPluginOrder.js +2 -12
  33. package/lib/EnterLeaveEventPlugin.js +11 -33
  34. package/lib/EventConstants.js +2 -2
  35. package/lib/EventListener.js +11 -13
  36. package/lib/EventPluginHub.js +44 -47
  37. package/lib/EventPluginRegistry.js +18 -74
  38. package/lib/EventPluginUtils.js +27 -38
  39. package/lib/EventPropagators.js +23 -26
  40. package/lib/ExecutionEnvironment.js +4 -8
  41. package/lib/FallbackCompositionState.js +3 -3
  42. package/lib/HTMLDOMPropertyConfig.js +7 -19
  43. package/lib/LinkedStateMixin.js +3 -6
  44. package/lib/LinkedValueUtils.js +34 -64
  45. package/lib/LocalEventTrapMixin.js +9 -16
  46. package/lib/Object.assign.js +1 -1
  47. package/lib/PooledClass.js +8 -11
  48. package/lib/React.js +9 -129
  49. package/lib/ReactBrowserComponentMixin.js +9 -2
  50. package/lib/ReactBrowserEventEmitter.js +26 -82
  51. package/lib/ReactCSSTransitionGroup.js +13 -24
  52. package/lib/ReactCSSTransitionGroupChild.js +18 -28
  53. package/lib/ReactChildReconciler.js +11 -19
  54. package/lib/ReactChildren.js +21 -28
  55. package/lib/ReactClass.js +81 -234
  56. package/lib/ReactComponent.js +17 -33
  57. package/lib/ReactComponentBrowserEnvironment.js +4 -8
  58. package/lib/ReactComponentEnvironment.js +6 -12
  59. package/lib/ReactComponentWithPureRenderMixin.js +4 -5
  60. package/lib/ReactCompositeComponent.js +87 -311
  61. package/lib/ReactContext.js +2 -44
  62. package/lib/ReactCurrentOwner.js +1 -3
  63. package/lib/ReactDOM.js +4 -2
  64. package/lib/ReactDOMButton.js +3 -4
  65. package/lib/ReactDOMClient.js +85 -0
  66. package/lib/ReactDOMComponent.js +182 -146
  67. package/lib/ReactDOMForm.js +3 -3
  68. package/lib/ReactDOMIDOperations.js +11 -22
  69. package/lib/ReactDOMIframe.js +3 -3
  70. package/lib/ReactDOMImg.js +3 -3
  71. package/lib/ReactDOMInput.js +22 -35
  72. package/lib/ReactDOMOption.js +67 -10
  73. package/lib/ReactDOMSelect.js +50 -28
  74. package/lib/ReactDOMSelection.js +5 -20
  75. package/lib/ReactDOMServer.js +24 -0
  76. package/lib/ReactDOMTextComponent.js +17 -18
  77. package/lib/ReactDOMTextarea.js +15 -27
  78. package/lib/ReactDefaultBatchingStrategy.js +9 -13
  79. package/lib/ReactDefaultInjection.js +31 -40
  80. package/lib/ReactDefaultPerf.js +36 -69
  81. package/lib/ReactDefaultPerfAnalysis.js +8 -14
  82. package/lib/ReactElement.js +24 -57
  83. package/lib/ReactElementValidator.js +38 -105
  84. package/lib/ReactEmptyComponent.js +7 -11
  85. package/lib/ReactErrorUtils.js +2 -2
  86. package/lib/ReactEventEmitterMixin.js +3 -12
  87. package/lib/ReactEventListener.js +16 -38
  88. package/lib/ReactFragment.js +23 -54
  89. package/lib/ReactInjection.js +1 -1
  90. package/lib/ReactInputSelection.js +11 -21
  91. package/lib/ReactInstanceHandles.js +27 -57
  92. package/lib/ReactInstanceMap.js +5 -5
  93. package/lib/ReactIsomorphic.js +70 -0
  94. package/lib/ReactLifeCycle.js +1 -1
  95. package/lib/ReactLink.js +2 -4
  96. package/lib/ReactMarkupChecksum.js +5 -10
  97. package/lib/ReactMount.js +137 -260
  98. package/lib/ReactMultiChild.js +19 -45
  99. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  100. package/lib/ReactNativeComponent.js +7 -11
  101. package/lib/ReactOwner.js +7 -24
  102. package/lib/ReactPerf.js +8 -12
  103. package/lib/ReactPropTransferer.js +4 -4
  104. package/lib/ReactPropTypeLocationNames.js +2 -2
  105. package/lib/ReactPropTypeLocations.js +1 -1
  106. package/lib/ReactPropTypes.js +41 -61
  107. package/lib/ReactReconcileTransaction.js +9 -34
  108. package/lib/ReactReconciler.js +9 -19
  109. package/lib/ReactRef.js +5 -8
  110. package/lib/ReactRootIndex.js +2 -2
  111. package/lib/ReactServerRendering.js +7 -15
  112. package/lib/ReactServerRenderingTransaction.js +7 -32
  113. package/lib/ReactStateSetters.js +6 -6
  114. package/lib/ReactTestUtils.js +93 -165
  115. package/lib/ReactTransitionChildMapping.js +5 -7
  116. package/lib/ReactTransitionEvents.js +5 -5
  117. package/lib/ReactTransitionGroup.js +30 -52
  118. package/lib/ReactUpdateQueue.js +27 -90
  119. package/lib/ReactUpdates.js +27 -79
  120. package/lib/ReactWithAddons.js +7 -6
  121. package/lib/SVGDOMPropertyConfig.js +41 -4
  122. package/lib/SelectEventPlugin.js +28 -29
  123. package/lib/ServerReactRootIndex.js +2 -2
  124. package/lib/SimpleEventPlugin.js +136 -128
  125. package/lib/SyntheticClipboardEvent.js +3 -7
  126. package/lib/SyntheticCompositionEvent.js +3 -9
  127. package/lib/SyntheticDragEvent.js +1 -1
  128. package/lib/SyntheticEvent.js +8 -10
  129. package/lib/SyntheticFocusEvent.js +1 -1
  130. package/lib/SyntheticInputEvent.js +3 -9
  131. package/lib/SyntheticKeyboardEvent.js +4 -4
  132. package/lib/SyntheticMouseEvent.js +8 -14
  133. package/lib/SyntheticTouchEvent.js +1 -1
  134. package/lib/SyntheticUIEvent.js +3 -3
  135. package/lib/SyntheticWheelEvent.js +11 -15
  136. package/lib/Transaction.js +12 -24
  137. package/lib/ViewportMetrics.js +2 -2
  138. package/lib/accumulateInto.js +2 -5
  139. package/lib/adler32.js +2 -4
  140. package/lib/camelize.js +4 -2
  141. package/lib/camelizeStyleName.js +2 -2
  142. package/lib/cloneWithProps.js +5 -11
  143. package/lib/containsNode.js +29 -16
  144. package/lib/createArrayFromMixed.js +17 -16
  145. package/lib/createFullPageComponent.js +4 -11
  146. package/lib/createNodesFromMarkup.js +6 -8
  147. package/lib/dangerousStyleValue.js +2 -3
  148. package/lib/emptyFunction.js +10 -4
  149. package/lib/emptyObject.js +1 -1
  150. package/lib/escapeTextContentForBrowser.js +1 -1
  151. package/lib/findDOMNode.js +5 -24
  152. package/lib/flattenChildren.js +4 -10
  153. package/lib/focusNode.js +2 -3
  154. package/lib/forEachAccumulated.js +2 -2
  155. package/lib/getActiveElement.js +4 -2
  156. package/lib/getEventCharCode.js +1 -1
  157. package/lib/getEventKey.js +1 -1
  158. package/lib/getEventModifierState.js +1 -1
  159. package/lib/getEventTarget.js +1 -1
  160. package/lib/getIteratorFn.js +2 -4
  161. package/lib/getMarkupWrap.js +7 -5
  162. package/lib/getNodeForCharacterOffset.js +1 -1
  163. package/lib/getTextContentAccessor.js +2 -4
  164. package/lib/getUnboundedScrollPosition.js +1 -1
  165. package/lib/hyphenate.js +3 -1
  166. package/lib/hyphenateStyleName.js +2 -2
  167. package/lib/instantiateReactComponent.js +14 -38
  168. package/lib/invariant.js +8 -12
  169. package/lib/isEventSupported.js +7 -10
  170. package/lib/isNode.js +4 -6
  171. package/lib/isTextInputElement.js +2 -4
  172. package/lib/isTextNode.js +3 -1
  173. package/lib/joinClasses.js +2 -2
  174. package/lib/keyMirror.js +3 -6
  175. package/lib/keyOf.js +4 -3
  176. package/lib/mapObject.js +1 -1
  177. package/lib/memoizeStringOnly.js +2 -2
  178. package/lib/onlyChild.js +2 -5
  179. package/lib/performance.js +2 -5
  180. package/lib/performanceNow.js +3 -1
  181. package/lib/quoteAttributeValueForBrowser.js +1 -1
  182. package/lib/renderSubtreeIntoContainer.js +16 -0
  183. package/lib/setInnerHTML.js +11 -8
  184. package/lib/setTextContent.js +3 -3
  185. package/lib/shallowCompare.js +24 -0
  186. package/lib/shallowEqual.js +17 -11
  187. package/lib/shouldUpdateReactComponent.js +3 -64
  188. package/lib/toArray.js +8 -19
  189. package/lib/traverseAllChildren.js +22 -89
  190. package/lib/update.js +25 -85
  191. package/lib/validateDOMNesting.js +363 -0
  192. package/lib/warning.js +17 -15
  193. package/package.json +3 -3
  194. package/lib/MobileSafariClickEventPlugin.js +0 -56
  195. package/lib/ReactPutListenerQueue.js +0 -54
  196. package/lib/cx.js +0 -52
  197. package/lib/getReactRootElementInContainer.js +0 -33
@@ -29,18 +29,14 @@ var asapEnqueued = false;
29
29
  var batchingStrategy = null;
30
30
 
31
31
  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));
32
+ !(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined;
37
33
  }
38
34
 
39
35
  var NESTED_UPDATES = {
40
- initialize: function() {
36
+ initialize: function () {
41
37
  this.dirtyComponentsLength = dirtyComponents.length;
42
38
  },
43
- close: function() {
39
+ close: function () {
44
40
  if (this.dirtyComponentsLength !== dirtyComponents.length) {
45
41
  // Additional updates were enqueued by componentDidUpdate handlers or
46
42
  // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
@@ -56,10 +52,10 @@ var NESTED_UPDATES = {
56
52
  };
57
53
 
58
54
  var UPDATE_QUEUEING = {
59
- initialize: function() {
55
+ initialize: function () {
60
56
  this.callbackQueue.reset();
61
57
  },
62
- close: function() {
58
+ close: function () {
63
59
  this.callbackQueue.notifyAll();
64
60
  }
65
61
  };
@@ -70,18 +66,15 @@ function ReactUpdatesFlushTransaction() {
70
66
  this.reinitializeTransaction();
71
67
  this.dirtyComponentsLength = null;
72
68
  this.callbackQueue = CallbackQueue.getPooled();
73
- this.reconcileTransaction =
74
- ReactUpdates.ReactReconcileTransaction.getPooled();
69
+ this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled();
75
70
  }
76
71
 
77
- assign(
78
- ReactUpdatesFlushTransaction.prototype,
79
- Transaction.Mixin, {
80
- getTransactionWrappers: function() {
72
+ assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
73
+ getTransactionWrappers: function () {
81
74
  return TRANSACTION_WRAPPERS;
82
75
  },
83
76
 
84
- destructor: function() {
77
+ destructor: function () {
85
78
  this.dirtyComponentsLength = null;
86
79
  CallbackQueue.release(this.callbackQueue);
87
80
  this.callbackQueue = null;
@@ -89,25 +82,18 @@ assign(
89
82
  this.reconcileTransaction = null;
90
83
  },
91
84
 
92
- perform: function(method, scope, a) {
85
+ perform: function (method, scope, a) {
93
86
  // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
94
87
  // 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
- );
88
+ return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
103
89
  }
104
90
  });
105
91
 
106
92
  PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
107
93
 
108
- function batchedUpdates(callback, a, b, c, d) {
94
+ function batchedUpdates(callback, a, b, c, d, e) {
109
95
  ensureInjected();
110
- batchingStrategy.batchedUpdates(callback, a, b, c, d);
96
+ batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
111
97
  }
112
98
 
113
99
  /**
@@ -123,13 +109,7 @@ function mountOrderComparator(c1, c2) {
123
109
 
124
110
  function runBatchedUpdates(transaction) {
125
111
  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));
112
+ !(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
113
 
134
114
  // Since reconciling a component higher in the owner hierarchy usually (not
135
115
  // always -- see shouldComponentUpdate()) will reconcile children, reconcile
@@ -148,23 +128,17 @@ function runBatchedUpdates(transaction) {
148
128
  var callbacks = component._pendingCallbacks;
149
129
  component._pendingCallbacks = null;
150
130
 
151
- ReactReconciler.performUpdateIfNecessary(
152
- component,
153
- transaction.reconcileTransaction
154
- );
131
+ ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction);
155
132
 
156
133
  if (callbacks) {
157
134
  for (var j = 0; j < callbacks.length; j++) {
158
- transaction.callbackQueue.enqueue(
159
- callbacks[j],
160
- component.getPublicInstance()
161
- );
135
+ transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
162
136
  }
163
137
  }
164
138
  }
165
139
  }
166
140
 
167
- var flushBatchedUpdates = function() {
141
+ var flushBatchedUpdates = function () {
168
142
  // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
169
143
  // array and perform any updates enqueued by mount-ready handlers (i.e.,
170
144
  // componentDidUpdate) but we need to check here too in order to catch
@@ -185,11 +159,7 @@ var flushBatchedUpdates = function() {
185
159
  }
186
160
  }
187
161
  };
188
- flushBatchedUpdates = ReactPerf.measure(
189
- 'ReactUpdates',
190
- 'flushBatchedUpdates',
191
- flushBatchedUpdates
192
- );
162
+ flushBatchedUpdates = ReactPerf.measure('ReactUpdates', 'flushBatchedUpdates', flushBatchedUpdates);
193
163
 
194
164
  /**
195
165
  * Mark a component as needing a rerender, adding an optional callback to a
@@ -203,13 +173,7 @@ function enqueueUpdate(component) {
203
173
  // verify that that's the case. (This is called by each top-level update
204
174
  // function, like setProps, setState, forceUpdate, etc.; creation and
205
175
  // 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);
176
+ 'production' !== process.env.NODE_ENV ? warning(ReactCurrentOwner.current == null, 'enqueueUpdate(): Render methods should be a pure function of props ' + 'and state; triggering nested component updates from render is not ' + 'allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate.') : undefined;
213
177
 
214
178
  if (!batchingStrategy.isBatchingUpdates) {
215
179
  batchingStrategy.batchedUpdates(enqueueUpdate, component);
@@ -224,37 +188,21 @@ function enqueueUpdate(component) {
224
188
  * if no updates are currently being performed.
225
189
  */
226
190
  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));
191
+ !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
192
  asapCallbackQueue.enqueue(callback, context);
233
193
  asapEnqueued = true;
234
194
  }
235
195
 
236
196
  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));
197
+ injectReconcileTransaction: function (ReconcileTransaction) {
198
+ !ReconcileTransaction ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined;
242
199
  ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
243
200
  },
244
201
 
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'));
202
+ injectBatchingStrategy: function (_batchingStrategy) {
203
+ !_batchingStrategy ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined;
204
+ !(typeof _batchingStrategy.batchedUpdates === 'function') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined;
205
+ !(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? 'production' !== process.env.NODE_ENV ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined;
258
206
  batchingStrategy = _batchingStrategy;
259
207
  }
260
208
  };
@@ -275,4 +223,4 @@ var ReactUpdates = {
275
223
  asap: asap
276
224
  };
277
225
 
278
- module.exports = ReactUpdates;
226
+ module.exports = ReactUpdates;
@@ -20,15 +20,15 @@
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 renderSubtreeIntoContainer = require("./renderSubtreeIntoContainer");
31
+ var shallowCompare = require("./shallowCompare");
32
32
  var update = require("./update");
33
33
 
34
34
  React.addons = {
@@ -38,15 +38,16 @@ React.addons = {
38
38
  TransitionGroup: ReactTransitionGroup,
39
39
 
40
40
  batchedUpdates: ReactUpdates.batchedUpdates,
41
- classSet: cx,
42
41
  cloneWithProps: cloneWithProps,
43
42
  createFragment: ReactFragment.create,
43
+ renderSubtreeIntoContainer: renderSubtreeIntoContainer,
44
+ shallowCompare: shallowCompare,
44
45
  update: update
45
46
  };
46
47
 
47
- if ("production" !== process.env.NODE_ENV) {
48
+ if ('production' !== process.env.NODE_ENV) {
48
49
  React.addons.Perf = require("./ReactDefaultPerf");
49
50
  React.addons.TestUtils = require("./ReactTestUtils");
50
51
  }
51
52
 
52
- module.exports = React;
53
+ module.exports = React;
@@ -9,16 +9,20 @@
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: {
25
+ clipPath: MUST_USE_ATTRIBUTE,
22
26
  cx: MUST_USE_ATTRIBUTE,
23
27
  cy: MUST_USE_ATTRIBUTE,
24
28
  d: MUST_USE_ATTRIBUTE,
@@ -59,11 +63,34 @@ var SVGDOMPropertyConfig = {
59
63
  x1: MUST_USE_ATTRIBUTE,
60
64
  x2: MUST_USE_ATTRIBUTE,
61
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,
62
76
  y1: MUST_USE_ATTRIBUTE,
63
77
  y2: MUST_USE_ATTRIBUTE,
64
78
  y: MUST_USE_ATTRIBUTE
65
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
+ },
66
92
  DOMAttributeNames: {
93
+ clipPath: 'clip-path',
67
94
  fillOpacity: 'fill-opacity',
68
95
  fontFamily: 'font-family',
69
96
  fontSize: 'font-size',
@@ -83,8 +110,18 @@ var SVGDOMPropertyConfig = {
83
110
  strokeOpacity: 'stroke-opacity',
84
111
  strokeWidth: 'stroke-width',
85
112
  textAnchor: 'text-anchor',
86
- 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'
87
124
  }
88
125
  };
89
126
 
90
- 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
  *
@@ -56,8 +53,7 @@ var mouseDown = false;
56
53
  * @param {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
@@ -92,9 +88,7 @@ function constructSelectEvent(nativeEvent) {
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);
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,16 @@ 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) {
140
+
141
+ if (!hasListener) {
142
+ return null;
143
+ }
152
144
 
153
145
  switch (topLevelType) {
154
146
  // Track the input node that has focus.
155
147
  case topLevelTypes.topFocus:
156
- if (isTextInputElement(topLevelTarget) ||
157
- topLevelTarget.contentEditable === 'true') {
148
+ if (isTextInputElement(topLevelTarget) || topLevelTarget.contentEditable === 'true') {
158
149
  activeElement = topLevelTarget;
159
150
  activeElementID = topLevelTargetID;
160
151
  lastSelection = null;
@@ -187,7 +178,15 @@ var SelectEventPlugin = {
187
178
  case topLevelTypes.topKeyUp:
188
179
  return constructSelectEvent(nativeEvent);
189
180
  }
181
+
182
+ return null;
183
+ },
184
+
185
+ didPutListener: function (id, registrationName, listener) {
186
+ if (registrationName === ON_SELECT_KEY) {
187
+ hasListener = true;
188
+ }
190
189
  }
191
190
  };
192
191
 
193
- module.exports = SelectEventPlugin;
192
+ module.exports = SelectEventPlugin;
@@ -21,9 +21,9 @@
21
21
  var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
22
22
 
23
23
  var ServerReactRootIndex = {
24
- createReactRootIndex: function() {
24
+ createReactRootIndex: function () {
25
25
  return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
26
26
  }
27
27
  };
28
28
 
29
- module.exports = ServerReactRootIndex;
29
+ module.exports = ServerReactRootIndex;