react 0.12.2 → 0.13.0-beta.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 (184) hide show
  1. package/dist/JSXTransformer.js +986 -511
  2. package/dist/react-with-addons.js +6076 -4560
  3. package/dist/react-with-addons.min.js +6 -7
  4. package/dist/react.js +5386 -4170
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +388 -115
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +2 -2
  10. package/lib/CSSPropertyOperations.js +58 -11
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +4 -4
  13. package/lib/ClientReactRootIndex.js +2 -2
  14. package/lib/DOMChildrenOperations.js +10 -47
  15. package/lib/DOMProperty.js +2 -2
  16. package/lib/DOMPropertyOperations.js +11 -16
  17. package/lib/Danger.js +8 -7
  18. package/lib/DefaultEventPluginOrder.js +3 -4
  19. package/lib/EnterLeaveEventPlugin.js +2 -2
  20. package/lib/EventConstants.js +2 -2
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +10 -8
  23. package/lib/EventPluginRegistry.js +2 -2
  24. package/lib/EventPluginUtils.js +4 -4
  25. package/lib/EventPropagators.js +2 -2
  26. package/lib/ExecutionEnvironment.js +3 -4
  27. package/lib/FallbackCompositionState.js +89 -0
  28. package/lib/HTMLDOMPropertyConfig.js +23 -10
  29. package/lib/LinkedStateMixin.js +2 -2
  30. package/lib/LinkedValueUtils.js +4 -4
  31. package/lib/LocalEventTrapMixin.js +10 -3
  32. package/lib/MobileSafariClickEventPlugin.js +2 -2
  33. package/lib/Object.assign.js +4 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +19 -58
  36. package/lib/ReactBrowserComponentMixin.js +4 -14
  37. package/lib/ReactBrowserEventEmitter.js +6 -8
  38. package/lib/ReactCSSTransitionGroup.js +5 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +20 -7
  40. package/lib/ReactChildReconciler.js +125 -0
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +918 -0
  43. package/lib/ReactComponent.js +98 -406
  44. package/lib/ReactComponentBrowserEnvironment.js +11 -84
  45. package/lib/ReactComponentEnvironment.js +57 -0
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +574 -1140
  48. package/lib/ReactContext.js +17 -3
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +4 -9
  51. package/lib/ReactDOMButton.js +6 -7
  52. package/lib/ReactDOMComponent.js +123 -105
  53. package/lib/ReactDOMForm.js +6 -7
  54. package/lib/ReactDOMIDOperations.js +59 -77
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +5 -7
  57. package/lib/ReactDOMInput.js +6 -7
  58. package/lib/ReactDOMOption.js +6 -7
  59. package/lib/ReactDOMSelect.js +58 -66
  60. package/lib/ReactDOMSelection.js +7 -3
  61. package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
  62. package/lib/ReactDOMTextarea.js +6 -7
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +39 -9
  65. package/lib/ReactDefaultPerf.js +17 -8
  66. package/lib/ReactDefaultPerfAnalysis.js +2 -2
  67. package/lib/ReactElement.js +23 -15
  68. package/lib/ReactElementValidator.js +206 -89
  69. package/lib/ReactEmptyComponent.js +33 -15
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +2 -2
  72. package/lib/ReactEventListener.js +4 -5
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +8 -6
  75. package/lib/ReactInputSelection.js +4 -5
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +47 -0
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +2 -2
  80. package/lib/ReactMarkupChecksum.js +2 -2
  81. package/lib/ReactMount.js +264 -71
  82. package/lib/ReactMultiChild.js +50 -48
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +59 -25
  85. package/lib/ReactOwner.js +5 -49
  86. package/lib/ReactPerf.js +22 -2
  87. package/lib/ReactPropTransferer.js +3 -58
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +17 -25
  91. package/lib/ReactPutListenerQueue.js +2 -2
  92. package/lib/ReactReconcileTransaction.js +2 -2
  93. package/lib/ReactReconciler.js +121 -0
  94. package/lib/ReactRef.js +69 -0
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +6 -4
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +113 -27
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +53 -12
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +54 -62
  105. package/lib/ReactWithAddons.js +4 -2
  106. package/lib/SVGDOMPropertyConfig.js +2 -2
  107. package/lib/SelectEventPlugin.js +4 -4
  108. package/lib/ServerReactRootIndex.js +2 -2
  109. package/lib/SimpleEventPlugin.js +4 -4
  110. package/lib/SyntheticClipboardEvent.js +2 -3
  111. package/lib/SyntheticCompositionEvent.js +2 -3
  112. package/lib/SyntheticDragEvent.js +2 -2
  113. package/lib/SyntheticEvent.js +12 -4
  114. package/lib/SyntheticFocusEvent.js +2 -2
  115. package/lib/SyntheticInputEvent.js +2 -3
  116. package/lib/SyntheticKeyboardEvent.js +2 -2
  117. package/lib/SyntheticMouseEvent.js +3 -5
  118. package/lib/SyntheticTouchEvent.js +2 -2
  119. package/lib/SyntheticUIEvent.js +2 -2
  120. package/lib/SyntheticWheelEvent.js +2 -2
  121. package/lib/Transaction.js +4 -4
  122. package/lib/ViewportMetrics.js +3 -6
  123. package/lib/accumulateInto.js +2 -2
  124. package/lib/adler32.js +2 -2
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +4 -4
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +2 -2
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
  137. package/lib/findDOMNode.js +51 -0
  138. package/lib/flattenChildren.js +12 -23
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +2 -2
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +2 -2
  143. package/lib/getEventKey.js +2 -2
  144. package/lib/getEventModifierState.js +2 -2
  145. package/lib/getEventTarget.js +2 -2
  146. package/lib/getIteratorFn.js +42 -0
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +3 -3
  149. package/lib/getReactRootElementInContainer.js +2 -2
  150. package/lib/getTextContentAccessor.js +2 -2
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +90 -68
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +4 -5
  158. package/lib/isTextInputElement.js +3 -4
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +2 -2
  161. package/lib/keyMirror.js +2 -2
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +5 -6
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +13 -2
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +2 -2
  172. package/lib/shouldUpdateReactComponent.js +71 -7
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +114 -56
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/CompositionEventPlugin.js +0 -257
  179. package/lib/ReactLegacyElement.js +0 -243
  180. package/lib/copyProperties.js +0 -54
  181. package/lib/deprecated.js +0 -47
  182. package/lib/merge.js +0 -34
  183. package/lib/mergeInto.js +0 -24
  184. package/lib/monitorCodeUse.js +0 -30
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2014, Facebook, Inc.
2
+ * Copyright 2014-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -11,6 +11,8 @@
11
11
 
12
12
  // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
13
13
 
14
+ 'use strict';
15
+
14
16
  function assign(target, sources) {
15
17
  if (target == null) {
16
18
  throw new TypeError('Object.assign target cannot be null or undefined');
@@ -40,6 +42,6 @@ function assign(target, sources) {
40
42
  }
41
43
 
42
44
  return to;
43
- };
45
+ }
44
46
 
45
47
  module.exports = assign;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,7 +9,7 @@
9
9
  * @providesModule PooledClass
10
10
  */
11
11
 
12
- "use strict";
12
+ 'use strict';
13
13
 
14
14
  var invariant = require("./invariant");
15
15
 
package/lib/React.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,31 +9,30 @@
9
9
  * @providesModule React
10
10
  */
11
11
 
12
- "use strict";
12
+ /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
13
+
14
+ 'use strict';
13
15
 
14
- var DOMPropertyOperations = require("./DOMPropertyOperations");
15
16
  var EventPluginUtils = require("./EventPluginUtils");
16
17
  var ReactChildren = require("./ReactChildren");
17
18
  var ReactComponent = require("./ReactComponent");
18
- var ReactCompositeComponent = require("./ReactCompositeComponent");
19
+ var ReactClass = require("./ReactClass");
19
20
  var ReactContext = require("./ReactContext");
20
21
  var ReactCurrentOwner = require("./ReactCurrentOwner");
21
22
  var ReactElement = require("./ReactElement");
22
23
  var ReactElementValidator = require("./ReactElementValidator");
23
24
  var ReactDOM = require("./ReactDOM");
24
- var ReactDOMComponent = require("./ReactDOMComponent");
25
+ var ReactDOMTextComponent = require("./ReactDOMTextComponent");
25
26
  var ReactDefaultInjection = require("./ReactDefaultInjection");
26
27
  var ReactInstanceHandles = require("./ReactInstanceHandles");
27
- var ReactLegacyElement = require("./ReactLegacyElement");
28
28
  var ReactMount = require("./ReactMount");
29
- var ReactMultiChild = require("./ReactMultiChild");
30
29
  var ReactPerf = require("./ReactPerf");
31
30
  var ReactPropTypes = require("./ReactPropTypes");
31
+ var ReactReconciler = require("./ReactReconciler");
32
32
  var ReactServerRendering = require("./ReactServerRendering");
33
- var ReactTextComponent = require("./ReactTextComponent");
34
33
 
35
34
  var assign = require("./Object.assign");
36
- var deprecated = require("./deprecated");
35
+ var findDOMNode = require("./findDOMNode");
37
36
  var onlyChild = require("./onlyChild");
38
37
 
39
38
  ReactDefaultInjection.inject();
@@ -46,14 +45,6 @@ if ("production" !== process.env.NODE_ENV) {
46
45
  createFactory = ReactElementValidator.createFactory;
47
46
  }
48
47
 
49
- // TODO: Drop legacy elements once classes no longer export these factories
50
- createElement = ReactLegacyElement.wrapCreateElement(
51
- createElement
52
- );
53
- createFactory = ReactLegacyElement.wrapCreateFactory(
54
- createFactory
55
- );
56
-
57
48
  var render = ReactPerf.measure('React', 'render', ReactMount.render);
58
49
 
59
50
  var React = {
@@ -63,56 +54,31 @@ var React = {
63
54
  count: ReactChildren.count,
64
55
  only: onlyChild
65
56
  },
57
+ Component: ReactComponent,
66
58
  DOM: ReactDOM,
67
59
  PropTypes: ReactPropTypes,
68
60
  initializeTouchEvents: function(shouldUseTouch) {
69
61
  EventPluginUtils.useTouchEvents = shouldUseTouch;
70
62
  },
71
- createClass: ReactCompositeComponent.createClass,
63
+ createClass: ReactClass.createClass,
72
64
  createElement: createElement,
73
65
  createFactory: createFactory,
66
+ createMixin: function(mixin) {
67
+ // Currently a noop. Will be used to validate and trace mixins.
68
+ return mixin;
69
+ },
74
70
  constructAndRenderComponent: ReactMount.constructAndRenderComponent,
75
71
  constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
72
+ findDOMNode: findDOMNode,
76
73
  render: render,
77
74
  renderToString: ReactServerRendering.renderToString,
78
75
  renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
79
76
  unmountComponentAtNode: ReactMount.unmountComponentAtNode,
80
- isValidClass: ReactLegacyElement.isValidClass,
81
77
  isValidElement: ReactElement.isValidElement,
82
78
  withContext: ReactContext.withContext,
83
79
 
84
80
  // Hook for JSX spread, don't use this for anything else.
85
- __spread: assign,
86
-
87
- // Deprecations (remove for 0.13)
88
- renderComponent: deprecated(
89
- 'React',
90
- 'renderComponent',
91
- 'render',
92
- this,
93
- render
94
- ),
95
- renderComponentToString: deprecated(
96
- 'React',
97
- 'renderComponentToString',
98
- 'renderToString',
99
- this,
100
- ReactServerRendering.renderToString
101
- ),
102
- renderComponentToStaticMarkup: deprecated(
103
- 'React',
104
- 'renderComponentToStaticMarkup',
105
- 'renderToStaticMarkup',
106
- this,
107
- ReactServerRendering.renderToStaticMarkup
108
- ),
109
- isValidComponent: deprecated(
110
- 'React',
111
- 'isValidComponent',
112
- 'isValidElement',
113
- this,
114
- ReactElement.isValidElement
115
- )
81
+ __spread: assign
116
82
  };
117
83
 
118
84
  // Inject the runtime into a devtools global hook regardless of browser.
@@ -121,14 +87,11 @@ if (
121
87
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
122
88
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
123
89
  __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
124
- Component: ReactComponent,
125
90
  CurrentOwner: ReactCurrentOwner,
126
- DOMComponent: ReactDOMComponent,
127
- DOMPropertyOperations: DOMPropertyOperations,
128
91
  InstanceHandles: ReactInstanceHandles,
129
92
  Mount: ReactMount,
130
- MultiChild: ReactMultiChild,
131
- TextComponent: ReactTextComponent
93
+ Reconciler: ReactReconciler,
94
+ TextComponent: ReactDOMTextComponent
132
95
  });
133
96
  }
134
97
 
@@ -177,8 +140,6 @@ if ("production" !== process.env.NODE_ENV) {
177
140
  }
178
141
  }
179
142
 
180
- // Version exists only in the open-source version of React, not in Facebook's
181
- // internal version.
182
- React.version = '0.12.2';
143
+ React.version = '0.13.0-beta.2';
183
144
 
184
145
  module.exports = React;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -9,12 +9,9 @@
9
9
  * @providesModule ReactBrowserComponentMixin
10
10
  */
11
11
 
12
- "use strict";
12
+ 'use strict';
13
13
 
14
- var ReactEmptyComponent = require("./ReactEmptyComponent");
15
- var ReactMount = require("./ReactMount");
16
-
17
- var invariant = require("./invariant");
14
+ var findDOMNode = require("./findDOMNode");
18
15
 
19
16
  var ReactBrowserComponentMixin = {
20
17
  /**
@@ -25,14 +22,7 @@ var ReactBrowserComponentMixin = {
25
22
  * @protected
26
23
  */
27
24
  getDOMNode: function() {
28
- ("production" !== process.env.NODE_ENV ? invariant(
29
- this.isMounted(),
30
- 'getDOMNode(): A component must be mounted to have a DOM node.'
31
- ) : invariant(this.isMounted()));
32
- if (ReactEmptyComponent.isNullComponentID(this._rootNodeID)) {
33
- return null;
34
- }
35
- return ReactMount.getNode(this._rootNodeID);
25
+ return findDOMNode(this);
36
26
  }
37
27
  };
38
28
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -10,7 +10,7 @@
10
10
  * @typechecks static-only
11
11
  */
12
12
 
13
- "use strict";
13
+ 'use strict';
14
14
 
15
15
  var EventConstants = require("./EventConstants");
16
16
  var EventPluginHub = require("./EventPluginHub");
@@ -126,7 +126,7 @@ var topEventMapping = {
126
126
  /**
127
127
  * To ensure no conflicts with other potential React instances on the page
128
128
  */
129
- var topListenersIDKey = "_reactListenersID" + String(Math.random()).slice(2);
129
+ var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2);
130
130
 
131
131
  function getListeningForDocument(mountAt) {
132
132
  // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
@@ -183,8 +183,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
183
183
  */
184
184
  isEnabled: function() {
185
185
  return !!(
186
- ReactBrowserEventEmitter.ReactEventListener &&
187
- ReactBrowserEventEmitter.ReactEventListener.isEnabled()
186
+ (ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled())
188
187
  );
189
188
  },
190
189
 
@@ -219,8 +218,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
219
218
  for (var i = 0, l = dependencies.length; i < l; i++) {
220
219
  var dependency = dependencies[i];
221
220
  if (!(
222
- isListening.hasOwnProperty(dependency) &&
223
- isListening[dependency]
221
+ (isListening.hasOwnProperty(dependency) && isListening[dependency])
224
222
  )) {
225
223
  if (dependency === topLevelTypes.topWheel) {
226
224
  if (isEventSupported('wheel')) {
@@ -328,7 +326,7 @@ var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
328
326
  *
329
327
  * @see http://www.quirksmode.org/dom/events/scroll.html
330
328
  */
331
- ensureScrollValueMonitoring: function(){
329
+ ensureScrollValueMonitoring: function() {
332
330
  if (!isMonitoringScrollValue) {
333
331
  var refresh = ViewportMetrics.refreshScrollValues;
334
332
  ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -10,7 +10,7 @@
10
10
  * @providesModule ReactCSSTransitionGroup
11
11
  */
12
12
 
13
- "use strict";
13
+ 'use strict';
14
14
 
15
15
  var React = require("./React");
16
16
 
@@ -28,12 +28,14 @@ var ReactCSSTransitionGroup = React.createClass({
28
28
 
29
29
  propTypes: {
30
30
  transitionName: React.PropTypes.string.isRequired,
31
+ transitionAppear: React.PropTypes.bool,
31
32
  transitionEnter: React.PropTypes.bool,
32
33
  transitionLeave: React.PropTypes.bool
33
34
  },
34
35
 
35
36
  getDefaultProps: function() {
36
37
  return {
38
+ transitionAppear: false,
37
39
  transitionEnter: true,
38
40
  transitionLeave: true
39
41
  };
@@ -46,6 +48,7 @@ var ReactCSSTransitionGroup = React.createClass({
46
48
  return ReactCSSTransitionGroupChild(
47
49
  {
48
50
  name: this.props.transitionName,
51
+ appear: this.props.transitionAppear,
49
52
  enter: this.props.transitionEnter,
50
53
  leave: this.props.transitionLeave
51
54
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2013-2014, Facebook, Inc.
2
+ * Copyright 2013-2015, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -10,7 +10,7 @@
10
10
  * @providesModule ReactCSSTransitionGroupChild
11
11
  */
12
12
 
13
- "use strict";
13
+ 'use strict';
14
14
 
15
15
  var React = require("./React");
16
16
 
@@ -18,6 +18,7 @@ var CSSCore = require("./CSSCore");
18
18
  var ReactTransitionEvents = require("./ReactTransitionEvents");
19
19
 
20
20
  var onlyChild = require("./onlyChild");
21
+ var warning = require("./warning");
21
22
 
22
23
  // We don't remove the element from the DOM until we receive an animationend or
23
24
  // transitionend event. If the user screws up and forgets to add an animation
@@ -31,12 +32,14 @@ var noEventListener = null;
31
32
 
32
33
  if ("production" !== process.env.NODE_ENV) {
33
34
  noEventListener = function() {
34
- console.warn(
35
+ ("production" !== process.env.NODE_ENV ? warning(
36
+ false,
35
37
  'transition(): tried to perform an animation without ' +
36
38
  'an animationend or transitionend event after timeout (' +
37
- NO_EVENT_TIMEOUT + 'ms). You should either disable this ' +
38
- 'transition in JS or add a CSS animation/transition.'
39
- );
39
+ '%sms). You should either disable this ' +
40
+ 'transition in JS or add a CSS animation/transition.',
41
+ NO_EVENT_TIMEOUT
42
+ ) : null);
40
43
  };
41
44
  }
42
45
 
@@ -64,7 +67,9 @@ var ReactCSSTransitionGroupChild = React.createClass({
64
67
 
65
68
  // Usually this optional callback is used for informing an owner of
66
69
  // a leave animation and telling it to remove the child.
67
- finishCallback && finishCallback();
70
+ if (finishCallback) {
71
+ finishCallback();
72
+ }
68
73
  };
69
74
 
70
75
  ReactTransitionEvents.addEndEventListener(node, endListener);
@@ -107,6 +112,14 @@ var ReactCSSTransitionGroupChild = React.createClass({
107
112
  }
108
113
  },
109
114
 
115
+ componentWillAppear: function(done) {
116
+ if (this.props.appear) {
117
+ this.transition('appear', done);
118
+ } else {
119
+ done();
120
+ }
121
+ },
122
+
110
123
  componentWillEnter: function(done) {
111
124
  if (this.props.enter) {
112
125
  this.transition('enter', done);
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright 2014-2015, 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 ReactChildReconciler
10
+ * @typechecks static-only
11
+ */
12
+
13
+ 'use strict';
14
+
15
+ var ReactReconciler = require("./ReactReconciler");
16
+
17
+ var flattenChildren = require("./flattenChildren");
18
+ var instantiateReactComponent = require("./instantiateReactComponent");
19
+ var shouldUpdateReactComponent = require("./shouldUpdateReactComponent");
20
+
21
+ /**
22
+ * ReactChildReconciler provides helpers for initializing or updating a set of
23
+ * children. Its output is suitable for passing it onto ReactMultiChild which
24
+ * does diffed reordering and insertion.
25
+ */
26
+ var ReactChildReconciler = {
27
+
28
+ /**
29
+ * Generates a "mount image" for each of the supplied children. In the case
30
+ * of `ReactDOMComponent`, a mount image is a string of markup.
31
+ *
32
+ * @param {?object} nestedChildNodes Nested child maps.
33
+ * @return {?object} A set of child instances.
34
+ * @internal
35
+ */
36
+ instantiateChildren: function(nestedChildNodes, transaction, context) {
37
+ var children = flattenChildren(nestedChildNodes);
38
+ for (var name in children) {
39
+ if (children.hasOwnProperty(name)) {
40
+ var child = children[name];
41
+ // The rendered children must be turned into instances as they're
42
+ // mounted.
43
+ var childInstance = instantiateReactComponent(child, null);
44
+ children[name] = childInstance;
45
+ }
46
+ }
47
+ return children;
48
+ },
49
+
50
+ /**
51
+ * Updates the rendered children and returns a new set of children.
52
+ *
53
+ * @param {?object} prevChildren Previously initialized set of children.
54
+ * @param {?object} nextNestedChildNodes Nested child maps.
55
+ * @param {ReactReconcileTransaction} transaction
56
+ * @param {object} context
57
+ * @return {?object} A new set of child instances.
58
+ * @internal
59
+ */
60
+ updateChildren: function(
61
+ prevChildren,
62
+ nextNestedChildNodes,
63
+ transaction,
64
+ context) {
65
+ // We currently don't have a way to track moves here but if we use iterators
66
+ // instead of for..in we can zip the iterators and check if an item has
67
+ // moved.
68
+ // TODO: If nothing has changed, return the prevChildren object so that we
69
+ // can quickly bailout if nothing has changed.
70
+ var nextChildren = flattenChildren(nextNestedChildNodes);
71
+ if (!nextChildren && !prevChildren) {
72
+ return null;
73
+ }
74
+ var name;
75
+ for (name in nextChildren) {
76
+ if (!nextChildren.hasOwnProperty(name)) {
77
+ continue;
78
+ }
79
+ var prevChild = prevChildren && prevChildren[name];
80
+ var prevElement = prevChild && prevChild._currentElement;
81
+ var nextElement = nextChildren[name];
82
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
83
+ ReactReconciler.receiveComponent(
84
+ prevChild, nextElement, transaction, context
85
+ );
86
+ nextChildren[name] = prevChild;
87
+ } else {
88
+ if (prevChild) {
89
+ ReactReconciler.unmountComponent(prevChild, name);
90
+ }
91
+ // The child must be instantiated before it's mounted.
92
+ var nextChildInstance = instantiateReactComponent(
93
+ nextElement,
94
+ null
95
+ );
96
+ nextChildren[name] = nextChildInstance;
97
+ }
98
+ }
99
+ // Unmount children that are no longer present.
100
+ for (name in prevChildren) {
101
+ if (prevChildren.hasOwnProperty(name) &&
102
+ !(nextChildren && nextChildren.hasOwnProperty(name))) {
103
+ ReactReconciler.unmountComponent(prevChildren[name]);
104
+ }
105
+ }
106
+ return nextChildren;
107
+ },
108
+
109
+ /**
110
+ * Unmounts all rendered children. This should be used to clean up children
111
+ * when this component is unmounted.
112
+ *
113
+ * @param {?object} renderedChildren Previously initialized set of children.
114
+ * @internal
115
+ */
116
+ unmountChildren: function(renderedChildren) {
117
+ for (var name in renderedChildren) {
118
+ var renderedChild = renderedChildren[name];
119
+ ReactReconciler.unmountComponent(renderedChild);
120
+ }
121
+ }
122
+
123
+ };
124
+
125
+ module.exports = ReactChildReconciler;