react 0.11.2 → 0.12.2

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 (173) hide show
  1. package/dist/JSXTransformer.js +2714 -7859
  2. package/dist/react-with-addons.js +3139 -3593
  3. package/dist/react-with-addons.min.js +11 -17
  4. package/dist/react.js +2940 -3308
  5. package/dist/react.min.js +11 -16
  6. package/lib/AutoFocusMixin.js +5 -12
  7. package/lib/BeforeInputEventPlugin.js +12 -14
  8. package/lib/CSSCore.js +6 -13
  9. package/lib/CSSProperty.js +10 -14
  10. package/lib/CSSPropertyOperations.js +46 -12
  11. package/lib/CallbackQueue.js +7 -14
  12. package/lib/ChangeEventPlugin.js +5 -12
  13. package/lib/ClientReactRootIndex.js +5 -12
  14. package/lib/CompositionEventPlugin.js +5 -12
  15. package/lib/DOMChildrenOperations.js +8 -15
  16. package/lib/DOMProperty.js +16 -19
  17. package/lib/DOMPropertyOperations.js +14 -14
  18. package/lib/Danger.js +12 -17
  19. package/lib/DefaultEventPluginOrder.js +5 -12
  20. package/lib/EnterLeaveEventPlugin.js +5 -12
  21. package/lib/EventConstants.js +5 -12
  22. package/lib/EventListener.js +14 -0
  23. package/lib/EventPluginHub.js +8 -26
  24. package/lib/EventPluginRegistry.js +5 -12
  25. package/lib/EventPluginUtils.js +5 -12
  26. package/lib/EventPropagators.js +12 -17
  27. package/lib/ExecutionEnvironment.js +5 -12
  28. package/lib/HTMLDOMPropertyConfig.js +16 -15
  29. package/lib/LinkedStateMixin.js +5 -12
  30. package/lib/LinkedValueUtils.js +5 -12
  31. package/lib/LocalEventTrapMixin.js +8 -14
  32. package/lib/MobileSafariClickEventPlugin.js +5 -12
  33. package/lib/Object.assign.js +45 -0
  34. package/lib/PooledClass.js +5 -12
  35. package/lib/React.js +87 -54
  36. package/lib/ReactBrowserComponentMixin.js +5 -12
  37. package/lib/ReactBrowserEventEmitter.js +7 -14
  38. package/lib/ReactCSSTransitionGroup.js +15 -17
  39. package/lib/ReactCSSTransitionGroupChild.js +9 -13
  40. package/lib/ReactChildren.js +5 -12
  41. package/lib/ReactComponent.js +61 -68
  42. package/lib/ReactComponentBrowserEnvironment.js +5 -12
  43. package/lib/ReactComponentWithPureRenderMixin.js +5 -12
  44. package/lib/ReactCompositeComponent.js +191 -180
  45. package/lib/ReactContext.js +8 -15
  46. package/lib/ReactCurrentOwner.js +5 -12
  47. package/lib/ReactDOM.js +145 -177
  48. package/lib/ReactDOMButton.js +8 -14
  49. package/lib/ReactDOMComponent.js +103 -38
  50. package/lib/ReactDOMForm.js +9 -15
  51. package/lib/ReactDOMIDOperations.js +5 -12
  52. package/lib/ReactDOMImg.js +8 -14
  53. package/lib/ReactDOMInput.js +30 -38
  54. package/lib/ReactDOMOption.js +8 -14
  55. package/lib/ReactDOMSelect.js +25 -24
  56. package/lib/ReactDOMSelection.js +11 -18
  57. package/lib/ReactDOMTextarea.js +19 -24
  58. package/lib/ReactDefaultBatchingStrategy.js +14 -18
  59. package/lib/ReactDefaultInjection.js +23 -26
  60. package/lib/ReactDefaultPerf.js +14 -17
  61. package/lib/ReactDefaultPerfAnalysis.js +18 -17
  62. package/lib/ReactElement.js +242 -0
  63. package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +51 -56
  64. package/lib/ReactEmptyComponent.js +8 -13
  65. package/lib/ReactErrorUtils.js +5 -12
  66. package/lib/ReactEventEmitterMixin.js +5 -12
  67. package/lib/ReactEventListener.js +7 -14
  68. package/lib/ReactInjection.js +7 -14
  69. package/lib/ReactInputSelection.js +5 -12
  70. package/lib/ReactInstanceHandles.js +5 -12
  71. package/lib/ReactLegacyElement.js +243 -0
  72. package/lib/ReactLink.js +5 -12
  73. package/lib/ReactMarkupChecksum.js +5 -12
  74. package/lib/ReactMount.js +45 -32
  75. package/lib/ReactMultiChild.js +14 -18
  76. package/lib/ReactMultiChildUpdateTypes.js +5 -12
  77. package/lib/ReactNativeComponent.js +69 -0
  78. package/lib/ReactOwner.js +5 -12
  79. package/lib/ReactPerf.js +8 -13
  80. package/lib/ReactPropTransferer.js +34 -33
  81. package/lib/ReactPropTypeLocationNames.js +5 -12
  82. package/lib/ReactPropTypeLocations.js +5 -12
  83. package/lib/ReactPropTypes.js +38 -29
  84. package/lib/ReactPutListenerQueue.js +7 -14
  85. package/lib/ReactReconcileTransaction.js +7 -15
  86. package/lib/ReactRootIndex.js +5 -12
  87. package/lib/ReactServerRendering.js +21 -34
  88. package/lib/ReactServerRenderingTransaction.js +11 -15
  89. package/lib/ReactStateSetters.js +5 -12
  90. package/lib/ReactTestUtils.js +31 -33
  91. package/lib/ReactTextComponent.js +18 -21
  92. package/lib/ReactTransitionChildMapping.js +6 -13
  93. package/lib/ReactTransitionEvents.js +5 -12
  94. package/lib/ReactTransitionGroup.js +14 -17
  95. package/lib/ReactUpdates.js +43 -22
  96. package/lib/ReactWithAddons.js +7 -13
  97. package/lib/SVGDOMPropertyConfig.js +5 -12
  98. package/lib/SelectEventPlugin.js +13 -20
  99. package/lib/ServerReactRootIndex.js +5 -12
  100. package/lib/SimpleEventPlugin.js +20 -15
  101. package/lib/SyntheticClipboardEvent.js +5 -12
  102. package/lib/SyntheticCompositionEvent.js +5 -12
  103. package/lib/SyntheticDragEvent.js +5 -12
  104. package/lib/SyntheticEvent.js +9 -17
  105. package/lib/SyntheticFocusEvent.js +5 -12
  106. package/lib/SyntheticInputEvent.js +4 -11
  107. package/lib/SyntheticKeyboardEvent.js +17 -19
  108. package/lib/SyntheticMouseEvent.js +5 -12
  109. package/lib/SyntheticTouchEvent.js +5 -12
  110. package/lib/SyntheticUIEvent.js +5 -12
  111. package/lib/SyntheticWheelEvent.js +5 -12
  112. package/lib/Transaction.js +5 -12
  113. package/lib/ViewportMetrics.js +5 -12
  114. package/lib/accumulateInto.js +62 -0
  115. package/lib/adler32.js +6 -13
  116. package/lib/camelize.js +30 -0
  117. package/lib/camelizeStyleName.js +40 -0
  118. package/lib/cloneWithProps.js +9 -15
  119. package/lib/containsNode.js +5 -12
  120. package/lib/copyProperties.js +12 -12
  121. package/lib/createArrayFrom.js +5 -12
  122. package/lib/createFullPageComponent.js +12 -18
  123. package/lib/createNodesFromMarkup.js +5 -12
  124. package/lib/cx.js +5 -12
  125. package/lib/dangerousStyleValue.js +5 -12
  126. package/lib/deprecated.js +47 -0
  127. package/lib/emptyFunction.js +11 -22
  128. package/lib/emptyObject.js +5 -12
  129. package/lib/escapeTextForBrowser.js +5 -12
  130. package/lib/flattenChildren.js +19 -13
  131. package/lib/focusNode.js +10 -16
  132. package/lib/forEachAccumulated.js +5 -12
  133. package/lib/getActiveElement.js +5 -12
  134. package/lib/getEventCharCode.js +50 -0
  135. package/lib/getEventKey.js +9 -21
  136. package/lib/getEventModifierState.js +4 -11
  137. package/lib/getEventTarget.js +5 -12
  138. package/lib/getMarkupWrap.js +5 -12
  139. package/lib/getNodeForCharacterOffset.js +5 -12
  140. package/lib/getReactRootElementInContainer.js +5 -12
  141. package/lib/getTextContentAccessor.js +5 -12
  142. package/lib/getUnboundedScrollPosition.js +5 -12
  143. package/lib/hyphenate.js +5 -12
  144. package/lib/hyphenateStyleName.js +8 -15
  145. package/lib/instantiateReactComponent.js +90 -42
  146. package/lib/invariant.js +5 -12
  147. package/lib/isEventSupported.js +5 -12
  148. package/lib/isNode.js +5 -12
  149. package/lib/isTextInputElement.js +5 -12
  150. package/lib/isTextNode.js +5 -12
  151. package/lib/joinClasses.js +8 -13
  152. package/lib/keyMirror.js +5 -12
  153. package/lib/keyOf.js +5 -12
  154. package/lib/mapObject.js +35 -36
  155. package/lib/memoizeStringOnly.js +5 -12
  156. package/lib/merge.js +14 -17
  157. package/lib/mergeInto.js +13 -35
  158. package/lib/monitorCodeUse.js +5 -12
  159. package/lib/onlyChild.js +8 -15
  160. package/lib/performance.js +5 -12
  161. package/lib/performanceNow.js +5 -12
  162. package/lib/setInnerHTML.js +10 -19
  163. package/lib/shallowEqual.js +6 -13
  164. package/lib/shouldUpdateReactComponent.js +14 -22
  165. package/lib/toArray.js +5 -12
  166. package/lib/traverseAllChildren.js +34 -48
  167. package/lib/update.js +8 -15
  168. package/lib/warning.js +6 -13
  169. package/package.json +3 -8
  170. package/lib/ReactDescriptor.js +0 -251
  171. package/lib/accumulate.js +0 -54
  172. package/lib/mergeHelpers.js +0 -147
  173. package/lib/mixInto.js +0 -34
package/lib/ReactLink.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactLink
17
10
  * @typechecks static-only
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactMarkupChecksum
17
10
  */
package/lib/ReactMount.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactMount
17
10
  */
@@ -21,17 +14,23 @@
21
14
  var DOMProperty = require("./DOMProperty");
22
15
  var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
23
16
  var ReactCurrentOwner = require("./ReactCurrentOwner");
24
- var ReactDescriptor = require("./ReactDescriptor");
17
+ var ReactElement = require("./ReactElement");
18
+ var ReactLegacyElement = require("./ReactLegacyElement");
25
19
  var ReactInstanceHandles = require("./ReactInstanceHandles");
26
20
  var ReactPerf = require("./ReactPerf");
27
21
 
28
22
  var containsNode = require("./containsNode");
23
+ var deprecated = require("./deprecated");
29
24
  var getReactRootElementInContainer = require("./getReactRootElementInContainer");
30
25
  var instantiateReactComponent = require("./instantiateReactComponent");
31
26
  var invariant = require("./invariant");
32
27
  var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
33
28
  var warning = require("./warning");
34
29
 
30
+ var createElement = ReactLegacyElement.wrapCreateElement(
31
+ ReactElement.createElement
32
+ );
33
+
35
34
  var SEPARATOR = ReactInstanceHandles.SEPARATOR;
36
35
 
37
36
  var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
@@ -199,7 +198,7 @@ function findDeepestCachedAncestor(targetID) {
199
198
  * representative DOM elements and inserting them into a supplied `container`.
200
199
  * Any prior content inside `container` is destroyed in the process.
201
200
  *
202
- * ReactMount.renderComponent(
201
+ * ReactMount.render(
203
202
  * component,
204
203
  * document.getElementById('container')
205
204
  * );
@@ -305,7 +304,7 @@ var ReactMount = {
305
304
  'componentDidUpdate.'
306
305
  ) : null);
307
306
 
308
- var componentInstance = instantiateReactComponent(nextComponent);
307
+ var componentInstance = instantiateReactComponent(nextComponent, null);
309
308
  var reactRootID = ReactMount._registerComponent(
310
309
  componentInstance,
311
310
  container
@@ -333,35 +332,38 @@ var ReactMount = {
333
332
  * perform an update on it and only mutate the DOM as necessary to reflect the
334
333
  * latest React component.
335
334
  *
336
- * @param {ReactDescriptor} nextDescriptor Component descriptor to render.
335
+ * @param {ReactElement} nextElement Component element to render.
337
336
  * @param {DOMElement} container DOM element to render into.
338
337
  * @param {?function} callback function triggered on completion
339
338
  * @return {ReactComponent} Component instance rendered in `container`.
340
339
  */
341
- renderComponent: function(nextDescriptor, container, callback) {
340
+ render: function(nextElement, container, callback) {
342
341
  ("production" !== process.env.NODE_ENV ? invariant(
343
- ReactDescriptor.isValidDescriptor(nextDescriptor),
344
- 'renderComponent(): Invalid component descriptor.%s',
342
+ ReactElement.isValidElement(nextElement),
343
+ 'renderComponent(): Invalid component element.%s',
345
344
  (
346
- ReactDescriptor.isValidFactory(nextDescriptor) ?
345
+ typeof nextElement === 'string' ?
346
+ ' Instead of passing an element string, make sure to instantiate ' +
347
+ 'it by passing it to React.createElement.' :
348
+ ReactLegacyElement.isValidFactory(nextElement) ?
347
349
  ' Instead of passing a component class, make sure to instantiate ' +
348
- 'it first by calling it with props.' :
349
- // Check if it quacks like a descriptor
350
- typeof nextDescriptor.props !== "undefined" ?
350
+ 'it by passing it to React.createElement.' :
351
+ // Check if it quacks like a element
352
+ typeof nextElement.props !== "undefined" ?
351
353
  ' This may be caused by unintentionally loading two independent ' +
352
354
  'copies of React.' :
353
355
  ''
354
356
  )
355
- ) : invariant(ReactDescriptor.isValidDescriptor(nextDescriptor)));
357
+ ) : invariant(ReactElement.isValidElement(nextElement)));
356
358
 
357
359
  var prevComponent = instancesByReactRootID[getReactRootID(container)];
358
360
 
359
361
  if (prevComponent) {
360
- var prevDescriptor = prevComponent._descriptor;
361
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
362
+ var prevElement = prevComponent._currentElement;
363
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
362
364
  return ReactMount._updateRootComponent(
363
365
  prevComponent,
364
- nextDescriptor,
366
+ nextElement,
365
367
  container,
366
368
  callback
367
369
  );
@@ -377,7 +379,7 @@ var ReactMount = {
377
379
  var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
378
380
 
379
381
  var component = ReactMount._renderNewRootComponent(
380
- nextDescriptor,
382
+ nextElement,
381
383
  container,
382
384
  shouldReuseMarkup
383
385
  );
@@ -395,7 +397,8 @@ var ReactMount = {
395
397
  * @return {ReactComponent} Component instance rendered in `container`.
396
398
  */
397
399
  constructAndRenderComponent: function(constructor, props, container) {
398
- return ReactMount.renderComponent(constructor(props), container);
400
+ var element = createElement(constructor, props);
401
+ return ReactMount.render(element, container);
399
402
  },
400
403
 
401
404
  /**
@@ -654,9 +657,10 @@ var ReactMount = {
654
657
  false,
655
658
  'findComponentRoot(..., %s): Unable to find element. This probably ' +
656
659
  'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
657
- 'usually due to forgetting a <tbody> when using tables, nesting <p> ' +
658
- 'or <a> tags, or using non-SVG elements in an <svg> parent. Try ' +
659
- 'inspecting the child nodes of the element with React ID `%s`.',
660
+ 'usually due to forgetting a <tbody> when using tables, nesting tags ' +
661
+ 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
662
+ 'parent. ' +
663
+ 'Try inspecting the child nodes of the element with React ID `%s`.',
660
664
  targetID,
661
665
  ReactMount.getID(ancestorNode)
662
666
  ) : invariant(false));
@@ -678,4 +682,13 @@ var ReactMount = {
678
682
  purgeID: purgeID
679
683
  };
680
684
 
685
+ // Deprecations (remove for 0.13)
686
+ ReactMount.renderComponent = deprecated(
687
+ 'ReactMount',
688
+ 'renderComponent',
689
+ 'render',
690
+ this,
691
+ ReactMount.render
692
+ );
693
+
681
694
  module.exports = ReactMount;
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactMultiChild
17
10
  * @typechecks static-only
@@ -195,7 +188,7 @@ var ReactMultiChild = {
195
188
  if (children.hasOwnProperty(name)) {
196
189
  // The rendered children must be turned into instances as they're
197
190
  // mounted.
198
- var childInstance = instantiateReactComponent(child);
191
+ var childInstance = instantiateReactComponent(child, null);
199
192
  children[name] = childInstance;
200
193
  // Inlined for performance, see `ReactInstanceHandles.createReactID`.
201
194
  var rootID = this._rootNodeID + name;
@@ -286,12 +279,12 @@ var ReactMultiChild = {
286
279
  continue;
287
280
  }
288
281
  var prevChild = prevChildren && prevChildren[name];
289
- var prevDescriptor = prevChild && prevChild._descriptor;
290
- var nextDescriptor = nextChildren[name];
291
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
282
+ var prevElement = prevChild && prevChild._currentElement;
283
+ var nextElement = nextChildren[name];
284
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
292
285
  this.moveChild(prevChild, nextIndex, lastIndex);
293
286
  lastIndex = Math.max(prevChild._mountIndex, lastIndex);
294
- prevChild.receiveComponent(nextDescriptor, transaction);
287
+ prevChild.receiveComponent(nextElement, transaction);
295
288
  prevChild._mountIndex = nextIndex;
296
289
  } else {
297
290
  if (prevChild) {
@@ -300,7 +293,10 @@ var ReactMultiChild = {
300
293
  this._unmountChildByName(prevChild, name);
301
294
  }
302
295
  // The child must be instantiated before it's mounted.
303
- var nextChildInstance = instantiateReactComponent(nextDescriptor);
296
+ var nextChildInstance = instantiateReactComponent(
297
+ nextElement,
298
+ null
299
+ );
304
300
  this._mountChildByNameAtIndex(
305
301
  nextChildInstance, name, nextIndex, transaction
306
302
  );
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactMultiChildUpdateTypes
17
10
  */
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright 2014, 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
+ * @providesModule ReactNativeComponent
10
+ */
11
+
12
+ "use strict";
13
+
14
+ var assign = require("./Object.assign");
15
+ var invariant = require("./invariant");
16
+
17
+ var genericComponentClass = null;
18
+ // This registry keeps track of wrapper classes around native tags
19
+ var tagToComponentClass = {};
20
+
21
+ var ReactNativeComponentInjection = {
22
+ // This accepts a class that receives the tag string. This is a catch all
23
+ // that can render any kind of tag.
24
+ injectGenericComponentClass: function(componentClass) {
25
+ genericComponentClass = componentClass;
26
+ },
27
+ // This accepts a keyed object with classes as values. Each key represents a
28
+ // tag. That particular tag will use this class instead of the generic one.
29
+ injectComponentClasses: function(componentClasses) {
30
+ assign(tagToComponentClass, componentClasses);
31
+ }
32
+ };
33
+
34
+ /**
35
+ * Create an internal class for a specific tag.
36
+ *
37
+ * @param {string} tag The tag for which to create an internal instance.
38
+ * @param {any} props The props passed to the instance constructor.
39
+ * @return {ReactComponent} component The injected empty component.
40
+ */
41
+ function createInstanceForTag(tag, props, parentType) {
42
+ var componentClass = tagToComponentClass[tag];
43
+ if (componentClass == null) {
44
+ ("production" !== process.env.NODE_ENV ? invariant(
45
+ genericComponentClass,
46
+ 'There is no registered component for the tag %s',
47
+ tag
48
+ ) : invariant(genericComponentClass));
49
+ return new genericComponentClass(tag, props);
50
+ }
51
+ if (parentType === tag) {
52
+ // Avoid recursion
53
+ ("production" !== process.env.NODE_ENV ? invariant(
54
+ genericComponentClass,
55
+ 'There is no registered component for the tag %s',
56
+ tag
57
+ ) : invariant(genericComponentClass));
58
+ return new genericComponentClass(tag, props);
59
+ }
60
+ // Unwrap legacy factories
61
+ return new componentClass.type(props);
62
+ }
63
+
64
+ var ReactNativeComponent = {
65
+ createInstanceForTag: createInstanceForTag,
66
+ injection: ReactNativeComponentInjection
67
+ };
68
+
69
+ module.exports = ReactNativeComponent;
package/lib/ReactOwner.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactOwner
17
10
  */
package/lib/ReactPerf.js CHANGED
@@ -1,17 +1,10 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactPerf
17
10
  * @typechecks static-only
@@ -47,7 +40,7 @@ var ReactPerf = {
47
40
  measure: function(objName, fnName, func) {
48
41
  if ("production" !== process.env.NODE_ENV) {
49
42
  var measuredFunc = null;
50
- return function() {
43
+ var wrapper = function() {
51
44
  if (ReactPerf.enableMeasure) {
52
45
  if (!measuredFunc) {
53
46
  measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
@@ -56,6 +49,8 @@ var ReactPerf = {
56
49
  }
57
50
  return func.apply(this, arguments);
58
51
  };
52
+ wrapper.displayName = objName + '_' + fnName;
53
+ return wrapper;
59
54
  }
60
55
  return func;
61
56
  },
@@ -1,27 +1,23 @@
1
1
  /**
2
- * Copyright 2013-2014 Facebook, Inc.
2
+ * Copyright 2013-2014, Facebook, Inc.
3
+ * All rights reserved.
3
4
  *
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.
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.
15
8
  *
16
9
  * @providesModule ReactPropTransferer
17
10
  */
18
11
 
19
12
  "use strict";
20
13
 
14
+ var assign = require("./Object.assign");
21
15
  var emptyFunction = require("./emptyFunction");
22
16
  var invariant = require("./invariant");
23
17
  var joinClasses = require("./joinClasses");
24
- var merge = require("./merge");
18
+ var warning = require("./warning");
19
+
20
+ var didWarn = false;
25
21
 
26
22
  /**
27
23
  * Creates a transfer strategy that will merge prop values using the supplied
@@ -44,7 +40,7 @@ var transferStrategyMerge = createTransferStrategy(function(a, b) {
44
40
  // `merge` overrides the first object's (`props[key]` above) keys using the
45
41
  // second object's (`value`) keys. An object's style's existing `propA` would
46
42
  // get overridden. Flip the order here.
47
- return merge(b, a);
43
+ return assign({}, b, a);
48
44
  });
49
45
 
50
46
  /**
@@ -61,14 +57,6 @@ var TransferStrategies = {
61
57
  * Transfer the `className` prop by merging them.
62
58
  */
63
59
  className: createTransferStrategy(joinClasses),
64
- /**
65
- * Never transfer the `key` prop.
66
- */
67
- key: emptyFunction,
68
- /**
69
- * Never transfer the `ref` prop.
70
- */
71
- ref: emptyFunction,
72
60
  /**
73
61
  * Transfer the `style` prop (which is an object) by merging them.
74
62
  */
@@ -118,7 +106,7 @@ var ReactPropTransferer = {
118
106
  * @return {object} a new object containing both sets of props merged.
119
107
  */
120
108
  mergeProps: function(oldProps, newProps) {
121
- return transferInto(merge(oldProps), newProps);
109
+ return transferInto(assign({}, oldProps), newProps);
122
110
  },
123
111
 
124
112
  /**
@@ -134,26 +122,39 @@ var ReactPropTransferer = {
134
122
  *
135
123
  * This is usually used to pass down props to a returned root component.
136
124
  *
137
- * @param {ReactDescriptor} descriptor Component receiving the properties.
138
- * @return {ReactDescriptor} The supplied `component`.
125
+ * @param {ReactElement} element Component receiving the properties.
126
+ * @return {ReactElement} The supplied `component`.
139
127
  * @final
140
128
  * @protected
141
129
  */
142
- transferPropsTo: function(descriptor) {
130
+ transferPropsTo: function(element) {
143
131
  ("production" !== process.env.NODE_ENV ? invariant(
144
- descriptor._owner === this,
132
+ element._owner === this,
145
133
  '%s: You can\'t call transferPropsTo() on a component that you ' +
146
134
  'don\'t own, %s. This usually means you are calling ' +
147
135
  'transferPropsTo() on a component passed in as props or children.',
148
136
  this.constructor.displayName,
149
- descriptor.type.displayName
150
- ) : invariant(descriptor._owner === this));
151
-
152
- // Because descriptors are immutable we have to merge into the existing
137
+ typeof element.type === 'string' ?
138
+ element.type :
139
+ element.type.displayName
140
+ ) : invariant(element._owner === this));
141
+
142
+ if ("production" !== process.env.NODE_ENV) {
143
+ if (!didWarn) {
144
+ didWarn = true;
145
+ ("production" !== process.env.NODE_ENV ? warning(
146
+ false,
147
+ 'transferPropsTo is deprecated. ' +
148
+ 'See http://fb.me/react-transferpropsto for more information.'
149
+ ) : null);
150
+ }
151
+ }
152
+
153
+ // Because elements are immutable we have to merge into the existing
153
154
  // props object rather than clone it.
154
- transferInto(descriptor.props, this.props);
155
+ transferInto(element.props, this.props);
155
156
 
156
- return descriptor;
157
+ return element;
157
158
  }
158
159
 
159
160
  }