react 0.14.0-beta1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/addons.js +8 -3
  2. package/dist/react-with-addons.js +5048 -4095
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +4555 -3729
  5. package/dist/react.min.js +6 -5
  6. package/lib/AutoFocusUtils.js +3 -3
  7. package/lib/BeforeInputEventPlugin.js +13 -13
  8. package/lib/CSSProperty.js +18 -3
  9. package/lib/CSSPropertyOperations.js +27 -14
  10. package/lib/CallbackQueue.js +4 -4
  11. package/lib/ChangeEventPlugin.js +15 -14
  12. package/lib/DOMChildrenOperations.js +22 -7
  13. package/lib/DOMProperty.js +8 -8
  14. package/lib/DOMPropertyOperations.js +23 -10
  15. package/lib/Danger.js +21 -16
  16. package/lib/DefaultEventPluginOrder.js +2 -2
  17. package/lib/EnterLeaveEventPlugin.js +18 -10
  18. package/lib/EventConstants.js +23 -1
  19. package/lib/EventPluginHub.js +29 -21
  20. package/lib/EventPluginRegistry.js +8 -8
  21. package/lib/EventPluginUtils.js +34 -38
  22. package/lib/EventPropagators.js +8 -8
  23. package/lib/FallbackCompositionState.js +9 -3
  24. package/lib/HTMLDOMPropertyConfig.js +24 -4
  25. package/lib/LinkedStateMixin.js +2 -2
  26. package/lib/LinkedValueUtils.js +8 -8
  27. package/lib/MetaMatchers.js +118 -0
  28. package/lib/OrderedMap.js +453 -0
  29. package/lib/PooledClass.js +3 -5
  30. package/lib/React.js +18 -7
  31. package/lib/ReactBrowserComponentMixin.js +4 -4
  32. package/lib/ReactBrowserEventEmitter.js +36 -7
  33. package/lib/ReactCSSTransitionGroup.js +35 -9
  34. package/lib/ReactCSSTransitionGroupChild.js +48 -30
  35. package/lib/ReactChildReconciler.js +24 -19
  36. package/lib/ReactChildren.js +72 -32
  37. package/lib/ReactClass.js +46 -46
  38. package/lib/ReactComponent.js +18 -16
  39. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  40. package/lib/ReactComponentEnvironment.js +2 -2
  41. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  42. package/lib/ReactCompositeComponent.js +95 -44
  43. package/lib/ReactDOM.js +74 -159
  44. package/lib/ReactDOMComponent.js +235 -93
  45. package/lib/ReactDOMFactories.js +177 -0
  46. package/lib/{emptyObject.js → ReactDOMFeatureFlags.js} +6 -8
  47. package/lib/ReactDOMIDOperations.js +8 -81
  48. package/lib/ReactDOMInput.js +18 -9
  49. package/lib/ReactDOMOption.js +7 -7
  50. package/lib/ReactDOMSelect.js +9 -9
  51. package/lib/ReactDOMSelection.js +19 -3
  52. package/lib/ReactDOMServer.js +5 -3
  53. package/lib/ReactDOMTextComponent.js +33 -20
  54. package/lib/ReactDOMTextarea.js +14 -12
  55. package/lib/ReactDefaultBatchingStrategy.js +4 -4
  56. package/lib/ReactDefaultInjection.js +23 -25
  57. package/lib/ReactDefaultPerf.js +17 -11
  58. package/lib/ReactDefaultPerfAnalysis.js +13 -12
  59. package/lib/ReactElement.js +85 -39
  60. package/lib/ReactElementValidator.js +47 -90
  61. package/lib/ReactEmptyComponent.js +26 -62
  62. package/lib/ReactEmptyComponentRegistry.js +48 -0
  63. package/lib/ReactErrorUtils.js +53 -9
  64. package/lib/ReactEventEmitterMixin.js +2 -2
  65. package/lib/ReactEventListener.js +33 -21
  66. package/lib/ReactFragment.js +27 -118
  67. package/lib/ReactInjection.js +10 -12
  68. package/lib/ReactInputSelection.js +4 -4
  69. package/lib/ReactInstanceHandles.js +10 -11
  70. package/lib/ReactIsomorphic.js +15 -11
  71. package/lib/ReactLink.js +2 -2
  72. package/lib/ReactMarkupChecksum.js +6 -2
  73. package/lib/ReactMount.js +186 -85
  74. package/lib/ReactMultiChild.js +119 -25
  75. package/lib/ReactMultiChildUpdateTypes.js +2 -1
  76. package/lib/ReactNativeComponent.js +3 -3
  77. package/lib/ReactNoopUpdateQueue.js +3 -3
  78. package/lib/ReactOwner.js +3 -3
  79. package/lib/ReactPerf.js +2 -2
  80. package/lib/ReactPropTransferer.js +3 -3
  81. package/lib/ReactPropTypeLocationNames.js +1 -1
  82. package/lib/ReactPropTypeLocations.js +1 -1
  83. package/lib/ReactPropTypes.js +38 -9
  84. package/lib/ReactReconcileTransaction.js +10 -8
  85. package/lib/ReactReconciler.js +5 -6
  86. package/lib/ReactRef.js +14 -2
  87. package/lib/ReactServerBatchingStrategy.js +5 -5
  88. package/lib/ReactServerRendering.js +12 -12
  89. package/lib/ReactServerRenderingTransaction.js +6 -5
  90. package/lib/ReactTestUtils.js +47 -39
  91. package/lib/ReactTransitionChildMapping.js +3 -6
  92. package/lib/ReactTransitionEvents.js +1 -1
  93. package/lib/ReactTransitionGroup.js +5 -6
  94. package/lib/ReactUpdateQueue.js +19 -19
  95. package/lib/ReactUpdates.js +15 -15
  96. package/lib/{performance.js → ReactVersion.js} +3 -12
  97. package/lib/ReactWithAddons.js +24 -15
  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 +19 -9
  103. package/lib/SimpleEventPlugin.js +198 -43
  104. package/lib/SyntheticClipboardEvent.js +1 -1
  105. package/lib/SyntheticCompositionEvent.js +1 -1
  106. package/lib/SyntheticDragEvent.js +1 -1
  107. package/lib/SyntheticEvent.js +18 -4
  108. package/lib/SyntheticFocusEvent.js +1 -1
  109. package/lib/SyntheticInputEvent.js +1 -1
  110. package/lib/SyntheticKeyboardEvent.js +4 -4
  111. package/lib/SyntheticMouseEvent.js +3 -3
  112. package/lib/SyntheticTouchEvent.js +2 -2
  113. package/lib/SyntheticUIEvent.js +2 -2
  114. package/lib/SyntheticWheelEvent.js +1 -1
  115. package/lib/TapEventPlugin.js +119 -0
  116. package/lib/Transaction.js +7 -7
  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 +11 -6
  121. package/lib/createHierarchyRenderer.js +85 -0
  122. package/lib/dangerousStyleValue.js +1 -1
  123. package/lib/deprecated.js +7 -6
  124. package/lib/findDOMNode.js +9 -9
  125. package/lib/flattenChildren.js +4 -4
  126. package/lib/getEventKey.js +1 -1
  127. package/lib/{isTextNode.js → getTestDocument.js} +7 -11
  128. package/lib/getTextContentAccessor.js +1 -1
  129. package/lib/instantiateReactComponent.js +15 -17
  130. package/lib/isEventSupported.js +1 -1
  131. package/lib/onlyChild.js +3 -3
  132. package/lib/quoteAttributeValueForBrowser.js +1 -1
  133. package/lib/reactComponentExpect.js +216 -0
  134. package/lib/renderSubtreeIntoContainer.js +1 -1
  135. package/lib/setInnerHTML.js +1 -1
  136. package/lib/setTextContent.js +3 -3
  137. package/lib/shallowCompare.js +1 -1
  138. package/lib/shouldUpdateReactComponent.js +12 -8
  139. package/lib/sliceChildren.js +34 -0
  140. package/lib/traverseAllChildren.js +25 -18
  141. package/lib/update.js +13 -13
  142. package/lib/validateDOMNesting.js +6 -6
  143. package/lib/webcomponents.js +6379 -0
  144. package/package.json +4 -6
  145. package/react.js +1 -51
  146. package/dist/JSXTransformer.js +0 -17588
  147. package/lib/CSSCore.js +0 -97
  148. package/lib/EventListener.js +0 -84
  149. package/lib/ExecutionEnvironment.js +0 -38
  150. package/lib/ReactDOMClient.js +0 -90
  151. package/lib/camelize.js +0 -32
  152. package/lib/camelizeStyleName.js +0 -40
  153. package/lib/containsNode.js +0 -55
  154. package/lib/createArrayFromMixed.js +0 -85
  155. package/lib/createNodesFromMarkup.js +0 -84
  156. package/lib/emptyFunction.js +0 -38
  157. package/lib/focusNode.js +0 -26
  158. package/lib/getActiveElement.js +0 -29
  159. package/lib/getMarkupWrap.js +0 -93
  160. package/lib/getUnboundedScrollPosition.js +0 -38
  161. package/lib/hyphenate.js +0 -33
  162. package/lib/hyphenateStyleName.js +0 -39
  163. package/lib/invariant.js +0 -49
  164. package/lib/isNode.js +0 -23
  165. package/lib/joinClasses.js +0 -39
  166. package/lib/keyMirror.js +0 -48
  167. package/lib/keyOf.js +0 -35
  168. package/lib/mapObject.js +0 -51
  169. package/lib/memoizeStringOnly.js +0 -31
  170. package/lib/performanceNow.js +0 -28
  171. package/lib/shallowEqual.js +0 -48
  172. package/lib/toArray.js +0 -57
  173. package/lib/warning.js +0 -57
@@ -11,10 +11,10 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ExecutionEnvironment = require("./ExecutionEnvironment");
14
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
15
15
 
16
- var getNodeForCharacterOffset = require("./getNodeForCharacterOffset");
17
- var getTextContentAccessor = require("./getTextContentAccessor");
16
+ var getNodeForCharacterOffset = require('./getNodeForCharacterOffset');
17
+ var getTextContentAccessor = require('./getTextContentAccessor');
18
18
 
19
19
  /**
20
20
  * While `isCollapsed` is available on the Selection object and `collapsed`
@@ -76,6 +76,22 @@ function getModernOffsets(node) {
76
76
 
77
77
  var currentRange = selection.getRangeAt(0);
78
78
 
79
+ // In Firefox, range.startContainer and range.endContainer can be "anonymous
80
+ // divs", e.g. the up/down buttons on an <input type="number">. Anonymous
81
+ // divs do not seem to expose properties, triggering a "Permission denied
82
+ // error" if any of its properties are accessed. The only seemingly possible
83
+ // way to avoid erroring is to access a property that typically works for
84
+ // non-anonymous divs and catch any error that may otherwise arise. See
85
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
86
+ try {
87
+ /* eslint-disable no-unused-expressions */
88
+ currentRange.startContainer.nodeType;
89
+ currentRange.endContainer.nodeType;
90
+ /* eslint-enable no-unused-expressions */
91
+ } catch (e) {
92
+ return null;
93
+ }
94
+
79
95
  // If the node and offset values are the same, the selection is collapsed.
80
96
  // `Selection.isCollapsed` is available natively, but IE sometimes gets
81
97
  // this value wrong.
@@ -11,14 +11,16 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactDefaultInjection = require("./ReactDefaultInjection");
15
- var ReactServerRendering = require("./ReactServerRendering");
14
+ var ReactDefaultInjection = require('./ReactDefaultInjection');
15
+ var ReactServerRendering = require('./ReactServerRendering');
16
+ var ReactVersion = require('./ReactVersion');
16
17
 
17
18
  ReactDefaultInjection.inject();
18
19
 
19
20
  var ReactDOMServer = {
20
21
  renderToString: ReactServerRendering.renderToString,
21
- renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup
22
+ renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
23
+ version: ReactVersion
22
24
  };
23
25
 
24
26
  module.exports = ReactDOMServer;
@@ -12,13 +12,15 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- var DOMPropertyOperations = require("./DOMPropertyOperations");
16
- var ReactComponentBrowserEnvironment = require("./ReactComponentBrowserEnvironment");
17
- var ReactDOMComponent = require("./ReactDOMComponent");
15
+ var DOMChildrenOperations = require('./DOMChildrenOperations');
16
+ var DOMPropertyOperations = require('./DOMPropertyOperations');
17
+ var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
18
+ var ReactMount = require('./ReactMount');
18
19
 
19
- var assign = require("./Object.assign");
20
- var escapeTextContentForBrowser = require("./escapeTextContentForBrowser");
21
- var validateDOMNesting = require("./validateDOMNesting");
20
+ var assign = require('./Object.assign');
21
+ var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
22
+ var setTextContent = require('./setTextContent');
23
+ var validateDOMNesting = require('./validateDOMNesting');
22
24
 
23
25
  /**
24
26
  * Text nodes violate a couple assumptions that React makes about components:
@@ -35,7 +37,9 @@ var validateDOMNesting = require("./validateDOMNesting");
35
37
  * @extends ReactComponent
36
38
  * @internal
37
39
  */
38
- var ReactDOMTextComponent = function (props) {};
40
+ var ReactDOMTextComponent = function (props) {
41
+ // This constructor and its argument is currently used by mocks.
42
+ };
39
43
 
40
44
  assign(ReactDOMTextComponent.prototype, {
41
45
 
@@ -63,23 +67,33 @@ assign(ReactDOMTextComponent.prototype, {
63
67
  * @internal
64
68
  */
65
69
  mountComponent: function (rootID, transaction, context) {
66
- if ('production' !== process.env.NODE_ENV) {
70
+ if (process.env.NODE_ENV !== 'production') {
67
71
  if (context[validateDOMNesting.ancestorInfoContextKey]) {
68
72
  validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
69
73
  }
70
74
  }
71
75
 
72
76
  this._rootNodeID = rootID;
73
- var escapedText = escapeTextContentForBrowser(this._stringText);
77
+ if (transaction.useCreateElement) {
78
+ var ownerDocument = context[ReactMount.ownerDocumentContextKey];
79
+ var el = ownerDocument.createElement('span');
80
+ DOMPropertyOperations.setAttributeForID(el, rootID);
81
+ // Populate node cache
82
+ ReactMount.getID(el);
83
+ setTextContent(el, this._stringText);
84
+ return el;
85
+ } else {
86
+ var escapedText = escapeTextContentForBrowser(this._stringText);
87
+
88
+ if (transaction.renderToStaticMarkup) {
89
+ // Normally we'd wrap this in a `span` for the reasons stated above, but
90
+ // since this is a situation where React won't take over (static pages),
91
+ // we can simply return the text as it is.
92
+ return escapedText;
93
+ }
74
94
 
75
- if (transaction.renderToStaticMarkup) {
76
- // Normally we'd wrap this in a `span` for the reasons stated above, but
77
- // since this is a situation where React won't take over (static pages),
78
- // we can simply return the text as it is.
79
- return escapedText;
95
+ return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>';
80
96
  }
81
-
82
- return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>';
83
97
  },
84
98
 
85
99
  /**
@@ -98,7 +112,8 @@ assign(ReactDOMTextComponent.prototype, {
98
112
  // and/or updateComponent to do the actual update for consistency with
99
113
  // other component types?
100
114
  this._stringText = nextStringText;
101
- ReactDOMComponent.BackendIDOperations.updateTextContentByID(this._rootNodeID, nextStringText);
115
+ var node = ReactMount.getNode(this._rootNodeID);
116
+ DOMChildrenOperations.updateTextContent(node, nextStringText);
102
117
  }
103
118
  }
104
119
  },
@@ -109,6 +124,4 @@ assign(ReactDOMTextComponent.prototype, {
109
124
 
110
125
  });
111
126
 
112
- module.exports = ReactDOMTextComponent;
113
-
114
- // This constructor and its argument is currently used by mocks.
127
+ module.exports = ReactDOMTextComponent;
@@ -11,13 +11,13 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var LinkedValueUtils = require("./LinkedValueUtils");
15
- var ReactDOMIDOperations = require("./ReactDOMIDOperations");
16
- var ReactUpdates = require("./ReactUpdates");
14
+ var LinkedValueUtils = require('./LinkedValueUtils');
15
+ var ReactDOMIDOperations = require('./ReactDOMIDOperations');
16
+ var ReactUpdates = require('./ReactUpdates');
17
17
 
18
- var assign = require("./Object.assign");
19
- var invariant = require("./invariant");
20
- var warning = require("./warning");
18
+ var assign = require('./Object.assign');
19
+ var invariant = require('fbjs/lib/invariant');
20
+ var warning = require('fbjs/lib/warning');
21
21
 
22
22
  function forceUpdateIfMounted() {
23
23
  if (this._rootNodeID) {
@@ -43,7 +43,7 @@ function forceUpdateIfMounted() {
43
43
  */
44
44
  var ReactDOMTextarea = {
45
45
  getNativeProps: function (inst, props, context) {
46
- !(props.dangerouslySetInnerHTML == null) ? 'production' !== process.env.NODE_ENV ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
46
+ !(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
47
47
 
48
48
  // Always set children to the same thing. In IE9, the selection range will
49
49
  // get reset if `textContent` is mutated.
@@ -58,18 +58,20 @@ var ReactDOMTextarea = {
58
58
  },
59
59
 
60
60
  mountWrapper: function (inst, props) {
61
- LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
61
+ if (process.env.NODE_ENV !== 'production') {
62
+ LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
63
+ }
62
64
 
63
65
  var defaultValue = props.defaultValue;
64
66
  // TODO (yungsters): Remove support for children content in <textarea>.
65
67
  var children = props.children;
66
68
  if (children != null) {
67
- if ('production' !== process.env.NODE_ENV) {
68
- 'production' !== process.env.NODE_ENV ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
69
+ if (process.env.NODE_ENV !== 'production') {
70
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
69
71
  }
70
- !(defaultValue == null) ? 'production' !== process.env.NODE_ENV ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
72
+ !(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
71
73
  if (Array.isArray(children)) {
72
- !(children.length <= 1) ? 'production' !== process.env.NODE_ENV ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
74
+ !(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
73
75
  children = children[0];
74
76
  }
75
77
 
@@ -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,28 +11,27 @@
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 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");
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 ReactDOMTextComponent = require('./ReactDOMTextComponent');
26
+ var ReactEventListener = require('./ReactEventListener');
27
+ var ReactInjection = require('./ReactInjection');
28
+ var ReactInstanceHandles = require('./ReactInstanceHandles');
29
+ var ReactMount = require('./ReactMount');
30
+ var ReactReconcileTransaction = require('./ReactReconcileTransaction');
31
+ var SelectEventPlugin = require('./SelectEventPlugin');
32
+ var ServerReactRootIndex = require('./ServerReactRootIndex');
33
+ var SimpleEventPlugin = require('./SimpleEventPlugin');
34
+ var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
36
35
 
37
36
  var alreadyInjected = false;
38
37
 
@@ -83,12 +82,11 @@ function inject() {
83
82
  ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
84
83
 
85
84
  ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
86
- ReactInjection.DOMComponent.injectIDOperations(ReactDOMIDOperations);
87
85
 
88
- if ('production' !== process.env.NODE_ENV) {
86
+ if (process.env.NODE_ENV !== 'production') {
89
87
  var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
90
88
  if (/[?&]react_perf\b/.test(url)) {
91
- var ReactDefaultPerf = require("./ReactDefaultPerf");
89
+ var ReactDefaultPerf = require('./ReactDefaultPerf');
92
90
  ReactDefaultPerf.start();
93
91
  }
94
92
  }
@@ -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');
@@ -143,13 +143,14 @@ var ReactDefaultPerf = {
143
143
  counts: {},
144
144
  writes: {},
145
145
  displayNames: {},
146
- totalTime: 0
146
+ totalTime: 0,
147
+ created: {}
147
148
  });
148
149
  start = performanceNow();
149
150
  rv = func.apply(this, args);
150
151
  ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].totalTime = performanceNow() - start;
151
152
  return rv;
152
- } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactDOMIDOperations') {
153
+ } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactBrowserEventEmitter' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations') {
153
154
  start = performanceNow();
154
155
  rv = func.apply(this, args);
155
156
  totalTime = performanceNow() - start;
@@ -177,13 +178,17 @@ var ReactDefaultPerf = {
177
178
  });
178
179
  } else {
179
180
  // basic format
180
- ReactDefaultPerf._recordWrite(args[0], fnName, totalTime, Array.prototype.slice.call(args, 1));
181
+ var id = args[0];
182
+ if (typeof id === 'object') {
183
+ id = ReactMount.getID(args[0]);
184
+ }
185
+ ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
181
186
  }
182
187
  return rv;
183
188
  } else if (moduleName === 'ReactCompositeComponent' && (fnName === 'mountComponent' || fnName === 'updateComponent' || // TODO: receiveComponent()?
184
189
  fnName === '_renderValidatedComponent')) {
185
190
 
186
- if (typeof this._currentElement.type === 'string') {
191
+ if (this._currentElement.type === ReactMount.TopLevelWrapper) {
187
192
  return func.apply(this, args);
188
193
  }
189
194
 
@@ -197,6 +202,7 @@ var ReactDefaultPerf = {
197
202
  if (isRender) {
198
203
  addValue(entry.counts, rootNodeID, 1);
199
204
  } else if (isMount) {
205
+ entry.created[rootNodeID] = true;
200
206
  mountStack.push(0);
201
207
  }
202
208
 
@@ -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
- 'updatePropertyByID': 'update attribute',
25
- 'deletePropertyByID': 'delete attribute',
26
- 'updateStylesByID': 'update styles',
27
- 'updateInnerHTMLByID': 'set innerHTML',
25
+ 'setValueForProperty': 'update attribute',
26
+ 'setValueForAttribute': 'update attribute',
27
+ 'deleteValueForProperty': 'remove attribute',
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
 
@@ -181,6 +178,10 @@ function getUnchangedComponents(measurement) {
181
178
  break;
182
179
  }
183
180
  }
181
+ // check if component newly created
182
+ if (measurement.created[id]) {
183
+ isDirty = true;
184
+ }
184
185
  if (!isDirty && measurement.counts[id] > 0) {
185
186
  cleanComponents[id] = true;
186
187
  }
@@ -11,15 +11,31 @@
11
11
 
12
12
  'use strict';
13
13
 
14
- var ReactCurrentOwner = require("./ReactCurrentOwner");
14
+ var ReactCurrentOwner = require('./ReactCurrentOwner');
15
15
 
16
- var assign = require("./Object.assign");
16
+ var assign = require('./Object.assign');
17
+
18
+ // The Symbol used to tag the ReactElement type. If there is no native Symbol
19
+ // nor polyfill, then a plain number is used for performance.
20
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
17
21
 
18
22
  var RESERVED_PROPS = {
19
23
  key: true,
20
- ref: true
24
+ ref: true,
25
+ __self: true,
26
+ __source: true
21
27
  };
22
28
 
29
+ var canDefineProperty = false;
30
+ if (process.env.NODE_ENV !== 'production') {
31
+ try {
32
+ Object.defineProperty({}, 'x', {});
33
+ canDefineProperty = true;
34
+ } catch (x) {
35
+ // IE will fail on defineProperty
36
+ }
37
+ }
38
+
23
39
  /**
24
40
  * Base constructor for all React elements. This is only used to make this
25
41
  * work with a dynamic instanceof check. Nothing should live on this prototype.
@@ -27,51 +43,75 @@ var RESERVED_PROPS = {
27
43
  * @param {*} type
28
44
  * @param {*} key
29
45
  * @param {string|object} ref
46
+ * @param {*} self A *temporary* helper to detect places where `this` is
47
+ * different from the `owner` when React.createElement is called, so that we
48
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
49
+ * functions, and as long as `this` and owner are the same, there will be no
50
+ * change in behavior.
51
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
52
+ * indicating filename, line number, and/or other information.
30
53
  * @param {*} owner
31
54
  * @param {*} props
32
55
  * @internal
33
56
  */
34
- var ReactElement = function (type, key, ref, owner, props) {
35
- // Built-in properties that belong on the element
36
- this.type = type;
37
- this.key = key;
38
- this.ref = ref;
57
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
58
+ var element = {
59
+ // This tag allow us to uniquely identify this as a React Element
60
+ $$typeof: REACT_ELEMENT_TYPE,
39
61
 
40
- // Record the component responsible for creating this element.
41
- this._owner = owner;
62
+ // Built-in properties that belong on the element
63
+ type: type,
64
+ key: key,
65
+ ref: ref,
66
+ props: props,
42
67
 
43
- this.props = props;
68
+ // Record the component responsible for creating this element.
69
+ _owner: owner
70
+ };
44
71
 
45
- if ('production' !== process.env.NODE_ENV) {
72
+ if (process.env.NODE_ENV !== 'production') {
46
73
  // The validation flag is currently mutative. We put it on
47
74
  // an external backing store so that we can freeze the whole object.
48
75
  // This can be replaced with a WeakMap once they are implemented in
49
76
  // commonly used development environments.
50
- this._store = {};
77
+ element._store = {};
51
78
 
52
79
  // To make comparing ReactElements easier for testing purposes, we make
53
80
  // the validation flag non-enumerable (where possible, which should
54
81
  // include every environment we run tests in), so the test framework
55
82
  // ignores it.
56
- try {
57
- Object.defineProperty(this._store, 'validated', {
83
+ if (canDefineProperty) {
84
+ Object.defineProperty(element._store, 'validated', {
58
85
  configurable: false,
59
86
  enumerable: false,
60
87
  writable: true,
61
88
  value: false
62
89
  });
63
- } catch (x) {
64
- this._store.validated = false;
90
+ // self and source are DEV only properties.
91
+ Object.defineProperty(element, '_self', {
92
+ configurable: false,
93
+ enumerable: false,
94
+ writable: false,
95
+ value: self
96
+ });
97
+ // Two elements created in two different places should be considered
98
+ // equal for testing purposes and therefore we hide it from enumeration.
99
+ Object.defineProperty(element, '_source', {
100
+ configurable: false,
101
+ enumerable: false,
102
+ writable: false,
103
+ value: source
104
+ });
105
+ } else {
106
+ element._store.validated = false;
107
+ element._self = self;
108
+ element._source = source;
65
109
  }
66
- Object.freeze(this.props);
67
- Object.freeze(this);
110
+ Object.freeze(element.props);
111
+ Object.freeze(element);
68
112
  }
69
- };
70
113
 
71
- // We intentionally don't expose the function on the constructor property.
72
- // ReactElement should be indistinguishable from a plain object.
73
- ReactElement.prototype = {
74
- _isReactElement: true
114
+ return element;
75
115
  };
76
116
 
77
117
  ReactElement.createElement = function (type, config, children) {
@@ -82,10 +122,14 @@ ReactElement.createElement = function (type, config, children) {
82
122
 
83
123
  var key = null;
84
124
  var ref = null;
125
+ var self = null;
126
+ var source = null;
85
127
 
86
128
  if (config != null) {
87
129
  ref = config.ref === undefined ? null : config.ref;
88
130
  key = config.key === undefined ? null : '' + config.key;
131
+ self = config.__self === undefined ? null : config.__self;
132
+ source = config.__source === undefined ? null : config.__source;
89
133
  // Remaining properties are added to a new props object
90
134
  for (propName in config) {
91
135
  if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
@@ -117,7 +161,7 @@ ReactElement.createElement = function (type, config, children) {
117
161
  }
118
162
  }
119
163
 
120
- return new ReactElement(type, key, ref, ReactCurrentOwner.current, props);
164
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
121
165
  };
122
166
 
123
167
  ReactElement.createFactory = function (type) {
@@ -131,10 +175,16 @@ ReactElement.createFactory = function (type) {
131
175
  return factory;
132
176
  };
133
177
 
178
+ ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
179
+ var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
180
+
181
+ return newElement;
182
+ };
183
+
134
184
  ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
135
- var newElement = new ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._owner, newProps);
185
+ var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
136
186
 
137
- if ('production' !== process.env.NODE_ENV) {
187
+ if (process.env.NODE_ENV !== 'production') {
138
188
  // If the key on the original is valid, then the clone is valid
139
189
  newElement._store.validated = oldElement._store.validated;
140
190
  }
@@ -151,6 +201,12 @@ ReactElement.cloneElement = function (element, config, children) {
151
201
  // Reserved names are extracted
152
202
  var key = element.key;
153
203
  var ref = element.ref;
204
+ // Self is preserved since the owner is preserved.
205
+ var self = element._self;
206
+ // Source is preserved since cloneElement is unlikely to be targeted by a
207
+ // transpiler, and the original source is probably a better indicator of the
208
+ // true owner.
209
+ var source = element._source;
154
210
 
155
211
  // Owner will be preserved, unless ref is overridden
156
212
  var owner = element._owner;
@@ -185,7 +241,7 @@ ReactElement.cloneElement = function (element, config, children) {
185
241
  props.children = childArray;
186
242
  }
187
243
 
188
- return new ReactElement(element.type, key, ref, owner, props);
244
+ return ReactElement(element.type, key, ref, self, source, owner, props);
189
245
  };
190
246
 
191
247
  /**
@@ -194,17 +250,7 @@ ReactElement.cloneElement = function (element, config, children) {
194
250
  * @final
195
251
  */
196
252
  ReactElement.isValidElement = function (object) {
197
- // ReactTestUtils is often used outside of beforeEach where as React is
198
- // within it. This leads to two different instances of React on the same
199
- // page. To identify a element from a different React instance we use
200
- // a flag instead of an instanceof check.
201
- var isElement = !!(object && object._isReactElement);
202
- // if (isElement && !(object instanceof ReactElement)) {
203
- // This is an indicator that you're using multiple versions of React at the
204
- // same time. This will screw with ownership and stuff. Fix it, please.
205
- // TODO: We could possibly warn here.
206
- // }
207
- return isElement;
253
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
208
254
  };
209
255
 
210
256
  module.exports = ReactElement;