react 0.9.0 → 0.11.0

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 (114) hide show
  1. package/README.md +3 -0
  2. package/dist/JSXTransformer.js +13448 -0
  3. package/dist/react-with-addons.js +20235 -0
  4. package/dist/react-with-addons.min.js +22 -0
  5. package/dist/react.js +18443 -0
  6. package/dist/react.min.js +21 -0
  7. package/lib/AutoFocusMixin.js +3 -1
  8. package/lib/BeforeInputEventPlugin.js +222 -0
  9. package/lib/CSSPropertyOperations.js +3 -3
  10. package/lib/{ReactMountReady.js → CallbackQueue.js} +32 -24
  11. package/lib/ChangeEventPlugin.js +1 -1
  12. package/lib/CompositionEventPlugin.js +5 -1
  13. package/lib/DOMChildrenOperations.js +33 -20
  14. package/lib/DOMProperty.js +51 -21
  15. package/lib/DOMPropertyOperations.js +28 -16
  16. package/lib/DefaultEventPluginOrder.js +1 -0
  17. package/lib/EventConstants.js +1 -0
  18. package/lib/EventListener.js +5 -2
  19. package/lib/EventPluginHub.js +2 -5
  20. package/lib/EventPluginRegistry.js +6 -4
  21. package/lib/EventPluginUtils.js +11 -1
  22. package/lib/ExecutionEnvironment.js +8 -2
  23. package/lib/{DefaultDOMPropertyConfig.js → HTMLDOMPropertyConfig.js} +41 -58
  24. package/lib/LinkedValueUtils.js +26 -28
  25. package/lib/LocalEventTrapMixin.js +52 -0
  26. package/lib/React.js +39 -3
  27. package/lib/ReactBrowserComponentMixin.js +46 -0
  28. package/lib/{ReactEventEmitter.js → ReactBrowserEventEmitter.js} +115 -94
  29. package/lib/ReactCSSTransitionGroup.js +12 -10
  30. package/lib/ReactCSSTransitionGroupChild.js +2 -5
  31. package/lib/ReactChildren.js +31 -10
  32. package/lib/ReactComponent.js +119 -223
  33. package/lib/ReactComponentBrowserEnvironment.js +3 -36
  34. package/lib/ReactComponentWithPureRenderMixin.js +54 -0
  35. package/lib/ReactCompositeComponent.js +249 -287
  36. package/lib/ReactDOM.js +25 -23
  37. package/lib/ReactDOMButton.js +2 -1
  38. package/lib/ReactDOMComponent.js +42 -23
  39. package/lib/ReactDOMForm.js +7 -12
  40. package/lib/ReactDOMIDOperations.js +2 -31
  41. package/lib/ReactDOMImg.js +7 -13
  42. package/lib/ReactDOMInput.js +2 -1
  43. package/lib/ReactDOMOption.js +11 -7
  44. package/lib/ReactDOMSelect.js +18 -16
  45. package/lib/ReactDOMSelection.js +35 -10
  46. package/lib/ReactDOMTextarea.js +9 -7
  47. package/lib/ReactDefaultBatchingStrategy.js +3 -3
  48. package/lib/ReactDefaultInjection.js +27 -14
  49. package/lib/ReactDefaultPerf.js +28 -11
  50. package/lib/ReactDefaultPerfAnalysis.js +4 -0
  51. package/lib/ReactDescriptor.js +251 -0
  52. package/lib/ReactDescriptorValidator.js +283 -0
  53. package/lib/ReactEmptyComponent.js +78 -0
  54. package/lib/ReactEventEmitterMixin.js +1 -3
  55. package/lib/ReactEventListener.js +189 -0
  56. package/lib/ReactInjection.js +8 -2
  57. package/lib/ReactInputSelection.js +2 -1
  58. package/lib/ReactLink.js +24 -0
  59. package/lib/ReactMount.js +61 -21
  60. package/lib/ReactMultiChild.js +18 -13
  61. package/lib/ReactOwner.js +6 -1
  62. package/lib/ReactPropTransferer.js +44 -29
  63. package/lib/ReactPropTypes.js +226 -242
  64. package/lib/ReactPutListenerQueue.js +2 -2
  65. package/lib/ReactReconcileTransaction.js +21 -20
  66. package/lib/ReactServerRendering.js +41 -11
  67. package/lib/ReactServerRenderingTransaction.js +115 -0
  68. package/lib/ReactTestUtils.js +39 -21
  69. package/lib/ReactTextComponent.js +21 -13
  70. package/lib/ReactTransitionChildMapping.js +2 -2
  71. package/lib/ReactTransitionEvents.js +19 -0
  72. package/lib/ReactTransitionGroup.js +9 -6
  73. package/lib/ReactUpdates.js +139 -22
  74. package/lib/ReactWithAddons.js +8 -3
  75. package/lib/SVGDOMPropertyConfig.js +97 -0
  76. package/lib/SimpleEventPlugin.js +7 -1
  77. package/lib/SyntheticInputEvent.js +52 -0
  78. package/lib/SyntheticKeyboardEvent.js +33 -4
  79. package/lib/SyntheticMouseEvent.js +3 -0
  80. package/lib/SyntheticTouchEvent.js +4 -1
  81. package/lib/SyntheticUIEvent.js +24 -2
  82. package/lib/Transaction.js +0 -32
  83. package/lib/cloneWithProps.js +10 -8
  84. package/lib/createFullPageComponent.js +1 -1
  85. package/lib/dangerousStyleValue.js +11 -5
  86. package/lib/{ReactComponentEnvironment.js → emptyObject.js} +6 -5
  87. package/lib/escapeTextForBrowser.js +2 -3
  88. package/lib/flattenChildren.js +9 -7
  89. package/lib/focusNode.js +33 -0
  90. package/lib/getEventKey.js +35 -5
  91. package/lib/getEventModifierState.js +52 -0
  92. package/lib/getMarkupWrap.js +2 -0
  93. package/lib/getTextContentAccessor.js +1 -1
  94. package/lib/hyphenate.js +3 -0
  95. package/lib/hyphenateStyleName.js +46 -0
  96. package/lib/instantiateReactComponent.js +62 -0
  97. package/lib/invariant.js +17 -19
  98. package/lib/isNode.js +1 -1
  99. package/lib/{objMap.js → mapObject.js} +8 -3
  100. package/lib/mergeHelpers.js +11 -0
  101. package/lib/mergeInto.js +3 -2
  102. package/lib/monitorCodeUse.js +37 -0
  103. package/lib/onlyChild.js +3 -3
  104. package/lib/performance.js +33 -0
  105. package/lib/performanceNow.js +5 -14
  106. package/lib/setInnerHTML.js +77 -0
  107. package/lib/shouldUpdateReactComponent.js +14 -28
  108. package/lib/toArray.js +1 -1
  109. package/lib/traverseAllChildren.js +9 -5
  110. package/lib/update.js +171 -0
  111. package/package.json +4 -3
  112. package/lib/ReactEventTopLevelCallback.js +0 -149
  113. package/lib/createObjectFrom.js +0 -61
  114. package/lib/objMapKeyVal.js +0 -47
@@ -19,7 +19,7 @@
19
19
  "use strict";
20
20
 
21
21
  var PooledClass = require("./PooledClass");
22
- var ReactEventEmitter = require("./ReactEventEmitter");
22
+ var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
23
23
 
24
24
  var mixInto = require("./mixInto");
25
25
 
@@ -39,7 +39,7 @@ mixInto(ReactPutListenerQueue, {
39
39
  putListeners: function() {
40
40
  for (var i = 0; i < this.listenersToPut.length; i++) {
41
41
  var listenerToPut = this.listenersToPut[i];
42
- ReactEventEmitter.putListener(
42
+ ReactBrowserEventEmitter.putListener(
43
43
  listenerToPut.rootNodeID,
44
44
  listenerToPut.propKey,
45
45
  listenerToPut.propValue
@@ -19,11 +19,10 @@
19
19
 
20
20
  "use strict";
21
21
 
22
- var ExecutionEnvironment = require("./ExecutionEnvironment");
22
+ var CallbackQueue = require("./CallbackQueue");
23
23
  var PooledClass = require("./PooledClass");
24
- var ReactEventEmitter = require("./ReactEventEmitter");
24
+ var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
25
25
  var ReactInputSelection = require("./ReactInputSelection");
26
- var ReactMountReady = require("./ReactMountReady");
27
26
  var ReactPutListenerQueue = require("./ReactPutListenerQueue");
28
27
  var Transaction = require("./Transaction");
29
28
 
@@ -51,27 +50,28 @@ var SELECTION_RESTORATION = {
51
50
  */
52
51
  var EVENT_SUPPRESSION = {
53
52
  /**
54
- * @return {boolean} The enabled status of `ReactEventEmitter` before the
55
- * reconciliation.
53
+ * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
54
+ * the reconciliation.
56
55
  */
57
56
  initialize: function() {
58
- var currentlyEnabled = ReactEventEmitter.isEnabled();
59
- ReactEventEmitter.setEnabled(false);
57
+ var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
58
+ ReactBrowserEventEmitter.setEnabled(false);
60
59
  return currentlyEnabled;
61
60
  },
62
61
 
63
62
  /**
64
- * @param {boolean} previouslyEnabled Enabled status of `ReactEventEmitter`
65
- * before the reconciliation occured. `close` restores the previous value.
63
+ * @param {boolean} previouslyEnabled Enabled status of
64
+ * `ReactBrowserEventEmitter` before the reconciliation occured. `close`
65
+ * restores the previous value.
66
66
  */
67
67
  close: function(previouslyEnabled) {
68
- ReactEventEmitter.setEnabled(previouslyEnabled);
68
+ ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
69
69
  }
70
70
  };
71
71
 
72
72
  /**
73
- * Provides a `ReactMountReady` queue for collecting `onDOMReady` callbacks
74
- * during the performing of the transaction.
73
+ * Provides a queue for collecting `componentDidMount` and
74
+ * `componentDidUpdate` callbacks during the the transaction.
75
75
  */
76
76
  var ON_DOM_READY_QUEUEING = {
77
77
  /**
@@ -127,7 +127,13 @@ var TRANSACTION_WRAPPERS = [
127
127
  */
128
128
  function ReactReconcileTransaction() {
129
129
  this.reinitializeTransaction();
130
- this.reactMountReady = ReactMountReady.getPooled(null);
130
+ // Only server-side rendering really needs this option (see
131
+ // `ReactServerRendering`), but server-side uses
132
+ // `ReactServerRenderingTransaction` instead. This option is here so that it's
133
+ // accessible and defaults to false when `ReactDOMComponent` and
134
+ // `ReactTextComponent` checks it in `mountComponent`.`
135
+ this.renderToStaticMarkup = false;
136
+ this.reactMountReady = CallbackQueue.getPooled(null);
131
137
  this.putListenerQueue = ReactPutListenerQueue.getPooled();
132
138
  }
133
139
 
@@ -140,16 +146,11 @@ var Mixin = {
140
146
  * TODO: convert to array<TransactionWrapper>
141
147
  */
142
148
  getTransactionWrappers: function() {
143
- if (ExecutionEnvironment.canUseDOM) {
144
- return TRANSACTION_WRAPPERS;
145
- } else {
146
- return [];
147
- }
149
+ return TRANSACTION_WRAPPERS;
148
150
  },
149
151
 
150
152
  /**
151
153
  * @return {object} The queue to collect `onDOMReady` callbacks with.
152
- * TODO: convert to ReactMountReady
153
154
  */
154
155
  getReactMountReady: function() {
155
156
  return this.reactMountReady;
@@ -164,7 +165,7 @@ var Mixin = {
164
165
  * instance to be resused.
165
166
  */
166
167
  destructor: function() {
167
- ReactMountReady.release(this.reactMountReady);
168
+ CallbackQueue.release(this.reactMountReady);
168
169
  this.reactMountReady = null;
169
170
 
170
171
  ReactPutListenerQueue.release(this.putListenerQueue);
@@ -18,22 +18,24 @@
18
18
  */
19
19
  "use strict";
20
20
 
21
- var ReactComponent = require("./ReactComponent");
21
+ var ReactDescriptor = require("./ReactDescriptor");
22
22
  var ReactInstanceHandles = require("./ReactInstanceHandles");
23
23
  var ReactMarkupChecksum = require("./ReactMarkupChecksum");
24
- var ReactReconcileTransaction = require("./ReactReconcileTransaction");
24
+ var ReactServerRenderingTransaction =
25
+ require("./ReactServerRenderingTransaction");
25
26
 
27
+ var instantiateReactComponent = require("./instantiateReactComponent");
26
28
  var invariant = require("./invariant");
27
29
 
28
30
  /**
29
31
  * @param {ReactComponent} component
30
- * @return {string} the markup
32
+ * @return {string} the HTML markup
31
33
  */
32
34
  function renderComponentToString(component) {
33
35
  ("production" !== process.env.NODE_ENV ? invariant(
34
- ReactComponent.isValidComponent(component),
36
+ ReactDescriptor.isValidDescriptor(component),
35
37
  'renderComponentToString(): You must pass a valid ReactComponent.'
36
- ) : invariant(ReactComponent.isValidComponent(component)));
38
+ ) : invariant(ReactDescriptor.isValidDescriptor(component)));
37
39
 
38
40
  ("production" !== process.env.NODE_ENV ? invariant(
39
41
  !(arguments.length === 2 && typeof arguments[1] === 'function'),
@@ -41,19 +43,47 @@ function renderComponentToString(component) {
41
43
  'returns the generated markup. Please remove the second parameter.'
42
44
  ) : invariant(!(arguments.length === 2 && typeof arguments[1] === 'function')));
43
45
 
44
- var id = ReactInstanceHandles.createReactRootID();
45
- var transaction = ReactReconcileTransaction.getPooled();
46
- transaction.reinitializeTransaction();
46
+ var transaction;
47
47
  try {
48
+ var id = ReactInstanceHandles.createReactRootID();
49
+ transaction = ReactServerRenderingTransaction.getPooled(false);
50
+
48
51
  return transaction.perform(function() {
49
- var markup = component.mountComponent(id, transaction, 0);
52
+ var componentInstance = instantiateReactComponent(component);
53
+ var markup = componentInstance.mountComponent(id, transaction, 0);
50
54
  return ReactMarkupChecksum.addChecksumToMarkup(markup);
51
55
  }, null);
52
56
  } finally {
53
- ReactReconcileTransaction.release(transaction);
57
+ ReactServerRenderingTransaction.release(transaction);
58
+ }
59
+ }
60
+
61
+ /**
62
+ * @param {ReactComponent} component
63
+ * @return {string} the HTML markup, without the extra React ID and checksum
64
+ * (for generating static pages)
65
+ */
66
+ function renderComponentToStaticMarkup(component) {
67
+ ("production" !== process.env.NODE_ENV ? invariant(
68
+ ReactDescriptor.isValidDescriptor(component),
69
+ 'renderComponentToStaticMarkup(): You must pass a valid ReactComponent.'
70
+ ) : invariant(ReactDescriptor.isValidDescriptor(component)));
71
+
72
+ var transaction;
73
+ try {
74
+ var id = ReactInstanceHandles.createReactRootID();
75
+ transaction = ReactServerRenderingTransaction.getPooled(true);
76
+
77
+ return transaction.perform(function() {
78
+ var componentInstance = instantiateReactComponent(component);
79
+ return componentInstance.mountComponent(id, transaction, 0);
80
+ }, null);
81
+ } finally {
82
+ ReactServerRenderingTransaction.release(transaction);
54
83
  }
55
84
  }
56
85
 
57
86
  module.exports = {
58
- renderComponentToString: renderComponentToString
87
+ renderComponentToString: renderComponentToString,
88
+ renderComponentToStaticMarkup: renderComponentToStaticMarkup
59
89
  };
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright 2014 Facebook, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * @providesModule ReactServerRenderingTransaction
17
+ * @typechecks
18
+ */
19
+
20
+ "use strict";
21
+
22
+ var PooledClass = require("./PooledClass");
23
+ var CallbackQueue = require("./CallbackQueue");
24
+ var ReactPutListenerQueue = require("./ReactPutListenerQueue");
25
+ var Transaction = require("./Transaction");
26
+
27
+ var emptyFunction = require("./emptyFunction");
28
+ var mixInto = require("./mixInto");
29
+
30
+ /**
31
+ * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
32
+ * during the performing of the transaction.
33
+ */
34
+ var ON_DOM_READY_QUEUEING = {
35
+ /**
36
+ * Initializes the internal `onDOMReady` queue.
37
+ */
38
+ initialize: function() {
39
+ this.reactMountReady.reset();
40
+ },
41
+
42
+ close: emptyFunction
43
+ };
44
+
45
+ var PUT_LISTENER_QUEUEING = {
46
+ initialize: function() {
47
+ this.putListenerQueue.reset();
48
+ },
49
+
50
+ close: emptyFunction
51
+ };
52
+
53
+ /**
54
+ * Executed within the scope of the `Transaction` instance. Consider these as
55
+ * being member methods, but with an implied ordering while being isolated from
56
+ * each other.
57
+ */
58
+ var TRANSACTION_WRAPPERS = [
59
+ PUT_LISTENER_QUEUEING,
60
+ ON_DOM_READY_QUEUEING
61
+ ];
62
+
63
+ /**
64
+ * @class ReactServerRenderingTransaction
65
+ * @param {boolean} renderToStaticMarkup
66
+ */
67
+ function ReactServerRenderingTransaction(renderToStaticMarkup) {
68
+ this.reinitializeTransaction();
69
+ this.renderToStaticMarkup = renderToStaticMarkup;
70
+ this.reactMountReady = CallbackQueue.getPooled(null);
71
+ this.putListenerQueue = ReactPutListenerQueue.getPooled();
72
+ }
73
+
74
+ var Mixin = {
75
+ /**
76
+ * @see Transaction
77
+ * @abstract
78
+ * @final
79
+ * @return {array} Empty list of operation wrap proceedures.
80
+ */
81
+ getTransactionWrappers: function() {
82
+ return TRANSACTION_WRAPPERS;
83
+ },
84
+
85
+ /**
86
+ * @return {object} The queue to collect `onDOMReady` callbacks with.
87
+ */
88
+ getReactMountReady: function() {
89
+ return this.reactMountReady;
90
+ },
91
+
92
+ getPutListenerQueue: function() {
93
+ return this.putListenerQueue;
94
+ },
95
+
96
+ /**
97
+ * `PooledClass` looks for this, and will invoke this before allowing this
98
+ * instance to be resused.
99
+ */
100
+ destructor: function() {
101
+ CallbackQueue.release(this.reactMountReady);
102
+ this.reactMountReady = null;
103
+
104
+ ReactPutListenerQueue.release(this.putListenerQueue);
105
+ this.putListenerQueue = null;
106
+ }
107
+ };
108
+
109
+
110
+ mixInto(ReactServerRenderingTransaction, Transaction.Mixin);
111
+ mixInto(ReactServerRenderingTransaction, Mixin);
112
+
113
+ PooledClass.addPoolingTo(ReactServerRenderingTransaction);
114
+
115
+ module.exports = ReactServerRenderingTransaction;
@@ -22,9 +22,9 @@ var EventConstants = require("./EventConstants");
22
22
  var EventPluginHub = require("./EventPluginHub");
23
23
  var EventPropagators = require("./EventPropagators");
24
24
  var React = require("./React");
25
- var ReactComponent = require("./ReactComponent");
25
+ var ReactDescriptor = require("./ReactDescriptor");
26
26
  var ReactDOM = require("./ReactDOM");
27
- var ReactEventEmitter = require("./ReactEventEmitter");
27
+ var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
28
28
  var ReactMount = require("./ReactMount");
29
29
  var ReactTextComponent = require("./ReactTextComponent");
30
30
  var ReactUpdates = require("./ReactUpdates");
@@ -57,21 +57,39 @@ var ReactTestUtils = {
57
57
  return React.renderComponent(instance, div);
58
58
  },
59
59
 
60
- isComponentOfType: function(inst, convenienceConstructor) {
60
+ isDescriptor: function(descriptor) {
61
+ return ReactDescriptor.isValidDescriptor(descriptor);
62
+ },
63
+
64
+ isDescriptorOfType: function(inst, convenienceConstructor) {
61
65
  return (
62
- ReactComponent.isValidComponent(inst) &&
66
+ ReactDescriptor.isValidDescriptor(inst) &&
63
67
  inst.type === convenienceConstructor.type
64
68
  );
65
69
  },
66
70
 
67
71
  isDOMComponent: function(inst) {
72
+ return !!(inst && inst.mountComponent && inst.tagName);
73
+ },
74
+
75
+ isDOMComponentDescriptor: function(inst) {
68
76
  return !!(inst &&
69
- ReactComponent.isValidComponent(inst) &&
77
+ ReactDescriptor.isValidDescriptor(inst) &&
70
78
  !!inst.tagName);
71
79
  },
72
80
 
73
81
  isCompositeComponent: function(inst) {
74
- if (!ReactComponent.isValidComponent(inst)) {
82
+ return typeof inst.render === 'function' &&
83
+ typeof inst.setState === 'function';
84
+ },
85
+
86
+ isCompositeComponentWithType: function(inst, type) {
87
+ return !!(ReactTestUtils.isCompositeComponent(inst) &&
88
+ (inst.constructor === type.type));
89
+ },
90
+
91
+ isCompositeComponentDescriptor: function(inst) {
92
+ if (!ReactDescriptor.isValidDescriptor(inst)) {
75
93
  return false;
76
94
  }
77
95
  // We check the prototype of the type that will get mounted, not the
@@ -79,19 +97,17 @@ var ReactTestUtils = {
79
97
  var prototype = inst.type.prototype;
80
98
  return (
81
99
  typeof prototype.render === 'function' &&
82
- typeof prototype.setState === 'function' &&
83
- typeof prototype.updateComponent === 'function'
100
+ typeof prototype.setState === 'function'
84
101
  );
85
102
  },
86
103
 
87
- isCompositeComponentWithType: function(inst, type) {
88
- return !!(ReactTestUtils.isCompositeComponent(inst) &&
89
- (inst.constructor === type.componentConstructor ||
90
- inst.constructor === type));
104
+ isCompositeComponentDescriptorWithType: function(inst, type) {
105
+ return !!(ReactTestUtils.isCompositeComponentDescriptor(inst) &&
106
+ (inst.constructor === type));
91
107
  },
92
108
 
93
109
  isTextComponent: function(inst) {
94
- return inst instanceof ReactTextComponent;
110
+ return inst instanceof ReactTextComponent.type;
95
111
  },
96
112
 
97
113
  findAllInRenderedTree: function(inst, test) {
@@ -182,7 +198,10 @@ var ReactTestUtils = {
182
198
  */
183
199
  scryRenderedComponentsWithType: function(root, componentType) {
184
200
  return ReactTestUtils.findAllInRenderedTree(root, function(inst) {
185
- return ReactTestUtils.isCompositeComponentWithType(inst, componentType);
201
+ return ReactTestUtils.isCompositeComponentWithType(
202
+ inst,
203
+ componentType
204
+ );
186
205
  });
187
206
  },
188
207
 
@@ -240,12 +259,11 @@ var ReactTestUtils = {
240
259
  * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent.
241
260
  */
242
261
  simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) {
243
- var virtualHandler =
244
- ReactEventEmitter.TopLevelCallbackCreator.createTopLevelCallback(
245
- topLevelType
246
- );
247
262
  fakeNativeEvent.target = node;
248
- virtualHandler(fakeNativeEvent);
263
+ ReactBrowserEventEmitter.ReactEventListener.dispatchEvent(
264
+ topLevelType,
265
+ fakeNativeEvent
266
+ );
249
267
  },
250
268
 
251
269
  /**
@@ -300,7 +318,7 @@ function makeSimulator(eventType) {
300
318
  // We don't use SyntheticEvent.getPooled in order to not have to worry about
301
319
  // properly destroying any properties assigned from `eventData` upon release
302
320
  var event = new SyntheticEvent(
303
- ReactEventEmitter.eventNameDispatchConfigs[eventType],
321
+ ReactBrowserEventEmitter.eventNameDispatchConfigs[eventType],
304
322
  ReactMount.getID(node),
305
323
  fakeNativeEvent
306
324
  );
@@ -318,7 +336,7 @@ function buildSimulators() {
318
336
  ReactTestUtils.Simulate = {};
319
337
 
320
338
  var eventType;
321
- for (eventType in ReactEventEmitter.eventNameDispatchConfigs) {
339
+ for (eventType in ReactBrowserEventEmitter.eventNameDispatchConfigs) {
322
340
  /**
323
341
  * @param {!Element || ReactDOMComponent} domComponentOrNode
324
342
  * @param {?object} eventData Fake event data to use in SyntheticEvent.
@@ -20,7 +20,9 @@
20
20
  "use strict";
21
21
 
22
22
  var DOMPropertyOperations = require("./DOMPropertyOperations");
23
+ var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
23
24
  var ReactComponent = require("./ReactComponent");
25
+ var ReactDescriptor = require("./ReactDescriptor");
24
26
 
25
27
  var escapeTextForBrowser = require("./escapeTextForBrowser");
26
28
  var mixInto = require("./mixInto");
@@ -40,11 +42,12 @@ var mixInto = require("./mixInto");
40
42
  * @extends ReactComponent
41
43
  * @internal
42
44
  */
43
- var ReactTextComponent = function(initialText) {
44
- this.construct({text: initialText});
45
+ var ReactTextComponent = function(descriptor) {
46
+ this.construct(descriptor);
45
47
  };
46
48
 
47
49
  mixInto(ReactTextComponent, ReactComponent.Mixin);
50
+ mixInto(ReactTextComponent, ReactBrowserComponentMixin);
48
51
  mixInto(ReactTextComponent, {
49
52
 
50
53
  /**
@@ -52,7 +55,7 @@ mixInto(ReactTextComponent, {
52
55
  * any features besides containing text content.
53
56
  *
54
57
  * @param {string} rootID DOM ID of the root node.
55
- * @param {ReactReconcileTransaction} transaction
58
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
56
59
  * @param {number} mountDepth number of components in the owner hierarchy
57
60
  * @return {string} Markup for this text node.
58
61
  * @internal
@@ -64,9 +67,19 @@ mixInto(ReactTextComponent, {
64
67
  transaction,
65
68
  mountDepth
66
69
  );
70
+
71
+ var escapedText = escapeTextForBrowser(this.props);
72
+
73
+ if (transaction.renderToStaticMarkup) {
74
+ // Normally we'd wrap this in a `span` for the reasons stated above, but
75
+ // since this is a situation where React won't take over (static pages),
76
+ // we can simply return the text as it is.
77
+ return escapedText;
78
+ }
79
+
67
80
  return (
68
81
  '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' +
69
- escapeTextForBrowser(this.props.text) +
82
+ escapedText +
70
83
  '</span>'
71
84
  );
72
85
  },
@@ -80,20 +93,15 @@ mixInto(ReactTextComponent, {
80
93
  */
81
94
  receiveComponent: function(nextComponent, transaction) {
82
95
  var nextProps = nextComponent.props;
83
- if (nextProps.text !== this.props.text) {
84
- this.props.text = nextProps.text;
96
+ if (nextProps !== this.props) {
97
+ this.props = nextProps;
85
98
  ReactComponent.BackendIDOperations.updateTextContentByID(
86
99
  this._rootNodeID,
87
- nextProps.text
100
+ nextProps
88
101
  );
89
102
  }
90
103
  }
91
104
 
92
105
  });
93
106
 
94
- // Expose the constructor on itself and the prototype for consistency with other
95
- // descriptors.
96
- ReactTextComponent.type = ReactTextComponent;
97
- ReactTextComponent.prototype.type = ReactTextComponent;
98
-
99
- module.exports = ReactTextComponent;
107
+ module.exports = ReactDescriptor.createFactory(ReactTextComponent);