react 0.14.0-alpha2 → 0.14.0-beta3

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 (196) hide show
  1. package/README.md +5 -2
  2. package/addons.js +6 -3
  3. package/dist/JSXTransformer.js +634 -274
  4. package/dist/react-with-addons.js +5350 -4954
  5. package/dist/react-with-addons.min.js +6 -6
  6. package/dist/react.js +4777 -4408
  7. package/dist/react.min.js +6 -5
  8. package/lib/{AutoFocusMixin.js → AutoFocusUtils.js} +15 -5
  9. package/lib/BeforeInputEventPlugin.js +13 -13
  10. package/lib/CSSProperty.js +3 -0
  11. package/lib/CSSPropertyOperations.js +13 -13
  12. package/lib/CallbackQueue.js +4 -4
  13. package/lib/ChangeEventPlugin.js +16 -14
  14. package/lib/DOMChildrenOperations.js +10 -6
  15. package/lib/DOMProperty.js +82 -117
  16. package/lib/DOMPropertyOperations.js +78 -33
  17. package/lib/Danger.js +14 -14
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +8 -8
  20. package/lib/EventConstants.js +23 -1
  21. package/lib/EventPluginHub.js +13 -13
  22. package/lib/EventPluginRegistry.js +8 -8
  23. package/lib/EventPluginUtils.js +17 -17
  24. package/lib/EventPropagators.js +7 -7
  25. package/lib/FallbackCompositionState.js +3 -3
  26. package/lib/HTMLDOMPropertyConfig.js +13 -3
  27. package/lib/LinkedStateMixin.js +2 -2
  28. package/lib/LinkedValueUtils.js +50 -38
  29. package/lib/MetaMatchers.js +118 -0
  30. package/lib/OrderedMap.js +453 -0
  31. package/lib/PooledClass.js +14 -2
  32. package/lib/React.js +6 -6
  33. package/lib/ReactBrowserComponentMixin.js +4 -4
  34. package/lib/ReactBrowserEventEmitter.js +30 -7
  35. package/lib/ReactCSSTransitionGroup.js +16 -5
  36. package/lib/ReactCSSTransitionGroupChild.js +20 -11
  37. package/lib/ReactChildReconciler.js +25 -18
  38. package/lib/ReactChildren.js +9 -9
  39. package/lib/ReactClass.js +65 -83
  40. package/lib/ReactComponent.js +22 -17
  41. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  42. package/lib/ReactComponentEnvironment.js +2 -2
  43. package/lib/ReactComponentWithPureRenderMixin.js +3 -3
  44. package/lib/ReactCompositeComponent.js +80 -111
  45. package/lib/ReactDOM.js +72 -158
  46. package/lib/ReactDOMButton.js +15 -26
  47. package/lib/ReactDOMComponent.js +378 -56
  48. package/lib/ReactDOMFactories.js +177 -0
  49. package/lib/ReactDOMIDOperations.js +23 -23
  50. package/lib/ReactDOMInput.js +83 -99
  51. package/lib/ReactDOMOption.js +25 -45
  52. package/lib/ReactDOMSelect.js +88 -98
  53. package/lib/ReactDOMSelection.js +3 -3
  54. package/lib/ReactDOMServer.js +2 -2
  55. package/lib/ReactDOMTextComponent.js +11 -11
  56. package/lib/ReactDOMTextarea.js +48 -61
  57. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  58. package/lib/ReactDefaultInjection.js +24 -71
  59. package/lib/ReactDefaultPerf.js +7 -7
  60. package/lib/ReactDefaultPerfAnalysis.js +6 -9
  61. package/lib/ReactElement.js +22 -83
  62. package/lib/ReactElementValidator.js +48 -117
  63. package/lib/ReactEmptyComponent.js +4 -4
  64. package/lib/ReactErrorUtils.js +1 -1
  65. package/lib/ReactEventEmitterMixin.js +3 -4
  66. package/lib/ReactEventListener.js +57 -12
  67. package/lib/ReactFragment.js +22 -17
  68. package/lib/ReactInjection.js +11 -11
  69. package/lib/ReactInputSelection.js +8 -7
  70. package/lib/ReactInstanceHandles.js +12 -12
  71. package/lib/ReactIsomorphic.js +11 -11
  72. package/lib/ReactLink.js +1 -1
  73. package/lib/ReactMarkupChecksum.js +6 -2
  74. package/lib/ReactMount.js +88 -88
  75. package/lib/ReactMultiChild.js +83 -22
  76. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  77. package/lib/ReactNativeComponent.js +3 -8
  78. package/lib/ReactNoopUpdateQueue.js +118 -0
  79. package/lib/ReactOwner.js +3 -3
  80. package/lib/ReactPerf.js +2 -2
  81. package/lib/ReactPropTransferer.js +3 -3
  82. package/lib/ReactPropTypeLocationNames.js +1 -1
  83. package/lib/ReactPropTypeLocations.js +1 -1
  84. package/lib/ReactPropTypes.js +49 -11
  85. package/lib/ReactReconcileTransaction.js +8 -8
  86. package/lib/ReactReconciler.js +18 -20
  87. package/lib/ReactRef.js +1 -1
  88. package/lib/ReactServerBatchingStrategy.js +23 -0
  89. package/lib/ReactServerRendering.js +22 -9
  90. package/lib/ReactServerRenderingTransaction.js +7 -7
  91. package/lib/ReactTestUtils.js +80 -58
  92. package/lib/ReactTransitionChildMapping.js +2 -2
  93. package/lib/ReactTransitionEvents.js +1 -1
  94. package/lib/ReactTransitionGroup.js +5 -6
  95. package/lib/ReactUpdateQueue.js +61 -36
  96. package/lib/ReactUpdates.js +14 -17
  97. package/lib/ReactWithAddons.js +14 -16
  98. package/lib/ResponderEventPlugin.js +514 -0
  99. package/lib/ResponderSyntheticEvent.js +40 -0
  100. package/lib/ResponderTouchHistoryStore.js +180 -0
  101. package/lib/SVGDOMPropertyConfig.js +1 -1
  102. package/lib/SelectEventPlugin.js +14 -15
  103. package/lib/SimpleEventPlugin.js +205 -29
  104. package/lib/SyntheticClipboardEvent.js +3 -3
  105. package/lib/SyntheticCompositionEvent.js +3 -3
  106. package/lib/SyntheticDragEvent.js +3 -3
  107. package/lib/SyntheticEvent.js +9 -8
  108. package/lib/SyntheticFocusEvent.js +3 -3
  109. package/lib/SyntheticInputEvent.js +3 -3
  110. package/lib/SyntheticKeyboardEvent.js +6 -6
  111. package/lib/SyntheticMouseEvent.js +5 -5
  112. package/lib/SyntheticTouchEvent.js +4 -4
  113. package/lib/SyntheticUIEvent.js +4 -4
  114. package/lib/SyntheticWheelEvent.js +3 -3
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +16 -10
  117. package/lib/accumulate.js +44 -0
  118. package/lib/accumulateInto.js +2 -2
  119. package/lib/adler32.js +19 -7
  120. package/lib/cloneWithProps.js +12 -7
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +47 -0
  124. package/lib/findDOMNode.js +11 -12
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/forEachAccumulated.js +1 -1
  127. package/lib/getEventCharCode.js +1 -1
  128. package/lib/getEventKey.js +1 -1
  129. package/lib/getEventModifierState.js +0 -1
  130. package/lib/getTestDocument.js +28 -0
  131. package/lib/getTextContentAccessor.js +1 -1
  132. package/lib/instantiateReactComponent.js +24 -20
  133. package/lib/isEventSupported.js +1 -1
  134. package/lib/isTextInputElement.js +2 -1
  135. package/lib/joinClasses.js +1 -1
  136. package/lib/onlyChild.js +3 -3
  137. package/lib/quoteAttributeValueForBrowser.js +1 -1
  138. package/lib/reactComponentExpect.js +210 -0
  139. package/lib/renderSubtreeIntoContainer.js +1 -1
  140. package/lib/setInnerHTML.js +2 -2
  141. package/lib/setTextContent.js +3 -3
  142. package/lib/shallowCompare.js +1 -1
  143. package/lib/sliceChildren.js +51 -0
  144. package/lib/traverseAllChildren.js +15 -14
  145. package/lib/update.js +13 -13
  146. package/lib/validateDOMNesting.js +14 -6
  147. package/lib/webcomponents.js +6379 -0
  148. package/package.json +4 -6
  149. package/react.js +53 -1
  150. package/addons/CSSTransitionGroup.js +0 -1
  151. package/addons/LinkedStateMixin.js +0 -1
  152. package/addons/Perf.js +0 -1
  153. package/addons/PureRenderMixin.js +0 -1
  154. package/addons/TestUtils.js +0 -1
  155. package/addons/TransitionGroup.js +0 -1
  156. package/addons/batchedUpdates.js +0 -1
  157. package/addons/cloneWithProps.js +0 -1
  158. package/addons/createFragment.js +0 -1
  159. package/addons/renderSubtreeIntoContainer.js +0 -1
  160. package/addons/shallowCompare.js +0 -1
  161. package/addons/update.js +0 -1
  162. package/lib/CSSCore.js +0 -97
  163. package/lib/EventListener.js +0 -84
  164. package/lib/ExecutionEnvironment.js +0 -38
  165. package/lib/LocalEventTrapMixin.js +0 -46
  166. package/lib/ReactContext.js +0 -32
  167. package/lib/ReactDOMClient.js +0 -85
  168. package/lib/ReactDOMForm.js +0 -47
  169. package/lib/ReactDOMIframe.js +0 -43
  170. package/lib/ReactDOMImg.js +0 -44
  171. package/lib/ReactLifeCycle.js +0 -35
  172. package/lib/camelize.js +0 -32
  173. package/lib/camelizeStyleName.js +0 -40
  174. package/lib/containsNode.js +0 -55
  175. package/lib/createArrayFromMixed.js +0 -85
  176. package/lib/createFullPageComponent.js +0 -51
  177. package/lib/createNodesFromMarkup.js +0 -84
  178. package/lib/emptyFunction.js +0 -38
  179. package/lib/emptyObject.js +0 -20
  180. package/lib/focusNode.js +0 -26
  181. package/lib/getActiveElement.js +0 -29
  182. package/lib/getMarkupWrap.js +0 -115
  183. package/lib/getUnboundedScrollPosition.js +0 -38
  184. package/lib/hyphenate.js +0 -33
  185. package/lib/hyphenateStyleName.js +0 -39
  186. package/lib/invariant.js +0 -49
  187. package/lib/isNode.js +0 -23
  188. package/lib/isTextNode.js +0 -25
  189. package/lib/keyMirror.js +0 -48
  190. package/lib/keyOf.js +0 -35
  191. package/lib/mapObject.js +0 -51
  192. package/lib/performance.js +0 -23
  193. package/lib/performanceNow.js +0 -28
  194. package/lib/shallowEqual.js +0 -48
  195. package/lib/toArray.js +0 -57
  196. package/lib/warning.js +0 -61
@@ -11,11 +11,11 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactUpdates = require("./ReactUpdates");
15
- var Transaction = require("./Transaction");
14
+ var ReactUpdates = require('./ReactUpdates');
15
+ var Transaction = require('./Transaction');
16
16
 
17
- var assign = require("./Object.assign");
18
- var emptyFunction = require("./emptyFunction");
17
+ var assign = require('./Object.assign');
18
+ var emptyFunction = require('fbjs/lib/emptyFunction');
19
19
 
20
20
  var RESET_BATCHED_UPDATES = {
21
21
  initialize: emptyFunction,
@@ -11,56 +11,28 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var BeforeInputEventPlugin = require("./BeforeInputEventPlugin");
15
- var ChangeEventPlugin = require("./ChangeEventPlugin");
16
- var ClientReactRootIndex = require("./ClientReactRootIndex");
17
- var DefaultEventPluginOrder = require("./DefaultEventPluginOrder");
18
- var EnterLeaveEventPlugin = require("./EnterLeaveEventPlugin");
19
- var ExecutionEnvironment = require("./ExecutionEnvironment");
20
- var HTMLDOMPropertyConfig = require("./HTMLDOMPropertyConfig");
21
- var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
22
- var ReactClass = require("./ReactClass");
23
- var ReactComponentBrowserEnvironment = require("./ReactComponentBrowserEnvironment");
24
- var ReactDefaultBatchingStrategy = require("./ReactDefaultBatchingStrategy");
25
- var ReactDOMComponent = require("./ReactDOMComponent");
26
- var ReactDOMButton = require("./ReactDOMButton");
27
- var ReactDOMForm = require("./ReactDOMForm");
28
- var ReactDOMImg = require("./ReactDOMImg");
29
- var ReactDOMIDOperations = require("./ReactDOMIDOperations");
30
- var ReactDOMIframe = require("./ReactDOMIframe");
31
- var ReactDOMInput = require("./ReactDOMInput");
32
- var ReactDOMOption = require("./ReactDOMOption");
33
- var ReactDOMSelect = require("./ReactDOMSelect");
34
- var ReactDOMTextarea = require("./ReactDOMTextarea");
35
- var ReactDOMTextComponent = require("./ReactDOMTextComponent");
36
- var ReactElement = require("./ReactElement");
37
- var ReactEventListener = require("./ReactEventListener");
38
- var ReactInjection = require("./ReactInjection");
39
- var ReactInstanceHandles = require("./ReactInstanceHandles");
40
- var ReactInstanceMap = require("./ReactInstanceMap");
41
- var ReactMount = require("./ReactMount");
42
- var ReactReconcileTransaction = require("./ReactReconcileTransaction");
43
- var SelectEventPlugin = require("./SelectEventPlugin");
44
- var ServerReactRootIndex = require("./ServerReactRootIndex");
45
- var SimpleEventPlugin = require("./SimpleEventPlugin");
46
- var SVGDOMPropertyConfig = require("./SVGDOMPropertyConfig");
47
-
48
- var createFullPageComponent = require("./createFullPageComponent");
49
-
50
- function autoGenerateWrapperClass(type) {
51
- return ReactClass.createClass({
52
- tagName: type.toUpperCase(),
53
- render: function () {
54
- // Copy owner down for debugging info
55
- var internalInstance = ReactInstanceMap.get(this);
56
- return new ReactElement(type, null, // key
57
- null, // ref
58
- internalInstance._currentElement._owner, // owner
59
- null, // context
60
- this.props);
61
- }
62
- });
63
- }
14
+ var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
15
+ var ChangeEventPlugin = require('./ChangeEventPlugin');
16
+ var ClientReactRootIndex = require('./ClientReactRootIndex');
17
+ var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
18
+ var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
19
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
20
+ var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
21
+ var ReactBrowserComponentMixin = require('./ReactBrowserComponentMixin');
22
+ var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
23
+ var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
24
+ var ReactDOMComponent = require('./ReactDOMComponent');
25
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
26
+ var ReactDOMTextComponent = require('./ReactDOMTextComponent');
27
+ var ReactEventListener = require('./ReactEventListener');
28
+ var ReactInjection = require('./ReactInjection');
29
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
30
+ var ReactMount = require('./ReactMount');
31
+ var ReactReconcileTransaction = require('./ReactReconcileTransaction');
32
+ var SelectEventPlugin = require('./SelectEventPlugin');
33
+ var ServerReactRootIndex = require('./ServerReactRootIndex');
34
+ var SimpleEventPlugin = require('./SimpleEventPlugin');
35
+ var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
64
36
 
65
37
  var alreadyInjected = false;
66
38
 
@@ -98,27 +70,8 @@ function inject() {
98
70
 
99
71
  ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent);
100
72
 
101
- ReactInjection.NativeComponent.injectAutoWrapper(autoGenerateWrapperClass);
102
-
103
- // This needs to happen before createFullPageComponent() otherwise the mixin
104
- // won't be included.
105
73
  ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
106
74
 
107
- ReactInjection.NativeComponent.injectComponentClasses({
108
- 'button': ReactDOMButton,
109
- 'form': ReactDOMForm,
110
- 'iframe': ReactDOMIframe,
111
- 'img': ReactDOMImg,
112
- 'input': ReactDOMInput,
113
- 'option': ReactDOMOption,
114
- 'select': ReactDOMSelect,
115
- 'textarea': ReactDOMTextarea,
116
-
117
- 'html': createFullPageComponent('html'),
118
- 'head': createFullPageComponent('head'),
119
- 'body': createFullPageComponent('body')
120
- });
121
-
122
75
  ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
123
76
  ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
124
77
 
@@ -132,10 +85,10 @@ function inject() {
132
85
  ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
133
86
  ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
134
87
 
135
- if ('production' !== process.env.NODE_ENV) {
88
+ if (process.env.NODE_ENV !== 'production') {
136
89
  var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
137
90
  if (/[?&]react_perf\b/.test(url)) {
138
- var ReactDefaultPerf = require("./ReactDefaultPerf");
91
+ var ReactDefaultPerf = require('./ReactDefaultPerf');
139
92
  ReactDefaultPerf.start();
140
93
  }
141
94
  }
@@ -12,12 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var DOMProperty = require("./DOMProperty");
16
- var ReactDefaultPerfAnalysis = require("./ReactDefaultPerfAnalysis");
17
- var ReactMount = require("./ReactMount");
18
- var ReactPerf = require("./ReactPerf");
15
+ var DOMProperty = require('./DOMProperty');
16
+ var ReactDefaultPerfAnalysis = require('./ReactDefaultPerfAnalysis');
17
+ var ReactMount = require('./ReactMount');
18
+ var ReactPerf = require('./ReactPerf');
19
19
 
20
- var performanceNow = require("./performanceNow");
20
+ var performanceNow = require('fbjs/lib/performanceNow');
21
21
 
22
22
  function roundFloat(val) {
23
23
  return Math.floor(val * 100) / 100;
@@ -103,8 +103,8 @@ var ReactDefaultPerf = {
103
103
  console.table(summary.map(function (item) {
104
104
  var result = {};
105
105
  result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
106
- result['type'] = item.type;
107
- result['args'] = JSON.stringify(item.args);
106
+ result.type = item.type;
107
+ result.args = JSON.stringify(item.args);
108
108
  return result;
109
109
  }));
110
110
  console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
@@ -11,7 +11,7 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var assign = require("./Object.assign");
14
+ var assign = require('./Object.assign');
15
15
 
16
16
  // Don't try to save users less than 1.2ms (a number I made up)
17
17
  var DONT_CARE_THRESHOLD = 1.2;
@@ -20,11 +20,11 @@ var DOM_OPERATION_TYPES = {
20
20
  INSERT_MARKUP: 'set innerHTML',
21
21
  MOVE_EXISTING: 'move',
22
22
  REMOVE_NODE: 'remove',
23
+ SET_MARKUP: 'set innerHTML',
23
24
  TEXT_CONTENT: 'set textContent',
24
25
  'updatePropertyByID': 'update attribute',
25
26
  'deletePropertyByID': 'delete attribute',
26
27
  'updateStylesByID': 'update styles',
27
- 'updateInnerHTMLByID': 'set innerHTML',
28
28
  'dangerouslyReplaceNodeWithMarkupByID': 'replace'
29
29
  };
30
30
 
@@ -43,11 +43,8 @@ function getTotalTime(measurements) {
43
43
 
44
44
  function getDOMSummary(measurements) {
45
45
  var items = [];
46
- for (var i = 0; i < measurements.length; i++) {
47
- var measurement = measurements[i];
48
- var id;
49
-
50
- for (id in measurement.writes) {
46
+ measurements.forEach(function (measurement) {
47
+ Object.keys(measurement.writes).forEach(function (id) {
51
48
  measurement.writes[id].forEach(function (write) {
52
49
  items.push({
53
50
  id: id,
@@ -55,8 +52,8 @@ function getDOMSummary(measurements) {
55
52
  args: write.args
56
53
  });
57
54
  });
58
- }
59
- }
55
+ });
56
+ });
60
57
  return items;
61
58
  }
62
59
 
@@ -11,79 +11,27 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactContext = require("./ReactContext");
15
- var ReactCurrentOwner = require("./ReactCurrentOwner");
14
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
16
15
 
17
- var assign = require("./Object.assign");
18
- var warning = require("./warning");
16
+ var assign = require('./Object.assign');
19
17
 
20
18
  var RESERVED_PROPS = {
21
19
  key: true,
22
20
  ref: true
23
21
  };
24
22
 
25
- /**
26
- * Warn for mutations.
27
- *
28
- * @internal
29
- * @param {object} object
30
- * @param {string} key
31
- */
32
- function defineWarningProperty(object, key) {
33
- Object.defineProperty(object, key, {
34
-
35
- configurable: false,
36
- enumerable: true,
37
-
38
- get: function () {
39
- if (!this._store) {
40
- return null;
41
- }
42
- return this._store[key];
43
- },
44
-
45
- set: function (value) {
46
- 'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set the %s property of the React element. Instead, ' + 'specify the correct value when initially creating the element.', key) : null;
47
- this._store[key] = value;
48
- }
49
-
50
- });
51
- }
52
-
53
- /**
54
- * This is updated to true if the membrane is successfully created.
55
- */
56
- var useMutationMembrane = false;
57
-
58
- /**
59
- * Warn for mutations.
60
- *
61
- * @internal
62
- * @param {object} element
63
- */
64
- function defineMutationMembrane(prototype) {
65
- try {
66
- var pseudoFrozenProperties = {
67
- props: true
68
- };
69
- for (var key in pseudoFrozenProperties) {
70
- defineWarningProperty(prototype, key);
71
- }
72
- useMutationMembrane = true;
73
- } catch (x) {}
74
- }
75
-
76
23
  /**
77
24
  * Base constructor for all React elements. This is only used to make this
78
25
  * work with a dynamic instanceof check. Nothing should live on this prototype.
79
26
  *
80
27
  * @param {*} type
81
- * @param {string|object} ref
82
28
  * @param {*} key
29
+ * @param {string|object} ref
30
+ * @param {*} owner
83
31
  * @param {*} props
84
32
  * @internal
85
33
  */
86
- var ReactElement = function (type, key, ref, owner, context, props) {
34
+ var ReactElement = function (type, key, ref, owner, props) {
87
35
  // Built-in properties that belong on the element
88
36
  this.type = type;
89
37
  this.key = key;
@@ -92,12 +40,14 @@ var ReactElement = function (type, key, ref, owner, context, props) {
92
40
  // Record the component responsible for creating this element.
93
41
  this._owner = owner;
94
42
 
95
- if ('production' !== process.env.NODE_ENV) {
96
- // The validation flag and props are currently mutative. We put them on
43
+ this.props = props;
44
+
45
+ if (process.env.NODE_ENV !== 'production') {
46
+ // The validation flag is currently mutative. We put it on
97
47
  // an external backing store so that we can freeze the whole object.
98
48
  // This can be replaced with a WeakMap once they are implemented in
99
49
  // commonly used development environments.
100
- this._store = { props: props, originalProps: assign({}, props) };
50
+ this._store = {};
101
51
 
102
52
  // To make comparing ReactElements easier for testing purposes, we make
103
53
  // the validation flag non-enumerable (where possible, which should
@@ -107,21 +57,15 @@ var ReactElement = function (type, key, ref, owner, context, props) {
107
57
  Object.defineProperty(this._store, 'validated', {
108
58
  configurable: false,
109
59
  enumerable: false,
110
- writable: true
60
+ writable: true,
61
+ value: false
111
62
  });
112
- } catch (x) {}
113
- this._store.validated = false;
114
-
115
- // We're not allowed to set props directly on the object so we early
116
- // return and rely on the prototype membrane to forward to the backing
117
- // store.
118
- if (useMutationMembrane) {
119
- Object.freeze(this);
120
- return;
63
+ } catch (x) {
64
+ this._store.validated = false;
121
65
  }
66
+ Object.freeze(this.props);
67
+ Object.freeze(this);
122
68
  }
123
-
124
- this.props = props;
125
69
  };
126
70
 
127
71
  // We intentionally don't expose the function on the constructor property.
@@ -130,10 +74,6 @@ ReactElement.prototype = {
130
74
  _isReactElement: true
131
75
  };
132
76
 
133
- if ('production' !== process.env.NODE_ENV) {
134
- defineMutationMembrane(ReactElement.prototype);
135
- }
136
-
137
77
  ReactElement.createElement = function (type, config, children) {
138
78
  var propName;
139
79
 
@@ -177,7 +117,7 @@ ReactElement.createElement = function (type, config, children) {
177
117
  }
178
118
  }
179
119
 
180
- return new ReactElement(type, key, ref, ReactCurrentOwner.current, ReactContext.current, props);
120
+ return new ReactElement(type, key, ref, ReactCurrentOwner.current, props);
181
121
  };
182
122
 
183
123
  ReactElement.createFactory = function (type) {
@@ -192,12 +132,13 @@ ReactElement.createFactory = function (type) {
192
132
  };
193
133
 
194
134
  ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
195
- var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, oldElement._context, newProps);
135
+ var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, newProps);
196
136
 
197
- if ('production' !== process.env.NODE_ENV) {
137
+ if (process.env.NODE_ENV !== 'production') {
198
138
  // If the key on the original is valid, then the clone is valid
199
139
  newElement._store.validated = oldElement._store.validated;
200
140
  }
141
+
201
142
  return newElement;
202
143
  };
203
144
 
@@ -244,7 +185,7 @@ ReactElement.cloneElement = function (element, config, children) {
244
185
  props.children = childArray;
245
186
  }
246
187
 
247
- return new ReactElement(element.type, key, ref, owner, element._context, props);
188
+ return new ReactElement(element.type, key, ref, owner, props);
248
189
  };
249
190
 
250
191
  /**
@@ -266,6 +207,4 @@ ReactElement.isValidElement = function (object) {
266
207
  return isElement;
267
208
  };
268
209
 
269
- module.exports = ReactElement;
270
-
271
- // IE will fail on defineProperty
210
+ module.exports = ReactElement;
@@ -18,16 +18,15 @@
18
18
 
19
19
  'use strict';
20
20
 
21
- var ReactElement = require("./ReactElement");
22
- var ReactFragment = require("./ReactFragment");
23
- var ReactPropTypeLocations = require("./ReactPropTypeLocations");
24
- var ReactPropTypeLocationNames = require("./ReactPropTypeLocationNames");
25
- var ReactCurrentOwner = require("./ReactCurrentOwner");
26
- var ReactNativeComponent = require("./ReactNativeComponent");
21
+ var ReactElement = require('./ReactElement');
22
+ var ReactFragment = require('./ReactFragment');
23
+ var ReactPropTypeLocations = require('./ReactPropTypeLocations');
24
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
25
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
27
26
 
28
- var getIteratorFn = require("./getIteratorFn");
29
- var invariant = require("./invariant");
30
- var warning = require("./warning");
27
+ var getIteratorFn = require('./getIteratorFn');
28
+ var invariant = require('fbjs/lib/invariant');
29
+ var warning = require('fbjs/lib/warning');
31
30
 
32
31
  function getDeclarationErrorAddendum() {
33
32
  if (ReactCurrentOwner.current) {
@@ -95,7 +94,12 @@ function validateExplicitKey(element, parentType) {
95
94
  }
96
95
  element._store.validated = true;
97
96
 
98
- warnAndMonitorForKeyUse('Each child in an array or iterator should have a unique "key" prop.', element, parentType);
97
+ var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
98
+ if (addenda === null) {
99
+ // we already showed the warning
100
+ return;
101
+ }
102
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
99
103
  }
100
104
 
101
105
  /**
@@ -111,42 +115,50 @@ function validatePropertyKey(name, element, parentType) {
111
115
  if (!NUMERIC_PROPERTY_REGEX.test(name)) {
112
116
  return;
113
117
  }
114
- warnAndMonitorForKeyUse('Child objects should have non-numeric keys so ordering is preserved.', element, parentType);
118
+ var addenda = getAddendaForKeyUse('numericKeys', element, parentType);
119
+ if (addenda === null) {
120
+ // we already showed the warning
121
+ return;
122
+ }
123
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Child objects should have non-numeric keys so ordering is preserved.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
115
124
  }
116
125
 
117
126
  /**
118
127
  * Shared warning and monitoring code for the key warnings.
119
128
  *
120
129
  * @internal
121
- * @param {string} message The base warning that gets output.
130
+ * @param {string} messageType A key used for de-duping warnings.
122
131
  * @param {ReactElement} element Component that requires a key.
123
132
  * @param {*} parentType element's parent's type.
133
+ * @returns {?object} A set of addenda to use in the warning message, or null
134
+ * if the warning has already been shown before (and shouldn't be shown again).
124
135
  */
125
- function warnAndMonitorForKeyUse(message, element, parentType) {
136
+ function getAddendaForKeyUse(messageType, element, parentType) {
126
137
  var ownerName = getCurrentOwnerDisplayName();
127
138
  var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
128
139
 
129
140
  var useName = ownerName || parentName;
130
- var memoizer = ownerHasKeyUseWarning[message] || (ownerHasKeyUseWarning[message] = {});
131
- if (memoizer.hasOwnProperty(useName)) {
132
- return;
141
+ var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
142
+ if (memoizer[useName]) {
143
+ return null;
133
144
  }
134
145
  memoizer[useName] = true;
135
146
 
136
- var parentOrOwnerAddendum = ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : '';
147
+ var addenda = {
148
+ parentOrOwner: ownerName ? ' Check the render method of ' + ownerName + '.' : parentName ? ' Check the React.render call using <' + parentName + '>.' : null,
149
+ url: ' See https://fb.me/react-warning-keys for more information.',
150
+ childOwner: null
151
+ };
137
152
 
138
153
  // Usually the current owner is the offender, but if it accepts children as a
139
154
  // property, it may be the creator of the child that's responsible for
140
155
  // assigning it a key.
141
- var childOwnerAddendum = '';
142
156
  if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
143
- // Name of the component that originally created this child.
144
- var childOwnerName = getName(element._owner);
145
-
146
- childOwnerAddendum = ' It was passed a child from ' + childOwnerName + '.';
157
+ // Give the component that originally created this child.
158
+ addenda.childOwner = ' It was passed a child from ' + getName(element._owner) + '.';
147
159
  }
148
160
 
149
- 'production' !== process.env.NODE_ENV ? warning(false, message + '%s%s See https://fb.me/react-warning-keys for more information.', parentOrOwnerAddendum, childOwnerAddendum) : null;
161
+ return addenda;
150
162
  }
151
163
 
152
164
  /**
@@ -212,93 +224,19 @@ function checkPropTypes(componentName, propTypes, props, location) {
212
224
  try {
213
225
  // This is intentionally an invariant that gets caught. It's the same
214
226
  // behavior as without this statement except with a better message.
215
- 'production' !== process.env.NODE_ENV ? invariant(typeof propTypes[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(typeof propTypes[propName] === 'function');
227
+ !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
216
228
  error = propTypes[propName](props, propName, componentName, location);
217
229
  } catch (ex) {
218
230
  error = ex;
219
231
  }
220
- 'production' !== process.env.NODE_ENV ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : null;
232
+ process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
221
233
  if (error instanceof Error && !(error.message in loggedTypeFailures)) {
222
234
  // Only monitor this failure once because there tends to be a lot of the
223
235
  // same error.
224
236
  loggedTypeFailures[error.message] = true;
225
237
 
226
238
  var addendum = getDeclarationErrorAddendum();
227
- 'production' !== process.env.NODE_ENV ? warning(false, 'Failed propType: %s%s', error.message, addendum) : null;
228
- }
229
- }
230
- }
231
- }
232
-
233
- var warnedPropsMutations = {};
234
-
235
- /**
236
- * Warn about mutating props when setting `propName` on `element`.
237
- *
238
- * @param {string} propName The string key within props that was set
239
- * @param {ReactElement} element
240
- */
241
- function warnForPropsMutation(propName, element) {
242
- var type = element.type;
243
- var elementName = typeof type === 'string' ? type : type.displayName;
244
- var ownerName = element._owner ? element._owner.getPublicInstance().constructor.displayName : null;
245
-
246
- var warningKey = propName + '|' + elementName + '|' + ownerName;
247
- if (warnedPropsMutations.hasOwnProperty(warningKey)) {
248
- return;
249
- }
250
- warnedPropsMutations[warningKey] = true;
251
-
252
- var elementInfo = '';
253
- if (elementName) {
254
- elementInfo = ' <' + elementName + ' />';
255
- }
256
- var ownerInfo = '';
257
- if (ownerName) {
258
- ownerInfo = ' The element was created by ' + ownerName + '.';
259
- }
260
-
261
- 'production' !== process.env.NODE_ENV ? warning(false, 'Don\'t set .props.%s of the React component%s. Instead, specify the ' + 'correct value when initially creating the element or use ' + 'React.cloneElement to make a new element with updated props.%s', propName, elementInfo, ownerInfo) : null;
262
- }
263
-
264
- // Inline Object.is polyfill
265
- function is(a, b) {
266
- if (a !== a) {
267
- // NaN
268
- return b !== b;
269
- }
270
- if (a === 0 && b === 0) {
271
- // +-0
272
- return 1 / a === 1 / b;
273
- }
274
- return a === b;
275
- }
276
-
277
- /**
278
- * Given an element, check if its props have been mutated since element
279
- * creation (or the last call to this function). In particular, check if any
280
- * new props have been added, which we can't directly catch by defining warning
281
- * properties on the props object.
282
- *
283
- * @param {ReactElement} element
284
- */
285
- function checkAndWarnForMutatedProps(element) {
286
- if (!element._store) {
287
- // Element was created using `new ReactElement` directly or with
288
- // `ReactElement.createElement`; skip mutation checking
289
- return;
290
- }
291
-
292
- var originalProps = element._store.originalProps;
293
- var props = element.props;
294
-
295
- for (var propName in props) {
296
- if (props.hasOwnProperty(propName)) {
297
- if (!originalProps.hasOwnProperty(propName) || !is(originalProps[propName], props[propName])) {
298
- warnForPropsMutation(propName, element);
299
-
300
- // Copy over the new value so that the two props objects match again
301
- originalProps[propName] = props[propName];
239
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
302
240
  }
303
241
  }
304
242
  }
@@ -311,32 +249,25 @@ function checkAndWarnForMutatedProps(element) {
311
249
  * @param {ReactElement} element
312
250
  */
313
251
  function validatePropTypes(element) {
314
- if (!(typeof element.type === 'string' || typeof element.type === 'function')) {
315
- // This has already warned. Don't throw.
252
+ var componentClass = element.type;
253
+ if (typeof componentClass !== 'function') {
316
254
  return;
317
255
  }
318
- // Extract the component class from the element. Converts string types
319
- // to a composite class which may have propTypes.
320
- // TODO: Validating a string's propTypes is not decoupled from the
321
- // rendering target which is problematic.
322
- var componentClass = ReactNativeComponent.getComponentClassForElement(element);
323
256
  var name = componentClass.displayName || componentClass.name;
324
257
  if (componentClass.propTypes) {
325
258
  checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
326
259
  }
327
260
  if (typeof componentClass.getDefaultProps === 'function') {
328
- 'production' !== process.env.NODE_ENV ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : null;
261
+ process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
329
262
  }
330
263
  }
331
264
 
332
265
  var ReactElementValidator = {
333
266
 
334
- checkAndWarnForMutatedProps: checkAndWarnForMutatedProps,
335
-
336
267
  createElement: function (type, props, children) {
337
268
  // We warn in this case but don't throw. We expect the element creation to
338
269
  // succeed and there will likely be errors in render.
339
- 'production' !== process.env.NODE_ENV ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : null;
270
+ process.env.NODE_ENV !== 'production' ? warning(typeof type === 'string' || typeof type === 'function', 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
340
271
 
341
272
  var element = ReactElement.createElement.apply(this, arguments);
342
273
 
@@ -360,19 +291,21 @@ var ReactElementValidator = {
360
291
  // Legacy hook TODO: Warn if this is accessed
361
292
  validatedFactory.type = type;
362
293
 
363
- if ('production' !== process.env.NODE_ENV) {
294
+ if (process.env.NODE_ENV !== 'production') {
364
295
  try {
365
296
  Object.defineProperty(validatedFactory, 'type', {
366
297
  enumerable: false,
367
298
  get: function () {
368
- 'production' !== process.env.NODE_ENV ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : null;
299
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
369
300
  Object.defineProperty(this, 'type', {
370
301
  value: type
371
302
  });
372
303
  return type;
373
304
  }
374
305
  });
375
- } catch (x) {}
306
+ } catch (x) {
307
+ // IE will fail on defineProperty (es5-shim/sham too)
308
+ }
376
309
  }
377
310
 
378
311
  return validatedFactory;
@@ -389,6 +322,4 @@ var ReactElementValidator = {
389
322
 
390
323
  };
391
324
 
392
- module.exports = ReactElementValidator;
393
-
394
- // IE will fail on defineProperty (es5-shim/sham too)
325
+ module.exports = ReactElementValidator;